From f8ae373dd51c720dd6c3855e1ddf78f60ad0dff2 Mon Sep 17 00:00:00 2001 From: Alessandro Comodi Date: Tue, 19 Jan 2021 17:13:37 +0100 Subject: [PATCH] 063-gtp-common-conf: add IBUFDS_GTE2 primitive as well This commit also solves an issue in the bitfilter function. Given that the GTP_COMMON and GTP_COMMON_MID_[LEFT|RIGHT] have the same bits, but in different frames, we need to add all of the possible frames to the bitfilter callback. This causes issues in determining the IN_USE feature, therefore, there must be two different bitfilter callbacks, one for GTP_COMMON, and one for GTP_COMMON_MID_[LEFT|RIGHT] Signed-off-by: Alessandro Comodi --- fuzzers/063-gtp-common-conf/generate.py | 52 ++++++++++++++++++-- fuzzers/063-gtp-common-conf/generate.tcl | 1 + fuzzers/063-gtp-common-conf/top.py | 60 ++++++++++++++++++++++-- prjxray/segmaker.py | 1 + 4 files changed, 106 insertions(+), 8 deletions(-) diff --git a/fuzzers/063-gtp-common-conf/generate.py b/fuzzers/063-gtp-common-conf/generate.py index 14ed3c88..5964ef96 100644 --- a/fuzzers/063-gtp-common-conf/generate.py +++ b/fuzzers/063-gtp-common-conf/generate.py @@ -19,9 +19,17 @@ INT = "INT" BIN = "BIN" -def bitfilter(frame, bit): +def bitfilter_gtp_common_mid(frame, bit): # Filter out interconnect bits. - if frame not in [28, 29, 0, 1]: + if frame not in [0, 1]: + return False + + return True + + +def bitfilter_gtp_common(frame, bit): + # Filter out interconnect bits. + if frame not in [28, 29]: return False return True @@ -37,10 +45,16 @@ def main(): print("Loading tags") with open("params.json") as f: - params_list = json.load(f) + params_dict = json.load(f) + tile_type = params_dict["tile_type"] + params_list = params_dict["params"] for params in params_list: site = params["site"] + + if "GTPE2_COMMON" not in site: + continue + in_use = params["IN_USE"] segmk.add_site_tag(site, "IN_USE", in_use) @@ -83,6 +97,38 @@ def main(): else: segmk.add_site_tag(site, "INV_" + param, params[param]) + for params in params_list: + site = params["site"] + + if "IBUFDS_GTE2" not in site: + continue + + in_use = params["IN_USE"] + segmk.add_site_tag(site, "IN_USE", in_use) + + if in_use: + tile = params["tile"] + + for param in ["CLKRCV_TRST", "CLKCM_CFG"]: + value = params[param] + segmk.add_site_tag(site, param, "TRUE" in value) + + bitstr = [ + int(x) for x in "{value:0{digits}b}".format( + value=params["CLKSWING_CFG"], digits=2)[::-1] + ] + + for i in range(2): + segmk.add_tile_tag( + tile, "IBUFDS_GTE2.%s[%u]" % (param, i), bitstr[i]) + + if tile_type == "GTP_COMMON": + bitfilter = bitfilter_gtp_common + elif tile_type == "GTP_COMMON_MID_RIGHT": + bitfilter = bitfilter_gtp_common_mid + else: + assert False, tile_type + segmk.compile(bitfilter=bitfilter) segmk.write() diff --git a/fuzzers/063-gtp-common-conf/generate.tcl b/fuzzers/063-gtp-common-conf/generate.tcl index ab44e0cb..0a95cab7 100644 --- a/fuzzers/063-gtp-common-conf/generate.tcl +++ b/fuzzers/063-gtp-common-conf/generate.tcl @@ -17,6 +17,7 @@ proc run {} { set_property IS_ENABLED 0 [get_drc_checks {NSTD-1}] set_property IS_ENABLED 0 [get_drc_checks {UCIO-1}] set_property IS_ENABLED 0 [get_drc_checks {REQP-48}] + set_property IS_ENABLED 0 [get_drc_checks {REQP-1619}] place_design route_design diff --git a/fuzzers/063-gtp-common-conf/top.py b/fuzzers/063-gtp-common-conf/top.py index abd9b318..e32bb45e 100644 --- a/fuzzers/063-gtp-common-conf/top.py +++ b/fuzzers/063-gtp-common-conf/top.py @@ -23,7 +23,7 @@ INT = "INT" BIN = "BIN" -def gen_sites(): +def gen_sites(site): db = Database(util.get_db_root(), util.get_part()) grid = db.grid() for tile_name in sorted(grid.tiles()): @@ -35,12 +35,14 @@ def gen_sites(): "GTP_COMMON_MID_RIGHT", ]: continue + else: + tile_type = gridinfo.tile_type for site_name, site_type in gridinfo.sites.items(): - if site_type != "GTPE2_COMMON": + if site_type != site: continue - yield site_name, site_type + yield tile_name, tile_type, site_name, site_type def main(): @@ -54,9 +56,17 @@ module top( assign out = in; ''') + params_dict = {"tile_type": None} params_list = list() - for site_name, site_type in gen_sites(): + for tile_name, tile_type, site_name, site_type in gen_sites( + "GTPE2_COMMON"): + + if params_dict["tile_type"]: + assert tile_type == params_dict["tile_type"] + else: + params_dict["tile_type"] = tile_type + params = dict() params['site'] = site_name @@ -113,10 +123,50 @@ assign out = in; params_list.append(params) + clkswing_cfg_tiles = dict() + for tile_name, _, site_name, site_type in gen_sites("IBUFDS_GTE2"): + # Both the IBUFDS_GTE2 in the same tile need to have + # the same CLKSWING_CFG parameter + if tile_name not in clkswing_cfg_tiles: + clkswing_cfg = random.randint(0, 3) + clkswing_cfg_tiles[tile_name] = clkswing_cfg + else: + clkswing_cfg = clkswing_cfg_tiles[tile_name] + + in_use = bool(random.randint(0, 9)) + params = { + "site": + site_name, + "tile": + tile_name, + "IN_USE": + in_use, + "CLKRCV_TRST": + verilog.quote("TRUE" if random.randint(0, 1) else "FALSE"), + "CLKCM_CFG": + verilog.quote("TRUE" if random.randint(0, 1) else "FALSE"), + "CLKSWING_CFG": + clkswing_cfg, + } + + if in_use: + print("(* KEEP, DONT_TOUCH, LOC=\"{}\" *)".format(site_name)) + print( + """ +IBUFDS_GTE2 #( + .CLKRCV_TRST({CLKRCV_TRST}), + .CLKCM_CFG({CLKCM_CFG}), + .CLKSWING_CFG({CLKSWING_CFG}) +) {site} ( + );""".format(**params)) + + params_list.append(params) + print("endmodule") + params_dict["params"] = params_list with open('params.json', 'w') as f: - json.dump(params_list, f, indent=2) + json.dump(params_dict, f, indent=2) if __name__ == '__main__': diff --git a/prjxray/segmaker.py b/prjxray/segmaker.py index 239a2cdc..19fc844e 100644 --- a/prjxray/segmaker.py +++ b/prjxray/segmaker.py @@ -331,6 +331,7 @@ class Segmaker: 'IDELAY': name_y0y1, 'ILOGIC': name_y0y1, 'OLOGIC': name_y0y1, + 'IBUFDS': name_y0y1, }.get(site_prefix, name_default)() self.verbose and print( 'site %s w/ %s prefix => tag %s' %