-
Notifications
You must be signed in to change notification settings - Fork 0
/
Single_Cycle_Top.v
104 lines (90 loc) · 2.96 KB
/
Single_Cycle_Top.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
`include "PC.v"
`include "Instruction_Memory.v"
`include "Register_File.v"
`include "Sign_Extend.v"
`include "ALU.v"
`include "Control_Unit_Top.v"
`include "Data_Memory.v"
`include "PC_Adder.v"
`include "Mux.v"
module Single_Cycle_Top(clk,rst);
input clk,rst;
wire [31:0] PC_Top,RD_Instr,RD1_Top,Imm_Ext_Top,ALUResult,ReadData,PCPlus4,RD2_Top,SrcB,Result;
wire RegWrite,MemWrite,ALUSrc,ResultSrc;
wire [1:0]ImmSrc;
wire [2:0]ALUControl_Top;
PC_Module PC(
.clk(clk),
.rst(rst),
.PC(PC_Top),
.PC_Next(PCPlus4)
);
PC_Adder PC_Adder(
.a(PC_Top),
.b(32'd4),
.c(PCPlus4)
);
Instruction_Memory Instruction_Memory(
.rst(rst),
.A(PC_Top),
.RD(RD_Instr)
);
Register_File Register_File(
.clk(clk),
.rst(rst),
.WE3(RegWrite),
.WD3(Result),
.A1(RD_Instr[19:15]),
.A2(RD_Instr[24:20]),
.A3(RD_Instr[11:7]),
.RD1(RD1_Top),
.RD2(RD2_Top)
);
Sign_Extend Sign_Extend(
.In(RD_Instr),
.ImmSrc(ImmSrc[0]),
.Imm_Ext(Imm_Ext_Top)
);
Mux Mux_Register_to_ALU(
.a(RD2_Top),
.b(Imm_Ext_Top),
.s(ALUSrc),
.c(SrcB)
);
ALU ALU(
.A(RD1_Top),
.B(SrcB),
.Result(ALUResult),
.ALUControl(ALUControl_Top),
.OverFlow(),
.Carry(),
.Zero(),
.Negative()
);
Control_Unit_Top Control_Unit_Top(
.Op(RD_Instr[6:0]),
.RegWrite(RegWrite),
.ImmSrc(ImmSrc),
.ALUSrc(ALUSrc),
.MemWrite(MemWrite),
.ResultSrc(ResultSrc),
.Branch(),
.funct3(RD_Instr[14:12]),
.funct7(RD_Instr[6:0]),
.ALUControl(ALUControl_Top)
);
Data_Memory Data_Memory(
.clk(clk),
.rst(rst),
.WE(MemWrite),
.WD(RD2_Top),
.A(ALUResult),
.RD(ReadData)
);
Mux Mux_DataMemory_to_Register(
.a(ALUResult),
.b(ReadData),
.s(ResultSrc),
.c(Result)
);
endmodule