-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmux.v
More file actions
55 lines (43 loc) · 1.08 KB
/
Copy pathmux.v
File metadata and controls
55 lines (43 loc) · 1.08 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
module mux2 #(parameter WIDTH = 8) (
input select,
input [WIDTH-1:0] d0, d1,
output [WIDTH-1:0] out
);
assign out = select ? d1 : d0;
endmodule
module mux3 #(parameter WIDTH = 8) (
input [1:0] select,
input [WIDTH-1:0] d0, d1, d2,
output [WIDTH-1:0] out
);
assign out = select[1] ? d2 : (select[0] ? d1 : d0);
endmodule
module mux4 #(parameter WIDTH = 8) (
input [1:0] select,
input [WIDTH-1:0] d0, d1, d2, d3,
output reg [WIDTH-1:0] out
);
always @ (*)
begin
case(select)
2'b00 : out <= d0;
2'b01 : out <= d1;
2'b10 : out <= d2;
2'b11 : out <= d3;
endcase
end
endmodule
module mux4_assign #(parameter WORD_SIZE_BIT = 32) (
input [1:0] s,
input [WORD_SIZE_BIT-1:0] d0, d1, d2, d3,
output [WORD_SIZE_BIT-1:0] y
);
assign y = (s == 2'd0) ? d0 : ((s == 2'd1) ? d1 : ((s == 2'd2) ? d2 : d3));
endmodule
module tri_buf #(parameter DATA_BLOCK = 128)(
input [DATA_BLOCK - 1 : 0] a,
input enable,
output [DATA_BLOCK - 1 : 0] b
);
assign b = enable ? a : {DATA_BLOCK{1'dz}};
endmodule