sim: fix slice assign

This commit is contained in:
Sebastien Bourdeauducq 2015-09-22 20:33:44 +08:00
parent 88f9d72e74
commit 8534562185

View file

@ -162,13 +162,13 @@ class Evaluator:
self.assign(element, value & (2**nbits-1)) self.assign(element, value & (2**nbits-1))
value >>= nbits value >>= nbits
elif isinstance(node, _Slice): elif isinstance(node, _Slice):
full_value = self.eval(node, True) full_value = self.eval(node.value, True)
# clear bits assigned to by the slice # clear bits assigned to by the slice
full_value &= ~((2**node.stop-1) - (2**node.start-1)) full_value &= ~((2**node.stop-1) - (2**node.start-1))
# set them to the new value # set them to the new value
value &= 2**(node.stop - node.start)-1 value &= 2**(node.stop - node.start)-1
full_value |= value << node.start full_value |= value << node.start
self.assign(node, full_value) self.assign(node.value, full_value)
elif isinstance(node, _ArrayProxy): elif isinstance(node, _ArrayProxy):
self.assign(node.choices[self.eval(node.key)], value) self.assign(node.choices[self.eval(node.key)], value)
elif isinstance(node, _MemoryLocation): elif isinstance(node, _MemoryLocation):