Wednesday, 22 February 2017

Mod 10 Up Counter ( Verilog ) with Test fixture



Test Fixture Program :-
module tf_mod10_vlog;

// Inputs
reg clk;
reg reset;

// Outputs
wire [3:0] out;

// Instantiate the Unit Under Test (UUT)
mod10_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 10 Up Counter (  VERILOG  ) :-

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

  endmodule












2 comments:

  1. After always their should be begin ..bcz processor through an error ..

    ReplyDelete
  2. Great tutorial. The Verilog code and test fixture are explained clearly, making it easier to understand how a down counter works through simulation.
    Snowflake Training in Hyderabad

    ReplyDelete