-
Notifications
You must be signed in to change notification settings - Fork 9
/
kronos_core.sv
150 lines (137 loc) · 4.14 KB
/
kronos_core.sv
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// Copyright (c) 2020 Sonal Pinto
// SPDX-License-Identifier: Apache-2.0
/*
Kronos
3-stage RISC-V RV32I_Zicsr_Zifencei Core
*/
module kronos_core
import kronos_types::*;
#(
parameter logic [31:0] BOOT_ADDR = 32'h0,
parameter FAST_BRANCH = 1,
parameter EN_COUNTERS = 1,
parameter EN_COUNTERS64B = 1,
parameter CATCH_ILLEGAL_INSTR = 1,
parameter CATCH_MISALIGNED_JMP = 1,
parameter CATCH_MISALIGNED_LDST = 1
)(
input logic clk,
input logic rstz,
// Instruction interface
output logic [31:0] instr_addr,
input logic [31:0] instr_data,
output logic instr_req,
input logic instr_ack,
// Data interface
output logic [31:0] data_addr,
input logic [31:0] data_rd_data,
output logic [31:0] data_wr_data,
output logic [3:0] data_mask,
output logic data_wr_en,
output logic data_req,
input logic data_ack,
// Interrupt sources
input logic software_interrupt,
input logic timer_interrupt,
input logic external_interrupt
);
logic [31:0] immediate;
logic [31:0] regrd_rs1;
logic [31:0] regrd_rs2;
logic regrd_rs1_en;
logic regrd_rs2_en;
logic [31:0] branch_target;
logic branch;
logic [31:0] regwr_data;
logic [4:0] regwr_sel;
logic regwr_en;
logic flush;
pipeIFID_t fetch;
pipeIDEX_t decode;
logic fetch_vld, fetch_rdy;
logic decode_vld, decode_rdy;
// ============================================================
// Fetch
// ============================================================
kronos_IF #(
.BOOT_ADDR(BOOT_ADDR),
.FAST_BRANCH(FAST_BRANCH)
) u_if (
.clk (clk ),
.rstz (rstz ),
.instr_addr (instr_addr ),
.instr_data (instr_data ),
.instr_req (instr_req ),
.instr_ack (instr_ack ),
.fetch (fetch ),
.immediate (immediate ),
.regrd_rs1 (regrd_rs1 ),
.regrd_rs2 (regrd_rs2 ),
.regrd_rs1_en (regrd_rs1_en ),
.regrd_rs2_en (regrd_rs2_en ),
.fetch_vld (fetch_vld ),
.fetch_rdy (fetch_rdy ),
.branch_target(branch_target),
.branch (branch ),
.regwr_data (regwr_data ),
.regwr_sel (regwr_sel ),
.regwr_en (regwr_en )
);
// ============================================================
// Decode
// ============================================================
kronos_ID #(
.CATCH_ILLEGAL_INSTR(CATCH_ILLEGAL_INSTR),
.CATCH_MISALIGNED_JMP(CATCH_MISALIGNED_JMP),
.CATCH_MISALIGNED_LDST(CATCH_MISALIGNED_LDST)
) u_id (
.clk (clk ),
.rstz (rstz ),
.flush (flush ),
.fetch (fetch ),
.immediate (immediate ),
.regrd_rs1 (regrd_rs1 ),
.regrd_rs2 (regrd_rs2 ),
.regrd_rs1_en(regrd_rs1_en),
.regrd_rs2_en(regrd_rs2_en),
.fetch_vld (fetch_vld ),
.fetch_rdy (fetch_rdy ),
.decode (decode ),
.decode_vld (decode_vld ),
.decode_rdy (decode_rdy ),
.regwr_data (regwr_data ),
.regwr_sel (regwr_sel ),
.regwr_en (regwr_en )
);
// ============================================================
// Execute
// ============================================================
kronos_EX #(
.BOOT_ADDR (BOOT_ADDR),
.EN_COUNTERS (EN_COUNTERS),
.EN_COUNTERS64B(EN_COUNTERS64B)
) u_ex (
.clk (clk ),
.rstz (rstz ),
.decode (decode ),
.decode_vld (decode_vld ),
.decode_rdy (decode_rdy ),
.regwr_data (regwr_data ),
.regwr_sel (regwr_sel ),
.regwr_en (regwr_en ),
.branch_target (branch_target ),
.branch (branch ),
.data_addr (data_addr ),
.data_rd_data (data_rd_data ),
.data_wr_data (data_wr_data ),
.data_mask (data_mask ),
.data_wr_en (data_wr_en ),
.data_req (data_req ),
.data_ack (data_ack ),
.software_interrupt(software_interrupt),
.timer_interrupt (timer_interrupt ),
.external_interrupt(external_interrupt)
);
// Flush pipeline on branch
assign flush = branch;
endmodule