Question

In: Electrical Engineering

(a) Design an FSM (only state diagram and state table) for a 3-bit counter that counts...

(a) Design an FSM (only state diagram and state table) for a 3-bit counter that counts through odd numbers downwards. Assume the reset state to be the lowest value of the counter. Use an active low reset to reset the counter.

(b) Write a behavioral VHDL code that implements the FSM.

(c) Write a VHDL test bench to test the FSM.

Solutions

Expert Solution

Part A)

Part B)

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity count_down is
port (
clk : in std_logic;
rst : in std_logic;
out1 : out std_logic_vector(2 downto 0)
);
end count_down;

architecture behavioural of count_down is
type state_type is (A, B, C, D);
signal cur_state, next_state : state_type;
begin

Process1 : process(clk) --current state logic
begin
if (clk'event and clk = '1') then
if (rst = '1') then
cur_state <= A;
else
cur_state <= next_state;
end if;
end if;
end process Process1;

Process2 : process(cur_state, X) --next state and output logic
begin
case (cur_state) is
when A => out1 <= "001";
next_state <= D;
when B => out1 <= "011";
next_state <= A;
when C => out1 <= "101";
next_state <= B;
when others => out1 <= "111";
next_state <= C;
  
end case;
end process Process2;

end behavioural;

Part C)
--Testbench of Count Down FSM
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity tb_counters is
end tb_counters;

architecture Testbench of tb_counters is

component count_down
Port ( clk : in std_logic; -- clock input
rst : in std_logic; -- reset input
out1 : out std_logic_vector(2 downto 0) -- output 3-bit counter
);
end component;

signal rst, clk : std_logic;
signal out1 : std_logic_vector(2 downto 0);

begin
dut: DOWN_COUNTER port map (clk => clk, rst => rst, out1 => out1);

-- Clock process definitions
clock_process :process
begin
clk <= '0';
wait for 10 ns;
clk <= '1';
wait for 10 ns;
end process;


-- Stimulus process
stim_proc: process
begin   
-- hold reset state for 100 ns.
reset <= '0';
wait for 20 ns;   
reset <= '1';
wait for 400 ns;   
wait;
end process;

end Testbench;


Related Solutions

Using Multisim, design a 2-bit, synchronous binary counter and verify that it counts in the right...
Using Multisim, design a 2-bit, synchronous binary counter and verify that it counts in the right sequence, Can count up or down and use any FF you desire; 4 screen shots in total: 1 for each input combination
21a. Draw the state graph and corresponding transition table for a 3-bit counter with no control...
21a. Draw the state graph and corresponding transition table for a 3-bit counter with no control inputs that counts in multiples of 3. That is, the count sequence is: 000-011-110-000-.... Use don't cares in the transition table as appropriate. b. Draw the state graph and corresponding transition table for a 3-bit binary counter with no control inputs which counts down rather than up. Include a Z output which signifies when the "count value modulo 3 is equal to 0." c....
Derive a minimal state table for a Moore model FSM that acts as a three-bit parity...
Derive a minimal state table for a Moore model FSM that acts as a three-bit parity generator. For every three bits that are observed on inputw during three consecutive clock cycles, the FSM generates the parity bit outputq = 1 if the number of 1s received in the sequence so far is odd. Thus, this is an even parity generator. Implement the FSM as a circuit in Logisim Evolution. Note that the FSM outputs a 1 as long as the...
1. (20pts) Design a 3-bit counter that counts from 0000 to 1111 using JK flip/flops. Do...
1. (20pts) Design a 3-bit counter that counts from 0000 to 1111 using JK flip/flops. Do not forget to include the carry to detect overflow.
Objective: Design, construct, and test a three-bit counter that counts up or down. An enable input...
Objective: Design, construct, and test a three-bit counter that counts up or down. An enable input E determines whether the counter is on or off.  If E=0, the counter is disabled and remains at its present count even though clock pulses are applied to the flip-flops.  If E=1, the counter is enabled and a second input, x, determines the direction of the count.  If x=1, the circuit counts upward with the sequence 000, 001, 010, 011, 100,...
Design a 5-bit binary counter using JK flip flops. Draw the flip-flop circuit diagram, the state...
Design a 5-bit binary counter using JK flip flops. Draw the flip-flop circuit diagram, the state graph, the timing diagram, the truth table (with clk pulse) and the state table (with present and next states).
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
Design a 5 bit binary counter on logicly?
Design a 5 bit binary counter on logicly?
Question 3: A)Design a BCD counter. -The circuit counts from 0 to 9, then resets back...
Question 3: A)Design a BCD counter. -The circuit counts from 0 to 9, then resets back to 0 to restart the counting sequence. -The circuit has one input run/stop. If the input is 1, the eounter will count. If the input is 0, the counter will freeze in its current location until the input is set to 1 again. -The circuit has one output. It becomes 1 when the counter completes a cycle and starts the next one. Otherwise, that...
design a counter that counts 0,3,2,4,1,5,7 and repeats using T-ff
design a counter that counts 0,3,2,4,1,5,7 and repeats using T-ff
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT