2015-11-13 09:46:08 -05:00
|
|
|
from litex.gen import *
|
|
|
|
from litex.gen.genlib.io import CRG
|
2015-09-12 12:19:30 -04:00
|
|
|
|
|
|
|
from targets import *
|
|
|
|
|
2015-11-11 18:56:49 -05:00
|
|
|
from litex.build.generic_platform import *
|
|
|
|
from litex.build.xilinx.platform import XilinxPlatform
|
|
|
|
|
|
|
|
from litex.soc.integration.soc_core import SoCCore
|
|
|
|
from litex.soc.cores.uart.bridge import UARTWishboneBridge
|
2015-09-27 12:47:30 -04:00
|
|
|
|
2015-09-12 12:19:30 -04:00
|
|
|
from litescope.core.port import LiteScopeTerm
|
2015-09-27 12:47:30 -04:00
|
|
|
from litescope.frontend.inout import LiteScopeInOut
|
|
|
|
from litescope.frontend.logic_analyzer import LiteScopeLogicAnalyzer
|
2015-09-12 12:19:30 -04:00
|
|
|
|
|
|
|
|
|
|
|
_io = [
|
2015-12-27 09:42:37 -05:00
|
|
|
("sys_clock", 0, Pins(1)),
|
|
|
|
("sys_reset", 1, Pins(1)),
|
2015-09-12 12:19:30 -04:00
|
|
|
("serial", 0,
|
2015-11-19 09:00:18 -05:00
|
|
|
Subsignal("tx", Pins(1)),
|
|
|
|
Subsignal("rx", Pins(1)),
|
2015-09-12 12:19:30 -04:00
|
|
|
),
|
2015-11-19 09:00:18 -05:00
|
|
|
("bus", 0, Pins(128))
|
2015-09-12 12:19:30 -04:00
|
|
|
]
|
|
|
|
|
|
|
|
class CorePlatform(XilinxPlatform):
|
|
|
|
name = "core"
|
|
|
|
default_clk_name = "sys_clk"
|
|
|
|
def __init__(self):
|
|
|
|
XilinxPlatform.__init__(self, "", _io)
|
|
|
|
|
|
|
|
def do_finalize(self, *args, **kwargs):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2015-11-11 18:56:49 -05:00
|
|
|
class Core(SoCCore):
|
2015-09-12 12:19:30 -04:00
|
|
|
platform = CorePlatform()
|
|
|
|
csr_map = {
|
2015-09-27 12:47:30 -04:00
|
|
|
"logic_analyzer": 16
|
2015-09-12 12:19:30 -04:00
|
|
|
}
|
2015-11-11 18:56:49 -05:00
|
|
|
csr_map.update(SoCCore.csr_map)
|
2015-09-12 12:19:30 -04:00
|
|
|
|
|
|
|
def __init__(self, platform, clk_freq=100*1000000):
|
|
|
|
self.clock_domains.cd_sys = ClockDomain("sys")
|
2015-12-27 09:42:37 -05:00
|
|
|
self.comb += [
|
|
|
|
self.cd_sys.clk.eq(platform.request("sys_clock")),
|
|
|
|
self.cd_sys.rst.eq(platform.request("sys_reset"))
|
|
|
|
]
|
2015-11-11 18:56:49 -05:00
|
|
|
SoCCore.__init__(self, platform, clk_freq,
|
|
|
|
cpu_type=None,
|
|
|
|
csr_data_width=32,
|
2015-09-12 12:19:30 -04:00
|
|
|
with_uart=False,
|
2015-11-11 18:56:49 -05:00
|
|
|
ident="Litescope example design",
|
2015-09-12 12:19:30 -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.bus = platform.request("bus")
|
2015-09-27 12:47:30 -04:00
|
|
|
self.submodules.logic_analyzer = LiteScopeLogicAnalyzer((self.bus), 512, with_rle=True, with_subsampler=True)
|
|
|
|
self.logic_analyzer.trigger.add_port(LiteScopeTerm(self.logic_analyzer.dw))
|
2015-09-12 12:19:30 -04:00
|
|
|
|
|
|
|
default_subtarget = Core
|