diff --git a/run_noc_pass.py b/run_noc_pass.py index 1caf6fd..b51faca 100644 --- a/run_noc_pass.py +++ b/run_noc_pass.py @@ -58,6 +58,7 @@ class SelectorEnum(Enum): f""" Please provide: 1. the JSON file generated by Rapidstream's NOC pass + or .xo file for the NONE selector 2. device name: {[e.name for e in DeviceEnum]} 3. design's 4. selector: {[e.name for e in SelectorEnum]} @@ -73,6 +74,7 @@ class SelectorEnum(Enum): mmap_port_json = sys.argv[3] selector = sys.argv[4] build_dir = sys.argv[5] + top_mod_name = sys.argv[6] # currently hard-coded parameters FREQUENCY = 250.0 @@ -107,23 +109,6 @@ class SelectorEnum(Enum): with open(mmap_port_json, "r", encoding="utf-8") as file: mmap_port_ir = json.load(file) - with open(rapidstream_json, "r", encoding="utf-8") as file: - rapidstream_ir = json.load(file) - - top_mod_name = rapidstream_ir["modules"]["top_name"] - print("Top module name:", top_mod_name) - top_ir = parse_top_mod(rapidstream_ir) - streams_slots, streams_widths = parse_inter_slot(top_ir) - - streams_bw = {} - for s, w in streams_widths.items(): - streams_bw[s] = w * FREQUENCY / 8 - - for a, b in streams_slots.items(): - print(a, b, streams_widths[a], streams_bw[a]) - assert len(streams_bw) == len(streams_slots), "parse_inter_slot ERROR" - print("Number of inter-slot streams:", len(streams_slots)) - D = Device( part_num=PART_NUM, board_part=BOARD_PART, @@ -152,16 +137,34 @@ class SelectorEnum(Enum): # Main algorithm: select streams for NoC if selector in (SelectorEnum.NONE.name, SelectorEnum.EMPTY.name): + streams_slots: dict[str, dict[str, str]] = {} noc_streams = [] - elif selector == SelectorEnum.RANDOM.name: - noc_streams = random_selector(streams_slots, D) - elif selector == SelectorEnum.GREEDY.name: - noc_streams = greedy_selector(streams_slots, D) - elif selector == SelectorEnum.GRB.name: - noc_streams = ilp_noc_selector(streams_slots, streams_bw, D) else: - raise NotImplementedError + with open(rapidstream_json, "r", encoding="utf-8") as file: + rapidstream_ir = json.load(file) + + top_mod_name = rapidstream_ir["modules"]["top_name"] + streams_slots, streams_widths = parse_inter_slot(parse_top_mod(rapidstream_ir)) + + streams_bw = {} + for s, w in streams_widths.items(): + streams_bw[s] = w * FREQUENCY / 8 + + for a, b in streams_slots.items(): + print(a, b, streams_widths[a], streams_bw[a]) + assert len(streams_bw) == len(streams_slots), "parse_inter_slot ERROR" + + if selector == SelectorEnum.RANDOM.name: + noc_streams = random_selector(streams_slots, D) + elif selector == SelectorEnum.GREEDY.name: + noc_streams = greedy_selector(streams_slots, D) + elif selector == SelectorEnum.GRB.name: + noc_streams = ilp_noc_selector(streams_slots, streams_bw, D) + else: + raise NotImplementedError + print("Top module name:", top_mod_name) + print("Number of inter-slot streams:", len(streams_slots)) print("Selected streams for NoC", noc_streams) for s in noc_streams: print(f"{s}\t {streams_slots[s]}\t {streams_widths[s]}") @@ -180,7 +183,13 @@ class SelectorEnum(Enum): with open(f"{build_dir}/{NOC_CONSTRAINT_TCL}", "w", encoding="utf-8") as file: file.write("\n".join(tcl)) - if selector in (SelectorEnum.NONE.name, SelectorEnum.EMPTY.name): + if selector == SelectorEnum.NONE.name: + assert rapidstream_json.endswith(".xo"), "NONE selector requires .xo input!" + zsh_cmds = f""" +unzip {rapidstream_json} -d {build_dir}/tmp +mv {build_dir}/tmp/ip_repo/*/src {build_dir}/rtl +""" + elif selector == SelectorEnum.EMPTY.name: # skip generating grouped ir and wrapper zsh_cmds = f""" rapidstream-exporter -i {rapidstream_json} -f {build_dir}/rtl