1 """simple core issuer verilog generator
5 from nmigen
.cli
import verilog
7 from openpower
.consts
import MSR
8 from soc
.config
.test
.test_loadstore
import TestMemPspec
9 from soc
.simple
.issuer
import TestIssuer
, TestIssuerInternal
12 if __name__
== '__main__':
13 parser
= argparse
.ArgumentParser(description
="Simple core issuer " \
15 parser
.add_argument("output_filename")
16 parser
.add_argument("--enable-xics", dest
='xics', action
="store_true",
17 help="Enable interrupts",
19 parser
.add_argument("--disable-xics", dest
='xics', action
="store_false",
20 help="Disable interrupts",
22 parser
.add_argument("--enable-lessports", dest
='lessports',
24 help="Enable less regfile ports",
26 parser
.add_argument("--disable-lessports", dest
='lessports',
28 help="enable more regfile ports",
30 parser
.add_argument("--enable-core", dest
='core', action
="store_true",
31 help="Enable main core",
33 parser
.add_argument("--disable-core", dest
='core', action
="store_false",
34 help="disable main core",
36 parser
.add_argument("--enable-mmu", dest
='mmu', action
="store_true",
39 parser
.add_argument("--disable-mmu", dest
='mmu', action
="store_false",
42 parser
.add_argument("--enable-pll", dest
='pll', action
="store_true",
45 parser
.add_argument("--disable-pll", dest
='pll', action
="store_false",
48 parser
.add_argument("--enable-testgpio", action
="store_true",
49 help="Disable gpio pins",
51 parser
.add_argument("--enable-sram4x4kblock", action
="store_true",
52 help="Disable sram 4x4k block",
54 parser
.add_argument("--debug", default
="jtag", help="Select debug " \
55 "interface [jtag | dmi] [default jtag]")
56 parser
.add_argument("--enable-svp64", dest
='svp64', action
="store_true",
59 parser
.add_argument("--disable-svp64", dest
='svp64', action
="store_false",
62 parser
.add_argument("--pc-reset", default
="0",
63 help="Set PC at reset (default 0)")
64 parser
.add_argument("--xlen", default
=64, type=int,
65 help="Set register width [default 64]")
66 # create a module that's directly compatible as a drop-in replacement
68 parser
.add_argument("--microwatt-compat", dest
='mwcompat',
70 help="generate microwatt-compatible interface",
72 parser
.add_argument("--old-microwatt-compat", dest
='old_mwcompat',
74 help="generate old microwatt-compatible interface",
76 parser
.add_argument("--microwatt-debug", dest
='mwdebug',
78 help="generate old microwatt-compatible interface",
81 parser
.add_argument("--small-cache", dest
='smallcache',
83 help="generate small caches",
86 # allow overlaps in TestIssuer
87 parser
.add_argument("--allow-overlap", dest
='allow_overlap',
89 help="allow overlap in TestIssuer",
92 args
= parser
.parse_args()
94 # convenience: set some defaults
101 args
.sram4x4kblock
= False
107 'cr': 1, 'branch': 1, 'trap': 1,
115 units
['mmu'] = 1 # enable MMU
117 # decide which memory type to configure
119 ldst_ifacetype
= 'mmu_cache_wb'
120 imem_ifacetype
= 'mmu_cache_wb'
122 ldst_ifacetype
= 'bare_wb'
123 imem_ifacetype
= 'bare_wb'
126 msr_reset
= (1<<MSR
.LE
) |
(1<<MSR
.SF
) # 64-bit, little-endian default
129 if args
.pc_reset
.startswith("0x"):
130 pc_reset
= int(args
.pc_reset
, 16)
132 pc_reset
= int(args
.pc_reset
)
134 pspec
= TestMemPspec(ldst_ifacetype
=ldst_ifacetype
,
135 imem_ifacetype
=imem_ifacetype
,
138 # pipeline and integer register file width
142 # set to 32 for instruction-memory width=32
144 # set to 32 to make data wishbone bus 32-bit
146 xics
=args
.xics
, # XICS interrupt controller
147 nocore
=not args
.core
, # test coriolis2 ioring
148 regreduce
= args
.lessports
, # less regfile ports
149 use_pll
=args
.pll
, # bypass PLL
150 gpio
=args
.enable_testgpio
, # for test purposes
151 sram4x4kblock
=args
.enable_sram4x4kblock
, # add SRAMs
152 debug
=args
.debug
, # set to jtag or dmi
153 svp64
=args
.svp64
, # enable SVP64
154 microwatt_mmu
=args
.mmu
, # enable MMU
155 microwatt_compat
=args
.mwcompat
, # microwatt compatible
156 microwatt_old
=args
.old_mwcompat
, # old microwatt api
157 microwatt_debug
=args
.mwdebug
, # microwatt debug signals
158 small_cache
=args
.smallcache
, # small cache/TLB sizes
159 allow_overlap
=args
.allow_overlap
, # allow overlap
164 # pspec.core_domain = 'sync'
166 print("mmu", pspec
.__dict
__["microwatt_mmu"])
167 print("nocore", pspec
.__dict
__["nocore"])
168 print("regreduce", pspec
.__dict
__["regreduce"])
169 print("gpio", pspec
.__dict
__["gpio"])
170 print("sram4x4kblock", pspec
.__dict
__["sram4x4kblock"])
171 print("xics", pspec
.__dict
__["xics"])
172 print("use_pll", pspec
.__dict
__["use_pll"])
173 print("debug", pspec
.__dict
__["debug"])
174 print("SVP64", pspec
.__dict
__["svp64"])
175 print("XLEN", pspec
.__dict
__["XLEN"])
176 print("MSR@reset", hex(pspec
.__dict
__["msr_reset"]))
177 print("PC@reset", hex(pspec
.__dict
__["pc_reset"]))
178 print("Microwatt compatibility", pspec
.__dict
__["microwatt_compat"])
179 print("Old Microwatt compatibility", pspec
.__dict
__["microwatt_old"])
180 print("Microwatt debug", pspec
.__dict
__["microwatt_debug"])
181 print("Small Cache/TLB", pspec
.__dict
__["small_cache"])
184 dut
= TestIssuerInternal(pspec
)
185 name
= "external_core_top"
187 dut
= TestIssuer(pspec
)
190 vl
= verilog
.convert(dut
, ports
=dut
.external_ports(), name
=name
)
191 with
open(args
.output_filename
, "w") as f
: