HITEQUEST
technical interview Q & A for high-tech professionals
 
 
Interview Questions
Electronics Hardware
Computer Software
Intel screening questions
Quick Thinking Tests
General questions
Phone screening questions
Submit your Q or A

Resources
Technical articles
Technical discussion
Engineers share info
Resume and interview
How to get a job in Silicon Valley
How much are you worth on market?
Why you may need an agent

Break point
Written Exam
Logic Tests
Professional Test
Tomato company
Cup of coffee
How stock market works
Engineering jokes

About Hitequest
About Hitequest
Home page

 
 
 
 
 
 

 
=Electronics Hardware Questions=

   
   

Q: Implement a comparator using combinational logic, that compares two 2-bit numbers A and B. The comparator should have 3 outputs:  A > B, A < B, A = B.
 
 

 
 

A:


A1	A0	B1	B0	A>B	B>A	A=B
---------------------------------------------------
0	0	0	0	0	0	1
0	0	0	1	0	1	0
0	0	1	0	0	1	0
0	0	1	1	0	1	0
0	1	0	0	1	0	0
0	1	0	1	0	0	1
0	1	1	0	0	1	0
0	1	1	1	0	1	0
1	0	0	0	1	0	0
1	0	0	1	1	0	0
1	0	1	0	0	0	1
1	0	1	1	0	1	0
1	1	0	0	1	0	0
1	1	0	1	1	0	0
1	1	1	0	1	0	0
1	1	1	1	0	0	1

Here is the behavioral model of the comparator in verilog:

module comp0 (y1,y2,y3,a,b); input [1:0] a,b; output y1,y2,y3; wire y1,y2,y3; assign y1= (a >b)? 1:0; assign y2= (b >a)? 1:0; assign y3= (a==b)? 1:0; endmodule


 
 
The gate level model:

module comp0 (y1,y2,y3,a,b);
 input [1:0] a,b;
 output y1,y2,y3;
 wire y1,y2,y3;
 wire xor1_out,xor2_out,nand1_out,nand2_out,nand3_out,nand4_out,or1_out,or2_out;
 
 xor  xor1 (xor1_out,a[0],b[0]);
 xor  xor2 (xor2_out,a[1],b[1]);
 nand nand1(nand1_out,a[0],xor1_out);
 nand nand2(nand2_out,b[0],xor1_out); 
 nand nand3(nand3_out,a[1],xor2_out); 
 nand nand4(nand4_out,b[1],xor2_out);  
 nand nand5(y1,or1_out,nand3_out); 
 nand nand6(y2,or2_out,nand4_out); 
 or   or1  (or1_out,nand1_out,xor1_out);
 or   or2  (or2_out,nand2_out,xor1_out);  
 nor  nor1 (y3,xor1_out,xor2_out);
 
endmodule

 
 
 
Submit your answer here