-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmux.v
More file actions
59 lines (46 loc) · 905 Bytes
/
mux.v
File metadata and controls
59 lines (46 loc) · 905 Bytes
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
// 2 and 4 way mux
module mux2(input[1:0] in, input control, output out);
assign out = in[control];
endmodule
module mux4(input[3:0] in, input[1:0] control, output out);
assign out = in[control];
endmodule
module Mux2_11bit(input[10:0] in0, input[10:0] in1, input control, output[10:0] out);
assign out = control ? in1 : in0;
endmodule
module Mux4_16bit(
input[15:0] in0,
input[15:0] in1,
input[15:0] in2,
input[15:0] in3,
input[1:0] control,
output reg[15:0] out
);
always @(*)
begin
case (control)
2'b00 : out = in0;
2'b01 : out = in1;
2'b10 : out = in2;
2'b11 : out = in3;
endcase
end
endmodule
module Mux4_11bit(
input[10:0] in0,
input[10:0] in1,
input[10:0] in2,
input[10:0] in3,
input[1:0] control,
output reg[10:0] out
);
always @(*)
begin
case (control)
2'b00 : out = in0;
2'b01 : out = in1;
2'b10 : out = in2;
2'b11 : out = in3;
endcase
end
endmodule