diff --git a/firmware/firmware.map b/firmware/firmware.map
index 03ca7e4..703fb8e 100644
--- a/firmware/firmware.map
+++ b/firmware/firmware.map
@@ -6,31 +6,31 @@
链结器命令稿和内存映射
-LOAD /tmp/ccljpktb.o
-LOAD /tmp/ccyHRNCG.o
+LOAD /tmp/ccAfohhF.o
+LOAD /tmp/ccqZrkCR.o
.memory 0x0000000000000000 0x1b0
0x0000000000000000 . = 0x0
*(.init)
- .init 0x0000000000000000 0x10 /tmp/ccljpktb.o
+ .init 0x0000000000000000 0x10 /tmp/ccAfohhF.o
*(.text)
- .text 0x0000000000000010 0x0 /tmp/ccljpktb.o
- .text 0x0000000000000010 0x82 /tmp/ccyHRNCG.o
+ .text 0x0000000000000010 0x0 /tmp/ccAfohhF.o
+ .text 0x0000000000000010 0x82 /tmp/ccqZrkCR.o
0x0000000000000010 putc
0x0000000000000052 puts
0x0000000000000078 memcpy
*(*)
- .data 0x0000000000000092 0x0 /tmp/ccljpktb.o
- .bss 0x0000000000000092 0x0 /tmp/ccljpktb.o
- .rela.init 0x0000000000000092 0x0 /tmp/ccljpktb.o
- .data 0x0000000000000092 0x0 /tmp/ccyHRNCG.o
- .bss 0x0000000000000092 0x0 /tmp/ccyHRNCG.o
- .text.startup 0x0000000000000092 0x88 /tmp/ccyHRNCG.o
+ .data 0x0000000000000092 0x0 /tmp/ccAfohhF.o
+ .bss 0x0000000000000092 0x0 /tmp/ccAfohhF.o
+ .rela.init 0x0000000000000092 0x0 /tmp/ccAfohhF.o
+ .data 0x0000000000000092 0x0 /tmp/ccqZrkCR.o
+ .bss 0x0000000000000092 0x0 /tmp/ccqZrkCR.o
+ .text.startup 0x0000000000000092 0x88 /tmp/ccqZrkCR.o
0x0000000000000092 main
*fill* 0x000000000000011a 0x2
.rodata.str1.4
- 0x000000000000011c 0x80 /tmp/ccyHRNCG.o
- .comment 0x000000000000019c 0x11 /tmp/ccyHRNCG.o
+ 0x000000000000011c 0x80 /tmp/ccqZrkCR.o
+ .comment 0x000000000000019c 0x11 /tmp/ccqZrkCR.o
0x12 (松开之前的大小)
0x00000000000001b0 . = ALIGN (0x4)
*fill* 0x00000000000001ad 0x3
diff --git a/scripts/kamikaze_test/kamikaze_test.al b/scripts/kamikaze_test/kamikaze_test.al
index c616359..9faa104 100644
--- a/scripts/kamikaze_test/kamikaze_test.al
+++ b/scripts/kamikaze_test/kamikaze_test.al
@@ -18,7 +18,7 @@
-
+
top
auto
@@ -26,6 +26,6 @@
0
-
+
diff --git a/src/csr.txt b/src/csr.txt
new file mode 100644
index 0000000..0177fc5
--- /dev/null
+++ b/src/csr.txt
@@ -0,0 +1,10 @@
+0x300 MSTATUS: IE[0], PRIV[2:1], CY[3]
+0x341 MEPC Storage last pc and jump to interrupt or exception address
+0x342 MCAUSE INT[31](it is trigged by an interrupt), Exception op-code[4:0]
+0x301 MISA ISA support RV32IMC
+
+0xF11 MVID "ANLG" (Anlogic)
+0xF12 MARCHID "ZYKZ" (Zhiyuan Kamikaze)
+0xF13 MIMPID "0000" (r0p0)
+
+/* performance counter will not be implemented in this CPU */
diff --git a/src/fetch.v b/src/fetch.v
index 9a2f6a4..0ac4e7c 100644
--- a/src/fetch.v
+++ b/src/fetch.v
@@ -14,7 +14,7 @@ module kamikaze_fetch(clk_i,
input [31:0] im_data_i;
output reg [31:0] instr_o;
output [31:0] im_addr_o;
- output reg instr_valid_o;
+ output instr_valid_o;
output is_compressed_instr_o;
output [31:0] pc_o;
//input stall_i; /* IF 停止信号 */
@@ -34,7 +34,10 @@ module kamikaze_fetch(clk_i,
assign is_compressed_instr_o = is_compressed_instr;
- localparam CPU_START = 32'h0; /* 启动地址 */
+ reg align_wait; /* 对齐等待 */
+
+ assign instr_valid_o = !align_wait;
+ localparam CPU_START = 32'h2; /* 启动地址 */
assign im_addr_o = pc_4[1]? (pc_4 + 2'b10): pc_4; /* 舍入 */
assign stall_requiring = (pc_add_prev == 2) && (pc[1:0] == 2'b00); /* 16位对齐等待,防止冲数据 */
@@ -42,29 +45,33 @@ module kamikaze_fetch(clk_i,
assign pc_o = pc;
+
+
always @(posedge clk_i or negedge rst_i)
begin
if(!rst_i)
begin
- pc_4 <= CPU_START;
- pc <= CPU_START;/* PC 比 pc_4 滞后1 CLK */
+ pc_4 <= {CPU_START[31:2], 2'b00};
+ pc <= {CPU_START[31:2], 2'b00};/* PC 比 pc_4 滞后1 CLK */
fetch_start <= 0;
pc_add_prev <= 4;
last_instr <= 32'h0;
- instr_valid_o <= 0;
+ align_wait = CPU_START[1];
end
else
begin
if(!stall_i)
- begin
+ begin
if(fetch_start == 1'b0)
begin
fetch_start <= 1'b1; /* 取 0 指令 */
pc_4 <= pc_4 + 16'h4;
- instr_valid_o <= 1;
end
else
begin
+ if(align_wait)
+ align_wait <= 0;
+
pc_4 <= pc_4 + pc_add;
pc <= pc + pc_add;
diff --git a/src/int_exp.txt b/src/int_exp.txt
new file mode 100644
index 0000000..4088ee2
--- /dev/null
+++ b/src/int_exp.txt
@@ -0,0 +1,11 @@
+interrupt & exception table:
+base_address: IVT_BASE, must be aligned to 4
+
+initial_sp
+reset_address
+bus_error(misaligned/invalid memory access)
+execute_error(divided by zero or illegal instruction)
+sys_call(ecall instruction, ebreak will triggers the debugger if it is online)
+nmi(not maskable interrupt, it is interrupt 0)
+interrupts 1-31
+
diff --git a/src/regfile.v b/src/regfile.v
new file mode 100644
index 0000000..e69de29
diff --git a/src/tb.v b/src/tb.v
index 48bca08..aaf8788 100644
--- a/src/tb.v
+++ b/src/tb.v
@@ -6,7 +6,6 @@ module system_tb;
initial begin
$dumpfile("kamikaze.vcd");
$dumpvars(0, system_tb);
- #10 rst = 0;
#15 rst = 1;
#1000 $finish;