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 = [
|
|
|
|
("sys_clk", 0, Pins("X")),
|
|
|
|
("sys_rst", 1, Pins("X")),
|
|
|
|
("serial", 0,
|
|
|
|
Subsignal("tx", Pins("X")),
|
|
|
|
Subsignal("rx", Pins("X")),
|
|
|
|
),
|
|
|
|
("bus", 0, Pins(" ".join(["X" for i in range(128)])))
|
|
|
|
]
|
|
|
|
|
|
|
|
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.clk_freq = clk_freq
|
|
|
|
self.clock_domains.cd_sys = ClockDomain("sys")
|
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
|
|
|
|
|
|
|
def get_ios(self):
|
|
|
|
ios = set()
|
|
|
|
ios = ios.union({self.cd_sys.clk,
|
|
|
|
self.cd_sys.rst})
|
|
|
|
ios = ios.union({self.platform.lookup_request("serial").rx,
|
|
|
|
self.platform.lookup_request("serial").tx})
|
|
|
|
ios = ios.union({self.bus})
|
|
|
|
return ios
|
|
|
|
|
|
|
|
default_subtarget = Core
|