# when sel==0, route it to shared rx and bridge rx
# when sel==1, route it only to bridge rx
self.comb += \
- If(self.sel==0,
+ If(self.sel == 0,
self.shared_pads.rx.eq(pads.rx),
self.bridge_pads.rx.eq(pads.rx)
).Else(
# when sel==0, route shared tx to pads tx
# when sel==1, route bridge tx to pads tx
self.comb += \
- If(self.sel==0,
+ If(self.sel == 0,
pads.tx.eq(self.shared_pads.tx)
).Else(
pads.tx.eq(self.bridge_pads.tx)
###
led_anim0(io)
led_anim1(io)
- print("%02X" %io.read())
+ print("{:02X}".format(io.read()))
###
wb.close()
datas = packet.records.pop().writes.get_datas()
if self.debug:
for i, data in enumerate(datas):
- print("RD %08X @ %08X" %(data, addr + 4*(i%to_int(burst_length))))
+ print("RD {:08X} @ {:08X}".format(data, addr + 4*(i%to_int(burst_length))))
return datas
def write(self, addr, datas):
if self.debug:
for i, data in enumerate(datas):
- print("WR %08X @ %08X" %(data, addr + 4*i))
+ print("WR {:08X} @ {:08X}".format(data, addr + 4*i))
def build(self):
for key, value in self.regs.d.items():
if self.name in key:
- key = key.replace(self.name +"_", "")
+ key = key.replace(self.name + "_", "")
setattr(self, key, value)
def write(self, value):
truth_table = []
for i in range(2**width):
for j in range(width):
- exec("%s = stim[j][i]" %operands[j])
+ exec("{} = stim[j][i]".format(operands[j]))
truth_table.append(eval(s) != 0)
return truth_table
data = data << 8
data |= ord(self.uart.read())
if self.debug:
- print("RD %08X @ %08X" %(data, (addr+j)*4))
+ print("RD {:08X} @ {:08X}".format(data, (addr+j)*4))
datas.append(data)
return datas
write_b(self.uart, (dat & 0xff000000) >> 24)
dat = dat << 8
if self.debug:
- print("WR %08X @ %08X" %(data[i], (addr + i)*4))
+ print("WR {:08X} @ {:08X}".format(data[i], (addr + i)*4))
else:
dat = data
for j in range(4):
write_b(self.uart, (dat & 0xff000000) >> 24)
dat = dat << 8
if self.debug:
- print("WR %08X @ %08X" %(data, (addr * 4)))
+ print("WR {:08X} @ {:08X}".format(data, (addr * 4)))
def dec2bin(d, nb=0):
- if d=="x":
+ if d == "x":
return "x"*nb
- elif d==0:
- b="0"
+ elif d == 0:
+ b = "0"
else:
- b=""
- while d!=0:
- b="01"[d&1]+b
- d=d>>1
+ b = ""
+ while d != 0:
+ b = "01"[d&1] + b
+ d = d >> 1
return b.zfill(nb)
self.vars.append(var)
def add_from_layout(self, layout, var):
- i=0
+ i = 0
for s, n in layout:
self.add(Var(s, n, var[i:i+n]))
i += n
else:
r += dec2bin(var.val, var.width)
r += ", "
- r+= "\n"
+ r += "\n"
return r
def write(self, filename):
for j, var in enumerate(reversed(self.vars)):
data = data << 1
try:
- data |= var.values[i] %2
+ data |= var.values[i] % 2
except:
pass
datas.append(data)
r += dec2bin(var.val, var.width)
r += " "
r += var.vcd_id
- r+= "\n"
+ r += "\n"
r += "$end\n"
return r