mirror of
https://github.com/enjoy-digital/litex.git
synced 2025-01-04 09:52:26 -05:00
update driver api
This commit is contained in:
parent
b1cbfe2326
commit
5e48f9c005
6 changed files with 34 additions and 37 deletions
|
@ -15,9 +15,9 @@ miio = miio.MiIo(MIIO_ADDR, 8, "IO", csr)
|
|||
|
||||
def led_anim0():
|
||||
for i in range(10):
|
||||
miio.write(0xA5)
|
||||
miio.set(0xA5)
|
||||
time.sleep(0.1)
|
||||
miio.write(0x5A)
|
||||
miio.set(0x5A)
|
||||
time.sleep(0.1)
|
||||
|
||||
def led_anim1():
|
||||
|
@ -25,13 +25,13 @@ def led_anim1():
|
|||
#Led <<
|
||||
ledData = 1
|
||||
for i in range(8):
|
||||
miio.write(ledData)
|
||||
miio.set(ledData)
|
||||
time.sleep(i*i*0.0020)
|
||||
ledData = (ledData<<1)
|
||||
#Led >>
|
||||
ledData = 128
|
||||
for i in range(8):
|
||||
miio.write(ledData)
|
||||
miio.set(ledData)
|
||||
time.sleep(i*i*0.0020)
|
||||
ledData = (ledData>>1)
|
||||
|
||||
|
@ -39,11 +39,11 @@ def led_anim1():
|
|||
# T E S T M I G I O
|
||||
#==============================================================================
|
||||
|
||||
print("- Small Led Animation...")
|
||||
print("- Led Animation...")
|
||||
led_anim0()
|
||||
time.sleep(1)
|
||||
led_anim1()
|
||||
time.sleep(1)
|
||||
|
||||
print("- Read Switch: ",end=' ')
|
||||
print("%02X" %miio.read())
|
||||
print("%02X" %miio.get())
|
||||
|
|
|
@ -35,10 +35,10 @@ def capture(size):
|
|||
global recorder
|
||||
global dat_vcd
|
||||
sum_tt = gen_truth_table("term")
|
||||
mila.trigger.sum.write(sum_tt)
|
||||
mila.trigger.sum.set(sum_tt)
|
||||
mila.recorder.reset()
|
||||
recorder.size(rec_size)
|
||||
mila.recorder.offset(rec_offset)
|
||||
recorder.set_size(rec_size)
|
||||
mila.recorder.set_offset(rec_offset)
|
||||
mila.recorder.arm()
|
||||
print("-Recorder [Armed]")
|
||||
print("-Waiting Trigger...", end=' ')
|
||||
|
@ -48,12 +48,12 @@ def capture(size):
|
|||
|
||||
print("-Receiving Data...", end=' ')
|
||||
sys.stdout.flush()
|
||||
dat_vcd += mila.recorder.read(size)
|
||||
dat_vcd += mila.recorder.pull(size)
|
||||
print("[Done]")
|
||||
|
||||
print("Capturing ...")
|
||||
print("----------------------")
|
||||
term.write(0x0000, 0xFFFF)
|
||||
term.set(0x0000, 0xFFFF)
|
||||
capture(rec_size)
|
||||
|
||||
mila_layout = [
|
||||
|
|
|
@ -37,8 +37,8 @@ class MiIo:
|
|||
#
|
||||
# Driver
|
||||
#
|
||||
def write(self, data):
|
||||
def set(self, data):
|
||||
self.interface.write(self.bank.get_base(), data)
|
||||
|
||||
def read(self):
|
||||
def get(self):
|
||||
return self.interface.read(self.bank.get_base() + self.words)
|
|
@ -28,8 +28,6 @@ class MiLa:
|
|||
self.trigger.set_interface(interface)
|
||||
self.recorder.set_interface(interface)
|
||||
|
||||
|
||||
|
||||
def get_fragment(self):
|
||||
comb =[
|
||||
self.trigger.trig.eq(self.trig),
|
||||
|
|
|
@ -129,7 +129,6 @@ class Sequencer:
|
|||
self.enable.eq(1)
|
||||
)
|
||||
|
||||
# trig_hit rising_edge
|
||||
hit_rising = RisingEdge(self.hit)
|
||||
|
||||
# connexion
|
||||
|
@ -243,13 +242,13 @@ class Recorder:
|
|||
def is_done(self):
|
||||
return self.interface.read(self.bank.get_base() + REC_DONE_BASE) == 1
|
||||
|
||||
def size(self, dat):
|
||||
def set_size(self, dat):
|
||||
self.interface.write_n(self.bank.get_base() + REC_SIZE_BASE, dat, 16)
|
||||
|
||||
def offset(self, dat):
|
||||
def set_offset(self, dat):
|
||||
self.interface.write_n(self.bank.get_base() + REC_OFFSET_BASE, dat, 16)
|
||||
|
||||
def read(self, size):
|
||||
def pull(self, size):
|
||||
r = []
|
||||
for i in range(size):
|
||||
self.interface.write(self.bank.get_base() + REC_READ_BASE, 1)
|
||||
|
|
|
@ -39,20 +39,20 @@ class Term:
|
|||
self.reg_p = RegParams("term_reg", 0, width, 2)
|
||||
self.reg = None
|
||||
|
||||
def get_registers_glue(self):
|
||||
def get_registers_comb(self):
|
||||
comb = [self.t.eq(self.reg.field.r[0*self.width:1*self.width])]
|
||||
comb += [self.m.eq(self.reg.field.r[1*self.width:2*self.width])]
|
||||
return comb
|
||||
|
||||
def get_fragment(self):
|
||||
comb = [self.o.eq((self.m & self.i) == self.t)]
|
||||
comb += self.get_registers_glue()
|
||||
comb += self.get_registers_comb()
|
||||
return Fragment(comb)
|
||||
|
||||
#
|
||||
# Driver
|
||||
#
|
||||
def write(self, dat, mask=None):
|
||||
def set(self, dat, mask=None):
|
||||
if mask is None:
|
||||
mask = (2**self.width)-1
|
||||
self.interface.write_n(self.reg_p.base, mask, self.width)
|
||||
|
@ -75,22 +75,22 @@ class RangeDetector:
|
|||
self.high = Signal(width)
|
||||
self.o = Signal()
|
||||
|
||||
def get_registers_glue(self):
|
||||
def get_registers_comb(self):
|
||||
comb = [self.low.eq(self.reg.field.r[0*self.width:1*self.width])]
|
||||
comb += [self.low.eq(self.reg.field.r[1*self.width:2*self.width])]
|
||||
return comb
|
||||
|
||||
def get_fragment(self):
|
||||
comb = [self.o.eq((self.i >= self.low) & (self.i <= self.high))]
|
||||
comb += self.get_registers_glue()
|
||||
comb += self.get_registers_comb()
|
||||
return Fragment(comb)
|
||||
#
|
||||
# Driver
|
||||
#
|
||||
def write_low(self, dat):
|
||||
def set_low(self, dat):
|
||||
self.interface.write_n(self.reg_p.base, dat ,self.width)
|
||||
|
||||
def write_high(self, dat):
|
||||
def set_high(self, dat):
|
||||
self.interface.write_n(self.reg_p.base + self.reg_p.words, dat ,self.width)
|
||||
|
||||
class EdgeDetector:
|
||||
|
@ -118,7 +118,7 @@ class EdgeDetector:
|
|||
self.bo = Signal()
|
||||
self.o = Signal()
|
||||
|
||||
def get_registers_glue(self):
|
||||
def get_registers_comb(self):
|
||||
comb = []
|
||||
i = 0
|
||||
if "R" in self.mode:
|
||||
|
@ -158,7 +158,7 @@ class EdgeDetector:
|
|||
comb += [self.o.eq(self.ro | self.fo | self.bo)]
|
||||
|
||||
# Registers
|
||||
comb += self.get_registers_glue()
|
||||
comb += self.get_registers_comb()
|
||||
|
||||
return Fragment(comb, sync)
|
||||
|
||||
|
@ -180,13 +180,13 @@ class EdgeDetector:
|
|||
return r
|
||||
return 0
|
||||
|
||||
def write_r(self, dat):
|
||||
def set_r(self, dat):
|
||||
self.interface.write_n(self.reg_p.base + self.get_offset("R"), dat ,self.width)
|
||||
|
||||
def write_f(self, dat):
|
||||
def set_f(self, dat):
|
||||
self.interface.write_n(self.reg_p.base + self.get_offset("F"), dat ,self.width)
|
||||
|
||||
def write_b(self, dat):
|
||||
def set_b(self, dat):
|
||||
self.interface.write_n(self.reg_p.base + self.get_offset("B"), dat ,self.width)
|
||||
|
||||
class Sum:
|
||||
|
@ -212,7 +212,7 @@ class Sum:
|
|||
self._lut_port = self._mem.get_port()
|
||||
self._prog_port = self._mem.get_port(write_capable=True)
|
||||
|
||||
def get_registers_glue(self):
|
||||
def get_registers_comb(self):
|
||||
comb = [
|
||||
self.prog_adr.eq(self.reg.field.r[0:16]),
|
||||
self.prog_dat.eq(self.reg.field.r[16]),
|
||||
|
@ -231,13 +231,13 @@ class Sum:
|
|||
|
||||
self.o.eq(self._o)
|
||||
]
|
||||
comb += self.get_registers_glue()
|
||||
comb += self.get_registers_comb()
|
||||
return Fragment(comb, specials={self._mem})
|
||||
|
||||
#
|
||||
# Driver
|
||||
#
|
||||
def write(self, truth_table):
|
||||
def set(self, truth_table):
|
||||
for i in range(len(truth_table)):
|
||||
val = truth_table[i]
|
||||
we = 1<<17
|
||||
|
|
Loading…
Reference in a new issue