File tree Expand file tree Collapse file tree 3 files changed +27
-39
lines changed
python/src/mlogv32/scripts Expand file tree Collapse file tree 3 files changed +27
-39
lines changed Original file line number Diff line number Diff line change @@ -331,10 +331,28 @@ def lookup(
331331 variable = variable_format .get_variable (variable_index )
332332
333333 print (
334- f" Address { hex (address )} is at processor { ram_index } ({ ram_x } , { ram_y } ) in variable { variable } ."
334+ f' Address { hex (address )} is at processor { ram_index } ({ ram_x } , { ram_y } ) in variable " { variable } ".'
335335 )
336336
337337
338+ @app .command ()
339+ def variables (
340+ indices : list [str ],
341+ ram_size : Annotated [int , Option (min = 1 , max = 726 * 6 )] = 4096 ,
342+ variable_format : Annotated [
343+ VariableFormat ,
344+ Option ("-f" , "--format" ),
345+ ] = VariableFormat .minimized ,
346+ ):
347+ for index_str in indices :
348+ index = int (index_str , base = 0 )
349+ if index >= ram_size :
350+ variable = "(out of range)"
351+ else :
352+ variable = variable_format .get_variable (index )
353+ print (f"{ index_str } -> { variable } " )
354+
355+
338356@app .command ()
339357def build (
340358 ram_size : Annotated [int , Option (min = 1 , max = 726 * 6 )] = 4096 ,
Original file line number Diff line number Diff line change @@ -78,36 +78,14 @@ reset__find_lookup_start:
7878
7979 set LOOKUP_START i
8080
81- # look up commonly used CSRs
82- set csr 0xc00
83- op add ret @counter 1
84- jump access_csr always
85- set CSR_CYCLE variable
86-
87- set csr 0xc01
88- op add ret @counter 1
89- jump access_csr always
90- set CSR_TIME variable
91-
92- set csr 0xc02
93- op add ret @counter 1
94- jump access_csr always
95- set CSR_INSTRET variable
96-
97- set csr 0xc80
98- op add ret @counter 1
99- jump access_csr always
100- set CSR_CYCLEH variable
101-
102- set csr 0xc81
103- op add ret @counter 1
104- jump access_csr always
105- set CSR_TIMEH variable
106-
107- set csr 0xc82
108- op add ret @counter 1
109- jump access_csr always
110- set CSR_INSTRETH variable
81+ # commonly used CSRs
82+ # NOTE: we need to manually update these if we change the RAM proc variables
83+ set CSR_CYCLE "WN" # 0xc00
84+ set CSR_TIME "WO" # 0xc01
85+ set CSR_INSTRET "WP" # 0xc02
86+ set CSR_CYCLEH "Y%" # 0xc80
87+ set CSR_TIMEH "Y&" # 0xc81
88+ set CSR_INSTRETH "Y(" # 0xc82
11189
11290 # read __etext from address 0, or default to ROM_SIZE if __etext is 0
11391 set address 0
@@ -121,8 +99,6 @@ reset__nonzero_etext:
12199
122100 # decode .text
123101 set STATE "decoding"
124- set decode_start_time @time
125- set decode_duration null # for debug output
126102 set decode_address 4
127103 set decode_var null
128104
@@ -138,7 +114,6 @@ reset__decode:
138114 op add decode_address decode_address 4
139115 jump reset__decode lessThan decode_address __etext
140116
141- op sub decode_duration @time decode_start_time
142117 set STATE "running"
143118
144119 # clear LR/SC reservation set
Original file line number Diff line number Diff line change @@ -155,8 +155,6 @@ loop:
155155 set instruction result
156156
157157 read __etext CPU "__etext"
158- read decode_time CPU "decode_duration"
159- op floor decode_time decode_time
160158 read reservation_set CPU "reservation_set"
161159
162160 print "ROM_START\n{0}"
@@ -384,9 +382,6 @@ loop:
384382 op add ret @counter 1
385383 jump format_hex always
386384
387- print "decode_time = {0} ms\n"
388- format decode_time
389-
390385 print "reservation_set = {0}\n\n"
391386 set n reservation_set
392387 op add ret @counter 1
You can’t perform that action at this time.
0 commit comments