This repository has been archived by the owner on Apr 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomplexIf.sv
132 lines (125 loc) · 2.92 KB
/
complexIf.sv
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
`default_nettype none
module main (
input wire clk, r_enable, controlArr,
input wire init_i,
input wire controlArrWEnable_a,
input wire[0:0] controlArrAddr_a,
output wire controlArrRData_a,
input wire controlArrWData_a,
output reg w_enable,
output reg[1:0] result
);
reg[2:0] stateR;
reg[2:0] linkreg;
reg[63:0] reg0;
wire[63:0] stationReg0;
reg[63:0] reg1;
wire[63:0] stationReg1;
reg[63:0] reg2;
wire[63:0] stationReg2;
reg[63:0] reg3;
wire[63:0] stationReg3;
wire in0_Bin0;
wire in1_Bin0;
wire out0_Bin0 = in0_Bin0 == in1_Bin0;
wire[1:0] in0_Bin1;
wire[1:0] in1_Bin1;
wire[1:0] out0_Bin1 = in0_Bin1 + in1_Bin1;
wire arrWEnable_a;
wire arrAddr_a;
wire arrRData_a;
wire arrWData_a;
arr_a arr_a(.*);
assign in0_Bin1 =
stateR == 3'd5 ? 2'd1 :
'x;
assign in1_Bin1 =
stateR == 3'd5 ? reg0[1:0] :
'x;
assign in0_Bin0 =
stateR == 3'd1 ? reg0[0:0] :
'x;
assign in1_Bin0 =
stateR == 3'd1 ? 1'd0 :
'x;
assign arrWEnable_a =
controlArr ? controlArrWEnable_a :
stateR == 3'd3 ? 1'd1 :
1'd0;
assign arrAddr_a =
controlArr ? controlArrAddr_a :
stateR == 3'd3 ? reg2[0:0] :
'x;
assign arrWData_a =
controlArr ? controlArrWData_a :
stateR == 3'd3 ? reg0[0:0] :
'x;
assign controlArrRData_a = controlArr ? arrRData_a : 'x;
assign stationReg0 =
stateR == 3'd4 ? 64'd2 :
stateR == 3'd5 ? {62'd0, out0_Bin1} :
reg0;
assign stationReg1 =
stateR == 3'd1 ? 64'd1 :
reg1;
assign stationReg2 =
stateR == 3'd1 ? {63'd0, out0_Bin0} :
stateR == 3'd2 ? 64'd0 :
reg2;
assign stationReg3 =
stateR == 3'd2 ? 64'd1 :
reg3;
always @(posedge clk) begin
if(r_enable) begin
stateR <= '0;
linkreg <= '1;
w_enable <= 1'd0;
reg0 <= {63'd0, init_i};
end else begin
case(stateR)
'1: begin
w_enable <= 1'd1;
result <= reg0[1:0];
end
3'd0: stateR <= 3'd1;
3'd1: stateR <= (stationReg2) ? 3'd2 : 3'd4;
3'd2: stateR <= 3'd3;
3'd3: stateR <= 3'd5;
3'd4: stateR <= 3'd5;
3'd5: stateR <= linkreg;
endcase
case(stateR)
3'd3: reg0 <= stationReg3;
3'd4: reg0 <= stationReg0;
3'd5: reg0 <= stationReg0;
default: reg0 <= stationReg0;
endcase
case(stateR)
default: reg1 <= stationReg1;
endcase
case(stateR)
default: reg2 <= stationReg2;
endcase
case(stateR)
default: reg3 <= stationReg3;
endcase
end
end
endmodule // main
module arr_a (
input wire clk, arrWEnable_a,
input wire[0:0] arrAddr_a,
output wire arrRData_a,
input wire arrWData_a
);
reg[0:0] delayedRAddr;
reg mem [0:1];
always @(posedge clk) begin
if(arrWEnable_a) begin
mem[arrAddr_a] <= arrWData_a;
end
delayedRAddr <= arrAddr_a;
end
assign arrRData_a = mem[delayedRAddr];
endmodule
`default_nettype wire