Question

In: Electrical Engineering

Write VHDL code (behavior model) to implement a 4-bit modulo-9 counter and simulate your VHDL code...

Write VHDL code (behavior model) to implement a 4-bit modulo-9 counter and simulate your VHDL code of 4-bit modulo-9 counter in ModelSim, and capture the screenshot

of your simulated waveform.

Assume clock period Tclk=100ns, initially, the counter is reset to Q3Q2Q1Q0=0000 you need to simulate a complete counting cycle plus one more additional clock period after it is reset to “0000” state.

Solutions

Expert Solution

--VHDL Code

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

entity mod9_counter is
   port (   clock   : in std_logic;
       reset   : in std_logic;
       Q3   : out std_logic;
       Q2   : out std_logic;
       Q1   : out std_logic;
       Q0   : out std_logic
   );
end mod9_counter;

architecture arch of mod9_counter is

signal count : std_logic_vector(3 downto 0):= "0000";

begin

process (clock, reset)
begin
   if (reset = '1') then
       count <= "0000";
   else
       if (clock'event and clock = '1') then
           if (count = "1000") then
               count <= "0000";
           else
               count <= count + "0001";
           end if;
       end if;
   end if;
end process;

Q3   <= count(3);
Q2   <= count(2);
Q1   <= count(1);
Q0   <= count(0);

end arch;

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

--Testbench

library IEEE;
use IEEE.Std_logic_1164.all;

entity mod9_counter_tb is
end;

architecture bench of mod9_counter_tb is

component mod9_counter
   port (   clock   : in std_logic;
       reset   : in std_logic;
       Q3   : out std_logic;
       Q2   : out std_logic;
       Q1   : out std_logic;
       Q0   : out std_logic
   );
end component;

signal clock: std_logic;
signal reset: std_logic;
signal Q3: std_logic;
signal Q2: std_logic;
signal Q1: std_logic;
signal Q0: std_logic ;

constant clock_period: time := 100 ns;
signal stop_the_clock: boolean;


begin

uut: mod9_counter port map ( clock => clock,
reset => reset,
Q3 => Q3,
Q2 => Q2,
Q1 => Q1,
Q0 => Q0 );

stimulus: process
begin
  
   reset <= '0';
   wait for 12 * clock_period;

   reset <= '1';
   wait for clock_period;

   reset <= '0';
   stop_the_clock <= true;
  
wait;
end process;

clocking: process
begin
while not stop_the_clock loop
clock <= '0', '1' after clock_period / 2;
wait for clock_period;
end loop;
wait;
end process;

end;

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

--Simulation


Related Solutions

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.
Create a VHDL code of a 4 bit Counter using D flip flop and a Frequency...
Create a VHDL code of a 4 bit Counter using D flip flop and a Frequency Divider that provides the clock signal input for counter
Write a VHDL code for a 4-bit comparator which takes two 4-bit input values and (0.5)...
Write a VHDL code for a 4-bit comparator which takes two 4-bit input values and (0.5) determines whether the numbers are equal. 2. 2. Write a structural VHDL code to implement the circuit of Fig. 2, using the components (0.5) developed in 1.3 and 2.1. 2. 3. Write a VHDL test bench for the above and verify by simulation. (0.5) 2. 4. Implement the design in an FPGA (Note: You may need a `clock manager' to reduce (1.0) the clock...
Using Behavorial VHDL, design a 4-bit up/down counter.
Using Behavorial VHDL, design a 4-bit up/down counter.
Describe in behavioral VHDL a modulo-m up/down counter with the following interface: – Generics • Modulo...
Describe in behavioral VHDL a modulo-m up/down counter with the following interface: – Generics • Modulo base (m with default value of 16) – Inputs Clock (clk  1 bit) Asynchronous reset (rst  1 bit) Counting direction (up_down1 bit) – 1Counting up – 0Counting down – Outputs 2 – Run behavioral simulation • Count value (count • In Vivado – Create a project   bits)
Using behavioral VHDL, 32-bit up counter with enable.
Using behavioral VHDL, 32-bit up counter with enable.
Write a Verilog code to implement 16 bit LFSR
Write a Verilog code to implement 16 bit LFSR
I am trying to write the code for an 8 bit adder in VHDL so that...
I am trying to write the code for an 8 bit adder in VHDL so that I can program it onto my Elbert V2 Spartan 3A FPGA Development Board, but I keep getting errors. Any ideas what I am doing wrong? library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity adder8bit is Port ( a : in STD_LOGIC_VECTOR(7 downto 0); b : in STD_LOGIC_VECTOR(7 downto 0); cin : in STD_LOGIC; o : out STD_LOGIC_VECTOR(7 downto 0); cout : out STD_LOGIC); end adder8bit; architecture Behavioral...
Write in verilog, code to implement a 6 bit multiplier. Cascade a 1 bit multiplier to...
Write in verilog, code to implement a 6 bit multiplier. Cascade a 1 bit multiplier to implement this.
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT