def generate_xbars(top, out_path): topname = top["name"] gencmd = ("// util/topgen.py -t hw/top_{topname}/data/top_{topname}.hjson " "-o hw/top_{topname}/\n\n".format(topname=topname)) for obj in top["xbar"]: xbar_path = out_path / 'ip/xbar_{}/data/autogen'.format(obj["name"]) xbar_path.mkdir(parents=True, exist_ok=True) xbar = tlgen.validate(obj) xbar.ip_path = 'hw/top_' + top["name"] + '/ip/{dut}' # Generate output of crossbar with complete fields xbar_hjson_path = xbar_path / "xbar_{}.gen.hjson".format(xbar.name) xbar_hjson_path.write_text(genhdr + gencmd + hjson.dumps(obj, for_json=True)) if not tlgen.elaborate(xbar): log.error("Elaboration failed." + repr(xbar)) try: results = tlgen.generate(xbar, "top_" + top["name"]) except: # noqa: E722 log.error(exceptions.text_error_template().render()) ip_path = out_path / 'ip/xbar_{}'.format(obj["name"]) for filename, filecontent in results: filepath = ip_path / filename filepath.parent.mkdir(parents=True, exist_ok=True) with filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(filecontent) dv_path = out_path / 'ip/xbar_{}/dv/autogen'.format(obj["name"]) dv_path.mkdir(parents=True, exist_ok=True) # generate testbench for xbar tlgen.generate_tb(xbar, dv_path, "top_" + top["name"]) # Read back the comportable IP and amend to Xbar xbar_ipfile = ip_path / ("data/autogen/xbar_%s.hjson" % obj["name"]) with xbar_ipfile.open() as fxbar: xbar_ipobj = hjson.load(fxbar, use_decimal=True, object_pairs_hook=OrderedDict) r_inter_signal_list = check_list( xbar_ipobj.get('inter_signal_list', []), 'inter_signal_list field') obj['inter_signal_list'] = [ InterSignal.from_raw( 'entry {} of the inter_signal_list field'.format(idx + 1), entry) for idx, entry in enumerate(r_inter_signal_list) ]
def generate_xbars(top, out_path): topname = top["name"] gencmd = ("// util/topgen.py -t hw/top_{topname}/data/top_{topname}.hjson " "-o hw/top_{topname}/\n\n".format(topname=topname)) for obj in top["xbar"]: xbar_path = out_path / 'ip/xbar_{}/data/autogen'.format(obj["name"]) xbar_path.mkdir(parents=True, exist_ok=True) xbar = tlgen.validate(obj) xbar.ip_path = 'hw/top_' + top["name"] + '/ip/{dut}' # Generate output of crossbar with complete fields xbar_hjson_path = xbar_path / "xbar_{}.gen.hjson".format(xbar.name) xbar_hjson_path.write_text(genhdr + gencmd + hjson.dumps(obj, for_json=True)) if not tlgen.elaborate(xbar): log.error("Elaboration failed." + repr(xbar)) try: results = tlgen.generate(xbar, "top_" + top["name"]) except: # noqa: E722 log.error(exceptions.text_error_template().render()) ip_path = out_path / 'ip/xbar_{}'.format(obj["name"]) for filename, filecontent in results: filepath = ip_path / filename filepath.parent.mkdir(parents=True, exist_ok=True) with filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(filecontent) dv_path = out_path / 'ip/xbar_{}/dv/autogen'.format(obj["name"]) dv_path.mkdir(parents=True, exist_ok=True) # generate testbench for xbar tlgen.generate_tb(xbar, dv_path, "top_" + top["name"]) # Read back the comportable IP and amend to Xbar xbar_ipfile = ip_path / ("data/autogen/xbar_%s.hjson" % obj["name"]) with xbar_ipfile.open() as fxbar: xbar_ipobj = hjson.load(fxbar, use_decimal=True, object_pairs_hook=OrderedDict) # Deepcopy of the inter_signal_list. # As of writing the code, it is not expected to write-back the # read xbar objects into files. Still, as `inter_signal_list` is # modified in the `elab_intermodule()` stage, it is better to keep # the original content. obj["inter_signal_list"] = deepcopy( xbar_ipobj["inter_signal_list"])
def generate_xbars(top, out_path): topname = top["name"] gencmd = ("// util/topgen.py -t hw/top_{topname}/data/top_{topname}.hjson " "-o hw/top_{topname}/\n\n".format(topname=topname)) for obj in top["xbar"]: xbar_path = out_path / 'ip/xbar_{}/data/autogen'.format(obj["name"]) xbar_path.mkdir(parents=True, exist_ok=True) xbar = tlgen.validate(obj) xbar.ip_path = 'hw/top_' + top["name"] + '/ip/{dut}' # Generate output of crossbar with complete fields xbar_hjson_path = xbar_path / "xbar_{}.gen.hjson".format(xbar.name) xbar_hjson_path.write_text(genhdr + gencmd + hjson.dumps(obj, for_json=True)) if not tlgen.elaborate(xbar): log.error("Elaboration failed." + repr(xbar)) try: out_rtl, out_pkg, out_core = tlgen.generate( xbar, "top_" + top["name"]) except: # noqa: E722 log.error(exceptions.text_error_template().render()) rtl_path = out_path / 'ip/xbar_{}/rtl/autogen'.format(obj["name"]) rtl_path.mkdir(parents=True, exist_ok=True) dv_path = out_path / 'ip/xbar_{}/dv/autogen'.format(obj["name"]) dv_path.mkdir(parents=True, exist_ok=True) rtl_filename = "xbar_%s.sv" % (xbar.name) rtl_filepath = rtl_path / rtl_filename with rtl_filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(out_rtl) pkg_filename = "tl_%s_pkg.sv" % (xbar.name) pkg_filepath = rtl_path / pkg_filename with pkg_filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(out_pkg) core_filename = "xbar_%s.core" % (xbar.name) core_filepath = rtl_path / core_filename with core_filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(out_core) # generate testbench for xbar tlgen.generate_tb(xbar, dv_path, "top_" + top["name"])
def generate_xbars(top, out_path): xbar_path = out_path / 'ip/xbar/data/autogen' xbar_path.mkdir(parents=True, exist_ok=True) gencmd = ("// util/topgen.py -t hw/top_earlgrey/data/top_earlgrey.hjson " "-o hw/top_earlgrey/\n\n") for obj in top["xbar"]: xbar = tlgen.validate(obj) # Generate output of crossbar with complete fields xbar_hjson_path = xbar_path / "xbar_{}.gen.hjson".format(xbar.name) xbar_hjson_path.write_text(genhdr + gencmd + hjson.dumps(obj, for_json=True)) if not tlgen.elaborate(xbar): log.error("Elaboration failed." + repr(xbar)) # Add clocks/resets to the top configuration obj["clocks"] = xbar.clocks try: out_rtl, out_pkg, out_bind = tlgen.generate(xbar) except: log.error(exceptions.text_error_template().render()) rtl_path = out_path / 'ip/xbar/rtl/autogen' rtl_path.mkdir(parents=True, exist_ok=True) dv_path = out_path / 'ip/xbar/dv/autogen' dv_path.mkdir(parents=True, exist_ok=True) rtl_filename = "xbar_%s.sv" % (xbar.name) rtl_filepath = rtl_path / rtl_filename with rtl_filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(out_rtl) pkg_filename = "tl_%s_pkg.sv" % (xbar.name) pkg_filepath = rtl_path / pkg_filename with pkg_filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(out_pkg) bind_filename = "xbar_%s_bind.sv" % (xbar.name) bind_filepath = dv_path / bind_filename with bind_filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(out_bind)
def main(): parser = argparse.ArgumentParser(prog="tlgen") parser.add_argument('--topcfg', '-t', metavar='file', type=argparse.FileType('r'), help="`top_cfg.hjson` file.") parser.add_argument('--doc', '-d', action='store_true', help='Generate self HTML document in stdout') parser.add_argument( '--outdir', '-o', help= "Target directory. tlgen needs 'rtl/' and 'dv/' directory under the target dir" ) parser.add_argument('--ip-path', default="", help=''' Additional path to generated rtl/ or dv/ folders: outdir/ip_path/rtl Only needed when there are multiple xbar in outdir''') parser.add_argument('--verbose', '-v', action='store_true', help='Verbose') args = parser.parse_args() if args.verbose: log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG) else: log.basicConfig(format="%(levelname)s: %(message)s") if args.doc: # Generate Doc and return sys.stdout.write(tlgen.selfdoc(heading=3, cmd='tlgen.py --doc')) return # Check if topcfg defined if not args.topcfg or not args.outdir: log.error("--topcfg option is mandatory to generate codes.") # Check if outdir exists. If not, show error and exit if not Path(args.outdir).is_dir(): log.error("'--outdir' should point to writable directory") # Load contents of top_cfg # Skip this part and use internal structure at this time try: obj = hjson.load(args.topcfg, use_decimal=True) except ValueError: raise SystemExit(sys.exc_info()[1]) log.info(obj) xbar = tlgen.validate(obj) xbar.ip_path = args.ip_path if not tlgen.elaborate(xbar): log.error("Elaboration failed." + repr(xbar)) # Generate results = tlgen.generate(xbar) dv_path = Path(args.outdir) / args.ip_path / 'dv/autogen' dv_path.mkdir(parents=True, exist_ok=True) for filename, filecontent in results: filepath = Path(args.outdir) / args.ip_path / filename filepath.parent.mkdir(parents=True, exist_ok=True) with filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(filecontent) # generate TB tlgen.generate_tb(xbar, dv_path)
def main(): parser = argparse.ArgumentParser(prog="tlgen") parser.add_argument('--topcfg', '-t', metavar='file', type=argparse.FileType('r'), help="`top_cfg.hjson` file.") parser.add_argument('--doc', '-d', action='store_true', help='Generate self HTML document in stdout') parser.add_argument( '--outdir', '-o', help= "Target directory. tlgen needs 'rtl/' and 'dv/' directory under the target dir" ) parser.add_argument('--verbose', '-v', action='store_true', help='Verbose') args = parser.parse_args() if args.verbose: log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG) else: log.basicConfig(format="%(levelname)s: %(message)s") if args.doc: # Generate Doc and return sys.stdout.write(tlgen.selfdoc(heading=3, cmd='tlgen.py --doc')) return # Check if topcfg defined if not args.topcfg or not args.outdir: log.error("--topcfg option is mandatory to generate codes.") # Check if outdir exists. If not, show error and exit if not Path(args.outdir).is_dir(): log.error("'--outdir' should point to writable directory") # Load contents of top_cfg # Skip this part and use internal structure at this time try: obj = hjson.load(args.topcfg, use_decimal=True) except ValueError: raise SystemExit(sys.exc_info()[1]) log.info(obj) xbar = tlgen.validate(obj) if not tlgen.elaborate(xbar): log.error("Elaboration failed." + repr(xbar)) # Generate out_rtl, out_pkg, out_core = tlgen.generate(xbar) rtl_path = Path(args.outdir) / 'rtl/autogen' rtl_path.mkdir(parents=True, exist_ok=True) dv_path = Path(args.outdir) / 'dv/autogen' dv_path.mkdir(parents=True, exist_ok=True) rtl_filename = "xbar_%s.sv" % (xbar.name) rtl_filepath = rtl_path / rtl_filename with rtl_filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(out_rtl) pkg_filename = "tl_%s_pkg.sv" % (xbar.name) pkg_filepath = rtl_path / pkg_filename with pkg_filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(out_pkg) core_filename = "xbar_%s.core" % (xbar.name) core_filepath = rtl_path / core_filename with core_filepath.open(mode='w', encoding='UTF-8') as fout: fout.write(out_core) # generate TB tlgen.generate_tb(xbar, dv_path)