-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmycpu_core.v
120 lines (108 loc) · 3.92 KB
/
mycpu_core.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
`include "lib/defines.vh"
module mycpu_core(
input wire clk,
input wire rst,
input wire [5:0] int,
output wire inst_sram_en,
output wire [3:0] inst_sram_wen,
output wire [31:0] inst_sram_addr,
output wire [31:0] inst_sram_wdata,
input wire [31:0] inst_sram_rdata,
output wire data_sram_en,
output wire [3:0] data_sram_wen,
output wire [31:0] data_sram_addr,
output wire [31:0] data_sram_wdata,
input wire [31:0] data_sram_rdata,
output wire [31:0] debug_wb_pc,
output wire [3:0] debug_wb_rf_wen,
output wire [4:0] debug_wb_rf_wnum,
output wire [31:0] debug_wb_rf_wdata
);
wire [`IF_TO_ID_WD-1:0] if_to_id_bus;
wire [`ID_TO_EX_WD-1:0] id_to_ex_bus;
wire [`EX_TO_MEM_WD-1:0] ex_to_mem_bus;
wire [`MEM_TO_WB_WD-1:0] mem_to_wb_bus;
wire [`BR_WD-1:0] br_bus;
wire [`DATA_SRAM_WD-1:0] ex_dt_sram_bus;
wire [`WB_TO_RF_WD-1:0] wb_to_rf_bus;
wire [`StallBus-1:0] stall;
wire ex_id_we;
wire stallreq_for_load;
wire stallreq_for_ex;
wire [65:0]ex_hilo;
wire is_lw;
IF u_IF(
.clk (clk ),
.rst (rst ),
.stall (stall ),
.br_bus (br_bus ),
.if_to_id_bus (if_to_id_bus ),
.inst_sram_en (inst_sram_en ),
.inst_sram_wen (inst_sram_wen ),
.inst_sram_addr (inst_sram_addr ),
.inst_sram_wdata (inst_sram_wdata )
);
ID u_ID(
.clk (clk ),
.rst (rst ),
.stall (stall ),
.stallreq (stallreq_for_load),
.if_to_id_bus (if_to_id_bus ),
.inst_sram_rdata (inst_sram_rdata ),
.wb_to_rf_bus (wb_to_rf_bus ),
//处于执行阶段指令要写入的寄存器信息
.ex_rf_we (ex_id_we ),
.ex_rf_waddr (ex_to_mem_bus[36:32]),
.ex_ex_result (ex_to_mem_bus[31:0]),
//处于访存阶段指令要写入的寄存器信息
.mem_rf_we (mem_to_wb_bus[37]),
.mem_rf_waddr (mem_to_wb_bus[36:32]),
.mem_rf_wdata (mem_to_wb_bus[31:0]),
//处于写回阶段指令要写入的寄存器信息
.id_to_ex_bus (id_to_ex_bus ),
.br_bus (br_bus ),
.is_lw (is_lw ),
.ex_hilo(ex_hilo)
);
EX u_EX(
.clk (clk ),
.rst (rst ),
.stall (stall ),
.id_to_ex_bus (id_to_ex_bus ),
.ex_to_mem_bus (ex_to_mem_bus ),
.data_sram_en (data_sram_en ),
.data_sram_wen (data_sram_wen ),
.data_sram_addr (data_sram_addr ),
.data_sram_wdata (data_sram_wdata ),
.is_lw (is_lw ),
.ex_id_we (ex_id_we ),
/////
.stallreq_for_ex (stallreq_for_ex ),
.ex_hilo (ex_hilo )
);
MEM u_MEM(
.clk (clk ),
.rst (rst ),
.stall (stall ),
.ex_to_mem_bus (ex_to_mem_bus ),
.data_sram_rdata (data_sram_rdata ),
.mem_to_wb_bus (mem_to_wb_bus )
);
WB u_WB(
.clk (clk ),
.rst (rst ),
.stall (stall ),
.mem_to_wb_bus (mem_to_wb_bus ),
.wb_to_rf_bus (wb_to_rf_bus ),
.debug_wb_pc (debug_wb_pc ),
.debug_wb_rf_wen (debug_wb_rf_wen ),
.debug_wb_rf_wnum (debug_wb_rf_wnum ),
.debug_wb_rf_wdata (debug_wb_rf_wdata )
);
CTRL u_CTRL(
.rst (rst ),
.stallreq_for_ex (stallreq_for_ex ),
.stallreq_for_load (stallreq_for_load),
.stall (stall )
);
endmodule