-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLFSR_tb.v
38 lines (31 loc) · 931 Bytes
/
LFSR_tb.v
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
// Testbench for Linear Feedback Shift Register (LFSR)
module day7_tb ();
reg clk; // Clock signal
reg reset; // Reset signal
wire [3:0] lfsr_o; // Output from the LFSR
// Instantiate the LFSR module
day7 DAY7 (
.clk(clk),
.reset(reset),
.lfsr_o(lfsr_o)
);
// Clock generation
initial begin
clk = 1'b0; // Initialize clock to 0
forever begin
#5 clk = ~clk; // Toggle clock every 5 time units
end
end
// Test stimulus
initial begin
reset = 1'b1; // Apply reset
@(posedge clk); // Wait for the first clock edge
reset = 1'b0; // Release reset
// Run for 32 clock cycles
for (integer i = 0; i < 32; i = i + 1) begin
@(posedge clk); // Wait for each clock cycle
$display("Cycle %0d: LFSR Output = %b", i, lfsr_o); // Print the output at each clock cycle
end
$finish(); // End the simulation
end
endmodule