File size: 1,648 Bytes
035592e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | `timescale 1ns/1ns
module testbench;
// Parameters
parameter CLK_PERIOD = 10; // Clock period in simulation time units
// Inputs
reg clk;
reg rst_n;
// Outputs
wire [63:0] Q;
// Instantiate the module
JC_counter uut (
.clk(clk),
.rst_n(rst_n),
.Q(Q)
);
// Clock generation
always #((CLK_PERIOD)/2) clk = ~clk;
integer error=0;
// Initial block for stimulus generation
initial begin
// Initialize inputs
clk = 0;
rst_n = 1;
// Wait for a few clock cycles
#((CLK_PERIOD) * 2);
// Release reset
rst_n = 0;
#((CLK_PERIOD) * 2);
rst_n = 1;
// Simulate for a number of clock cycles
#((CLK_PERIOD) * 20);
error = (Q ==64'b 1111111111111111111100000000000000000000000000000000000000000000)? error : error+1;
#((CLK_PERIOD) * 44);
error = (Q ==64'b 1111111111111111111111111111111111111111111111111111111111111111)? error : error+1;
#((CLK_PERIOD) * 1);
error = (Q ==64'b 0111111111111111111111111111111111111111111111111111111111111111)? error : error+1;
#((CLK_PERIOD) * 62);
error = (Q ==64'b 0000000000000000000000000000000000000000000000000000000000000001)? error : error+1;
if (error == 0) begin
$display("===========Your Design Passed===========");
end
else begin
$display("===========Error===========");
end
// $display("Q = %b", Q);
// Finish simulation
$finish;
end
endmodule
|