import unittest
+from soc.decoder.selectable_int import SelectableInt
def exts(value, bits):
def EXTS64(value):
- return exts(value, 32) & ((1 << 64)-1)
+ if isinstance(value, SelectableInt):
+ value = value.value
+ return SelectableInt(exts(value, 32) & ((1 << 64)-1), 64)
def EXTZ64(value):
- return value & ((1<<32)-1)
+ if isinstance(value, SelectableInt):
+ value = value.value
+ return SelectableInt(value & ((1<<32)-1), 64)
def rotl(value, bits, wordlen):
mask = (1 << wordlen) - 1
from nmigen import Module, Signal
from soc.decoder.pseudo.parser import GardenSnakeCompiler
+from soc.decoder.selectable_int import SelectableInt
####### Test code #######
cnttzd = """
n <- 0
do while n < 64
- if (RS)[63-n] = 0b1 then
+ if (RS)[63-n] = 0b1 then
leave
- n <- n + 1
+ n <- n + 1
RA <- EXTZ64(n)
print (RA)
"""
def get_reg_hex(reg):
- report = ''.join(map(str, reg))
- return hex(int('0b%s' % report, 2))
+ return hex(reg.value)
class GPR(dict):
self.sd = sd
self.regfile = regfile
for i in range(32):
- self[i] = [0] * 64 # TODO: needs to be IntClass(value=0, len=64)
+ self[i] = SelectableInt(0, 64)
def set_form(self, form):
self.form = form
reg = getform[wname]
print ("write regs", wname, d[wname], reg)
regidx = yield reg
- gsc.gpr[regidx] = tolist(d[wname])
+ gsc.gpr[regidx] = d[wname]
sim.add_process(process)
with sim.write_vcd("simulator.vcd", "simulator.gtkw",
def __getitem__(self, key):
if isinstance(key, int):
- assert key < self.bits
+ assert key < self.bits, "key %d accessing %d" % (key, self.bits)
assert key >= 0
key = self.bits - (key + 1)