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

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....
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.
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...
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
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...
Using JK flipflopDesign a multisim schematic for a 4 bit synchronous counter that counts numbers in...
Using JK flipflopDesign a multisim schematic for a 4 bit synchronous counter that counts numbers in Gray code. 4 bit Gray code is as follows: 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101 1111 1110 1010 1001 1000
Design an 8-bit ALU Circuit diagram,
Design an 8-bit ALU Circuit diagram,
You are to design an 4 bit counter that takes as input a clock and a...
You are to design an 4 bit counter that takes as input a clock and a reset signal and outputs a 4-bit count When the clock is asserted and the reset is high, the clock increments. When it increments at 1111,it resets to 0000 Create a schematic diagram of your design using either Xilinx ISE or a drawing tool of your choice or a neatly hand-drawn diagram Create a Verilog module within Xilinx. Verify your design is syntactically correct. Create...
On logisim or any circuit building program, design a counter that counts 9,8,7,6,5,4,3,2,1,0 then back to...
On logisim or any circuit building program, design a counter that counts 9,8,7,6,5,4,3,2,1,0 then back to 9. After, add to it's output a 7 segment decoder and it's display. thank you!
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT