Magnitude Comparator

Download Report

Transcript Magnitude Comparator

Cascading 1-Bit Comparators Lecture L6.3

A 1-Bit Comparator

y x Gout Eout Lout 1-bit comparator Gin Lin The variable The variable The variable

Gout Eout Lout

is 1 if is 1 if is 1 if

x

>

y

or if

x

=

y

and

Gin

= 1.

x

=

y

and

Gin

= 0 and

Lin

= 0.

x

<

y

or if

x

=

y

and

Lin

= 1.

The variable The variable The variable

Gout Eout Lout

is 1 if is 1 if is 1 if

x

>

y

or if

x

=

y

and

Gin

= 1.

x

=

y

and

Gin

= 0 and

Lin

= 0.

x

<

y

or if

x

=

y

and

Lin

= 1.

1 1 1 1 1 x 0 0 0 0 0 0 0 0 1 1 1 0 0 0 1 1 y 0 0 0 0 1 1 1 1 0 1 1 Gin 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 Lin 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Gout 0 0 1 1 0 0 0 0 1 1 1 1 0 0 1 1 Eout 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 Lout 0 1 0 1 1 1 1 1 0 0 0 0 0 1 0 1

Gout = x & !y # x & Gin # !y & Gin Eout = !x & !y & !Gin & !Lin # x & y & !Gin & !Lin

Lout = !x & y # !x & Lin # y & Lin

0 0 0 1 1 y 0 0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 x 0 0 0 0 0 0 0 0 1 1 1 Gin 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 Lin 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Gout 0 0 1 1 0 0 0 0 1 1 1 1 0 0 1 1 Eout 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 Lout 0 1 0 1 1 1 1 1 0 0 0 0 0 1 0 1

A 4-Bit Comparator

x 3 y 3 x 2 y 2 x 1 y 1 x 0 y 0 gt eq lt G 4 L 4 1-bit comp G 3 1-bit comp L 3 G 2 1-bit comp L 2 G 1 1-bit comp L 1 G 0 Gin=0 Lin=0 L 0

Lab 3

3. Using Listing 6.1 of the Section 6.1 handout as a guide, write an ABEL program called

Comp41.abl

for the 4-bit magnitude comparator shown in Figure 2 below using a Xilinx XC95108 PC84 chip on a PLDT-3 unit. In the

DECLARATIONS

section, start by assigning inputs

x3..x0

to S6, switches 1 to 4 and write a vector equation,

x = [x3..x0]

. Assign inputs

y3..y0

to S7, switches 1 to 4 and write a vector equation,

y = [y3..y0]

. For outputs, assign

gt, eq, lt

to LEDs 9 to 11 respectively. x 3 y 3 x 2 y 2 x 1 y 1 x 0 y 0 gt eq lt G 4 L 4 1-bit comp G 3 1-bit comp L 3 G 2 1-bit comp L 2 G 1 1-bit comp L 1 G 0 Gin=0 Lin=0 L 0

4. You will also need intermediate nodes to describe the

Gin

,

Lin

,

Gout

,

Eout

, and

Lout

signals for each of the four 1-bit comparators. For example, add the following node and vector definitions:

G4..G0 NODE ISTYPE 'com'; " internal greater than Gin = [C3..C0]; " internal greater input vector Gout = [C4..C1]; " internal greater output vector

Add similar node and vector definitions for

Lin

,

Lout

, and

Eout

. Note that you will need to define nodes

E4

..

E1

not shown in Figure 2. 5. In the

EQUATIONS

section, set

G0

and

L0

equal to 0. Then write the equations you found in Part 2 for

Gout

,

Eout

, and

Lout

. Finally write equations for the outputs

lt

,

eq

, and

gt

. Print out a copy of your file. 6. Include at least 10 test vectors to verify the operation of the comparator. 7. Type in your ABLE program, save as

Comp41.abl

to your lab disk, print out a copy of this file and bring this to lab.