forked from cyLi-Tiger/Single-Cycle-CPU-10
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMUX.v
76 lines (66 loc) · 1.54 KB
/
MUX.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
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 2019/11/24 09:42:00
// Design Name:
// Module Name: MUX2X5
// Project Name:
// Target Devices:
// Tool Versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module MUX2X5(A0,A1,S,Y);
input [4:0] A0,A1;
input S;
output [4:0] Y;
function [4:0] select;
input [4:0] A0,A1;
input S;
case(S)
0:select=A0;
1:select=A1;
endcase
endfunction
assign Y=select(A0,A1,S);
endmodule
module MUX2X32(A0,A1,S,Y);
input [31:0] A0,A1;
input S;
output [31:0] Y;
function [31:0] select;
input [31:0] A0,A1;
input S;
case(S)
0:select=A0;
1:select=A1;
endcase
endfunction
assign Y=select(A0,A1,S);
endmodule
module MUX5X32 (A0, A1, A2, A3, A4, S, Y);
input [31:0] A0, A1, A2, A3, A4;
input [2:0] S;
output [31:0] Y;
function [31:0] select;
input [31:0] A0, A1, A2, A3, A4;
input [2:0] S;
case(S)
3'b000: select = A0;
3'b001: select = A1;
3'b010: select = A2;
3'b011: select = A3;
3'b100: select = A3;
3'b101: select = A4;
endcase
endfunction
assign Y = select (A0, A1, A2, A3, A4, S);
endmodule