Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
U
urv-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
hdl-core-lib
urv-core
Commits
9016844b
Commit
9016844b
authored
Mar 11, 2018
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fixed incorrect exception handling (exception address delayed by 1 instruction)
parent
f1fcd338
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
157 additions
and
84 deletions
+157
-84
urv_exceptions.v
rtl/urv_exceptions.v
+7
-1
urv_exec.v
rtl/urv_exec.v
+3
-7
Manifest.py
tb/isa-testsuite/Manifest.py
+1
-1
main.sv
tb/isa-testsuite/main.sv
+18
-29
wave.do
tb/isa-testsuite/wave.do
+128
-46
No files found.
rtl/urv_exceptions.v
View file @
9016844b
...
...
@@ -74,6 +74,9 @@ module urv_exceptions
reg
[
5
:
0
]
except_vec_masked
;
reg
exception_pending
;
reg
[
31
:
0
]
x_exception_pc_d
;
assign
csr_mcause_o
=
{
28'h0
,
csr_mcause
};
assign
csr_mepc_o
=
csr_mepc
;
assign
csr_mie_o
=
csr_mie
;
...
...
@@ -157,11 +160,14 @@ module urv_exceptions
exception_pending
<=
0
;
end
else
if
(
!
x_stall_i
&&
!
x_kill_i
)
begin
x_exception_pc_d
<=
x_exception_pc_i
;
if
(
d_is_eret_i
)
exception_pending
<=
0
;
else
if
(
x_exception_taken_i
)
begin
csr_mepc
<=
x_exception_pc_
i
;
csr_mepc
<=
x_exception_pc_
d
;
csr_mcause
<=
cause
;
exception_pending
<=
1
;
end
...
...
rtl/urv_exec.v
View file @
9016844b
...
...
@@ -44,8 +44,6 @@ module urv_exec
input
d_valid_i
,
input
d_load_hazard_i
,
input
[
4
:
0
]
d_opcode_i
,
input
d_shifter_sign_i
,
...
...
@@ -77,8 +75,6 @@ module urv_exec
output
reg
[
31
:
0
]
f_branch_target_o
,
output
f_branch_take_o
,
output
w_load_hazard_o
,
input
irq_i
,
// Writeback stage I/F
...
...
@@ -436,9 +432,9 @@ module urv_exec
w_rd_o
<=
d_rd_i
;
w_rd_value_o
<=
rd_value
;
w_rd_write_o
<=
d_rd_write_i
&&
!
x_kill_i
&&
d_valid_i
&&
!
exception
;
w_load_o
<=
d_is_load_i
&&
!
x_kill_i
&&
d_valid_i
&&
!
exception
;
w_store_o
<=
d_is_store_i
&&
!
x_kill_i
&&
d_valid_i
&&
!
exception
;
w_rd_write_o
<=
d_rd_write_i
&&
!
x_kill_i
&&
d_valid_i
&&
!
exception
&&
!
d_is_undef_i
;
w_load_o
<=
d_is_load_i
&&
!
x_kill_i
&&
d_valid_i
&&
!
exception
&&
!
d_is_undef_i
;
w_store_o
<=
d_is_store_i
&&
!
x_kill_i
&&
d_valid_i
&&
!
exception
&&
!
d_is_undef_i
;
w_rd_source_o
<=
d_rd_source_i
;
w_fun_o
<=
d_fun_i
;
...
...
tb/isa-testsuite/Manifest.py
View file @
9016844b
sim_tool
=
"modelsim"
top_module
=
"main"
syn_device
=
"xc6slx150t"
sim_top
=
"main"
action
=
"simulation"
target
=
"xilinx"
include_dirs
=
[
"../../rtl"
]
...
...
tb/isa-testsuite/main.sv
View file @
9016844b
...
...
@@ -18,33 +18,37 @@
*/
`include
"rv_defs.v"
`define
URV_PLATFORM_SPARTAN6
`include
"urv_defs.v"
`timescale
1
ns
/
1
ps
module
main
;
module
main
;
reg
clk
=
0
;
reg
rst
=
1
;
wire
[
31
:
0
]
im_addr
;
reg
[
31
:
0
]
im_data
;
reg
im_valid
;
reg
[
31
:
0
]
im_data
;
reg
im_valid
;
wire
[
31
:
0
]
dm_addr
;
wire
[
31
:
0
]
dm_data_s
;
reg
[
31
:
0
]
dm_data_l
;
reg
[
31
:
0
]
dm_data_l
;
wire
[
3
:
0
]
dm_data_select
;
wire
dm_write
;
reg
dm_valid_l
=
1
;
reg
dm_ready
;
reg
dm_ready
;
wire
irq
=
0
;
localparam
int
mem_size
=
16384
;
reg
[
31
:
0
]
mem
[
0
:
mem_size
-
1
]
;
// loads memory contents from a text file
task
automatic
load_ram
(
string
filename
)
;
int
f
=
$
fopen
(
filename
,
"r"
)
;
int
n
,
i
;
...
...
@@ -55,8 +59,6 @@ module main;
$
stop
;
end
while
(
!
$
feof
(
f
))
begin
int
addr
,
data
;
...
...
@@ -73,8 +75,7 @@ module main;
int
seed
;
// instruction and data memories
always
@
(
posedge
clk
)
begin
if
(
$
dist_uniform
(
seed
,
0
,
100
)
<=
100
)
begin
...
...
@@ -82,8 +83,6 @@ module main;
im_valid
<=
1
;
end
else
im_valid
<=
0
;
if
(
dm_write
&&
dm_data_select
[
0
])
mem
[(
dm_addr
/
4
)
%
mem_size
][
7
:
0
]
<=
dm_data_s
[
7
:
0
]
;
...
...
@@ -94,24 +93,17 @@ module main;
if
(
dm_write
&&
dm_data_select
[
3
])
mem
[(
dm_addr
/
4
)
%
mem_size
][
31
:
24
]
<=
dm_data_s
[
31
:
24
]
;
// dm_data_l <= mem[(dm_addr/4) % mem_size];
end
// always@ (posedge clk)
always
@
(
posedge
clk
)
begin
dm_ready
<=
1'b1
;
// $dist_uniform(seed, 0, 100 ) <= 50;
dm_data_l
<=
mem
[(
dm_addr
/
4
)
%
mem_size
]
;
end
end
rv_cpu
DUT
u
rv_cpu
DUT
(
.
clk_i
(
clk
)
,
.
rst_i
(
rst
)
,
...
...
@@ -145,7 +137,7 @@ module main;
string
tests
[$]
;
string
test_dir
=
"../../sw/testsuite/isa"
;
// load all tests listed in the file
int
f
=
$
fopen
(
{
test_dir
,
"/tests.lst"
}
,
"r"
)
;
int
n
,
i
;
...
...
@@ -157,8 +149,6 @@ module main;
$
fscanf
(
f
,
"%s"
,
fname
)
;
tests
.
push_back
(
fname
)
;
end
...
...
@@ -180,21 +170,20 @@ module main;
end
// initial begin
// report test completeness/status. The test applets indicate this by writing predefined
// memory locations.
always
@
(
posedge
clk
)
if
(
dm_write
)
begin
if
(
dm_addr
==
'h100000
)
begin
// $display("\n ****** TX '%c' \n", dm_data_s[7:0]) ;
// $fwrite(f_exec_log,"\n ****** TX '%c' \n", dm_data_s[7:0]) ;
$
write
(
"%c"
,
dm_data_s
[
7
:
0
])
;
$
fwrite
(
f_console
,
"%c"
,
dm_data_s
[
7
:
0
])
;
$
fflush
(
f_console
)
;
end
else
if
(
dm_addr
==
'h100004
)
begin
// $display("Test complete." );
test_complete
=
1
;
end
end
...
...
tb/isa-testsuite/wave.do
View file @
9016844b
onerror {resume}
quietly WaveActivateNextPane {} 0
add wave -noupdate /main/DUT/clk_i
add wave -noupdate /main/DUT/rst_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/clk_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/rst_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/d_stall_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/rf_rs1_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/rf_rs2_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/d_rs1_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/d_rs2_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/x_rs1_value_o
add wave -noupdate -expand -group RF-old /main/DUT/regfile/x_rs2_value_o
add wave -noupdate -expand -group RF-old /main/DUT/regfile/w_rd_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/w_rd_value_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/w_rd_store_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/w_bypass_rd_write_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/w_bypass_rd_value_i
add wave -noupdate -expand -group RF-old /main/DUT/regfile/rs1_regfile
add wave -noupdate -expand -group RF-old /main/DUT/regfile/rs2_regfile
add wave -noupdate -expand -group RF-old /main/DUT/regfile/write
add wave -noupdate -expand -group RF-old /main/DUT/regfile/rs1_bypass
add wave -noupdate -expand -group RF-old /main/DUT/regfile/rs2_bypass
add wave -noupdate -expand -group RF-old /main/DUT/regfile/bank0/bypass
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/clk_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/rst_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/d_stall_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/rf_rs1_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/rf_rs2_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/d_rs1_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/d_rs2_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/x_rs1_value_o
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/x_rs2_value_o
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/w_rd_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/w_rd_value_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/w_rd_store_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/w_bypass_rd_write_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/w_bypass_rd_value_i
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/rs1_regfile
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/rs2_regfile
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/write
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/rs1_bypass_x
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/rs2_bypass_x
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/rs1_bypass_w
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/rs2_bypass_w
add wave -noupdate -expand -group RF-new /main/DUT/regfile2/bypass_w
add wave -noupdate -expand -group Exec /main/DUT/execute/clk_i
add wave -noupdate -expand -group Exec /main/DUT/execute/rst_i
add wave -noupdate -expand -group Exec /main/DUT/execute/x_stall_i
add wave -noupdate -expand -group Exec /main/DUT/execute/x_kill_i
add wave -noupdate -expand -group Exec /main/DUT/execute/x_stall_req_o
add wave -noupdate -expand -group Exec /main/DUT/execute/d_pc_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_rd_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_fun_i
add wave -noupdate -expand -group Exec /main/DUT/execute/rf_rs1_value_i
add wave -noupdate -expand -group Exec /main/DUT/execute/rf_rs2_value_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_valid_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_opcode_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_shifter_sign_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_is_csr_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_is_eret_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_csr_imm_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_csr_sel_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_imm_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_is_signed_compare_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_is_signed_alu_op_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_is_add_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_is_shift_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_is_load_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_is_store_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_is_divide_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_is_undef_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_alu_op1_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_alu_op2_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_use_op1_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_use_op2_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_rd_source_i
add wave -noupdate -expand -group Exec /main/DUT/execute/d_rd_write_i
add wave -noupdate -expand -group Exec /main/DUT/execute/f_branch_target_o
add wave -noupdate -expand -group Exec /main/DUT/execute/f_branch_take_o
add wave -noupdate -expand -group Exec /main/DUT/execute/irq_i
add wave -noupdate -expand -group Exec /main/DUT/execute/w_fun_o
add wave -noupdate -expand -group Exec /main/DUT/execute/w_load_o
add wave -noupdate -expand -group Exec /main/DUT/execute/w_store_o
add wave -noupdate -expand -group Exec /main/DUT/execute/w_valid_o
add wave -noupdate -expand -group Exec /main/DUT/execute/w_rd_o
add wave -noupdate -expand -group Exec /main/DUT/execute/w_rd_value_o
add wave -noupdate -expand -group Exec /main/DUT/execute/w_rd_write_o
add wave -noupdate -expand -group Exec /main/DUT/execute/w_dm_addr_o
add wave -noupdate -expand -group Exec /main/DUT/execute/w_rd_source_o
add wave -noupdate -expand -group Exec /main/DUT/execute/w_rd_shifter_o
add wave -noupdate -expand -group Exec /main/DUT/execute/w_rd_multiply_o
add wave -noupdate -expand -group Exec /main/DUT/execute/dm_addr_o
add wave -noupdate -expand -group Exec /main/DUT/execute/dm_data_s_o
add wave -noupdate -expand -group Exec /main/DUT/execute/dm_data_select_o
add wave -noupdate -expand -group Exec /main/DUT/execute/dm_store_o
add wave -noupdate -expand -group Exec /main/DUT/execute/dm_load_o
add wave -noupdate -expand -group Exec /main/DUT/execute/dm_ready_i
add wave -noupdate -expand -group Exec /main/DUT/execute/csr_time_i
add wave -noupdate -expand -group Exec /main/DUT/execute/csr_cycles_i
add wave -noupdate -expand -group Exec /main/DUT/execute/timer_tick_i
add wave -noupdate -expand -group Exec /main/DUT/execute/rs1
add wave -noupdate -expand -group Exec /main/DUT/execute/rs2
add wave -noupdate -expand -group Exec /main/DUT/execute/alu_op1
add wave -noupdate -expand -group Exec /main/DUT/execute/alu_op2
add wave -noupdate -expand -group Exec /main/DUT/execute/alu_result
add wave -noupdate -expand -group Exec /main/DUT/execute/rd_value
add wave -noupdate -expand -group Exec /main/DUT/execute/exception_taken
add wave -noupdate -expand -group Exec /main/DUT/execute/branch_take
add wave -noupdate -expand -group Exec /main/DUT/execute/branch_condition_met
add wave -noupdate -expand -group Exec /main/DUT/execute/branch_target
add wave -noupdate -expand -group Exec /main/DUT/execute/dm_addr
add wave -noupdate -expand -group Exec /main/DUT/execute/dm_data_s
add wave -noupdate -expand -group Exec /main/DUT/execute/dm_select_s
add wave -noupdate -expand -group Exec /main/DUT/execute/cmp_op1
add wave -noupdate -expand -group Exec /main/DUT/execute/cmp_op2
add wave -noupdate -expand -group Exec /main/DUT/execute/cmp_rs
add wave -noupdate -expand -group Exec /main/DUT/execute/cmp_equal
add wave -noupdate -expand -group Exec /main/DUT/execute/cmp_lt
add wave -noupdate -expand -group Exec /main/DUT/execute/f_branch_take
add wave -noupdate -expand -group Exec /main/DUT/execute/rd_csr
add wave -noupdate -expand -group Exec /main/DUT/execute/rd_div
add wave -noupdate -expand -group Exec /main/DUT/execute/exception
add wave -noupdate -expand -group Exec /main/DUT/execute/csr_mie
add wave -noupdate -expand -group Exec /main/DUT/execute/csr_mip
add wave -noupdate -expand -group Exec /main/DUT/execute/csr_mepc
add wave -noupdate -expand -group Exec /main/DUT/execute/csr_mstatus
add wave -noupdate -expand -group Exec /main/DUT/execute/csr_mcause
add wave -noupdate -expand -group Exec /main/DUT/execute/csr_write_value
add wave -noupdate -expand -group Exec /main/DUT/execute/exception_address
add wave -noupdate -expand -group Exec /main/DUT/execute/exception_vector
add wave -noupdate -expand -group Exec /main/DUT/execute/exception_pc
add wave -noupdate -expand -group Exec /main/DUT/execute/alu_addsub_op1
add wave -noupdate -expand -group Exec /main/DUT/execute/alu_addsub_op2
add wave -noupdate -expand -group Exec /main/DUT/execute/alu_addsub_result
add wave -noupdate -expand -group Exec /main/DUT/execute/divider_stall_req
add wave -noupdate -expand -group Exec /main/DUT/execute/unaligned_addr
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/clk_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/rst_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/x_stall_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/x_kill_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/d_is_csr_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/d_is_eret_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/d_fun_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/d_csr_imm_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/d_csr_sel_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/exp_irq_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/exp_tick_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/exp_breakpoint_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/exp_unaligned_load_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/exp_unaligned_store_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/exp_invalid_insn_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/x_csr_write_value_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/x_exception_o
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/x_exception_pc_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/x_exception_pc_o
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/x_exception_vector_o
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/x_exception_taken_i
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/csr_mstatus_o
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/csr_mip_o
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/csr_mie_o
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/csr_mepc_o
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/csr_mcause_o
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/csr_mepc
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/csr_mie
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/csr_ie
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/csr_mcause
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/exception
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/cause
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/except_vec_masked
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/exception_pending
add wave -noupdate -expand -group Except /main/DUT/execute/exception_unit/csr_mip
TreeUpdate [SetDefaultTree]
WaveRestoreCursors {{Cursor 1} {
1252556
ps} 0}
WaveRestoreCursors {{Cursor 1} {
2308604
ps} 0}
configure wave -namecolwidth 250
configure wave -valuecolwidth 100
configure wave -justifyvalue left
...
...
@@ -60,4 +142,4 @@ configure wave -griddelta 40
configure wave -timeline 0
configure wave -timelineunits ps
update
WaveRestoreZoom {
21150368 ps} {21728928
ps}
WaveRestoreZoom {
0 ps} {7564032
ps}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment