From 5e48f9c005050ddf823527937798d635cf028267 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Fri, 22 Mar 2013 12:35:12 +0100 Subject: [PATCH] update driver api --- examples/de0_nano/client/test_miio.py | 12 +++++----- examples/de0_nano/client/test_mila.py | 10 ++++----- miscope/miio.py | 6 ++--- miscope/mila.py | 2 -- miscope/recorder.py | 9 ++++---- miscope/trigger.py | 32 +++++++++++++-------------- 6 files changed, 34 insertions(+), 37 deletions(-) diff --git a/examples/de0_nano/client/test_miio.py b/examples/de0_nano/client/test_miio.py index dea73da9..747e48d9 100644 --- a/examples/de0_nano/client/test_miio.py +++ b/examples/de0_nano/client/test_miio.py @@ -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()) diff --git a/examples/de0_nano/client/test_mila.py b/examples/de0_nano/client/test_mila.py index fcd6a755..2b904925 100644 --- a/examples/de0_nano/client/test_mila.py +++ b/examples/de0_nano/client/test_mila.py @@ -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 = [ diff --git a/miscope/miio.py b/miscope/miio.py index 07729103..d104928a 100644 --- a/miscope/miio.py +++ b/miscope/miio.py @@ -35,10 +35,10 @@ class MiIo: return Fragment(comb) + self.bank.get_fragment() # - #Driver + # 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) \ No newline at end of file diff --git a/miscope/mila.py b/miscope/mila.py index 177ee583..9596cbd1 100644 --- a/miscope/mila.py +++ b/miscope/mila.py @@ -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), diff --git a/miscope/recorder.py b/miscope/recorder.py index caa23674..af6c6cfc 100644 --- a/miscope/recorder.py +++ b/miscope/recorder.py @@ -129,7 +129,6 @@ class Sequencer: self.enable.eq(1) ) - # trig_hit rising_edge hit_rising = RisingEdge(self.hit) # connexion @@ -230,7 +229,7 @@ class Recorder: _pull_stb_rising.get_fragment() # - #Driver + # Driver # def reset(self): self.interface.write(self.bank.get_base() + REC_RST_BASE, 1) @@ -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) diff --git a/miscope/trigger.py b/miscope/trigger.py index 8beae529..33fe873e 100644 --- a/miscope/trigger.py +++ b/miscope/trigger.py @@ -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 + # 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 -- 2.30.2