Professional Documents
Culture Documents
Course contents
Digital design Combinatorial circuits: without status Sequential circuits: with status FSMD design: hardwired processors Language based HW design: VHDL
VHDL
2/1
VHDL
2/2
VHDL
Technology mapping Correct timing behavior Basic RTL building blocks (Adder, ALU, MUX, )
2/3
VHDL
Technology mapping Correct timing behavior Basic RTL building blocks (Adder, ALU, MUX, )
2/4
Karnaugh map
Motivation:
Assume: F=xyz+xyz Cost = Delay
Assume: relative gate delay NAND or NOR or NOT = 0.6 + fan-in * 0.4
VHDL
F=xyz+xyz
2/5
Karnaugh map
Motivation:
F=xyz+xyz =xy(z+z) =xy The value of z hence does not matter Cost = Delay
VHDL
Assume: relative gate delay NAND or NOR or NOT = 0.6 + fan-in * 0.4 Delay = (gate-delay)critical path = 1 + (1.4+1) = 3.4 i.o. 6.2
x y z F
2/6
Karnaugh map
Minimization via manipulation of Boolean expressions is clumsy: no method exists to select the theorems such that we are sure to obtain the minimum cost Is it possible to see in the truth table which input value does not matter?
x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 F 0 0 0 0 1 1 0 0 xyz xyz -
VHDL
We indeed see easily that the value of F equals 1 for x=1 and y=0 irrespective of the value of z We however see this easily only for z, since only for z the lines z=0 and z=1 for equal x and y are consecutive
2/7
Karnaugh map
A Karnaugh map contains the same information as a truth table (each square is a minterm), but neighboring squares differ only in the value of 1 variable!!
x 0 x 1 x z x yz y 00 01 11 10 x y 0 xy xy 1 xy xy 0 1
VHDL
1 xyz xyz
xyz
xyz
Karnaugh map
x 0 1 x y 0 1 0 1
m0
m1
m0
m2
m1
m3
z x yz 0 x 1
VHDL
y
00 01 11 10
0
4
1
5
3
7
2
6
2/9
Karnaugh map
Fill out from truth table w xy zw z 00 0 1 4 0 12 0 8 1 01 1 0 5 1 13 1 9 0 11 3 0 7 1 15 1 11 0 10 2 0 6 0 14 0 10 1
x 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 y 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 z 0 0 1 1 0 0 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
w 0 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 F F 1 1 0 0 0 0 0 0 0 0 1 1 0 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 0 0 1 1
00
01 y 11
VHDL
x
10
2/10
Karnaugh map
Minimize F=xyzw+xyzw+xyzw+xyzw+xyzw+xyzw+xyzw
w xy
zw
z
00 01 11 10
00
1
0 0 1
0
1 1 0
0
1 1 0
0
0 0 1 F= yw +xyw +yzw
VHDL
01
y 11 x 10
2/11
Karnaugh map
Implement F=xyzw+xyzw+xyzw+xyzw+xyzw+xyzw+xyzw x y z w Cost = = Delay = = 4*(1) + 7*(4) + 1*(7) 39 1 + (2.2+1) + (3.4+1) 8.6
VHDL
2/12
Karnaugh map
Implement F=yw+xyw+yzw x y z w
VHDL
Cost
= = Delay = =
2/13
Karnaugh map
v w zw xy 00 y 01 z 00 01 11 0 4 1 5 3 7 10 2 6 14 10 10 18 22 30 26 z xy 19 17 16 00 23 21 20 01 31 29 28 11 27 25 24 10 y 11 01 00 w
VHDL
11
12 13 15 8 9 11
10
Karnaugh map
Differs from course book w zw xy 00 z 00 01 11 0 4 1 5 3 7 10 2 6 10 18 22 z xy 19 17 16 00 23 21 20 01 x y 11 01 00 v w
01
y x 11 10
12 13 15 14
8 9 11 10
30 31 29 28 11
26 27 25 24 10
VHDL
F=(u,v,x,y,z,w) x 10 11 01 40 41 43 44 45 47 36 37 39 42 46 38 58 62 54 59 57 56 10 63 61 60 11 55 53 52 01 x
2/15
00
32 33 35 34
50 51 49 48 00
VHDL
Technology mapping Correct timing behavior Basic RTL building blocks (Adder, ALU, MUX, )
2/16
VHDL
y
1 x w 1 1 1 1 1 1 1 1 1
VHDL
Rule: - Take product term per product term and indicate where in the Karnaugh map it equals 1
2/18
y
1 x w 1 1 1 1 1 1 1 1 1
VHDL
Rule: - Analyze each 1-minterm - Determine the largest sub-cube(s) that contain(s) the minterm and add them to the list of prime implicants (without adding an already listed sub-cube)
2/19
y
1 x w 1 1 1 1 1 1 1 1 1
VHDL
Rule: - Search for 1-minterms that are only contained in 1 prime implicant - Indicate this prime implicant as
2/20
essential
Fmin=xyz+wy+wz
VHDL
Rule: - Goal: search for the smallest set of (as big as possible) prime implicants that contain all 1-minterms - Take all essential prime implicants as initial list - Repeatedly add a prime implicant to the list that contains the largest number of not yet covered 1-minterms. When there are two that contain the same number of not yet covered 1-minterms, make a random choice.
2/21
Such a strategy is known as Greedy strategy: at each decision point, take the best choice without looking to future implications - This does not always lead to a global optimum
Minimal Fmin=xyz+wy+wz
wxyz
VHDL
Cost=4*1+2*3+2*2+1*4=18 Delay
2/22
Cost Delay
=(1)+(.6+3*.4+1) +(.6+4*.4+1)=7
VHDL
2/23
VHDL
Cost=(5*1)+(12*(5+1))+(1*(12+1))=90 Delay=(.6+1*.4)+(.6+5*.4+1)+(.6+12*.4+1)=11
2/24
0
x w 0 0 0
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
VHDL
2/25
0
x w 0 0 0
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
VHDL
2/26
0
x w 0 0 0
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
VHDL
VHDL
2/28
VHDL
2/29
0
x w 0 0 0
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
VHDL
2/30
0
x w 0 0 0
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
VHDL
2/31
0
x w 0 0 0
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
0
1 1 1
0
1 1 1
0
0 0 0
VHDL
2/32
VHDL
2/33
Area/time trade-off Well see that, depending on the technology mapping, we will eventually obtain for an ASIC realisation: OR-AND-INV Cost = 11 (Rel. cost=12%) Delay = 4 (Rel. delay=36%) NOR Cost = 10 (Rel. cost=11%) Delay = 4.2 (Rel. delay=38%)
VHDL
2/34
VHDL
Technology mapping Correct timing behavior Basic RTL building blocks (Adder, ALU, MUX, )
2/35
BCD7-segment a f e d g b c
VHDL
2/36
w b z
1 1 1 1 1 0 1 0 x x x x 1 1 x x
w c z
1 1 1 0 1 1 1 1 x x x x 1 1 x x
w d z
1 0 1 1 0 1 0 1 x x x x 1 1 x x
x x x x 1 1 x x
e
1 0 0 1
f
1 0 0 0 1 1 0 1
g
0 0 1 1 1 1 0 1
VHDL
y x
0 0 0 1
x x x x
1 0 x x
x x x x
1 1 x x
x x x x
1 1 x x
2/37
w b z
1 1 1 1 1 0 1 0 x x x x 1 1 x x
w c z
1 1 1 0 1 1 1 1 x x x x 1 1 x x
w d z
1 0 1 1 0 1 0 1 x x x x 1 1 x x
x x x x 1 1 x x
e
1 0 0 1
f
1 0 0 0 1 1 0 1
g
0 0 1 1 1 1 0 1
VHDL
y x
0 0 0 1
x x x x
1 0 x x
x x x x
1 1 x x
x x x x
1 1 x x
2/38
w b z
1 1 1 1 1 0 1 0
w c z
1 1 1 0 1 1 1 1
w d z
1 0 1 1 0 1 0 1
x x x x
1 1 x x Complete coverage
x x x x
1 1 x x Complete coverage
x x x x
1 1 x x Complete coverage
x x x x
1 1 x x Complete coverage
VHDL
e
1 0 0 1
f
1 0 0 0
1 1 0 1 x x x x 1 1 x x Complete coverage
g
0 0 1 1
1 1 0 1 x x x x 1 1 x x Incomplete coverage
y x
0 0 0 1 x x x x 1 0 x x Complete coverage
2/39
VHDL
Selection of the cube that realises the remaining minterm: - Select all cubes that realise the minterm and are already essential for another function; in this case, both are already essential - Select that cube that appears in the smallest number of other functions to keep the fan-out as low as possible
2/40
yw z yw x
x x x x
1 1 x x
VHDL
a=yw+z+yw+x
2/41
x x x x
1 1 x x
yw z yw x y zw zw
VHDL
a=yw+z+yw+x b=y+zw+zw
2/42
x x x x
1 1 x x
VHDL
yw z yw x y zw zw z w y
2/43
x x x x
1 1 x x
VHDL
yw z yw x y zw zw z w y yz yzw zw
2/44
e
1 0 0 1
y x
0 0 0 1
x x x x
1 0 x x
VHDL
f
1 0 0 0 1 1 0 1
x x x x
1 1 x x
VHDL
g
0 0 1 1 1 1 0 1
x x x x
1 1 x x
VHDL
2/47
VHDL
a
2/48
329 (100%)
VHDL
2/49
VHDL
2/50
VHDL
Technology mapping Correct timing behavior Basic RTL building blocks (Adder, ALU, MUX, )
2/51
Quine-McCluskey
Method with Karnaugh map
OK for human minimisation : visually oriented no guarantee for optimum solution
Computer method
Quine-McCluskey table oriented leads to optimum solution is the basis of all CAD circuit design tools hardly doable by hand
VHDL
2/52
VHDL
Correct timing behavior Basic RTL building blocks (Adder, ALU, MUX, )
2/53
VHDL
Correct timing behavior Basic RTL building blocks (Adder, ALU, MUX, )
2/54
VHDL
Conversion
VHDL
Optimisation
Retiming
2/56
(xy) = (x + y)
(x+y) = (xy)
VHDL
Optimisation rule:
(x) = x
2/57
VHDL
The realisation with only NAND or only NOR is faster: we save an invertor per gate!
2/58
VHDL
2/59
VHDL
2/60
VHDL
2/61
VHDL
VHDL
VHDL
Correct timing behavior Basic RTL building blocks (Adder, ALU, MUX, )
2/64
VHDL
2/65
F= (0,1,2,3,4,5,8,9,12,13,16,17,18,19,20, 22,24,26,28,30)
z
F y v w x y z
1 x
w 1 1 1
1
1 1 1
1
0 0 0
1
0 0 0
1
1 1 1
1
0 0 0
1
0 0 0
1
1 1 1
VHDL
2/66
Determine critical path Replace repeatedly 2 layers of gates on critical path by AOI/OAI Replace repeatedly 2 layers of gates off critical path by AOI/OAI
VHDL
2/67
y w z
VHDL
Cost=11 Cost=10 Cost=9 Cost=14 Cost=? (64%) (79%) (71%) Delay=? (53%) Delay=5.2 Delay=5.6 Delay=3.8 Delay=7.2 (72%) (78%)
2/68
VHDL
Correct timing behavior Basic RTL building blocks (Adder, ALU, MUX, )
2/69
VHDL
2/70
VHDL
Correct timing behavior Basic RTL building blocks (Adder, ALU, MUX, )
2/71
VHDL
2/72
VHDL
Technology mapping
2/73
VHDL
2/74
VHDL
2/75
VHDL
2/76
VHDL
b
c
2/77
VHDL
2/78
0 x x x a F
VHDL
The danger for hazards increases when rise times and fall times are not equal
Are hazards a problem?
For synchronous circuits, they are not
Unless they control the clock of a memory element For asynchronous circuits, they always are a problem This is why asynchronous design is heavily demotivated for FPGAs (the delay of the different paths is only known after APRAutomatic Placement and Routing)
VHDL
2/80
VHDL
2/81
VHDL
2/82
Ripple-carry adders
Half adder
xi 0 0 1 1 yi 0 1 0 1 ci+1 0 0 0 1 si 0 1 1 0
ci+1 0
yi 0 1
si 0
yi 1 0
xi
xi
VHDL
xi
yi
ci+1
xi
yi
HA
ci+1
2/83
si
si
1 CLB
Ripple-carry adders
Full adder
xi 0 0 0 0 1 1 1 1 yi 0 0 1 1 0 0 1 1 ci 0 1 0 1 0 1 0 1 ci+1 0 0 0 1 0 1 1 1 si 0 1 1 0 1 0 0 1
yi ci+1 1 ci 1 1 1 ci 1 xi si
yi xi 1 1 1
VHDL
xi yi ci
1 CLB
2/84
ci+1
si
Ripple-carry adders
Full adder: alternative implementation
xi 0 0 0 0 1 1 1 1 yi 0 0 1 1 0 0 1 1 ci 0 1 0 1 0 1 0 1 ci+1 0 0 0 1 0 1 1 1 si 0 1 1 0 1 0 0 1
yi ci+1 1 ci xi yi ci 1 1 1 ci 1 xi si
yi xi 1 1 1
VHDL
1 gate less, larger delay from xi&yi to ci+1, same delay from ci to ci+1 xi yi ci+1 FA si ci ci+1 si
2/85
Ripple-carry adders
4-bit ripple-carry adder
x3 c4 FA s3 y3 c3 x2 FA s2 y2 c2 x1 FA s1 y1 c1 x0 FA s0 y0 c0=0
VHDL
In principal 1 CLB per bit Because of special circuitry (dedicated carry chain): 1 CLB per 2 bits
2/86
VHDL
2/87
Carry-look-ahead adders
Ripple-carry adder is slow because the critical path x0 to cn+1 is long Speed-up is possible by computing for example c4 directly (in principle in 2 layers of logic) from c0, x0x3 en y0y3. Hence the name Carry-look-ahead How is this done? See exercises and course book
xii+3 yii+3
VHDL
ci+4
4-bit CLA
ci
2/88
sii+3
VHDL
2/89
Adder-subtractors
X Y S
S 0 1 Function X+Y X-Y=X+Y*=X+Y+1 Note Addition Subtraction
Cout
Adder/ subtractor F
x3 S
y3
x2
y2
x1
y1
x0
y0
VHDL
c4
FA
c3
FA
c2
FA
c1
FA
c0
f3
overflow
f2
f1
f0
2/90
VHDL
2/91
Multipliers
A 1-bit by 1-bit multiplier: C=BA
b0
b0 0 0 1 1 a0 0 1 0 1 c0=a0.b0 0 0 0 1
a0
a0b0
VHDL
c0
2/92
Multipliers
A 2-bit by 2-bit multiplier: C=BA
a0 a1 b0 b1 b1
b1
a1 a0b1 a1b1 c3 c2 a1b0 c1
b0
a0 a0b0 c0
b0
VHDL
HA c3 c2
HA c1 c0
Multipliers
A 4-bit by 3-bit multiplier: cost=O(n2)
a0 a1 b0 0 b3 b3 b2 b1 b2 b1 b0
s2
s1
s0
VHDL
b0
cout c6
4-bit adder s3 s2 c5 c4
s1 c3
s0 c2 c1 c0
2/94
VHDL
2/95
Logic units
Goal: implement a unit that can realise all 16 Boolean functions of 2 bits The unit has two inputs X and Y and 4 select bits S3S2S1S0 that select the wanted function The coding of the select bits is identical to the function number in the table of possible Boolean functions
VHDL
2/96
Logic units
1-minterms m3 m2 m2+m3 m1 m1+m3 m1+m2 m1+m2+m3 m0 m0+m3 m0+m2 m0+m2+m3 m0+m1 m0+m1+m3 m0+m1+m2 m0+m1+m2+m3 Function value for x,y 00 01 10 11 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 Expression F0=0 F1=xy F2=xy F3=x F4=xy F5=y F6=xy+xy F7=x+y F8=(x+y) F9=xy+xy F10=y F11=x+y F12=x F13=x+y F14=(xy) F15=1
VHDL
2/97
Logic units
xi yi
S0 S1 S2 S3
xi
yi
S0..3
LU
VHDL
fi fi
2/98
VHDL
2/99
Arithmetic-logic units
Goal: build a unit that realises 4 arithmetic operations (addition, subtraction, increment and decrement) and 4 logic operations (AND, OR, INV, identity) Realisation principle: use an adder in front of which we place a modifier circuit (Arithmetic-Logic Extender) This principle has already been applied for the 2-complement adder/subtractor: this was an adder in front of which we placed an exor circuit to allow for subtraction
VHDL
2/100
Arithmetic-logic units
a4 b4 a3 b3 a2 b2 a1 b1 a0 b0
VHDL
FA Cout f4
FA
FA
FA
FA
f3
f2
f1
f0
Arithmetic-logic units
a4 b4 a3 b3 a2 b2 a1 b1 a0 b0
S01
M
ALE ALE ALE ALE X FA Cout f4 f3 f2 f1 f0 FA FA FA FA ALE Y
VHDL
M selects the type of operation: 0=logic, 1=arithmetic S0 and S1 select the operation
2/102
Arithmetic-logic units
M M S S M 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 1 1 1 0 0 1 1 1 0 0 1 1 1 1 1 1 S S S 0 0 0 0 0 0 1 1 1 0 0 1 1 0 0 1 1 0 0 1 Function Function Function Complement Complement Complement AND AND Identity OR Decrement Decrement Add Subtract Subtract Increment F F X Y F X Y X Y A A A 0 A A 0 A 0 A AAND AND ANDB B B A A AAND AND ANDB B A 00 A A A A 00 A A OR OR B B A AOR ORB B 00 A-1 A-1 A A all all11 A+B A+B A A B B A-B A-B A A B B A+1 A all 0 C C C 00 0 0 0 0 00 00 00 00 00 11 1
VHDL
2/103
Arithmetic-logic units
M 0 0 0 0 1 1 1 1 S1 0 0 1 1 0 0 1 1 S0 0 1 0 1 0 1 0 1 Function Complement AND Identity OR Decrement Add Subtract Increment F A A AND B A A OR B A-1 A+B A-B A+1 X A A AND B A A OR B A A A A Y 0 0 0 0 all 1 B B all 0 C0 0 0 0 0 0 0 1 1
VHDL
c0
S0
S1
M S1
1 1 c0
2/104
Arithmetic-logic units
M 0 0 0 0 1 1 1 1 S1 0 0 1 1 0 0 1 1 S0 0 1 0 1 0 1 0 1 Function Complement AND Identity OR Decrement Add Subtract Increment F A A AND B A A OR B A-1 A+B A-B A+1 X A A AND B A A OR B A A A A Y 0 0 0 0 all 1 B B all 0 C0 0 0 0 0 0 0 1 1
VHDL
X 1
S0
S1
S1
M S0
a b S0 S1 M
bi
ai
2/105
1 1 1 1 1 1 1 1 1 1 1 1 1 1 X
Arithmetic-logic units
M 0 0 0 0 1 1 1 1 S1 0 0 1 1 0 0 1 1 S0 0 1 0 1 0 1 0 1 Function Complement AND Identity OR Decrement Add Subtract Increment F A A AND B A A OR B A-1 A+B A-B A+1 X A A AND B A A OR B A A A A Y 0 0 0 0 all 1 B B all 0 C0 0 0 0 0 0 0 1 1
VHDL
S0
S1 1
S1
M S0 1 1 1 1 1
a b S0 S1 M
bi
ai
2/106
Arithmetic-logic units
a4 b4 a3 b3 a2 b2 a1 b1 a0 b0
S01
M
ALE ALE ALE ALE X FA Cout f4 f3 f2 f1 f0 FA FA FA FA ALE Y
VHDL
2/107
VHDL
2/108
Decoders
E 0 0 0 0 1 1 1 1 A1 0 0 1 1 0 0 1 1 A0 0 1 0 1 0 1 0 1 C3 0 0 0 0 0 0 0 1 C2 0 0 0 0 0 0 1 0 C1 0 0 0 0 0 1 0 0 C0 0 0 0 0 1 0 0 0
E A1 A0
C3
C2
C1
C0
VHDL
C3..0
2/109
Decoders
A3..2 E Decoder
A1..0 E Decoder E
A1..0 Decoder E
A1..0 Decoder E
A1..0 Decoder
VHDL
C15..12
C11..8
C7..4
C3..0
2/110
VHDL
2/111
Selectors
S1 0 0 1 1 S0 0 1 0 1 Y D0 D1 D2 D3
D3
D2
D1
D0 S1 S0
VHDL
D3..0
In principle: 2-to-1 MUX is 1/2 CLB Due to special provisions: 4-to-1 MUX is 1 CLB
S1..0
4-to-1 MUX Y
2/112
Selectors
D3 D2 D1 D0
S1 0 0 1 1 S0 0 1 0 1 Y D0 D1 D2 D3
Decoder
S1 S0
Y Alternative implementation
VHDL
2/113
Selectors
D15..12 S1..0 S1..0 D11..8 S1..0 D7..4 S1..0 D3..0
4-to-1 selector
4-to-1 selector
4-to-1 selector
4-to-1 selector
VHDL
S3..2
4-to-1 selector Y
2/114
VHDL
2/115
Buses
Problem with high fan-in MUX:
fan-in OR gate too big all inputs have to be routed to 1 central location: substantial routing delay and difficult routing
VHDL
Decoder
2/116
Buses
In an FPGA (lab session) a limited number of tristate buffers is foreseen, connected to horizontal long lines. It is possible to indicate for a certain signal that we prefer to map it to a long line. Note that a Boolean signal already can have 4 different values:
0: the logical signal 0 1: the logical signal 1 x: dont care Z: high-impedant
VHDL
VHDL
2/118
Priority encoders
D3 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 D2 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 D1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 D0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
A1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 A0 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 Any 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Any
0 D2 D3 A1
D0
D1
D0
D1
0 0 0 0
VHDL
D2
D3 D0 D1
A0
1 1 D2 D3 1 1 1 1 1 1 1 1
2/119
Priority encoders
Any
D3 D0 D2 0 D3 A1 D0 D1 D0 D1
0 0 0 0
VHDL
Any A1
D3..0
A0
D2
D3 D0 D1
Any
1 1 1 1 1 1 1 1 1 1
2/120
Priority encoders
D15..12 D11..8 D7..4 D3..0
Priority encoder
Priority encoder
Priority encoder
Priority encoder
VHDL
Any
Priority encoder
4-to-1 MUX
4-to-1 MUX
A3..2
2/121
A1
A0
VHDL
2/122
Magnitude comparators
x1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 y1 1 0 0 0 0 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 x x0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 y y0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 G G (X>Y) (X>Y) 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 1 1 0 0 L L (X<Y) (X<Y) 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0
y0
x0 1
y1
x1
1 1 1 1 1 y0
x0
VHDL
y1
x1
1 1 1 1 1 1
2/123
Magnitude comparators
G x1 x0 y1 y0 y0 x0 1 y1
x1
1 1 1 1 1 y0
x0
VHDL
y1
x1
1 1 1 1 1 1
Comp
2/124
Magnitude comparators
x7 y7 G L x6 y6 x5 y5 x4 y4 x3 y3 x2 y2
x1 y1 x0 y0
x7 y7
Comp
x6 y6
x5 y5
Comp
x4 y4
x3 y3
Comp
x2 y2
x1 y1 x0 y0 Comp
VHDL
Comp
Comp
Comp G
2/125
Magnitude comparators
Simpler circuits are used for comparison with constants!!
X X x7 x6 X is 8 bits y y=1 when X>=64 y y=1 when X=0 x0 y y=1 when X is even y y=1 when X=255 y y=1 when X<192 x7 x6
VHDL
2/126
VHDL
2/127
VHDL
For a left shift m zeros are shifted in from the right For a right shift m times the MSB is shifted in from the left (for 2complement)
For a logic shift
VHDL
2/129
VHDL
4-to-1 MUX y3
4-to-1 MUX y2
4-to-1 MUX y1
4-to-1 MUX y0
2/130
S0
VHDL
S1
S2
2/131