Skip to content

Commit ca0ee79

Browse files
committed
sc_fpga_lib: improve error reporting of sc_lib_riscv_csr_impl
Minor corrections: - report the value for the timeout when .busy bit is not cleared for a long time - remove extra space from some error messages - fixed typo in the name of sc_lib_riscv_encode_abstract_command function
1 parent b5a9765 commit ca0ee79

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tcl/syntacore/sc_fpga_lib.tcl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ namespace eval _SC_INTERNALS {
175175
return -code error "invalid MXL value: $xlen"
176176
}
177177

178-
proc sc_lib_riscv_encode_abstarct_command {regno write transfer aarsize cmdtype} {
178+
proc sc_lib_riscv_encode_abstract_command {regno write transfer aarsize cmdtype} {
179179
set cmd [expr {($regno & 0xFFFF) |
180180
($write << 16) |
181181
($transfer << 17) |
@@ -196,24 +196,26 @@ namespace eval _SC_INTERNALS {
196196
proc sc_lib_riscv_csr_impl {csr_num value write xlen} {
197197
set aarsize [sc_lib_get_aarsize $xlen]
198198
set COMMAND_ADDR 0x17
199-
riscv dmi_write $COMMAND_ADDR [sc_lib_riscv_encode_abstarct_command $csr_num \
199+
riscv dmi_write $COMMAND_ADDR [sc_lib_riscv_encode_abstract_command $csr_num \
200200
$write 1 $aarsize 0]
201201

202202
set ABSTRACTCS_ADDR 0x16
203203
set abstractcs [riscv dmi_read $ABSTRACTCS_ADDR]
204204
set start_time [clock seconds]
205205

206+
set max_busy_duration [sc_fpga_get_busy_duration]
206207
while {$abstractcs & 0x1000 != 0} {
207-
if {([clock seconds] - $start_time) >= [sc_fpga_get_busy_duration]} {
208-
return -code error "Busy bit set after duration time"
208+
if {([clock seconds] - $start_time) >= $max_busy_duration} {
209+
return -code error "busy bit still set after\
210+
$max_busy_duration seconds (see busy_duration)"
209211
}
210212
set abstractcs [riscv dmi_read $ABSTRACTCS_ADDR]
211213
}
212214

213215
set cmderr [expr {($abstractcs & 0x700) >> 8}]
214216
if {$cmderr != 0} {
215217
riscv dmi_write $ABSTRACTCS_ADDR 0x700
216-
return -code error "problem with abstract command execution, \
218+
return -code error "problem with abstract command execution,\
217219
error code : $cmderr"
218220
}
219221
}

0 commit comments

Comments
 (0)