-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.v
111 lines (91 loc) · 1.33 KB
/
main.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
`timescale 1ns/1ps
module main(
input clk,
input rst_n
);
wire [31:0] Instr, PC, ALUResult, WriteData, ReadData, RD1, RD2, SrcA, SrcB, PCPlus, SigImm, Result;
wire [4:0] Regfile_A3;
wire [3:0] ALUOp;
wire ALUSrc, MemtoReg, RegDst, Zero;
assign SrcA = RD1;
assign WriteData = RD2;
and branch(
PCSrc,
Zero,
Branch
);
textrom text_rom(
.a(PC[11:2]),
.spo(Instr)
);
dataram data_ram (
.a(ALUResult[11:2]), // input wire [9 : 0] a
.d(WriteData), // input wire [31 : 0] d
.clk(clk), // input wire clk
.we(MemWrite), // input wire we
.spo(ReadData) // output wire [31 : 0] dpo
);
ALU mainALU (
ALUOp,
SrcA,
SrcB,
ALUResult,
Zero
);
Ext SignExt(
1'b1,
Instr[15:0],
SigImm
);
pc prog_cnt(
clk,
PCSrc,
SigImm,
Instr[25:0],
Jump,
PC,
PCPlus
);
control ct1 (
Instr[31:26],
Instr[5:0],
RegDst,
ALUSrc,
MemtoReg,
RegWrite,
MemRead,
MemWrite,
Branch,
ALUOp,
Jump
);
reg_file Reg(
clk,
rst_n,
Instr[25:21],
Instr[20:16],
Regfile_A3,
Result,
RegWrite,
RD1,
RD2
);
mux alumux(
ALUSrc,
RD2,
SigImm,
SrcB
);
mux resmux(
MemtoReg,
ALUResult,
ReadData,
Result
);
mux regmux(
RegDst,
{27'd0,Instr[20:16]},
{27'd0,Instr[15:11]},
Regfile_A3
);
endmodule