Makefile: Added rule for generating mw-compatible core with SVP64
[soc.git] / src / soc / simple / issuer_verilog.py
1 """simple core issuer verilog generator
2 """
3
4 import argparse
5 from nmigen.cli import verilog
6
7 from openpower.consts import MSR
8 from soc.config.test.test_loadstore import TestMemPspec
9 from soc.simple.issuer import TestIssuer, TestIssuerInternal
10
11
12 if __name__ == '__main__':
13 parser = argparse.ArgumentParser(description="Simple core issuer " \
14 "verilog generator")
15 parser.add_argument("output_filename")
16 parser.add_argument("--enable-xics", dest='xics', action="store_true",
17 help="Enable interrupts",
18 default=True)
19 parser.add_argument("--disable-xics", dest='xics', action="store_false",
20 help="Disable interrupts",
21 default=False)
22 parser.add_argument("--enable-lessports", dest='lessports',
23 action="store_true",
24 help="Enable less regfile ports",
25 default=True)
26 parser.add_argument("--disable-lessports", dest='lessports',
27 action="store_false",
28 help="enable more regfile ports",
29 default=False)
30 parser.add_argument("--enable-core", dest='core', action="store_true",
31 help="Enable main core",
32 default=True)
33 parser.add_argument("--disable-core", dest='core', action="store_false",
34 help="disable main core",
35 default=False)
36 parser.add_argument("--enable-mmu", dest='mmu', action="store_true",
37 help="Enable mmu",
38 default=False)
39 parser.add_argument("--disable-mmu", dest='mmu', action="store_false",
40 help="Disable mmu",
41 default=False)
42 parser.add_argument("--enable-pll", dest='pll', action="store_true",
43 help="Enable pll",
44 default=False)
45 parser.add_argument("--disable-pll", dest='pll', action="store_false",
46 help="Disable pll",
47 default=False)
48 parser.add_argument("--enable-testgpio", action="store_true",
49 help="Disable gpio pins",
50 default=False)
51 parser.add_argument("--enable-sram4x4kblock", action="store_true",
52 help="Disable sram 4x4k block",
53 default=False)
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",
57 help="Enable SVP64",
58 default=True)
59 parser.add_argument("--disable-svp64", dest='svp64', action="store_false",
60 help="disable SVP64",
61 default=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
67 # in microwatt.v
68 parser.add_argument("--microwatt-compat", dest='mwcompat',
69 action="store_true",
70 help="generate microwatt-compatible interface",
71 default=False)
72 parser.add_argument("--microwatt-compat-svp64", dest='mwcompatsvp64',
73 action="store_true",
74 help="generate microwatt-compatible interface + SVP64",
75 default=False)
76 parser.add_argument("--old-microwatt-compat", dest='old_mwcompat',
77 action="store_true",
78 help="generate old microwatt-compatible interface",
79 default=True)
80 parser.add_argument("--microwatt-debug", dest='mwdebug',
81 action="store_true",
82 help="generate old microwatt-compatible interface",
83 default=False)
84 # create a module with Fabric compatibility
85 parser.add_argument("--fabric-compat", dest='fabriccompat',
86 action="store_true",
87 help="generate Fabric-compatible interface",
88 default=False)
89 # small cache option
90 parser.add_argument("--small-cache", dest='smallcache',
91 action="store_true",
92 help="generate small caches",
93 default=False)
94
95 # allow overlaps in TestIssuer
96 parser.add_argument("--allow-overlap", dest='allow_overlap',
97 action="store_true",
98 help="allow overlap in TestIssuer",
99 default=False)
100
101 args = parser.parse_args()
102
103 # convenience: set some defaults
104 if args.mwcompat:
105 args.pll = False
106 args.debug = 'dmi'
107 args.core = True
108 args.xics = False
109 args.gpio = False
110 args.sram4x4kblock = False
111 args.svp64 = False
112
113 # Yes, this is duplicating mwcompat, but for the sake of simplicity
114 # adding support for svp64 like this
115 if args.mwcompatsvp64:
116 args.pll = False
117 args.debug = 'dmi'
118 args.core = True
119 args.xics = False
120 args.gpio = False
121 args.sram4x4kblock = False
122 args.svp64 = True
123 args.mwcompat = True # Ensures TestMemPspec gets the expected value
124
125 print(args)
126
127 units = {'alu': 1,
128 'cr': 1, 'branch': 1, 'trap': 1,
129 'logical': 1,
130 'spr': 1,
131 'div': 1,
132 'mul': 1,
133 'shiftrot': 1
134 }
135 if args.mmu:
136 units['mmu'] = 1 # enable MMU
137
138 # decide which memory type to configure
139 if args.mmu:
140 ldst_ifacetype = 'mmu_cache_wb'
141 imem_ifacetype = 'mmu_cache_wb'
142 else:
143 ldst_ifacetype = 'bare_wb'
144 imem_ifacetype = 'bare_wb'
145
146 # default MSR
147 msr_reset = (1<<MSR.LE) | (1<<MSR.SF) # 64-bit, little-endian default
148
149 # default PC
150 if args.pc_reset.startswith("0x"):
151 pc_reset = int(args.pc_reset, 16)
152 else:
153 pc_reset = int(args.pc_reset)
154
155 pspec = TestMemPspec(ldst_ifacetype=ldst_ifacetype,
156 imem_ifacetype=imem_ifacetype,
157 addr_wid=64,
158 mask_wid=8,
159 # pipeline and integer register file width
160 XLEN=args.xlen,
161 # must leave at 64
162 reg_wid=64,
163 # set to 32 for instruction-memory width=32
164 imem_reg_wid=64,
165 # set to 32 to make data wishbone bus 32-bit
166 #wb_data_wid=32,
167 xics=args.xics, # XICS interrupt controller
168 nocore=not args.core, # test coriolis2 ioring
169 regreduce = args.lessports, # less regfile ports
170 use_pll=args.pll, # bypass PLL
171 gpio=args.enable_testgpio, # for test purposes
172 sram4x4kblock=args.enable_sram4x4kblock, # add SRAMs
173 debug=args.debug, # set to jtag or dmi
174 svp64=args.svp64, # enable SVP64
175 microwatt_mmu=args.mmu, # enable MMU
176 microwatt_compat=args.mwcompat, # microwatt compatible
177 microwatt_old=args.old_mwcompat, # old microwatt api
178 microwatt_debug=args.mwdebug, # microwatt debug signals
179 fabric_compat=args.fabriccompat, # fabric compatible (overlaps with microwatt compat)
180 small_cache=args.smallcache, # small cache/TLB sizes
181 allow_overlap=args.allow_overlap, # allow overlap
182 units=units,
183 msr_reset=msr_reset,
184 pc_reset=pc_reset)
185 #if args.mwcompat:
186 # pspec.core_domain = 'sync'
187
188 print("mmu", pspec.__dict__["microwatt_mmu"])
189 print("nocore", pspec.__dict__["nocore"])
190 print("regreduce", pspec.__dict__["regreduce"])
191 print("gpio", pspec.__dict__["gpio"])
192 print("sram4x4kblock", pspec.__dict__["sram4x4kblock"])
193 print("xics", pspec.__dict__["xics"])
194 print("use_pll", pspec.__dict__["use_pll"])
195 print("debug", pspec.__dict__["debug"])
196 print("SVP64", pspec.__dict__["svp64"])
197 print("XLEN", pspec.__dict__["XLEN"])
198 print("MSR@reset", hex(pspec.__dict__["msr_reset"]))
199 print("PC@reset", hex(pspec.__dict__["pc_reset"]))
200 print("Microwatt compatibility", pspec.__dict__["microwatt_compat"])
201 print("Old Microwatt compatibility", pspec.__dict__["microwatt_old"])
202 print("Microwatt debug", pspec.__dict__["microwatt_debug"])
203 print("Fabric compatibility", pspec.__dict__["fabric_compat"])
204 print("Small Cache/TLB", pspec.__dict__["small_cache"])
205
206 if args.mwcompat:
207 dut = TestIssuerInternal(pspec)
208 name = "external_core_top"
209 else:
210 dut = TestIssuer(pspec)
211 name = "test_issuer"
212
213 vl = verilog.convert(dut, ports=dut.external_ports(), name=name)
214 with open(args.output_filename, "w") as f:
215 f.write(vl)