test.v
1.9 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
module test;
wire clk;
wire stall;
wire[4:0] in1, out1, out2, out3, out4, out5, out6;
wire stall_1;
assign stall_1 = 0;
Clock clock(clk);
testPC tpc(clk, stall, in1);
testA ta1(clk, stall, in1, out1);
testA ta2(clk, stall, out1, out2);
testA ta3(clk, stall, out2, out3);
testA ta4(clk, stall_1, out3, out4);
testA ta5(clk, stall_1, out4, out5);
testA ta6(clk, stall_1, out5, out6);
testB stl(clk, out1, stall);
initial begin
end
endmodule
module testA(clk, stall, in1, out1);
input clk, stall;
input[4:0] in1;
output reg[4:0] out1;
reg[4:0] temp1;
reg stallfinished;
initial begin
temp1 = 5'b00000;
out1 = 5'b00000;
stallfinished = 1'b0;
end
always @(posedge clk) begin
if(stall == 1'b1) out1 <= 5'b00000;
else if(stallfinished == 1'b1) begin
out1 <= temp1;
stallfinished <= 1'b0;
end
else out1 <= in1;
end
always @(posedge stall) begin
temp1 = in1;
end
always @(negedge stall) begin
stallfinished = 1'b1;
end
endmodule
module testB(clk, out1, stall);
input clk;
input[4:0] out1;
output reg stall;
integer i;
initial begin
stall = 1'b0;
i = 0;
end
always @(negedge clk)
if(i > 0) i = i-1;
else begin
if(out1 == 5'b00101) begin
i = 2;
stall = 1'b1;
end
else stall = 1'b0;
end
endmodule
module testPC(clk, stall, in1);
input clk, stall;
output reg[4:0] in1;
reg[4:0] PC;
initial begin
PC = 5'd0;
end
always @(posedge clk) begin
if(stall == 1'b0) PC <= PC+1;
in1 <= PC;
end
endmodule
/*
module test;
wire clk;
reg sig1;
reg[31:0] in1;
wire[31:0] out1, out2;
Clock clock(clk);
testA ta(clk, sig1, in1, out1, out2);
initial begin
sig1 <= 1'b0;
in1 <= 32'd0;
#100;
in1 <= 32'hffffffff;
#100;
sig1 <= 1'b1;
in1 <= 32'h0000ffff;
#100;
sig1 <= 1'b1;
in1 <= 32'hffff0000;
#100;
end
endmodule
module testA(clk, sig1, in1, out1, out2);
input clk, sig1;
input[31:0] in1;
output reg[31:0] out1, out2;
always @(posedge clk) begin
out1 <= in1;
if(sig1 == 1) out2 <= in1;
end
endmodule
*/