Midterm Exam
Review
Suketu Naik
Combinational
Logic
Suketu Naik
Suketu Naik
Boolean Algebra
A1=A
Complement:
AA=0
A+A= 1
Commutativity: A + B = B + A
AB=BA
Associativity: A + (B + C)= (A + B) + C
A (BC) = (AB) C
Distributed Law: A (B + C) = AB + AC
A + BC= (A + B) (A + C)
Important:
A+A=A
Note:
A + B = AB + AB
DeMorgans:
AA =A
(A + B + ) = AB
EE 3610 Digital Systems
A B +A B=A
(ABC) = A+B+
Suketu Naik
Co
ADDER
Ci
Truth Table
Outputs
Simplification
EE 3610 Digital Systems
Suketu Naik
Karnough Maps
Simplification can be difficult; use K-Map
Suketu Naik
Suketu Naik
NAND Gate
A
Vout
Suketu Naik
Sequential
Logic
Suketu Naik
Introduction
10
Combinational Logic
Mathematical function: single input has a single and unique output
Same inputs produce same outputs
Sequential Logic
Output depends on current and past inputs
Same inputs can yield different outputs, depending on memory
Suketu Naik
SR Truth Table
11
1) Active HIGH
2) S=1, R=1 is metastable
(invalid)
Red =1
Black=0
Suketu Naik
12
D flip-flop symbol
(Qs)
Clock
Timing Diagram
While Clock (Enable) stays Clock
high, Qs will follow D after
D
some delay; while clock stays
low, Qs will remember its
Qm
previous state and will not
respond to any changes in D Qs
until the clock goes high again
Suketu Naik
13
Timing Diagram
Suketu Naik
JK Flip-Flop
JK flip-flop circuit
JK flip-flop symbol
J
14
CLK
Q
Y
Clock
Truth Table
Timing Diagram
If J and K are different, Q takes the value of J at the next clk edge
If J and K are both low, no change occurs
If J and K are both high, the output will toggle
EE 3610 Digital Systems
Suketu Naik
T Flip-Flop
T flip-flop symbol
1
J
K
15
Timing Diagram
Q
Q
T (CLK)
Suketu Naik
4-bit Register
16
Suketu Naik
Counters
17
Binary 4-bit
Synchronous Up
Counter
Output in
synchronization with
the clock
Individual output bits
change state at exactly
the same time in
response to the
common clock signal:
no ripple effect and no
propagation delay.
EE 3610 Digital Systems
Suketu Naik
Multiplexer (MUX)
18
4-to-1 Multiplexer
Truth Table
dxxs1s0
dxxs1s0
EE 3610 Digital Systems
Suketu Naik
Demultiplexer (DMX)
19
1-to-4 Demultiplexer
Select input to output based on S1S0
3 input AND gate
Truth Table
ds1s0
ds1s0
EE 3610 Digital Systems
Suketu Naik
20
Legend:
input/output
State
00
01
11
10
State table
Suketu Naik
21
State table
State
00
01
11
10
Transition Table
Q1 Q2
D Flip-Flop
D
Q
Q
Q1 + Q 2 +
X=0
X=1
X=0
X=1
00
00
01
01
00
11
11
10
11
10
00
01
Suketu Naik
22
Q 1 Q2
Q1 + Q2 +
X=0
X=1
X=0
X=1
00
00
01
01
00
11
11
10
11
10
00
01
K-maps
Q1 +
X
Q2 +
00
01
11
10
Q1Q2
00
01
11
10
Q1Q2
00
01
11
10
Q1Q2
Suketu Naik
23
Q2 +
00
01
11
10
Q1Q2
00
01
11
10
Q1Q2
XQ2
Z
X
00
01
11
10
Q1Q2
Q1 Q 2
D1 = Q1+ = X Q2 + Q1 Q2
D 2 = Q2+ = X
Z = X Q 1 Q2
Dont forget:
1) Q1 , Q2 are the outputs (current states) of the FFs,
2) Q1+, Q2+ are the inputs (next states) to the FFs,
3) Z is the final output of the design
EE 3610 Digital Systems
Suketu Naik
24
Step 8: Circuit !
Q1+ = XQ2 + Q1Q2
Q1Q2
Z = XQ1Q2
Q2+ = X
Q1+
SET
Q1
XQ2
CLR
Q1Q2
Q2
Q1
Q2
Q2+
SET
CLR
Q2
Suketu Naik
25
VHDL
Suketu Naik
VHDL: Overview
26
Model
Mathematical Description of a physical device
Simulation
Analysis (automated) of a model given a set of inputs
Digital Circuit Models
Structural: defines sub-models and how they are
interconnected (FFs, Gates, etc)
Behavioral: defines the behavior of the circuit (no
actual components)
Suketu Naik
27
S <=AB
Behavioral
(Algorithms, Dataflow)
Structural
(Components,
interconnections)
Physical
Suketu Naik
Combinational Circuits
28
Concurrent Statements
C<=A and B after 5 ns;
E<=C or D after 5 ns;
Order is not important
E<=C or D after 5 ns;
C<=A and B after 5 ns;
EE 3610 Digital Systems
Suketu Naik
Priority of Operators
29
Suketu Naik
30
+ Ci
entity FullAdder is
port (A,B,Ci: in bit
Co,S: out bit
end FullAdder;
architecture Eq of FullAdder is
begin
S <= A xor B xor Ci;
Co <= (A and b) or (A and Ci) or (B
and Ci);
end Eq;
Use ( )to specify order of
precedence
EE 3610 Digital Systems
Suketu Naik
Suketu Naik
32
Propagation
Suketu Naik
33
entity CLA1 is
port(A,B,C1: in std_logic;
P,G,S: out std_logic);
end CLA1;
architecture behav of CLA1 is
begin
S <= A xor B xor C1;
P <= A or B; --A xor B is more accurate
G <= A and B;
end behav;
Suketu Naik
34
Suketu Naik
35
Suketu Naik
Sequential Statements
36
Suketu Naik
37
--------------------------------------------
process(D, G)
begin
if (G='1') then
Q <= D;
end if;
end process;
-------------------------------------------EE 3610 Digital Systems
Suketu Naik
D Flip Flop
entity DFF is
port (D, CLK, CLR: in bit;
Q: out bit; QN: out bit:='1');
CLR
signals
end DFF
architecture so of DFF is
begin
process (CLK,CLR)
begin
if CLR='0' then
Rising Edge of the
Q <='0'; QN<='1';
Clock
else if CLK'event and CLK='1' then
Can also use
Q <= D after 10 ns;
if rising_edge(clk)) then
QN <= not D after 10 ns;
end if;
end if;
end process;
EE 3610 Digital Systems
Suketu Naik
State Machines
39
Enumerated Types
type state_type is(state A, state B,...);
signal present_state, next_state:state_type
Suketu Naik
40
F <= I0
I1
I2
I3
when
when
when
when
B='00' else
B='01' else
B='10' else
B='11';
not necessary
bit_array (1 down to 0)
Suketu Naik
Arrays
41
Suketu Naik
Loops: Examples
42
Suketu Naik
43
Suketu Naik
Usefulness of ROM
Figure
9.20
8-Word
X 4-Bit
ROM
ROM can
model
anyAn
n-input,
m-output
combinational
44
logic problem
Example: BCD to 7-Segment Display
Inputs: 4 bit BCD code
Outputs: 7 control signals for the display
Suketu Naik
45
use ieee.std_logic_1164.all;
entity rom16x8 is
port(addr: in integer range 0 to 15;---can also have bits
here instead
data: out std_ulogic_vector(7 downto 0));
end entity;
architecture sevenseg of rom16x8 is
type rom_array is array (0 to 15) of std_ulogic_vector (7
downto 0);
constant rom: rom_array := ( 11111011, 00010010,
10011011, 10010011, 01011011, 00111010,
11111011, 00010010, 10100011, 10011010,
01111011, 00010010, 10101001, 00110110,
11011011, 01010010);
begin
data <= rom(addr);-may have to use to to_integer if bits
end architecture;
EE 3610 Digital Systems
Suketu Naik
46
Vector/Numeric
Conversions
Suketu Naik
Vector/Numeric Conversions
47
unsigned_vect
<= to_unsigned
(int, 8) FPGA
Figure 9.32
Layout of a Typical
int <= to_integer (unsigned_vect);
unsigned_vect <= unsigned (vect);
vect <= std_logic_vector (unsigned_vect);
Suketu Naik
48
Registers
and Counters
in VHDL
Suketu Naik
Register
49
-- shift register
process (clk, reset)
begin
if reset = '1' then
tsr <= "111111111";
elsif rising_edge (clk) then
if load = '1' then
tsr <= tbr & '0';
elsif shift = '1' then
tsr <= '1' & tsr(8 downto 1);
end if;
end if;
end process;
tsmt <= tsr(0);
EE 3610 Digital Systems
Suketu Naik
Counter
50
--Timer
Process (clk)
begin
if rising_edge (clk) then
if full_bit = '1' then t <= 5208;
else t <= t-1;
end if;
end if;
end process;
timeout <= '1' when t = 0 else '0';
Suketu Naik
51
State Machine
Charts
Suketu Naik
52
X
A
Z1=X
X
Z1=X
X
0
B
X
Z1
Z1
Z2
C/Z2
1
0
State Box
Condition
EE 3610 Digital Systems
Conditional Output
Suketu Naik
21
Suketu Naik
54
Suketu Naik
55
FPGAs contain
an 9.32
array Layout
of logic cells
configurable
logic blocks
Figure
ofcalled
a Typical
FPGA
CLB
Programmable
Interconnect
Area
Suketu Naik
56
Suketu Naik
Xilinx's CLB
57
Suketu Naik
58
16:1 MUX
Address (A[3:0]):
(1) Dynamically changes the length of the shift register
(2) Asynchronous path to D (output)
EE 3610 Digital Systems
Suketu Naik
59
Suketu Naik
60
Debouncer
and
Single Pulser
Suketu Naik
61
Suketu Naik
62
Suketu Naik
63
entity spulser is
port(reset, SYNCPRESS:in std_logic;
SP: out std_logic);
end spulser;
architecture behav of spulser is
type state_type is (S0,S1);
signal pstate, nstate:state_type;
begin
------------STATE REGISTER--------------------------------process(clk, reset) ----without reset in the sensitivity list,
--it's a sync process
begin
if reset='1' then
pstate <= S0;
elsif rising_edge(clk) then -- rising edge of clock
pstate <= nstate;
end if;
end process;
-------------------------------------------------------------EE 3610 Digital Systems
Suketu Naik
64
Suketu Naik