def build(self):
for key, value in self.regs.d.items():
if self.name in key:
- key.replace(self.name +"_")
+ key = key.replace(self.name +"_", "")
setattr(self, key, value)
def write(self, value):
def build(self):
for key, value in self.regs.d.items():
if self.name == key[:len(self.name)]:
- key.replace(self.name + "_")
+ key = key.replace(self.name + "_")
setattr(self, key, value)
value = 1
for name, length in self.layout:
from litescope.common import *
from litescope.bridge.uart2wb import LiteScopeUART2WB
+from litescope.frontend.io import LiteScopeIO
+
class _CRG(Module):
def __init__(self, clk_in):
class LiteScopeSoC(GenSoC, AutoCSR):
default_platform = "de0nano"
- csr_map = {}
+ csr_map = {
+ "io": 10
+ }
csr_map.update(GenSoC.csr_map)
def __init__(self, platform, export_mila=False):
GenSoC.__init__(self, platform, clk_freq)
self.submodules.crg = _CRG(platform.request("clk50"))
+ self.submodules.io = LiteScopeIO(8)
+ self.leds = Cat(*[platform.request("user_led", i) for i in range(8)])
+ self.comb += self.leds.eq(self.io.o)
+
default_subtarget = LiteScopeSoC
test_regs:
$(CMD) test_regs.py
+
+test_io:
+ $(CMD) test_io.py
--- /dev/null
+import time
+
+from config import *
+from litescope.host.driver import LiteScopeIODriver
+
+def led_anim0(io):
+ for i in range(10):
+ io.write(0xA5)
+ time.sleep(0.1)
+ io.write(0x5A)
+ time.sleep(0.1)
+
+def led_anim1(io):
+ for j in range(4):
+ #Led <<
+ led_data = 1
+ for i in range(8):
+ io.write(led_data)
+ time.sleep(i*i*0.0020)
+ led_data = (led_data<<1)
+ #Led >>
+ ledData = 128
+ for i in range(8):
+ io.write(led_data)
+ time.sleep(i*i*0.0020)
+ led_data = (led_data>>1)
+
+io = LiteScopeIODriver(wb.regs, "io")
+wb.open()
+###
+led_anim0(io)
+led_anim1(io)
+print("%02X" %io.read())
+###
+wb.close()