-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSIPO-SR_tb.v
53 lines (42 loc) · 1.04 KB
/
SIPO-SR_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
`timescale 1ns / 1ns // Set timescale for simulation
module testbench_SIPO_Shift_Register();
// Define signals for the testbench
reg clock;
reg reset;
reg serial_in;
wire [7:0] parallel_out;
// Instantiate the SIPO shift register module
SIPO_Shift_Register uut (
.clock(clock),
.reset(reset),
.serial_in(serial_in),
.parallel_out(parallel_out)
);
// Clock generation
always begin
clock = 0;
#5; // 5ns clock cycle
clock = 1;
#5;
end
// Stimulus generation
initial begin
reset = 1; // Reset initially
serial_in = 0;
// Apply reset
#10;
reset = 0;
// Apply serial data and observe parallel output
serial_in = 1;
#10;
assert(parallel_out === 8'b00000001) // Check parallel output
else $display("Test failed!");
serial_in = 0;
#10;
assert(parallel_out === 8'b00000000) // Check parallel output
else $display("Test failed!");
// Add more test cases here as needed
$display("All tests passed!");
$finish;
end
endmodule