-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauxModules.sv
140 lines (101 loc) · 2 KB
/
auxModules.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
133
134
135
136
137
138
139
140
module mux2_1_5bits(
input logic control,
input logic [4:0] input0,
input logic [4:0] input1,
output logic [4:0] output0
);
always_comb begin
case(control)
0: begin
output0 <= input0;
end
1: begin
output0 <= input1;
end
endcase
end
endmodule
module shiftLef_2_32bits(
input logic [31:0] input0,
output logic [31:0] output0
);
always_comb begin
output0 <= input0 << 2;
end
endmodule
module shiftLeft_2_26_28_bits(
input logic [25:0] input0,
output logic [27:0] output0
);
always_comb begin
output0[27:2] <= input0;
output0[1:0] <= 0;
end
endmodule
module adder_32bits(
input logic [31:0] input0,
input logic [31:0] input1,
output logic [31:0] output0
);
always_comb begin
output0 <= input0 + input1;
end
endmodule
module mux2_1_32bits(
input logic control,
input logic [31:0] input0,
input logic [31:0] input1,
output logic [31:0] output0
);
always_comb begin
case(control)
0: begin
output0 <= input0;
end
1: begin
output0 <= input1;
end
endcase
end
endmodule
module signalExtender16_32bits(
input logic [15:0] preExtended,
output logic [31:00] postExtended
);
always_comb begin
case(preExtended[15])
1: begin
postExtended[31:16] <= '{default:1};
postExtended[15:0] <= preExtended;
end
0: begin
postExtended[31:16] <= '{default:0};
postExtended[15:0] <= preExtended;
end
endcase
end
endmodule
module mux3_1_32bits(
input logic [1:0] control,
input logic [31:0] input0,
input logic [31:0] input1,
input logic [31:0] input2,
output logic [31:0] output0
);
always_comb begin
case(control)
0: begin
output0 <= input0;
end
1: begin
output0 <= input1;
end
2: begin
output0 <= input2;
end
default: begin
output0 <= 0;
end
endcase
end
endmodule