9191
9292#% set labels.next_tick = 11
9393
94- #% set labels.end_instruction_with_rd_and_poll_interrupts = 143
94+ #% set labels.end_instruction_with_rd_and_poll_interrupts = 144
9595#% set labels.end_instruction_with_rd_and_fire_interrupts = _labels_vals|last + 1
9696#% set labels.end_instruction_with_rd = _labels_vals|last + 1
9797#% set labels.end_instruction = _labels_vals|last + 2
@@ -134,9 +134,7 @@ reset:
134134
135135#directive end_fetch
136136
137- jump reset__running equal state "decoding"
138137 jump reset notEqual state "running"
139- reset__running:
140138
141139 # tell the next worker to fetch the hart state from us
142140 write @this {{CONTROLLER}} "prev_proc"
@@ -287,9 +285,14 @@ main__read_icache:
287285 read rs2 {{REGISTERS}} rs2_id
288286
289287 # TODO: should breakpoints use virtual or physical addresses?
290- jump state->breakpoint strictEqual pc breakpoint_address
291- jump state->breakpoint equal single_step_enabled true
292- END_BREAKPOINT:
288+ jump main__breakpoint strictEqual pc breakpoint_address
289+ jump main__no_breakpoint notEqual single_step_enabled true
290+
291+ main__breakpoint:
292+ # the controller will increment @counter and set state to "running" when it's time to unpause
293+ set state "breakpoint"
294+ stop
295+ main__no_breakpoint:
293296
294297#% do reset_locals()
295298 # jump to instruction handler
@@ -355,11 +358,6 @@ state->reset:
355358 set state "reset"
356359 jump reset always
357360
358- # the controller will set @counter to END_BREAKPOINT and set state to "running" when it's time to unpause
359- state->breakpoint:
360- set state "breakpoint"
361- stop
362-
363361ILLEGAL_OP:
364362#% do reset_locals()
365363 set mcause 2
@@ -2098,13 +2096,13 @@ WFI:
20982096 # the simplest possible implementation of WFI would be a plain no-op
20992097 # however, it seems like another valid implementation is to just stall for a bounded amount of time
21002098 # since the wait is bounded, we don't need to check mstatus.TW
2101- # we check mip/mie first to avoid unnecessarily stalling if an interrupt is already pending and enabled
2102- op and $interrupts csr_mip csr_mie
2103- jump end_instruction notEqual $interrupts 0
2099+ # we check interrupt_flags first to avoid unnecessarily stalling if there may be an interrupt ready
2100+ jump end_instruction notEqual interrupt_flags 0b00
21042101
21052102 set state "pause"
21062103 wait 1e-5
2107- jump end_instruction_and_state->running always
2104+ set state "running"
2105+ jump end_instruction always
21082106
21092107PRIV:
21102108 # I-type: rs1, rs1_id=uimm, imm=funct12/csr, rd_id
@@ -2657,7 +2655,6 @@ MLOGSYS:
26572655 # init icache
26582656 # require M-mode so that we don't need to do address translation
26592657 jump ILLEGAL_OP lessThan privilege_mode 0b11
2660- set state "decoding"
26612658
26622659 op min __etext rs1 ROM_SIZE
26632660 op min __etext __etext ICACHE_SIZE
@@ -2679,8 +2676,6 @@ MLOGSYS__decode_loop:
26792676 jump MLOGSYS__decode_loop lessThan address __etext
26802677
26812678 # this is also used by PAUSE/WFI
2682- end_instruction_and_state->running:
2683- set state "running"
26842679 jump end_instruction always
26852680
26862681#% endblock contents
0 commit comments