Wednesday, 1 March 2017

Mod 5 Up Counter (Verilog) with Test Fixture



Test Fixture Program :-
module tf_mod5_vlog;

// Inputs
reg clk;
reg reset;

// Outputs
wire [2:0] out;

// Instantiate the Unit Under Test (UUT)
mod5_vlog uut (
.out(out),
.clk(clk),
.reset(reset)
);

initial begin
clk=1'b1;
forever #5 clk=~clk;
end


initial begin
reset = 1;#10;
reset = 0;#30;

end
   
endmodule


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

Program for Mod 5 Up Counter (  VERILOG  ) :-

module mod5_vlog(
 out      ,  // Output of the counter
 clk      ,  // clock input
 reset       // reset input
 );
 //----------Output Ports--------------
  output [2:0] out;
  //------------Input Ports--------------
  input clk, reset;
  //------------Internal Variables--------
  reg [2:0] out;
  //-------------Code Starts Here-------
  always @(posedge clk)
if (reset)
begin // active high reset
out <= 2'b0 ;
end
else if (out<4)
begin
out <= out + 1;
end
else
begin
out <= 2'b0 ;
end

  endmodule













2 comments:

  1. can you please give the test bench?

    ReplyDelete
    Replies
    1. Test bench is given as the Test Fixture program.
      Please check it. If any problem , please reply... ...

      Delete