Question

In: Electrical Engineering

Using behavioral VHDL, design a Moore-type finite state machine that detects input test vector that contains...

  1. Using behavioral VHDL, design a Moore-type finite state machine that detects input test vector that contains the sequence of ‘100’. If the sequence ‘100’ is detected, the output Z should go high. The input is to be named W, the output is to be named Z, a Clock input is to be used and an active low reset signal (Resetn) should asynchronously reset the machine.

a) Draw the Moore-type model state diagram for the FSM.

b) Write the VHDL code to implement the FSM.

Solutions

Expert Solution

a)

(b)

--VHDL Code

library ieee;
use ieee.std_logic_1164.all;

entity moore_sm is
   port (   clock   : in std_logic;
       Resetn   : in std_logic;
       W   : in std_logic;
       Z   : out std_logic
   );
end moore_sm;

architecture arch of moore_sm is

type state is (S0, S1, S2, S3);

signal current_state, next_state : state;

begin

   process (clock, Resetn)
   begin
       if (Resetn = '0') then
           current_state <= S0;
       else
           if rising_edge (clock) then
               current_state <= next_state;
           end if;
       end if;
   end process;

   process(current_state, W)
   begin

       case (current_state) is
           when S0=>   if (W = '1') then
                       next_state <= S1;
                   else
                       next_state <= S0;
                   end if;
                   Z   <= '0';

           when S1=>   if (W = '0') then
                       next_state <= S2;
                   else
                       next_state <= S1;
                   end if;
                   Z   <= '0';

           when S2=>   if (W = '1') then
                       next_state <= S1;
                   else
                       next_state <= S3;
                   end if;
                   Z   <= '0';

           when S3=>   if (W = '1') then
                       next_state <= S1;
                   else
                       next_state <= S0;
                   end if;
                   Z   <= '1';

           when others=>    null;

       end case;

   end process;

end arch;

----------------------------------------------------------------------------------------------------------------------------------------------------------------------

--Testbench

library IEEE;
use IEEE.Std_logic_1164.all;

entity moore_sm_tb is
end;

architecture bench of moore_sm_tb is

component moore_sm
   port (   clock   : in std_logic;
       Resetn   : in std_logic;
       W   : in std_logic;
       Z   : out std_logic
   );
end component;

signal clock: std_logic;
signal Resetn: std_logic;
signal W: std_logic;
signal Z: std_logic ;
  
begin

uut: moore_sm port map ( clock => clock,
Resetn => Resetn,
W => W,
Z => Z );

stimulus: process
begin
   Resetn    <= '0';
   W   <= '1';

   wait for 10 ns;

   W   <= '0';
   wait for 40 ns;

   W   <= '1';
   wait for 60 ns;

   Resetn    <= '1';
   W   <= '1';
   wait for 60 ns;

   W   <= '0';
   wait for 20 ns;

   W   <= '0';
   wait for 20 ns;

   W   <= '0';
   wait for 20 ns;
   wait;
  
end process;

clocking: process
begin
   clock <= '0';
   wait for 10 ns;
clock <= '1';
   wait for 10 ns;
end process;

end;

------------------------------------------------------------------------------------------------------------------------------------------------------------------

--Simulated on ModelSim


Related Solutions

Using behavioral VHDL, design a Mealy-type finite state machine that detects input test vector that contains...
Using behavioral VHDL, design a Mealy-type finite state machine that detects input test vector that contains the sequence of ‘100’. If the sequence ‘100’ is detected, the output Z should go high. The input is to be named W, the output is to be named Z, a Clock input is to be used and an active low reset signal (Resetn) should asynchronously reset the machine. a) Draw the Mealy-type state diagram for the FSM. b) Write the VHDL code to...
Design B: Using behavioral VHDL, design a Mealy-type finite state machine that detects input test vector...
Design B: Using behavioral VHDL, design a Mealy-type finite state machine that detects input test vector that contains the sequence of ‘10’. If the sequence ‘10’ is detected, the output Z should go high. The input is to be named W, the output is to be named Z, a Clock input is to be used and an active low reset signal (Resetn) should asynchronously reset the machine. a) Draw the Mealy-type state diagram for the FSM. b) Write the VHDL...
Design a Moore state machine that has an input w and an output z that should...
Design a Moore state machine that has an input w and an output z that should output a ‘1’ when the previous 4 values of w were 1001 or 1111. Overlapping patterns are allowed. Show the state diagram and state table. Use a simple binary counting order for the state assignment. Derive all of the next-state and output equations. You do not need to draw the resulting circuit, instead write a Verilog module for it.
Write a VHDL mealy state machine that detects the pattern 01110 in a stream of bits....
Write a VHDL mealy state machine that detects the pattern 01110 in a stream of bits. The machine should have three inputs; in, clk, reset. The output of the machine goes high whenever the pattern is detected.
Write a VHDL code to implement a Finite State Machine that with an 8 bit sequence...
Write a VHDL code to implement a Finite State Machine that with an 8 bit sequence input (can be any sequence, but lets say it is 11001000), determine how many states there are as well; so if the input sequence is correct it will show the number 1 in a 7 segment display, otherwise it will be 0 in the same 7 segment display. If the input sequence is incorrect, start from the beginning.
Write a truth table for Moore finite state machine modeling a traffic light.
Write a truth table for Moore finite state machine modeling a traffic light.
1. Using Moore machine approach design a sequence detector with one input and one output. When...
1. Using Moore machine approach design a sequence detector with one input and one output. When input sequence 010 occurs the output becomes 1 and remains 1 until the sequence 010 occurs again in which case the output returns to 0. The output remains 0 until, 010 occurs the third time, and so on. Your design should be able to handle overlapping sequences, i.e., input sequence 11001010100 should produce the output 00000110011. Implement your detector using D flip-flops and the...
write sample code in VHDL Design and implementation of Pressetable ripple counter using behavioral style of...
write sample code in VHDL Design and implementation of Pressetable ripple counter using behavioral style of modeling by using pic74196
Consider a finite state machine with a control input called mode. When mode = 0, the...
Consider a finite state machine with a control input called mode. When mode = 0, the machine operates as a mod-3 down counter, where the outputs are the count values. When mode = 1, the machine's output progresses through the last 4 digits of your WCU ID (1133) number (1 digit per clock cycle). Complete each of the steps which follow. (a) Draw the state diagram for this machine. (b) Write RTL Verilog code which implements this design. Submit your...
Derive a state diagram and table for a single-input and single-output Moore-type FSM that produces an...
Derive a state diagram and table for a single-input and single-output Moore-type FSM that produces an output of 1 if an input sequence of 101 is detected
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT