Dept. of Electrical and Computer Eng., NCTU Lab 3. 2-bit Comparator Presenter: Chun-Hsien Ko Contributors: Chung-Ting Jiang and Lin-Kai Chiu Dept. of Electrical and Computer Eng., NCTU
Dept. of Electrical and Computer Eng., NCTU What is comparator? Design a 2-bit comparator Input: A (2-bit) and B (2-bit) Output: A=B, A>B, A<B LAB: 2-bit Comparator Dept. of Electrical and Computer Eng., NCTU
Dept. of Electrical and Computer Eng., NCTU What is comparator? If we only have 1-bit input A and B… A>B, iff A=1, B=0 A=B, iff A=1, B=1 OR A=0,B=0 A<B, iff A=0, B=1 Truth table A B A>B A=B A<B 1 Dept. of Electrical and Computer Eng., NCTU
Dept. of Electrical and Computer Eng., NCTU Design a 2-bit comparator Input: A [A1 A0] and B [B1 B0] Output: A=B, A>B, A<B For A>B: {A1>B1, A0, B0 don’t care} {A1=B1, A0>B0} For A<B: {A1<B1, A0, B0 don’t care} {A1=B1, A0<B0} For A=B: {A1=B1, A0=B0} A1 B1 A1=B1 1 XNOR Dept. of Electrical and Computer Eng., NCTU
Dept. of Electrical and Computer Eng., NCTU Design a 2-bit comparator How to implement XNOR? Sum of Product: 𝑋=𝐴𝐵+ 𝐴 𝐵 𝑋= (𝐴 𝐵 + 𝐴 𝐵) A B X 1 Dept. of Electrical and Computer Eng., NCTU
Dept. of Electrical and Computer Eng., NCTU Design a 2-bit comparator How to implement XNOR? 𝑋= (𝐴 𝑋𝑂𝑅 𝐵) 𝑋= (𝐴 𝐵 + 𝐴 𝐵) A1 B1 A1=B1 1 NOR Dept. of Electrical and Computer Eng., NCTU
Dept. of Electrical and Computer Eng., NCTU Design a 2-bit comparator For A=B: {A1=B1, A0=B0} X1: A1=B1 For A>B: {A1>B1} {A1=B1, A0>B0} For A<B: {A1<B1} {A1=B1, A0<B0} X1 Dept. of Electrical and Computer Eng., NCTU
Dept. of Electrical and Computer Eng., NCTU Implement a 2-bit comparator Show the relation between two two-bit inputs, A and B Design the circuit of A>B and A<B Reuse the circuit of {A=B} Equipment: Use LED x 3 for display A>B, A=B, A<B Use the following IC to implement Lab 6 7402 (NOR) x 1, 7408 (AND) x 2, 7404 (Inverter) x 1, 7432 (OR) x 1 Dept. of Electrical and Computer Eng., NCTU