Skip to content

Commit 4f3269b

Browse files
committed
sc_fpga_lib: sc_fpga_riscv_csr_write/read should not be called when background poll is enabled
sc_fpga_riscv_csr_read and sc_fpga_riscv_csr_write should not be used in contexts where background poll is enabled, since the current implementation of poll can clobber data0/data1 registers.
1 parent ca0ee79 commit 4f3269b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tcl/syntacore/sc_fpga_lib.tcl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ namespace eval _SC_INTERNALS {
191191
}
192192
}
193193

194+
proc sc_lib_require_disabled_background_poll {} {
195+
set poll_output [poll]
196+
if {[string first "background polling: off" $poll_output] == -1} {
197+
return -code error "background polling must be disabled"
198+
}
199+
}
200+
194201
variable FPGA_LIB_BUSY_DURATION 3
195202

196203
proc sc_lib_riscv_csr_impl {csr_num value write xlen} {
@@ -366,6 +373,7 @@ proc sc_fpga_set_busy_duration {value} {
366373
}
367374

368375
proc sc_fpga_riscv_csr_read {csr_num {xlen 64}} {
376+
_SC_INTERNALS::sc_lib_require_disabled_background_poll
369377
_SC_INTERNALS::sc_lib_require_halted_and_check_csr $csr_num
370378

371379
_SC_INTERNALS::sc_lib_riscv_csr_impl $csr_num 0 0 $xlen
@@ -381,6 +389,7 @@ proc sc_fpga_riscv_csr_read {csr_num {xlen 64}} {
381389
}
382390

383391
proc sc_fpga_riscv_csr_write {csr_num value {xlen 64}} {
392+
_SC_INTERNALS::sc_lib_require_disabled_background_poll
384393
_SC_INTERNALS::sc_lib_require_halted_and_check_csr $csr_num
385394

386395
set DATA_0 0x04

0 commit comments

Comments
 (0)