example_designs: add core example
This commit is contained in:
parent
820b444061
commit
d4c4bb2c01
|
@ -68,26 +68,33 @@ if __name__ == "__main__":
|
||||||
else:
|
else:
|
||||||
top_class = target_module.default_subtarget
|
top_class = target_module.default_subtarget
|
||||||
|
|
||||||
if args.platform is None:
|
if hasattr(top_class, "platform"):
|
||||||
if hasattr(top_class, "default_platform"):
|
platform = top_class.platform
|
||||||
platform_name = top_class.default_platform
|
platform_name = top_class.platform.name
|
||||||
else:
|
|
||||||
raise ValueError("Target has no default platform, specify a platform with -p your_platform")
|
|
||||||
else:
|
else:
|
||||||
platform_name = args.platform
|
if args.platform is None:
|
||||||
platform_module = _import("mibuild.platforms", platform_name)
|
if hasattr(top_class, "default_platform"):
|
||||||
platform_kwargs = dict((k, autotype(v)) for k, v in args.platform_option)
|
platform_name = top_class.default_platform
|
||||||
platform = platform_module.Platform(**platform_kwargs)
|
else:
|
||||||
|
raise ValueError("Target has no default platform, specify a platform with -p your_platform")
|
||||||
|
else:
|
||||||
|
platform_name = args.platform
|
||||||
|
platform_module = _import("mibuild.platforms", platform_name)
|
||||||
|
platform_kwargs = dict((k, autotype(v)) for k, v in args.platform_option)
|
||||||
|
platform = platform_module.Platform(**platform_kwargs)
|
||||||
|
|
||||||
build_name = top_class.__name__.lower() + "-" + platform_name
|
build_name = top_class.__name__.lower() + "-" + platform_name
|
||||||
top_kwargs = dict((k, autotype(v)) for k, v in args.target_option)
|
top_kwargs = dict((k, autotype(v)) for k, v in args.target_option)
|
||||||
soc = top_class(platform, **top_kwargs)
|
soc = top_class(platform, **top_kwargs)
|
||||||
soc.finalize()
|
soc.finalize()
|
||||||
memory_regions = soc.get_memory_regions()
|
try:
|
||||||
csr_regions = soc.get_csr_regions()
|
memory_regions = soc.get_memory_regions()
|
||||||
|
csr_regions = soc.get_csr_regions()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# decode actions
|
# decode actions
|
||||||
action_list = ["clean", "build-csr-csv", "build-bitstream", "load-bitstream", "all"]
|
action_list = ["clean", "build-csr-csv", "build-core", "build-bitstream", "load-bitstream", "all"]
|
||||||
actions = {k: False for k in action_list}
|
actions = {k: False for k in action_list}
|
||||||
for action in args.action:
|
for action in args.action:
|
||||||
if action in actions:
|
if action in actions:
|
||||||
|
@ -108,11 +115,17 @@ if __name__ == "__main__":
|
||||||
A small footprint and configurable embedded FPGA
|
A small footprint and configurable embedded FPGA
|
||||||
logic analyzer core powered by Migen
|
logic analyzer core powered by Migen
|
||||||
|
|
||||||
====== Building parameters: ======
|
====== Building parameters: ======""")
|
||||||
|
if hasattr(soc, "io"):
|
||||||
|
print("""
|
||||||
LiscopeIO
|
LiscopeIO
|
||||||
---------
|
---------
|
||||||
Width: {}
|
Width: {}
|
||||||
|
""".format(soc.io.dw)
|
||||||
|
)
|
||||||
|
|
||||||
|
if hasattr(soc, "la"):
|
||||||
|
print("""
|
||||||
LiscopeLA
|
LiscopeLA
|
||||||
---------
|
---------
|
||||||
Width: {}
|
Width: {}
|
||||||
|
@ -120,7 +133,6 @@ Depth: {}
|
||||||
Subsampler: {}
|
Subsampler: {}
|
||||||
RLE: {}
|
RLE: {}
|
||||||
===============================""".format(
|
===============================""".format(
|
||||||
soc.io.dw,
|
|
||||||
soc.la.dw,
|
soc.la.dw,
|
||||||
soc.la.depth,
|
soc.la.depth,
|
||||||
str(soc.la.with_subsampler),
|
str(soc.la.with_subsampler),
|
||||||
|
@ -144,6 +156,19 @@ RLE: {}
|
||||||
csr_csv = cpuif.get_csr_csv(csr_regions)
|
csr_csv = cpuif.get_csr_csv(csr_regions)
|
||||||
write_to_file(args.csr_csv, csr_csv)
|
write_to_file(args.csr_csv, csr_csv)
|
||||||
|
|
||||||
|
if actions["build-core"]:
|
||||||
|
ios = soc.get_ios()
|
||||||
|
if not isinstance(soc, _Fragment):
|
||||||
|
soc = soc.get_fragment()
|
||||||
|
platform.finalize(soc)
|
||||||
|
so = {
|
||||||
|
NoRetiming: XilinxNoRetiming,
|
||||||
|
MultiReg: XilinxMultiReg,
|
||||||
|
AsyncResetSynchronizer: XilinxAsyncResetSynchronizer
|
||||||
|
}
|
||||||
|
v_output = verilog.convert(soc, ios, special_overrides=so)
|
||||||
|
v_output.write("build/litescope.v")
|
||||||
|
|
||||||
if actions["build-bitstream"]:
|
if actions["build-bitstream"]:
|
||||||
build_kwargs = dict((k, autotype(v)) for k, v in args.build_option)
|
build_kwargs = dict((k, autotype(v)) for k, v in args.build_option)
|
||||||
vns = platform.build(soc, build_name=build_name, **build_kwargs)
|
vns = platform.build(soc, build_name=build_name, **build_kwargs)
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
from migen.genlib.io import CRG
|
||||||
|
from migen.genlib.resetsync import AsyncResetSynchronizer
|
||||||
|
|
||||||
|
from mibuild.generic_platform import *
|
||||||
|
from mibuild.xilinx.platform import XilinxPlatform
|
||||||
|
|
||||||
|
from targets import *
|
||||||
|
|
||||||
|
from misoclib.soc import SoC
|
||||||
|
from litescope.common import *
|
||||||
|
from litescope.core.port import LiteScopeTerm
|
||||||
|
from litescope.frontend.io import LiteScopeIO
|
||||||
|
from litescope.frontend.la import LiteScopeLA
|
||||||
|
|
||||||
|
|
||||||
|
_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)])))
|
||||||
|
]
|
||||||
|
|
||||||
|
from misoclib.com.uart.bridge import UARTWishboneBridge
|
||||||
|
|
||||||
|
class CorePlatform(XilinxPlatform):
|
||||||
|
name = "core"
|
||||||
|
default_clk_name = "sys_clk"
|
||||||
|
def __init__(self):
|
||||||
|
XilinxPlatform.__init__(self, "", _io)
|
||||||
|
|
||||||
|
def do_finalize(self, *args, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Core(SoC):
|
||||||
|
platform = CorePlatform()
|
||||||
|
csr_map = {
|
||||||
|
"la": 16
|
||||||
|
}
|
||||||
|
csr_map.update(SoC.csr_map)
|
||||||
|
|
||||||
|
def __init__(self, platform, clk_freq=100*1000000):
|
||||||
|
self.clk_freq = clk_freq
|
||||||
|
self.clock_domains.cd_sys = ClockDomain("sys")
|
||||||
|
SoC.__init__(self, platform, clk_freq,
|
||||||
|
cpu_type="none",
|
||||||
|
with_csr=True, csr_data_width=32,
|
||||||
|
with_uart=False,
|
||||||
|
with_identifier=True,
|
||||||
|
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.la = LiteScopeLA((self.bus), 512, with_rle=True, with_subsampler=True)
|
||||||
|
self.la.trigger.add_port(LiteScopeTerm(self.la.dw))
|
||||||
|
|
||||||
|
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
|
|
@ -4,3 +4,4 @@ PYTHON = python3
|
||||||
example_designs:
|
example_designs:
|
||||||
cd ../example_designs && $(PYTHON) make.py -t simple -p de0nano -Ob run False build-bitstream
|
cd ../example_designs && $(PYTHON) make.py -t simple -p de0nano -Ob run False build-bitstream
|
||||||
cd ../example_designs && $(PYTHON) make.py -t simple -p kc705 -Ob run False build-bitstream
|
cd ../example_designs && $(PYTHON) make.py -t simple -p kc705 -Ob run False build-bitstream
|
||||||
|
cd ../example_designs && $(PYTHON) make.py -t core build-core
|
||||||
|
|
Loading…
Reference in New Issue