ie1204 digital design l7: combinational circuits, introduction ......ie1204 digital design l7:...
TRANSCRIPT
![Page 1: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/1.jpg)
IE1204 Digital Design
L7: Combinational circuits,Introduction to VHDL
Masoumeh (Azin) Ebrahimi ([email protected])
Elena Dubrova ([email protected])KTH / ICT / ES
![Page 2: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/2.jpg)
• BV 318-339, 60-65, 280-291,341-365
This lecture
IE1204 Digital Design, Autumn 2015 2
![Page 3: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/3.jpg)
PLD (eg. PAL)
IE1204 Digital Design, Autumn 2015
Fan-in issue3
![Page 4: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/4.jpg)
FPGA (eg. Cyclone II)
IE1204 Digital Design, Autumn 2015
Typically 50000 logicelements
Technology : MUX tree4
![Page 5: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/5.jpg)
Multiplexer (MUX)
• The multiplexer canselect which input youare going to connectto the output
• ”If S then X, else Y”1
0
X
Y
S
Z
IE1204 Digital Design, Autumn 2015
Z = SX + SY
5
![Page 6: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/6.jpg)
Multiplexer (MUX)
• The multiplexer canselect which input youare going to connectto the output
• ”If S then X, else Y”1
0
X
Y
S
Z
IE1204 Digital Design, Autumn 2015
Z = SX + SY1
6
![Page 7: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/7.jpg)
Multiplexer (MUX)
• The multiplexer canselect which input youare going to connectto the output
• ”If S then X, else Y”1
0
X
Y
S
Z
IE1204 Digital Design, Autumn 2015
Z = SX + SY0
7
![Page 8: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/8.jpg)
Implementation of functions usingMUXes
How can the following functionsbe implemented with a 2:1multiplexer?
• Z = B (INV)• Z = AB (AND)• Z = A + B (OR)• Z = A Å B (XOR)
1
0
X
Y
S
Z
IE1204 Digital Design, Autumn 2015
Z = SX + SY
8
![Page 9: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/9.jpg)
Quickie Question …
IE1204 Digital Design, Autumn 2015
• How to connect the inputs of the MUX inorder to implement an inverter?
9
![Page 10: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/10.jpg)
Inverter implemented with a MUX
1
0
0
1Z
Input x0
1 0
x0 0 1
NOT
IE1204 Digital Design, Autumn 2015
Specification:if input = ’1’ then result <= ’0’;if input = ’0’ then result <= ’1’;
0 00 0 1
Z S X S Y
x x x NOT
= × + × =
= × + × =
10
![Page 11: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/11.jpg)
Quickie Question …
IE1204 Digital Design, Autumn 2015
• How to connect the inputs of the MUX inorder to implement an AND gate?
11
![Page 12: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/12.jpg)
AND implemented with a MUX
• Specification:
1
0
x0
0Z
x1
0 00 1
x0x1
0
1
0 1
IE1204 Digital Design, Autumn 2015
01101 0 xxxxxYSSXZ ×=×+×=+=
12
![Page 13: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/13.jpg)
AND implemented with a MUX
• Specification:
1
0
x0
0Z
x1
0 00 1
x0x1
0
1
0 1
IE1204 Digital Design, Autumn 2015
01101 0 xxxxxYSSXZ ×=×+×=+=1
13
![Page 14: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/14.jpg)
AND implemented with a MUX
• Specification:
1
0
x0
0Z
x1
0 00 1
x0x1
0
1
0 1
IE1204 Digital Design, Autumn 2015
01101 0 xxxxxYSSXZ ×=×+×=+=0
14
![Page 15: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/15.jpg)
OR implemented with a Mux
• Specification:
1
0
1
X0
Z
X1
0 11 1
x0x1
0
1
0 1
IE1204 Digital Design, Autumn 2015
1 01 0 0 1
0 11 0 0
11 0
{ } ( )
1
Z x x x x x x
SX SY x x x x x
x x x
= + + =
= + = + + × =
= × + ×15
![Page 16: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/16.jpg)
OR implemented with a Mux
• Specification:
1
0
1
X0
Z
X1
0 11 1
x0x1
0
1
0 1
IE1204 Digital Design, Autumn 2015
1 01 0 0 1
0 11 0 0
11 0
{ } ( )
1
Z x x x x x x
SX SY x x x x x
x x x
= + + =
= + = + + × =
= × + ×
1
16
![Page 17: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/17.jpg)
OR implemented with a Mux
• Specification:
1
0
1
X0
Z
X1
0 11 1
x0x1
0
1
0 1
IE1204 Digital Design, Autumn 2015
1 01 0 0 1
0 11 0 0
11 0
{ } ( )
1
Z x x x x x x
SX SY x x x x x
x x x
= + + =
= + = + + × =
= × + ×
0
17
![Page 18: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/18.jpg)
XOR implemented with a Mux
• Specification:
1
0
X0
X0
Z
X1
0 11 0
x0x1
0
1
0 1
IE1204 Digital Design, Autumn 2015
010101 xxxxxx
YSSXZ
Å=×+×=
=+=
18
![Page 19: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/19.jpg)
XOR implemented with a Mux
• Specification:
1
0
X0
X0
Z
X1
0 11 0
x0x1
0
1
0 1
IE1204 Digital Design, Autumn 2015
010101 xxxxxx
YSSXZ
Å=×+×=
=+= 1
19
![Page 20: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/20.jpg)
XOR implemented with a Mux
• Specification:
1
0
X0
X0
Z
X1
0 11 0
x0x1
0
1
0 1
IE1204 Digital Design, Autumn 2015
010101 xxxxxx
YSSXZ
Å=×+×=
=+= 0
20
![Page 21: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/21.jpg)
Hierarchy of MUXes
1
0
X11
X10
Z
S1
1
0
1
0
X01
X00
S0
11100100
ZX01
S1S0
IE1204 Digital Design, Autumn 2015
X00
X10
X11
000
0X00
X10
21
![Page 22: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/22.jpg)
1 1 0 0
0 1 1 0
xyz 00 01 11 10
0
Implementation of larger functionswith MUXes
An (n + 1)-input function can be implemented with a MUX that has nselect inputs!
Choose any of the inputs as address inputs ...
... And minimize/implement function for each input.Draw new Karnaugh diagrams if necessary.
IE1204 Digital Design, Autumn 2015
x y
f
z 11100100
01z
zyyxxzf ++=1
22
![Page 23: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/23.jpg)
• Any Boolean function f (xn, ..., x1, x0) can be partitioned asf(xn, ..., x1, x0) = x0 f1(xn, ..., x1,1) + x0 f0(xn, ..., x1,0)
• The function can then be implemented with a multiplexer
Mapping into MUXes:Shannon decomposition (BV 6.1.2)
IE1204 Digital Design, Autumn 2015
fxn
x0
x1
f1xn
1x1
f0xn
0x1
f
x0 123
![Page 24: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/24.jpg)
• Any Boolean function f (xn, ..., x1, x0) can be partitioned asf(xn, ..., x1, x0) = x0 f (xn, ..., x1,1) + x0 f (xn, ..., x1,0)
• The function can then be implemented with a multiplexer
Mapping into MUXes:Shannon decomposition (BV 6.1.2)
IE1204 Digital Design, Autumn 2015
fxn
x0
x1
f1xn
1x1
f0xn
0x1
f
x0 024
![Page 25: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/25.jpg)
Mapping to MUXes:Shannon decomposition
• Any Boolean function f (xn, ..., x1, x0) can be decomposed(recursively) as
f(xn,...,x1,x0) = x0 f1(xn, ..., x1,1) + x0 f0(xn, ..., x1,0)= x1x0 f11(xn, ..., x2,1,1) + x1x0 f10(xn, ..., x2,1,0)+ x1x0 f01(xn, ..., x2,0,1) + x1x0 f00(xn, ..., x2,0,0)
IE1204 Digital Design, Autumn 2015
1
0
f11
f10
f
x1
1
0
1
0
f01
f00
x0
1
0f
x0
f1
f0
f1
f0
25
![Page 26: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/26.jpg)
Proof
• Right-hand side:– If x0 = 1 then the right term is zero. Then f is equal to the left term.– If x0 = 0, the left term is zero. Then f is equal to the right term.
• Left-hand side:– if x0 = 1, then f is equal to f (xn, ..., x1,1) (= left term on the right-hand side)– if x0 = 0 then f is equal to f (xn, ..., x1,0) (= right term in the right-hand side)
• Left-hand side = Right-hand side
IE1204 Digital Design, Autumn 2015
)0,,...,()1,,...,(),,...,( 101001 xxfxxxfxxxxf nnn ×+×=
Right-hand sideLeft-hand side
Right termLeft term
26
![Page 27: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/27.jpg)
Mux circuits
0 1 0 1
1 0 1 0
yzx
0
1
Address
10
z
10
10
y
10
10
10
10
x
111 1
011 0
101 0
001 1
110 0
010 1
100 1
000 0
AddressBut this is a memory
(ROM, RAM ...) Address pins
Value
IE1204 Digital Design, Autumn 2015
00 01 11 10
XYZ
27
![Page 28: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/28.jpg)
Look-up tables (LUT)
0/1
0/1
0/1
0/1x1
x2
f
Two-input LUT
Programmablecell 1
0
1
0
1
0
A LUT with n inputs canrealize all combinationalfunctions with up to ninputs
IE1204 Digital Design, Autumn 2015 28
![Page 29: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/29.jpg)
Example: XOR gate
0
1
1
0x1
x2
f
Two-input LUT
ProgrammedValues 1
0
1
0
1
0
IE1204 Digital Design, Autumn 2015
1 2
1 1 01 0 10 1 10 0 0
x x f
29
![Page 30: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/30.jpg)
• The simplest FPGA cell consists of a singletable (e.g. Look-Up-Table - LUT), a D flip-flop and a bypass MUX.
A simple FPGA cell
IE1204 Digital Design, Autumn 2015
LUT D Q
CLK
ABCD M
RESET
S01
D-flipflop will be explained soonin this course
30
![Page 31: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/31.jpg)
One way to identify functions...
n inputs => 2(2n) possibledifferent Boolean functions
IE1204 Digital Design, Autumn 2015
MSB
LSB
)(69960123 "0101100110100110"),,,( Hfxxxxf ==
The functions that are storedin a LUT are usuallynumbered after the numberthat is made up of the 1's inthe truth table / Karnaughmap.
Bit # 15 Bit # 0Bit # 1
31
![Page 32: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/32.jpg)
LUT function number
IE1204 Digital Design, Autumn 2015
69960123 "0101100110100110"),,,( fxxxxf ==
01236996 xxxxf ÅÅÅ=
With a LUT, all functions arerealized in the same way, so allof them have the same costOdd parity
32
![Page 33: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/33.jpg)
• Mostly used as address decoders• Only one output is active when the
'enable' (En) signal is active• The active output is selected by a1a0
Decoder
En a1 a0 y0 y1 y2 y3
1 0 0 1 0 0 01 0 1 0 1 0 01 1 0 0 0 1 01 1 1 0 0 0 10 - - 0 0 0 0
a0
a1
En
y3y2y1y0
IE1204 Digital Design, Autumn 2015
2-to-4 decoder
33
![Page 34: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/34.jpg)
Demultiplexer
• The demultiplexer has basically the same functionas the decoder, but it is drawn differently
• The input I is connected to a selected output
I a1 a0 y0 y1 y2 y3
1 0 0 1 0 0 01 0 1 0 1 0 01 1 0 0 0 1 01 1 1 0 0 0 10 - - 0 0 0 0
a1a0
I
y3y2y1y0
IE1204 Digital Design, Autumn 2015
a1a0
y3y2y1y0
10
I
34
![Page 35: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/35.jpg)
Read-Only Memory
0/1 0/1 ... 0/1
0/1 0/1 ... 0/1
.
.
.
0/1 0/1 ... 0/1
a0
a1
...am-1
Sel0
Sel1
.
.
.
Sel2m-1
En
dn-1 dn-2 …. d0
IE1204 Digital Design, Autumn 2015
Programablebits
Three-statebuffers
Decoder
35
![Page 36: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/36.jpg)
Encoders
• Encoder has the opposite function to adecoder, i.e. it translates 2N bit input into anN-bit code.– The information is greatly reduced
IE1204 Digital Design, Autumn 2015
2n
inputs
w0
w2n 1-
y0
yn 1-
noutputs
w0 w1 w2 w3 y1 y0
1 0 0 0 0 00 1 0 0 0 10 0 1 0 1 00 0 0 1 1 1
36
![Page 37: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/37.jpg)
Priority Encoder
• A Priority Encoder gives back the address of the input withthe lowest (or highest) indices that are set to 1 (or 0depending on what you are looking for)
• If all inputs are 0, the output z = 0, else z = 1
w0 w1 w2 w3 z y1 y0
1 - - - 1 0 00 1 - - 1 0 10 0 1 - 1 1 00 0 0 1 1 1 10 0 0 0 0 - -
IE1204 Digital Design, Autumn 2015
The output is well-defined even ifseveral inputs areactive at the sametime.
37
![Page 38: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/38.jpg)
Overview
a1a0
y3y2y1y0
IE1204 Digital Design, Autumn 2015
S1S0
w3w2w1w0
Demultiplexer
Multiplexer
Decoder
Encoder
f y1
y0
w3w2w1w0
noutputs
w0
w1
En
y3y2y1y0
ninputs
2n
outputs
2n
inputs
Equivalent
Z Used in priorityencoders
I
38
![Page 39: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/39.jpg)
Code converters
• A code converter translates from one code toanother. Typical examples are:– Binary to BCD (Binary-Coded Decimal)– Binary to Gray code– 7-4-2-1 code– BCD to seven-segment decoder
w0
w1
w2
w3
abcdefg
a
b
c
d
e
f
g
IE1204 Digital Design, Autumn 2015
A variant of the 7-4-2-1code is used today tostore the bar code
39
![Page 40: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/40.jpg)
BCD-to-seven segment decoder
IE1204 Digital Design, Autumn 2015
1011
111
w0 a
1
b
0 1
11
1
01
101
0
0
w1
011
0
0
w2
000
0
1
w3
000
0
0
c
1010
0110
1110
0001
1001
1111
011
0
1 1
11
1
11
011
1
d
0
10
0
10
e
101
1
1
01
0
01
000
1
f
1
00
1
11
g
101
1
1
11
1
01
• BCD-to-7 segment decoder consists of 7 differentcombinatorial circuits, one for each segment
• To get optimal circuits, all 7 functions have to be minimizedsimultaneously so that common logic is shared
w0w1w2w3
40
![Page 41: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/41.jpg)
Disadvantage of binary codes
IE1204 Digital Design, Autumn 2015
· For safe data registration use Gray code· For data processing use binary code
Binary code, adjacent code words:1-2 double change3-4 triple change5-6 double change7-8 quadruple change!9-A double changeB-C quadruple change!D-E double changeF-0 quadruple change!
Can two bits change at exactly the same time?
41
![Page 42: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/42.jpg)
• By changing the order of the codewords in abinary code, one construct codes in which nomore than one bit is changing at a time
• Such codes are called Gray codes
Gray code
IE1204 Digital Design, Autumn 2015
0000, 0001, 0011, 0010, 0110, 0111, 0101, 01001100, 1101, 1111, 1110, 1010, 1011, 1001, 1000
42
![Page 43: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/43.jpg)
Conversion between binary and Gray
IE1204 Digital Design, Autumn 2015
Binary ® Gray:If Binary bit bn and bit bn-1 are different,the Gray code bit gn-1 is ”1", else ”0".
Gray ® Binary (most common transformation direction):If Binary bit bn and Gray code bit gn-1 are different theBinary bit bn-1 is ”1", else ”0".
43
![Page 44: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/44.jpg)
Logic for Gray to Binary conversion
IE1204 Digital Design, Autumn 2015
XOR-gate is ”1” if itsinputs are different! 4 bit code converter
Gray code to Binary code
Gray/Bin
44
![Page 45: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/45.jpg)
Logic for Gray to Binary conversion
IE1204 Digital Design, Autumn 2015
XOR-gate is ”1” if itsinputs are different! 4 bit code converter
Gray code to Binary code
Gray/Bin0 0 1 0
0 0 1 1
45
![Page 46: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/46.jpg)
Introduction to VHDL
• VHDL is a language used to specify thehardware– HDL - VHSIC Hardware Description Language– VHSIC - Very High Speed Integrated Circuit– Used mostly in Europe
• Verilog is another language used to specifythe hardware– Used mostly in the United States
IE1204 Digital Design, Autumn 2015 46
![Page 47: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/47.jpg)
Why VHDL?
• VHDL is used to– verify that you have connected right by simulating the
circuit– describe the large structures in a simple way and then
generate the circuit by synthesis– allows for structured descriptions of a circuit
IE1204 Digital Design, Autumn 2015
VHDL increases the level of abstraction!
47
![Page 48: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/48.jpg)
• There are two types of VHDL code– VHDL for synthesis: The code is used as an
input to a synthesis tool which converts it intoan implementation (for example FPGA or ASIC)
– VHDL modeling and simulation code is used todescribe a system at an early stage. Since thecode can be simulated so you can checkwhether the intended functionality is correct
Types of VHDL code
IE1204 Digital Design, Autumn 2015 48
![Page 49: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/49.jpg)
Entity
IE1204 Digital Design, Autumn 2015
CinAB
SCout
FA
ENTITY fulladder ISPORT( A,B,Cin : IN STD_LOGIC;
S,Cout : OUT STD_LOGIC);END fulladder;
The entity describes the ports to the outside of the circuit.The circuit as a block.
49
![Page 50: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/50.jpg)
Architecture
IE1204 Digital Design, Autumn 2015
CinAB
SCout
FA
ARCHITECTURE behave OF fulladder ISBEGIN
S <= A xor B xor Cin;Cout <= (A and B) or (A and Cin) or (B and Cin);
END behave;
Architecture describes the function inside the circuit.
50
![Page 51: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/51.jpg)
Entity
• An entity describes a component's interface with theoutside world
• PORT-declaration indicates if it is an input or an output• An Entity is a symbol of a component.
ENTITY xor_gate ISPORT (x, y: IN BIT;
q: OUT BIT);END xor_gate;
x
yqxor_gate
IE1204 Digital Design, Autumn 2015
Use English names for variable names in the code!
51
![Page 52: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/52.jpg)
VHDL Basics
• PORT declaration establishes interface between thecomponent and the outside world
• A port declaration contains three things:– The name of the port– The direction of the port– Port's datatype
• Example: ENTITY test ISPORT ( name : direction data_type);
END test;
IE1204 Digital Design, Autumn 2015 52
![Page 53: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/53.jpg)
The most common data types
• Scalars (single-variable signals)– Bit ("0", "1")– Std_logic ('U', '0', ’1', 'X', 'Z', 'L', 'H', 'W', '-')– Integer– Real– Time
• Vectors (many-variable signals)– BIT_VECTOR - vector of bits– STD_LOGIC_VECTOR - vector of std_logic
IE1204 Digital Design, Autumn 2015 53
![Page 54: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/54.jpg)
Architecture
• An architecture describes the operation of a component• An entity can have many architectures, but only one can be
active at a time• An architecture corresponds to the component diagram or
behavior
ARCHITECTURE behavior OF xor_gate ISBEGIN
q <= a xor b after 5 ns;End behavior;
x
yq
IE1204 Digital Design, Autumn 2015
Code for Simulation
54
![Page 55: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/55.jpg)
VHDL Example: 4/1 MUX
IE1204 Digital Design, Autumn 2015
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY Multiplexer_41 IS
PORT(ce_n: IN std_logic; -- Chip Enable (active low)
data_in: IN std_logic_vector(3 DOWNTO 0);
sel: IN std_logic_vector(1 DOWNTO 0);
data_out: OUT std_logic); -- TriState Output
END ENTITY Multiplexer_41;
sel(1) sel(0)
data_out11100100
data_in(3)data_in(2)data_in(1)data_in(0)
ce_n
Ñ
55
![Page 56: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/56.jpg)
VHDL Example: 4/1 MUX (cont.)
IE1204 Digital Design, Autumn 2015
ARCHITECTURE RTL OF Multiplexer_41 IS
BEGIN
PROCESS(ce_n, data_in, sel)
BEGIN
IF ce_n = '1' THEN
data_out <= 'Z';
ELSE
CASE sel is
WHEN "00"=> data_out <= data_in(0);
WHEN "01"=> data_out <= data_in(1);
WHEN "10"=> data_out <= data_in(2);
WHEN "11"=> data_out <= data_in(3);
WHEN OTHERS => null;
END CASE;
END IF;
END PROCESS;
END ARCHITECTURE RTL;
sel(1) sel(0)
data_out11100100
data_in(3)data_in(2)data_in(1)data_in(0)
ce_n
Ñ
56
![Page 57: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/57.jpg)
• The study material on synthesis shows anumber of VHDL constructs and theresulting hardware
• The following slides contain extra materialThe book gives many examples anddetailed explanations of VHDL
More on VHDL
IE1204 Digital Design, Autumn 2015 57
![Page 58: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/58.jpg)
• The course textbook contains a CD with thesynthesis tool, Quartus
• You will use Quartus in Lab 3
Synthesis tool Quartus
IE1204 Digital Design, Autumn 2015 58
![Page 59: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/59.jpg)
• Implementation of functions with MUXes– Shannon decomposition
• Look-up tables, ROM• Decoder, encoder, code converters• Introduction to VHDL• Next lecture: BV pp. 383-418, 469-471
Summary
IE1204 Digital Design, Autumn 2015 59
![Page 60: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/60.jpg)
VHDL (Not part of the exam)
IE1204 Digital Design, Autumn 2015 60
![Page 61: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/61.jpg)
Signal declaration
Signal-declaration is used inside architectures to declareinternal (local) signals:
signal a, b, c, d: bit;
signal a, b, sum: bit_vector (31 downto 0);
Signal-assignment is used to describe the behavior:
sum <= a + b; signal assignment without delay
IE1204 Digital Design, Autumn 2015 61
![Page 62: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/62.jpg)
VHDL description styles
• Structural– similar to how to connect components
• Sequential– similar to how to write desktop applications
• Data Flow– Concurrent assignments
IE1204 Digital Design, Autumn 2015 62
![Page 63: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/63.jpg)
Sequential vs Parallel Code
• There are two types of code execution in VHDL:sequential and parallel
• Hardware can then be modeled in two different ways
– VHDL supports different levels of abstraction.
• Sequential code describes the hardware from a"programmer's" point of view and it is executed in theorder which is defined
• The parallel code is executed regardless of the order. It isasynchronous.
IE1204 Digital Design, Autumn 2015 63
![Page 64: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/64.jpg)
Sequential style
XOR gatex
yq
Process (x, y)begin
if (x/= y) thenq <= '1';
elseq <= '0';
end if;end process;
IE1204 Digital Design, Autumn 2015 64
![Page 65: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/65.jpg)
Data flow style
XOR gatex
yq
q <= a xor b;
- Or in behavioral dataflow style
q <= '1' When a /= b else "0";
IE1204 Digital Design, Autumn 2015 65
![Page 66: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/66.jpg)
Structural style
IE1204 Digital Design, Autumn 2015
x
yq
u1: not_gate port map (x,xi);u2: not_gate port map (y,yi);u3: and_gate port map (xi,y,t3);u4: and_gate port map (yi,x,t4);u5: or_gate port map (t3,t4,q);
yi
xi t3
t4
66
![Page 67: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/67.jpg)
Structural Code
• A component must be declared before it can be used
• It is necessary, unless it is not in a library somewhere
ARCHITECTURE Test OF test_entityCOMPONENT and_gatePort (in1, in2: IN BIT;
out1: BIT OUT);END COMPONENT;
... more statements...
IE1204 Digital Design, Autumn 2015 67
![Page 68: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/68.jpg)
Instantiation
• Component instantiation ring connects the componentinterface with the signals in the architecture
ARCHITECTURE Test OF test_entityCOMPONENT and_gatePort (in1, in2: IN BIT;
out1: BIT OUT);END COMPONENT;SIGNAL S1, S2, S3: BIT;
BEGINGate1: and_gate PORT MAP (S1, S2, S3);
END test;
IE1204 Digital Design, Autumn 2015
in1
in2out1
S1
S2S3
68
![Page 69: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/69.jpg)
Generate
• Generate-statement couples many similar elementsENTITY adder IS
GENERIC (N: integer)PORT (a, b: IN bit_vector (N-1 downto 0);
sum: OUT bit_vector (N-1 downto 0));END adder;ARCHITECTURE OF structural adder ISCOMPONENT full_adderPORT (a, b, cin: IN bit; cout, s: OUT bit);
END COMPONENT;signal c: bit_vector (N-2 downto 0);
BEGING0: for i in 1 to N-2 GenerateU0: full_adder PORT MAP (a (i), b (i), c (i-1), c (i), p (i));
end Generate; - G0U0: full_adder PORT MAP (a(0), b(0), ’0’, c(0), p(0));UN: full_adder PORT MAP (a(n-1),b(n-1),c(n-2),OPEN, s(n-1);
END structural;
IE1204 Digital Design, Autumn 2015 69
![Page 70: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/70.jpg)
Generate n-bit adder
IE1204 Digital Design, Autumn 2015
FA
a1 b1
cin1FA
a0 b0
cin0
s0s1
FA
an-1 bn-1
cinn-1
sn-1
cut0cutn-1
Five lines of code generates the ripple-carry n-bit adderfrom F5!
70
![Page 71: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/71.jpg)
The test bench stimuli 1
IE1204 Digital Design, Autumn 2015
ENTITY testbench IS END testbench;
ARCHITECTURE xor_stimuli_1 of testbench ISCOMPONENT xor_gatePORT(x,y:IN bit; q:OUT bit);
END COMPONENT;signal x,y,u1:bit;
BEGINx <= not(x) after 10 ns;y <= not(y) after 20 ns;U1:xor_gate PORT MAP (x,y,ut1);
END example;
The ENTITY is empty!
Here are the testsignals generated
The circuit under test isused as a component of thetest bench program
71
![Page 72: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/72.jpg)
The test bench stimuli 2
IE1204 Digital Design, Autumn 2015
ENTITY testbench IS END testbench;
ARCHITECTURE xor_stimuli_2 of testbench ISCOMPONENT xor_gatePORT(x,y:IN bit;q:OUT bit);
END COMPONENT;signal x,u1,u2,u3:bit; -- Endast en in-signalfor U1:xor_gate use entity work.xor_gate(behave);for U2:xor_gate use entity work.xor_gate(data_flow);for U3:xor_gate use entity work.xor_gate(structural);
BEGINx <= not(x) after 10 ns;U1:xor_gate PORT MAP (x,x,ut1);U2:xor_gate PORT MAP (x,x,ut2);U3:xor_gate PORT MAP (x,x,ut3);
END example;
72
![Page 73: IE1204 Digital Design L7: Combinational circuits, Introduction ......IE1204 Digital Design L7: Combinational circuits, Introduction to VHDL Masoumeh (Azin) Ebrahimi (masebr@kth.se)](https://reader033.vdocuments.us/reader033/viewer/2022051607/6039b0b507afd125b949963f/html5/thumbnails/73.jpg)
Test bench
IE1204 Digital Design, Autumn 2015
A test bench can mark when the desired eventsoccur during the execution.
Or mark when unwanted events occur
The result of a run with a test bench can be saved in a file, as proofthat everything is ok - or as a troubleshooting aid if it did not gowell.
73