-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArithmeticLogicUnitSystem.v
More file actions
112 lines (104 loc) · 3.34 KB
/
ArithmeticLogicUnitSystem.v
File metadata and controls
112 lines (104 loc) · 3.34 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
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
`timescale 1ns / 1ps
module MUX_A(
input wire [1:0] MuxASel,
input wire [15:0] O1,
input wire [15:0] O2,
input wire [7:0] O3,
input wire [15:0] O4,
output reg [15:0] OutMuxA
);
always@(*) begin
case (MuxASel)
2'b00: OutMuxA = O1;
2'b01: OutMuxA = O2;
2'b10: begin
OutMuxA[7:0] = O3;
OutMuxA[15:8] = 8'd0;
end
2'b11: begin
OutMuxA[7:0] = O4[7:0];
OutMuxA[15:8] = 8'd0;
end
endcase
end
endmodule
module MUX_B(
input wire [1:0] MuxBSel,
input wire [15:0] O1,
input wire [15:0] O2,
input wire [7:0] O3,
input wire [15:0] O4,
output reg [15:0] OutMuxB
);
always@(*) begin
case (MuxBSel)
2'b00: OutMuxB = O1;
2'b01: OutMuxB = O2;
2'b10: begin
OutMuxB[7:0] = O3;
OutMuxB[15:8] = 8'd0;
end
2'b11: begin
OutMuxB[7:0] = O4[7:0];
OutMuxB[15:8] = 8'd0;
end
endcase
end
endmodule
module MUX_C(
input wire MuxCSel,
input wire [15:0] O1,
output reg [7:0] OutMuxC
);
always@(*) begin
case (MuxCSel)
1'b0: OutMuxC = O1[7:0];
1'b1: OutMuxC = O1[15:8];
endcase
end
endmodule
module ArithmeticLogicUnitSystem (
input wire [2:0] RF_FunSel,
input wire [2:0] ARF_FunSel,
input wire [4:0] ALU_FunSel,
input wire [2:0] RF_OutASel,
input wire [2:0] RF_OutBSel,
input wire [3:0] RF_RegSel,
input wire [3:0] RF_ScrSel,
input wire [1:0] ARF_OutCSel,
input wire [1:0] ARF_OutDSel,
input wire [2:0] ARF_RegSel,
input wire [1:0] MuxASel,
input wire [1:0] MuxBSel,
input wire MuxCSel,
input wire ALU_WF,
input wire IR_LH,
input wire IR_Write,
input wire Clock,
input wire Mem_WR,
input wire Mem_CS
);
wire [3:0] FlagsOut;
wire [15:0] ALUOut;
wire [15:0] OutC;
wire [15:0] OutD;
wire [15:0] OutA;
wire [15:0] OutB;
wire [15:0] IROut;
wire [15:0] MuxAOut;
wire [15:0] MuxBOut;
wire [7:0] MuxCOut;
wire [7:0] MemOut;
wire [15:0] Address;
wire [7:0] Data;
ArithmeticLogicUnit ALU(.FunSel(ALU_FunSel), .A(OutA), .B(OutB), .WF(ALU_WF), .ALUOut(ALUOut), .Clock(Clock), .FlagsOut(FlagsOut));
AddressRegisterFile ARF(.FunSel(ARF_FunSel), .OutCSel(ARF_OutCSel), .OutDSel(ARF_OutDSel), .OutC(OutC), .OutD(OutD), .RegSel(ARF_RegSel), .I(MuxBOut), .Clock(Clock));
RegisterFile RF(.OutASel(RF_OutASel), .OutBSel(RF_OutBSel), .RegSel(RF_RegSel), .ScrSel(RF_ScrSel), .FunSel(RF_FunSel), .I(MuxAOut), .Clock(Clock), .OutA(OutA), .OutB(OutB));
InstructionRegister IR(.I(MemOut), .LH(IR_LH), .Write(IR_Write), .IROut(IROut), .Clock(Clock));
Memory MEM(.Address(OutD), .Data(MuxCOut), .WR(Mem_WR), .MemOut(MemOut), .CS(Mem_CS), .Clock(Clock));
MUX_A MUXA(.MuxASel(MuxASel), .O1(ALUOut), .O2(OutC), .O3(MemOut), .O4(IROut), .OutMuxA(MuxAOut));
MUX_B MUXB(.MuxBSel(MuxBSel), .O1(ALUOut), .O2(OutC), .O3(MemOut), .O4(IROut), .OutMuxB(MuxBOut));
MUX_C MUXC(.MuxCSel(MuxCSel), .O1(ALUOut), .OutMuxC(MuxCOut));
assign Address = OutD;
assign Data = MuxCOut;
endmodule