@@ -55,6 +55,7 @@ def assemble(text_program):
5555 pass
5656 elif line .startswith (".side_set" ):
5757 sideset_count = int (line .split ()[1 ])
58+ sideset_enable = 1 if "opt" in line else 0
5859 elif line .endswith (":" ):
5960 label = line [:- 1 ]
6061 if label in labels :
@@ -64,7 +65,7 @@ def assemble(text_program):
6465 # Only add as an instruction if the line isn't empty
6566 instructions .append (line )
6667
67- max_delay = 2 ** (5 - sideset_count ) - 1
68+ max_delay = 2 ** (5 - sideset_count - sideset_enable ) - 1
6869 assembled = []
6970 for instruction in instructions :
7071 # print(instruction)
@@ -76,10 +77,13 @@ def assemble(text_program):
7677 raise RuntimeError ("Delay too long:" , delay )
7778 instruction .pop ()
7879 if len (instruction ) > 1 and instruction [- 2 ] == "side" :
80+ if sideset_count == 0 :
81+ raise RuntimeError ("No side_set count set" )
7982 sideset_value = int (instruction [- 1 ])
8083 if sideset_value > 2 ** sideset_count :
8184 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
8387 instruction .pop ()
8488 instruction .pop ()
8589
@@ -186,6 +190,6 @@ def assemble(text_program):
186190 else :
187191 raise RuntimeError ("Unknown instruction:" + instruction [0 ])
188192 assembled [- 1 ] |= delay << 8
189- # print(hex (assembled[-1]))
193+ # print(bin (assembled[-1]))
190194
191195 return array .array ("H" , assembled )
0 commit comments