Skip to content

Commit d655a0d

Browse files
committed
Lazily patch debugger, temporarily stub decode instruction, update controller
1 parent 9abfd08 commit d655a0d

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

src/cpu/controller.mlog.jinja

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ halt:
2525
reset:
2626
setrate 1000
2727

28-
# tell workers to reset
28+
# tell workers to halt
2929
set prev_proc @this
30-
set state "reset"
30+
set state "halt"
3131

3232
# load config
3333
read MEMORY_X {{CONFIG}} "MEMORY_X"
@@ -55,7 +55,7 @@ reset:
5555
# align to tick
5656
wait 1e-5
5757

58-
# set prev_proc and state again, just in case a worker changed them
58+
# change state from halt to reset, and set prev_proc again in case a worker changed it
5959
set prev_proc @this
6060
set state "reset"
6161

@@ -182,7 +182,6 @@ init_incr:
182182
# default values for writable CSRs
183183
write 0 {{CSRS}} "{{ 'mepc'|csr }}"
184184
write 0 {{CSRS}} "{{ 'mscratch'|csr }}"
185-
write 0 {{CSRS}} "{{ 'mcause'|csr }}"
186185
write 0 {{CSRS}} "{{ 'mtval'|csr }}"
187186

188187
# finally, tick-align again to be safe, finish any last-second initialization, then start the workers
@@ -235,9 +234,6 @@ end_pause:
235234
sensor enabled {{POWER_SWITCH}} @enabled
236235
jump halt equal enabled false
237236

238-
sensor enabled {{PAUSE_SWITCH}} @enabled
239-
jump pause_once equal enabled true
240-
241237
# update time
242238
# TODO: handle mtimeh/mcycleh overflow
243239

@@ -295,7 +291,6 @@ end_pause:
295291

296292
pause:
297293
control enabled {{SINGLE_STEP_SWITCH}} true
298-
pause_once:
299294
control enabled {{PAUSE_SWITCH}} true
300295

301296
pause__loop:

src/cpu/worker.mlog.jinja

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1965,6 +1965,15 @@ MLOGSYS:
19651965
jump end_instruction always
19661966

19671967
MLOGSYS__init_icache:
1968+
# FIXME: hack
1969+
setrate 500000
1970+
set state "decoding"
1971+
1972+
print "decoding @ {0} {1}"
1973+
format @thisx
1974+
format @thisy
1975+
printflush {{ERROR_OUTPUT}}
1976+
19681977
op min __etext __etext ICACHE_SIZE
19691978

19701979
# decode .text
@@ -1983,7 +1992,17 @@ MLOGSYS__init_icache__loop:
19831992
op add decode_address decode_address 4
19841993
jump MLOGSYS__init_icache__loop lessThan decode_address __etext
19851994

1986-
jump end_instruction always
1995+
# FIXME: hack 2
1996+
setrate 1000
1997+
wait 1e-5
1998+
1999+
read controller_state {{CONTROLLER}} "state"
2000+
jump state->halt equal controller_state "halt"
2001+
2002+
read prev_proc {{CONTROLLER}} "prev_proc"
2003+
write "running" prev_proc "state"
2004+
printflush {{ERROR_OUTPUT}}
2005+
jump next_tick always
19872006

19882007
MLOGDRAW:
19892008
# I-type: rs1, imm=funct12, rd_id

src/peripherals/debugger.mlog.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ loop:
193193
read mtval CSRS "{{ 'mtval'|csr }}"
194194

195195
read ipt CPU "IPT"
196-
read state CPU "STATE"
196+
read state CPU "state"
197197
read pc CPU "pc"
198198
read op_id CPU "op_id"
199199
read rs1 CPU "rs1_id"

0 commit comments

Comments
 (0)