@@ -55,6 +55,7 @@ def assemble(text_program):
55
55
pass
56
56
elif line .startswith (".side_set" ):
57
57
sideset_count = int (line .split ()[1 ])
58
+ sideset_enable = 1 if "opt" in line else 0
58
59
elif line .endswith (":" ):
59
60
label = line [:- 1 ]
60
61
if label in labels :
@@ -64,7 +65,7 @@ def assemble(text_program):
64
65
# Only add as an instruction if the line isn't empty
65
66
instructions .append (line )
66
67
67
- max_delay = 2 ** (5 - sideset_count ) - 1
68
+ max_delay = 2 ** (5 - sideset_count - sideset_enable ) - 1
68
69
assembled = []
69
70
for instruction in instructions :
70
71
# print(instruction)
@@ -76,10 +77,13 @@ def assemble(text_program):
76
77
raise RuntimeError ("Delay too long:" , delay )
77
78
instruction .pop ()
78
79
if len (instruction ) > 1 and instruction [- 2 ] == "side" :
80
+ if sideset_count == 0 :
81
+ raise RuntimeError ("No side_set count set" )
79
82
sideset_value = int (instruction [- 1 ])
80
83
if sideset_value > 2 ** sideset_count :
81
84
raise RuntimeError ("Sideset value too large" )
82
- delay |= sideset_value << (5 - sideset_count )
85
+ delay |= sideset_value << (5 - sideset_count - sideset_enable )
86
+ delay |= sideset_enable << 4
83
87
instruction .pop ()
84
88
instruction .pop ()
85
89
@@ -186,6 +190,6 @@ def assemble(text_program):
186
190
else :
187
191
raise RuntimeError ("Unknown instruction:" + instruction [0 ])
188
192
assembled [- 1 ] |= delay << 8
189
- # print(hex (assembled[-1]))
193
+ # print(bin (assembled[-1]))
190
194
191
195
return array .array ("H" , assembled )
0 commit comments