2018-02-23 07:43:47 -05:00
|
|
|
from migen import *
|
|
|
|
from migen.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
|
2015-09-27 12:47:30 -04:00
|
|
|
|
2016-03-31 05:37:00 -04:00
|
|
|
from litescope import LiteScopeAnalyzer
|
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 = {
|
2016-03-31 05:37:00 -04:00
|
|
|
"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")
|
2016-03-31 05:37:00 -04:00
|
|
|
self.submodules.analyzer = LiteScopeAnalyzer((self.bus), 512)
|
2015-09-12 12:19:30 -04:00
|
|
|
|
|
|
|
default_subtarget = Core
|