Process Statements - Wait Statements - Variable and Signal Assignments - If and Case Statements - Loop Statements - While Statements
Process Statements - Wait Statements - Variable and Signal Assignments - If and Case Statements - Loop Statements - While Statements
State Machines
• Until now, we showed state machines being
modeled by data flow (using concurrent
statements)
• We will describe using algorithmic or procedural
form using conventional programming language
semantics
– process statements
– wait statements
– variable and signal assignments
– if and case statements
– loop statements
– while statements
Sequential Style Syntax
[ process_label : ] PROCESS
[( sensitivity_list )]
-- process_declarations NO
BEGIN SIGNAL
process_statements DECLARATIONS!
END PROCESS [ process_label ];
Summation:
PROCESS( A, B, Cin)
BEGIN
Sum <= A xor B xor Cin;
END PROCESS Summation;
Summation: PROCESS
BEGIN
Sum <= A xor B xor Cin;
WAIT ON A, B, Cin;
END PROCESS Summation;
S0
000 S1
S7 001
111
S6 S2
110 010
S5 S3
101 011
S4
100
VHDL Model of Counter
architecture ALGORITHM of BIN_COUNTER is
begin
process
variable PRESENT_STATE: BIT_VECTOR(2 downto 0) := B”111”;
begin
case PRESENT_STATE is
when B”000” => PRESENT_STATE := B”001”;
when B”001” => PRESENT_STATE := B”010”;
when B”010” => PRESENT_STATE := B”011”;
when B”011” => PRESENT_STATE := B”100”;
when B”100” => PRESENT_STATE := B”101”;
when B”101” => PRESENT_STATE := B”110”;
when B”110” => PRESENT_STATE := B”111”;
when B”111” => PRESENT_STATE := B”000”;
end case;
Z <= PRESENT_STATE after 10 nsec;
wait until (CLK = ‘1’;
end process;
end ALGORITHM;
FOR- Vs WHILE-statement Syntax
END example;
Alternate Carry Process
00/0 01/0
01/1 10/0
S1
10/1 S0 11/1
00/1
NS: process(p_state, n_state,x,y)
Begin
entity seq is State: process Case p_state is
port (x, y, clk: in std_logic; Begin When S0 =>
entity mem is
port( read,write,clk : in std_logic;
address : in unsigned(7 downto 0);
data : inout std_logic_vector(7 downto 0);
end entity;
1 1 1 0
0
S0 S1 S2 S3
/0 /0 /0 /1
0 1
0
VHDL Description of Moore 110 Sequence
Detector
ENTITY moore_110_detector IS
PORT (x, clk : IN BIT; z : OUT BIT);
END moore_110_detector;
ARCHITECTURE behavioral OF moore_110_detector IS
TYPE state IS (S0,S1,S2,S3);
SIGNAL current : state := S0;
BEGIN
PROCESS(clk)
BEGIN
IF (clk = '1' AND CLK’Event) THEN
CASE current IS
WHEN S0=>
IF x = '1' THEN current <= S1;
ELSE current <= S0; END IF;
WHEN S1 =>
IF x = '1' THEN current <= S2;
ELSE current <= S0; END IF;
WHEN S2=>
IF x = '1' THEN current <= S2;
ELSE current <= S3; END IF;
WHEN S3=>
IF x = '1' THEN current <=S1;
ELSE current <= S0; END IF;
END CASE;
END IF;
END PROCESS;
z <='1' WHEN current = S3 ELSE '0';
END behavioral;