litescope/example_designs/targets/core.py

62 lines
1.6 KiB
Python
Raw Normal View History

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
2017-04-19 04:46:17 -04:00
from litex.soc.cores.uart import UARTWishboneBridge
from litescope import LiteScopeAnalyzer
2015-09-12 12:19:30 -04:00
_io = [
("sys_clock", 0, Pins(1)),
("sys_reset", 1, Pins(1)),
2015-09-12 12:19:30 -04:00
("serial", 0,
Subsignal("tx", Pins(1)),
Subsignal("rx", Pins(1)),
2015-09-12 12:19:30 -04: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 = {
"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")
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")
self.submodules.analyzer = LiteScopeAnalyzer((self.bus), 512)
2015-09-12 12:19:30 -04:00
default_subtarget = Core