11#% macro fetch_variables()
2+ read _rom prev_proc "_rom"
23 read __etext prev_proc "__etext"
34 read _address prev_proc "_address"
4- read _rom prev_proc "_rom"
55 read address prev_proc "address"
66 read csr_mie prev_proc "csr_mie"
77 read csr_minstret prev_proc "csr_minstret"
8989#% set labels = namespace()
9090#% set _labels_vals = (labels|namespace_dict).values()
9191
92- #% set labels.next_tick = 12
92+ #% set labels.next_tick = 11
9393
94- #% set labels.end_instruction_with_rd_and_poll_interrupts = 144
94+ #% set labels.end_instruction_with_rd_and_poll_interrupts = 143
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
@@ -101,7 +101,7 @@ reset:
101101 setrate 1000
102102
103103 # define this variable FIRST so that we can read other variables over it
104- set _rom null
104+ # set _rom null
105105
106106 # load config
107107 read MEMORY_X {{CONFIG}} "MEMORY_X"
@@ -1564,6 +1564,11 @@ store_value:
15641564 # handle write-only MMIO
15651565 jump store_value__syscon equal address {{SYSCON}}
15661566
1567+ # fast path for 32-bit writes
1568+ set value rs2
1569+ op add ret2 @counter 13 # update this if anything below is changed
1570+ jump access_ram equal length 32
1571+
15671572 # create a bitmask with 0 in the section we want to replace and 1 everywhere else
15681573 op mod $shift address 4
15691574 op mul $shift $shift 8
@@ -1588,6 +1593,7 @@ store_value:
15881593 op add value result nonlocal2 # inserted value
15891594
15901595 # align address to word
1596+ # NOTE: we jump to this line from access_ram if length == 32
15911597 op and address address 0xfffffffc
15921598
15931599 # if it's in the MMIO range, handle it separately
@@ -2644,7 +2650,9 @@ modify_csr__minstreth:
26442650
26452651MLOGSYS:
26462652 # I-type: rs1, imm=funct12, rd_id
2647- jump ILLEGAL_OP greaterThan imm 0
2653+
2654+ # for now we can just ignore imm, since MLOGSYS is only used for decoding
2655+ # jump ILLEGAL_OP greaterThan imm 0
26482656
26492657 # init icache
26502658 # require M-mode so that we don't need to do address translation
0 commit comments