Professional Documents
Culture Documents
Lec #3 - State Machine Charts Using VHDL (New 2024)
Lec #3 - State Machine Charts Using VHDL (New 2024)
(Lecture #3)
Rashid A Saeed
• Counters
• Shift Registers
• Arbitrary finite state machines (FSM)
–Mealy and Moore model designs
Half Adder
Full Adder
Lookahead carry
Subtraction
Dual Mode M=0 (adder), M=1 (Subtracter)
Overflow
Comparator
Decoder
Encoder (4- Bit Priority, Decimal to Binary or BCD
Encoder) 6
process(sensitivity-list)
A basic process form: Begin
sequential-statements
end process;
Modeling Flip-Flops Using VHDL Processes
1 entity JKFF is
J-K Flip-Flop 2 Port (SN, RN, J, K, CLK: in bit; Q, QN: out bit);
Model 3 end JKFF;
4 architecture JKFF1 of JKFF is
5 signal Qint: bit; --- internal value of Q
6 begin
7 Q<=Qint;
8 QN<=not Qint;
9 process (SN, RN, CLK)
10 begin
11 if RN=‘0’ then Qint<=‘0’ after 8ns; --- RN=‘0’ will clear the FF
12 elsif SN=‘0’ then Qint<=‘1’ after 8ns; --- SN=‘0’ will set the FF
13 elsif CLK’event and CLK =‘0’ then --- falling edge of CLK
14 Qint<=(J and not Qint) or (not K and Qint) after 10ns;
15 end if;
16 end process;
17 end JKFF1;
Modeling Registers and Counters Using VHDL Processes
Q1 Q3; Q 2 Q1; Q3 Q 2;
Modeling Registers and Counters Using VHDL Processes
Register with
Synchronous
Clear and Load
Left-Shift Register
with Synchronous
Clear and Load
Modeling Registers and Counters Using VHDL Processes
• Counters
• Shift Registers
• Arbitrary finite state machines (FSM)
–Mealy and Moore model designs
library ieee;
use ieee.std_logic_1164.all;
entity detect is
port( clk, reset_n, w : in std_logic;
z : out std_logic);
end detect;
1/0
A B 1/1
w/z 0/0
0/0
Fall 2021@Rashid A Saeed 23
Mealy ’11’ detector VHDL
code