-
Notifications
You must be signed in to change notification settings - Fork 0
/
mux2_to_1.v
121 lines (99 loc) · 2 KB
/
mux2_to_1.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
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
module mux2_to_1(input_a,input_b,sel,result);
input [15:0] input_a;
input [15:0] input_b;
input sel;
output [15:0] result;
reg [15:0] result;
initial begin
result<=16'h0000;
end
always@(*)
begin
case(sel)
0:begin result <= input_a; end
1:begin result <= input_b; end
default: begin result <= 16'b0; end
endcase
end
endmodule
module mux2_to_1_3bit(input_a,input_b,sel,result);
input [2:0] input_a;
input [2:0] input_b;
input sel;
output [2:0] result;
reg [2:0] result;
initial begin
result<=3'b000;
end
always@(*)
begin
case(sel)
0:begin result <= input_a; end
1:begin result <= input_b; end
default: begin result <= 3'b0; end
endcase
end
endmodule
module mux3Bit_4_to_1(input_a,input_b, input_c, input_d, sel,result);
input [2:0] input_a;
input [2:0] input_b;
input [2:0] input_c;
input [2:0] input_d;
input [1:0] sel;
output reg [2:0] result;
initial begin
result<=3'b000;
end
always@(*)
begin
case(sel)
2'b00:begin result <= input_a; end
2'b01:begin result <= input_b; end
2'b10:begin result <= input_c; end
2'b11:begin result <= input_d; end
default: begin result <= 3'b0; end
endcase
end
endmodule
//module mux3_to_1(input_a,input_b, input_c, sel,result);
//
//input [15:0] input_a;
//input [15:0] input_b;
//input [15:0] input_c;
//input [1:0]sel;
//
//output [15:0] result;
//reg [15:0] result;
//
//always@(*)
//begin
// case(sel)
// 2'b00:begin result <= input_a; end
// 2'b01:begin result <= input_b; end
// 2'b10:begin result <= input_c; end
// default: begin result <= 16'b0; end
// endcase
//end
//endmodule
module mux4_to_1(input_a,input_b, input_c, input_d, sel,result);
input [15:0] input_a;
input [15:0] input_b;
input [15:0] input_c;
input [15:0] input_d;
input [1:0]sel;
output [15:0] result;
reg [15:0] result;
initial begin
result<=16'h0000;
end
always@(*)
begin
case(sel)
2'b00:begin result <= input_a; end
2'b01:begin result <= input_b; end
2'b10:begin result <= input_c; end
2'b11:begin result <= input_d; end
default: begin result <= 16'b0; end
endcase
end
endmodule