VHDL Sequential Logic Modeling
VHDL Sequential Logic Modeling
Sequential Logic
Modeling
• Current state update could use IF or WAIT to monitor the rising edge
of the clock.
• Any CASE statement must cover all possible state values to control
the behavior of the state machine in unreachable states.
TYPE state IS
(ang 0, ang 1, ang 2, ang 3, ang 4, ang 5, ang 6, ang 7);
ENTITY fsm IS 0 0
PORT( clk, reset: IN std logic; 1
x: IN std logic;
y: OUT std logic); even odd
END ENTITY fsm; [0] [1]
reset MOORE
1
.
.
.
WHEN odd =>
IF x = ’1’ THEN
current state <= even;
ELSE
current state <= odd;
END IF;
END CASE;
END IF;
CASE current state IS
WHEN even =>
y <= ’0’;
WHEN odd =>
y <= ’1’;
END CASE;
END PROCESS same;
END ARCHITECTURE moore 1p;
clk
reset
y (Mealy)
y (Moore)
clock
hold time th
Propagation delay td
Combinational
logic
LIBRARY ieee;
USE ieee.std logic 1164.ALL;
ENTITY sr IS
GENERIC( width: positive := 4);
PORT( clk, clr, l in, r in, s0, s1: IN std logic;
d: IN std logic vector (width-1 DOWNTO 0);
q: INOUT std logic vector (width-1 DOWNTO 0));
END ENTITY sr;
.
.
.
LIBRARY ieee;
USE ieee.std logic 1164.ALL;
USE ieee.numeric std.ALL;
ENTITY rom IS
GENERIC( n: integer := 3;
m: integer := 6);
PORT( enable: IN std logic;
address: IN unsigned (n-1 DOWNTO 0);
data: OUT unsigned (m-1 DOWNTO 0));
END ENTITY rom;
.
.
.
.
.
.
memory: PROCESS (initialized, enable, address) IS
BEGIN
IF initialized THEN
IF enable = ’1’ THEN
data <= word(to integer(address));
ELSE
data <= (OTHERS => ’Z’);
END IF;
END IF;
END PROCESS memory;
END ARCHITECTURE init process arch;
Note: This process will actually run twice. But, the ROM itself will be
initialized only once.