-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmips.v
128 lines (112 loc) · 1.84 KB
/
mips.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
`include "datapath/pc.v"
`include "datapath/alu.v"
`include "datapath/dm.v"
`include "datapath/ext.v"
`include "datapath/im.v"
`include "datapath/npc.v"
`include "datapath/rf.v"
`include "datapath/mux.v"
`include "control/ctrl.v"
module mips (clk, rst);
input clk;
input rst;
wire [31:0] pc_next;
wire [31:0] pc_cur;
wire [31:0] ins;
wire [31:0] ext_imm;
wire [31:0] routa;
wire [31:0] routb;
wire [31:0] rin;
wire [31:0] aluSrc_mux_out;
wire [31:0] alu_out;
wire [31:0] dm_out;
wire [4:0] rWin;
wire [3:0] aluCtr;
wire branch;
wire jump;
wire regDst;
wire aluSrc;
wire regWr;
wire memWr;
wire extOp;
wire memtoReg;
wire zero;
pc pc(
.clk(clk),
.rst(rst),
.niaddr(pc_next),
.iaddr(pc_cur)
);
npc npc(
.iaddr(pc_cur),
.branch(branch),
.jump(jump),
.zero(zero),
.imm16(ins[15:0]),
.imm26(ins[25:0]),
.niaddr(pc_next)
);
im_4k im(
.iaddr(pc_cur[11:2]),
.ins(ins)
);
ext extOp_ext(
.imm16(ins[15:0]),
.extOp(extOp),
.dout(ext_imm)
);
mux #(32) aluSrc_mux(
.a(routb),
.b(ext_imm),
.ctrl_s(aluSrc),
.dout(aluSrc_mux_out)
);
mux #(5) regDst_mux(
.a(ins[20:16]),
.b(ins[15:11]),
.ctrl_s(regDst),
.dout(rWin)
);
regFile rf(
.busW(rin),
.clk(clk),
.wE(regWr),
.rW(rWin),
.rA(ins[25:21]),
.rB(ins[20:16]),
.busA(routa),
.busB(routb)
);
alu alu(
.ALUop(aluCtr),
.a(routa),
.b(aluSrc_mux_out),
.result(alu_out),
.zero(zero)
);
dm_4k dm(
.addr(alu_out[11:2]),
.din(routb),
.wEn(memWr),
.clk(clk),
.dout(dm_out)
);
mux memtoReg_mux(
.a(alu_out),
.b(dm_out),
.ctrl_s(memtoReg),
.dout(rin)
);
ctrl ctrl(
.ins(ins),
.branch(branch),
.jump(jump),
.regDst(regDst),
.aluSrc(aluSrc),
.aluCtr(aluCtr),
.regWr(regWr),
.memWr(memWr),
.extOp(extOp),
.memtoReg(memtoReg)
);
endmodule // MIPS main program;