ASIC: Switch to ghdl --synth

Use ghdl --synth to convert to verilog directly instead of going
through Yosys.

Signed-off-by: Anton Blanchard <anton@linux.ibm.com>
caravel-mpw7-20220822
Anton Blanchard 2 years ago committed by Anton Blanchard
parent 82c8f48f77
commit 68495c9b4b

@ -253,7 +253,7 @@ microwatt.v: $(synth_files) $(RAM_INIT_FILE)
$(YOSYS) $(GHDLSYNTH) -p "ghdl --std=08 --no-formal $(GHDL_IMAGE_GENERICS) $(synth_files) -e toplevel; write_verilog $@" $(YOSYS) $(GHDLSYNTH) -p "ghdl --std=08 --no-formal $(GHDL_IMAGE_GENERICS) $(synth_files) -e toplevel; write_verilog $@"


microwatt_asic.v: $(asic_synth_files) microwatt_asic.v: $(asic_synth_files)
$(YOSYS) $(GHDLSYNTH) -p "ghdl --std=08 --no-formal $(GHDL_IMAGE_GENERICS) $(asic_synth_files) -e toplevel; write_verilog $@" $(GHDL) --synth --std=08 --no-formal --out=verilog $(GHDL_IMAGE_GENERICS) $(asic_synth_files) -e toplevel > $@


microwatt-verilator: microwatt.v verilator/microwatt-verilator.cpp verilator/uart-verilator.c microwatt-verilator: microwatt.v verilator/microwatt-verilator.cpp verilator/uart-verilator.c
$(VERILATOR) $(VERILATOR_FLAGS) -CFLAGS "$(VERILATOR_CFLAGS) -DCLK_FREQUENCY=$(CLK_FREQUENCY)" -Iuart16550 --assert --cc --exe --build $^ -o $@ -top-module toplevel $(VERILATOR) $(VERILATOR_FLAGS) -CFLAGS "$(VERILATOR_CFLAGS) -DCLK_FREQUENCY=$(CLK_FREQUENCY)" -Iuart16550 --assert --cc --exe --build $^ -o $@ -top-module toplevel

@ -5,28 +5,16 @@ import re


module_regex = r'[a-zA-Z0-9_:\.\\]+' module_regex = r'[a-zA-Z0-9_:\.\\]+'


# match: module_re = re.compile(r'module\s+(' + module_regex + r')')
# module dcache(clk, rst, d_in, m_in, wishbone_in, d_out, m_out, stall_out, wishbone_out);
# A bit of a hack - ignore anything contining a '`', and assume that means we've already
# processed this module in a previous run. This helps when having to run this script
# multiple times for different power names.
multiline_module_re = re.compile(r'module\s+(' + module_regex + r')\(([^`]*?)\);', re.DOTALL)
module_re = re.compile(r'module\s+(' + module_regex + r')\((.*?)\);')


# match: # match:
# dcache_64_2_2_2_2_12_0 dcache_0 ( # dcache_64_2_2_2_2_12_0 dcache_0 (
hookup_re = re.compile(r'\s+(' + module_regex + r') ' + module_regex + r'\s+\(') hookup_re = re.compile(r'\s+(' + module_regex + r') ' + module_regex + r'\s+\(')


header1 = """\ header = """\
`ifdef USE_POWER_PINS
{power}, {ground},
`endif\
"""

header2 = """\
`ifdef USE_POWER_PINS `ifdef USE_POWER_PINS
inout {power}; inout {power},
inout {ground}; inout {ground},
`endif\ `endif\
""" """


@ -48,25 +36,23 @@ parser.add_argument('--module', required=True, action='append', help='Module to
args = parser.parse_args() args = parser.parse_args()


with open(args.verilog, 'r') as f: with open(args.verilog, 'r') as f:
d = f.read() strip_lpar = False
# Remove newlines from module definitions, yosys started doing this as of for line in f:
# commit ff8e999a7112 ("Split module ports, 20 per line") line = line.rstrip()
fixed = multiline_module_re.sub(lambda m: m.group(0).replace("\n", ""), d)


for line in fixed.splitlines():
m = module_re.match(line) m = module_re.match(line)
m2 = hookup_re.match(line) m2 = hookup_re.match(line)
if m and m.group(1) in args.module: if m and m.group(1) in args.module:
module_name = m.group(1) strip_lpar = True
module_args = m.group(2) print(line)
print('module %s(' % (module_name)) print('(')
print("") print(header.format(power=args.power, ground=args.ground))
print(header1.format(power=args.power, ground=args.ground))
print(' %s);' % module_args)
print(header2.format(power=args.power, ground=args.ground))
elif m2 and m2.group(1) in args.module: elif m2 and m2.group(1) in args.module:
print(line) print(line)
print(header3.format(parent_power=args.parent_power, parent_ground=args.parent_ground, power=args.power, ground=args.ground)) print(header3.format(parent_power=args.parent_power, parent_ground=args.parent_ground, power=args.power, ground=args.ground))
elif strip_lpar:
print(line.replace('(', ' '))
strip_lpar = False
else: else:
print(line) print(line)



@ -18,7 +18,7 @@ mv ${FILE_OUT}.tmp2 ${FILE_OUT}
rm ${FILE_OUT}.tmp1 rm ${FILE_OUT}.tmp1


# Add defines # Add defines
sed -i '1 a\ sed -i '1 i\
\ \
/* JTAG */\ /* JTAG */\
`include "tap_top.v"\ `include "tap_top.v"\

Loading…
Cancel
Save