litescope/example_designs/targets/simple.py

49 lines
1.7 KiB
Python
Raw Normal View History

2015-11-13 09:46:08 -05:00
from litex.gen.genlib.io import CRG
2015-09-07 05:49:54 -04:00
from litescope.common import *
from litescope.core.port import LiteScopeTerm
from litescope.frontend.inout import LiteScopeInOut
from litescope.frontend.logic_analyzer import LiteScopeLogicAnalyzer
2015-09-07 05:49:54 -04:00
2015-11-11 18:56:49 -05:00
from litex.soc.integration.soc_core import SoCCore
from litex.soc.cores.uart.bridge import UARTWishboneBridge
2015-09-07 05:49:54 -04:00
2015-11-11 18:56:49 -05:00
class LiteScopeSoC(SoCCore):
2015-09-07 05:49:54 -04:00
csr_map = {
"inout" : 16,
"logic_analyzer" : 17
2015-09-07 05:49:54 -04:00
}
2015-11-11 18:56:49 -05:00
csr_map.update(SoCCore.csr_map)
2015-09-07 05:49:54 -04:00
def __init__(self, platform):
clk_freq = int((1/(platform.default_clk_period))*1000000000)
2015-11-11 18:56:49 -05:00
SoCCore.__init__(self, platform, clk_freq,
cpu_type=None,
csr_data_width=32,
2015-09-07 05:49:54 -04:00
with_uart=False,
2015-11-11 18:56:49 -05:00
ident="Litescope example design",
2015-09-07 05:49:54 -04:00
with_timer=False
)
self.add_cpu_or_bridge(UARTWishboneBridge(platform.request("serial"), clk_freq, baudrate=115200))
self.add_wb_master(self.cpu_or_bridge.wishbone)
self.submodules.crg = CRG(platform.request(platform.default_clk_name))
self.submodules.inout = LiteScopeInOut(8)
2015-09-07 05:49:54 -04:00
for i in range(8):
try:
self.comb += platform.request("user_led", i).eq(self.inout.o[i])
2015-09-07 05:49:54 -04:00
except:
pass
2015-11-24 15:13:23 -05:00
counter = Signal(16)
self.sync += counter.eq(counter + 1)
self.debug = (counter)
self.submodules.logic_analyzer = LiteScopeLogicAnalyzer(self.debug, 512, with_rle=True, with_subsampler=True)
self.logic_analyzer.trigger.add_port(LiteScopeTerm(self.logic_analyzer.dw))
2015-09-07 05:49:54 -04:00
def do_exit(self, vns):
self.logic_analyzer.export(vns, "test/logic_analyzer.csv")
2015-09-07 05:49:54 -04:00
default_subtarget = LiteScopeSoC