self.submodules.trigger = trigger.Trigger(trig_w, [self.term])
self.submodules.recorder = recorder.Recorder(dat_w, rec_size)
- self.submodules.mila = mila.MiLa(MILA_ADDR, self.trigger, self.recorder)
+ self.submodules.mila = mila.MiLa(MILA_ADDR, self.trigger, self.recorder, trig_is_dat=True)
# Uart2Csr
self.submodules.uart2csr = uart2csr.Uart2Csr(clk_freq, 115200)
# Mila
#
self.comb +=[
- self.mila.trig[0].eq(self.freqgen.o),
- self.mila.trig[1].eq(self.eventgen_rising.o),
- self.mila.trig[2].eq(self.eventgen_falling.o),
- self.mila.trig[3:11].eq(self.cnt),
- self.mila.dat[0].eq(self.freqgen.o),
- self.mila.dat[1].eq(self.eventgen_rising.o),
- self.mila.dat[2].eq(self.eventgen_falling.o),
- self.mila.dat[3:11].eq(self.cnt),
+ self.mila.trig.eq(Cat(
+ self.freqgen.o,
+ self.eventgen_rising.o,
+ self.eventgen_falling.o,
+ self.cnt)
+ )
]
self.sync += self.cnt.eq(self.cnt+1)
from migen.bank import csrgen
from migen.bank.description import *
+from miscope.tools.misc import *
+
class MiIo:
#
# Definition
# Driver
#
def set(self, data):
- self.interface.write(self.bank.get_base(), data)
+ self.interface.write(get_csr_base(self.bank), data)
def get(self):
- return self.interface.read(self.bank.get_base() + self.words)
\ No newline at end of file
+ return self.interface.read(get_csr_base(self.bank) + self.words)
\ No newline at end of file
from migen.bank.description import *
from miscope import trigger, recorder
+from miscope.tools.misc import *
class MiLa:
- def __init__(self, address, trigger, recorder, interface=None):
+ def __init__(self, address, trigger, recorder, interface=None, trig_is_dat=False):
self.trigger = trigger
self.recorder = recorder
self.interface = interface
+ self.trig_is_dat = trig_is_dat
self.stb = Signal(reset=1)
self.trig = Signal(self.trigger.width)
self.recorder.stb.eq(self.stb),
self.trigger.trig.eq(self.trig),
- self.recorder.dat.eq(self.dat),
self.recorder.hit.eq(self.trigger.hit)
]
+ if self.trig_is_dat:
+ comb +=[
+ self.recorder.dat.eq(self.trig),
+ ]
+ else:
+ self.recorder.dat.eq(self.dat),
+
return Fragment(comb)
\ No newline at end of file
from migen.genlib.misc import optree
from migen.genlib.fsm import *
-from miscope.tools.misc import RisingEdge
+from miscope.tools.misc import *
class Storage:
#
# Driver
#
def reset(self):
- self.interface.write(self.bank.get_base() + REC_RST_BASE, 1)
- self.interface.write(self.bank.get_base() + REC_RST_BASE, 0)
+ self.interface.write(get_csr_base(self.bank) + REC_RST_BASE, 1)
+ self.interface.write(get_csr_base(self.bank) + REC_RST_BASE, 0)
def enable_rle(self):
- self.interface.write(self.bank.get_base() + REC_RLE_BASE, 1)
+ self.interface.write(get_csr_base(self.bank) + REC_RLE_BASE, 1)
def disable_rle(self):
- self.interface.write(self.bank.get_base() + REC_RLE_BASE, 0)
+ self.interface.write(get_csr_base(self.bank) + REC_RLE_BASE, 0)
def arm(self):
- self.interface.write(self.bank.get_base() + REC_ARM_BASE, 1)
- self.interface.write(self.bank.get_base() + REC_ARM_BASE, 0)
+ self.interface.write(get_csr_base(self.bank) + REC_ARM_BASE, 1)
+ self.interface.write(get_csr_base(self.bank) + REC_ARM_BASE, 0)
def is_done(self):
- return self.interface.read(self.bank.get_base() + REC_DONE_BASE) == 1
+ return self.interface.read(get_csr_base(self.bank) + REC_DONE_BASE) == 1
def set_size(self, dat):
- self.interface.write_n(self.bank.get_base() + REC_SIZE_BASE, dat, 16)
+ self.interface.write_n(get_csr_base(self.bank) + REC_SIZE_BASE, dat, 16)
def set_offset(self, dat):
- self.interface.write_n(self.bank.get_base() + REC_OFFSET_BASE, dat, 16)
+ self.interface.write_n(get_csr_base(self.bank) + REC_OFFSET_BASE, dat, 16)
def pull(self, size):
r = []
for i in range(size):
- self.interface.write(self.bank.get_base() + REC_READ_BASE, 1)
- self.interface.write(self.bank.get_base() + REC_READ_BASE, 0)
- r.append(self.interface.read_n(self.bank.get_base() + REC_READ_DATA_BASE, self.width))
+ self.interface.write(get_csr_base(self.bank) + REC_READ_BASE, 1)
+ self.interface.write(get_csr_base(self.bank) + REC_READ_BASE, 0)
+ r.append(self.interface.read_n(get_csr_base(self.bank) + REC_READ_DATA_BASE, self.width))
if i%128 == 0:
print(i)
return r
]
else:
self.comb += self.rst.eq(0)
- self._fragment += Fragment(sync={"sys_no_reset" : sync_no_reset})
\ No newline at end of file
+ self._fragment += Fragment(sync={"sys_no_reset" : sync_no_reset})
+
+def get_csr_base(bank, name=None):
+ base = 0
+ if name != None:
+ base = None
+ for i, c in enumerate(bank.simple_csrs):
+ if name in c.name:
+ if base == None:
+ base = i
+ elif base >= i:
+ base = i
+ return (bank.address<<9) + base
\ No newline at end of file
from migen.bank.description import *
from migen.genlib.misc import optree
+from miscope.tools.misc import *
class RegParams:
def __init__(self, name, base, width, nb):
self.address = address
self.bank = csrgen.Bank(self.regs, address=self.address)
for port in self.ports:
- port.reg_p.base = self.bank.get_base(port.reg_p.name)
- self.sum.reg_p.base = self.bank.get_base(self.sum.reg_p.name)
+ port.reg_p.base = get_csr_base(self.bank, port.reg_p.name)
+ self.sum.reg_p.base = get_csr_base(self.bank, self.sum.reg_p.name)
def set_interface(self, interface):
self.interface = interface