Question

In: Computer Science

Provide the VHDL code and simulation results for a mod-7 counter, with asynchronous active low reset.

Provide the VHDL code and simulation results for a mod-7 counter, with asynchronous active low reset.

Solutions

Expert Solution

Design

module modN_ctr  
  # (parameter N = 7,  
     parameter WIDTH = 4)  
  
  ( input   clk,  
    input   rstn,  
    output  reg[WIDTH-1:0] out);  
  
  always @ (posedge clk) begin  
    if (!rstn) begin  
      out <= 0;  
    end else begin  
      if (out == N-1)  
        out <= 0;  
      else  
        out <= out + 1;  
    end  
  end  
endmodule 

Testbench

    module tb;  
      parameter N = 7;  
      parameter WIDTH = 4;  
      
      reg clk;  
      reg rstn;  
      wire [WIDTH-1:0] out;  
      
      modN_ctr u0  (    .clk(clk),  
                        .rstn(rstn),  
                        .out(out));  
      
      always #10 clk = ~clk;  
      
      initial begin  
        {clk, rstn} <= 0;  
      
        $monitor ("T=%0t rstn=%0b out=0x%0h", $time, rstn, out);  
        repeat(2) @ (posedge clk);  
        rstn <= 1;  
      
        repeat(20) @ (posedge clk);  
        $finish;  
      end  
    endmodule  

Simulation Result

ncsim> run
T=0 rstn=0 out=0xx
T=10 rstn=0 out=0x0
T=30 rstn=1 out=0x0
T=50 rstn=1 out=0x1
T=70 rstn=1 out=0x2
T=90 rstn=1 out=0x3
T=110 rstn=1 out=0x4
T=130 rstn=1 out=0x5
T=150 rstn=1 out=0x6
T=170 rstn=1 out=0x7
T=190 rstn=1 out=0x0
T=210 rstn=1 out=0x1
T=230 rstn=1 out=0x2
T=250 rstn=1 out=0x3
T=270 rstn=1 out=0x4
T=290 rstn=1 out=0x5
T=310 rstn=1 out=0x6
T=330 rstn=1 out=0x7
T=350 rstn=1 out=0x0
T=370 rstn=1 out=0x1
T=390 rstn=1 out=0x2
T=410 rstn=1 out=0x3
Simulation complete via $finish(1) at time 430 NS + 0

Please comment if anything else is needed


Related Solutions

Write a VHDL code and testbench for a positive-edge-triggered JK-type FF with asynchronous active-low reset (RN)...
Write a VHDL code and testbench for a positive-edge-triggered JK-type FF with asynchronous active-low reset (RN) - JKFFR
Write and verify a behavioral Verilog model of J-K flip-flop with active-low asynchronous reset.
Write and verify a behavioral Verilog model of J-K flip-flop with active-low asynchronous reset.
VHDL Code will not run simulation. What is the problem with my code?? --VHDL Code library...
VHDL Code will not run simulation. What is the problem with my code?? --VHDL Code library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.NUMERIC_STD.ALL; entity DataMemory16Bits is Port ( Address_DM : in STD_LOGIC_VECTOR(15 downto 0); Data_In_DM : in STD_LOGIC_VECTOR(15 downto 0); Clock : in STD_LOGIC; We_DM : in STD_LOGIC; Re_DM : in STD_LOGIC; Data_Out_DM : out STD_LOGIC_VECTOR(15 downto 0)); end DataMemory16Bits; architecture Behavioral of DataMemory16Bits is Type DataMemory16Bits is array(0 to 31) of STD_LOGIC_VECTOR(15 downto 0); signal memory: DataMemory16Bits; begin process...
Design a mod 5 counter as a (a) synchronous circuit (b) asynchronous circuit
Design a mod 5 counter as a (a) synchronous circuit (b) asynchronous circuit
Design in VHDL a gray code decoder to excess 3 code Screenshot the simulation and code.
Design in VHDL a gray code decoder to excess 3 code Screenshot the simulation and code.
Design in VHDL a 8-1 Multiplexer Screenshot the simulation and code.
Design in VHDL a 8-1 Multiplexer Screenshot the simulation and code.
Design in VHDL a 16-1 Demultiplexer Screenshot the simulation and code.
Design in VHDL a 16-1 Demultiplexer Screenshot the simulation and code.
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.
Write the VHDL PROCESS statements for a D flip-flop with synchronous active-LOW clear, synchronous active-LOW preset,...
Write the VHDL PROCESS statements for a D flip-flop with synchronous active-LOW clear, synchronous active-LOW preset, and responsive to a rising edge clock. Use D for the input, Q for the output, PRE for the preset, CLR for the clear, and CLK for the clock. All signals are BIT type
Direct reset MOD 12 synchronous down counter circuit Designed using falling edge trigger SR FF It...
Direct reset MOD 12 synchronous down counter circuit Designed using falling edge trigger SR FF It is desirable. A, B, C, and D FFs in the circuit to be designed It will be used. Here the highest-valued output is considered A It will be. When this design is done, only SA and RA of A FF after doing logic functions to be applied to their inputs then write in the fields below. (Counter circuit design write the steps in the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT