Preparations for DSP and IpCon fuzzing

This commit is contained in:
David Shah 2017-11-08 16:05:42 +00:00
parent c69b87d593
commit 629621642f
9 changed files with 75 additions and 10 deletions

View File

@ -55,6 +55,12 @@ endif
ifneq ($(RAM_SUFFIX),_5k)
cp cached_ramb_5k.txt bitdata_ramb_5k.txt
cp cached_ramt_5k.txt bitdata_ramt_5k.txt
cp cached_dsp0_5k.txt bitdata_dsp0_5k.txt
cp cached_dsp1_5k.txt bitdata_dsp1_5k.txt
cp cached_dsp2_5k.txt bitdata_dsp2_5k.txt
cp cached_dsp3_5k.txt bitdata_dsp3_5k.txt
cp cached_ipcon_5k.txt bitdata_ipcon_5k.txt
endif
ICEDEVICE=$(DEVICECLASS) python3 database.py
python3 export.py
@ -62,6 +68,11 @@ endif
diff -U0 cached_logic.txt bitdata_logic.txt || cp -v bitdata_logic.txt cached_logic.txt
diff -U0 cached_ramb$(RAM_SUFFIX).txt bitdata_ramb$(RAM_SUFFIX).txt || cp -v bitdata_ramb$(RAM_SUFFIX).txt cached_ramb$(RAM_SUFFIX).txt
diff -U0 cached_ramt$(RAM_SUFFIX).txt bitdata_ramt$(RAM_SUFFIX).txt || cp -v bitdata_ramt$(RAM_SUFFIX).txt cached_ramt$(RAM_SUFFIX).txt
diff -U0 cached_dsp0_5k.txt bitdata_dsp0_5k.txt || cp -v bitdata_dsp0_5k.txt cached_dsp0_5k.txt
diff -U0 cached_dsp1_5k.txt bitdata_dsp1_5k.txt || cp -v bitdata_dsp1_5k.txt cached_dsp1_5k.txt
diff -U0 cached_dsp2_5k.txt bitdata_dsp2_5k.txt || cp -v bitdata_dsp2_5k.txt cached_dsp2_5k.txt
diff -U0 cached_dsp3_5k.txt bitdata_dsp3_5k.txt || cp -v bitdata_dsp3_5k.txt cached_dsp3_5k.txt
diff -U0 cached_ipcon_5k.txt bitdata_ipcon_5k.txt || cp -v bitdata_ipcon_5k.txt cached_ipcon_5k.txt
timings:
ifeq ($(DEVICECLASS),8k)
@ -97,11 +108,18 @@ timings_html:
python3 timings.py -h tmedges.txt -t timings_lp8k.txt -l "LP8K with default temp/volt settings" > timings_lp8k.html
python3 timings.py -h tmedges.txt -t timings_lp384.txt -l "LP384 with default temp/volt settings" > timings_lp384.html
data_cached.txt: cached_io.txt cached_logic.txt cached_ramb$(RAM_SUFFIX).txt cached_ramt$(RAM_SUFFIX).txt
data_cached.txt: cached_io.txt cached_logic.txt cached_ramb$(RAM_SUFFIX).txt cached_ramt$(RAM_SUFFIX).txt cached_dsp0_5k.txt cached_dsp1_5k.txt cached_dsp2_5k.txt cached_dsp3_5k.txt cached_ipcon_5k.txt
gawk '{ print "io", $$0; }' cached_io.txt > data_cached.new
gawk '{ print "logic", $$0; }' cached_logic.txt >> data_cached.new
gawk '{ print "ramb$(RAM_SUFFIX)", $$0; }' cached_ramb$(RAM_SUFFIX).txt >> data_cached.new
gawk '{ print "ramt$(RAM_SUFFIX)", $$0; }' cached_ramt$(RAM_SUFFIX).txt >> data_cached.new
gawk '{ print "dsp0_5k", $$0; }' cached_dsp0_5k.txt >> data_cached.new
gawk '{ print "dsp1_5k", $$0; }' cached_dsp1_5k.txt >> data_cached.new
gawk '{ print "dsp2_5k", $$0; }' cached_dsp2_5k.txt >> data_cached.new
gawk '{ print "dsp3_5k", $$0; }' cached_dsp3_5k.txt >> data_cached.new
gawk '{ print "ipcon_5k", $$0; }' cached_ipcon_5k.txt >> data_cached.new
mv data_cached.new data_cached.txt
bitdata_io.txt: data_cached.txt $(addprefix data_$(DEVICECLASS)_,$(addsuffix .txt,$(TESTS)))
@ -116,6 +134,21 @@ bitdata_ramb$(RAM_SUFFIX).txt: data_cached.txt $(addprefix data_$(DEVICECLASS)_,
bitdata_ramt$(RAM_SUFFIX).txt: data_cached.txt $(addprefix data_$(DEVICECLASS)_,$(addsuffix .txt,$(TESTS)))
grep ^ramt$(RAM_SUFFIX) $^ | tr -s ' ' | tr -d '\r' | cut -f2- -d' ' | sort -u > $@
bitdata_dsp0_5k.txt: data_cached.txt $(addprefix data_$(DEVICECLASS)_,$(addsuffix .txt,$(TESTS)))
grep ^dsp0_5k$(RAM_SUFFIX) $^ | tr -s ' ' | tr -d '\r' | cut -f2- -d' ' | sort -u > $@
bitdata_dsp1_5k.txt: data_cached.txt $(addprefix data_$(DEVICECLASS)_,$(addsuffix .txt,$(TESTS)))
grep ^dsp1_5k$(RAM_SUFFIX) $^ | tr -s ' ' | tr -d '\r' | cut -f2- -d' ' | sort -u > $@
bitdata_dsp2_5k.txt: data_cached.txt $(addprefix data_$(DEVICECLASS)_,$(addsuffix .txt,$(TESTS)))
grep ^dsp2_5k$(RAM_SUFFIX) $^ | tr -s ' ' | tr -d '\r' | cut -f2- -d' ' | sort -u > $@
bitdata_dsp3_5k.txt: data_cached.txt $(addprefix data_$(DEVICECLASS)_,$(addsuffix .txt,$(TESTS)))
grep ^dsp3_5k$(RAM_SUFFIX) $^ | tr -s ' ' | tr -d '\r' | cut -f2- -d' ' | sort -u > $@
bitdata_ipcon_5k.txt: data_cached.txt $(addprefix data_$(DEVICECLASS)_,$(addsuffix .txt,$(TESTS)))
grep ^ipcon_5k$(RAM_SUFFIX) $^ | tr -s ' ' | tr -d '\r' | cut -f2- -d' ' | sort -u > $@
datafiles: $(addprefix data_,$(addsuffix .txt,$(TESTS)))
../icepack/icepack:

View File

View File

View File

View File

View File

View File

@ -28,6 +28,9 @@ def read_database(filename, tile_type):
line = re.sub(r"^Ram config bit:", "RamConfig", line)
line = re.sub(r"^PLL config bit:", "PLL", line)
line = re.sub(r"^Icegate Enable bit:", "Icegate", line)
line = re.sub(r"^MAC16 functional bit:", "DspConfig", line)
line = re.sub(r"^Hard IP config bit:", "IpConfig", line)
line = line.split()
if line[0] == "routing":
if line[3] == "wire_gbuf/in": line[3] = "fabout"
@ -61,7 +64,7 @@ def read_database(filename, tile_type):
line[1] = re.sub(r"glb_netwk_", "1k_glb_netwk_", line[1])
raw_db.append((bit, (line[0], line[1])))
elif line[0] == "Cascade":
match = re.match("LH_LC0(\d)_inmux02_5", line[1])
match = re.match("(MULT\d|LH)_LC0(\d)_inmux02_5", line[1])
if match:
raw_db.append((bit, ("buffer", "wire_logic_cluster/lc_%d/lout" % (int(match.group(1))-1), "input_2_%s" % match.group(1))))
else:
@ -87,6 +90,11 @@ def read_database(filename, tile_type):
raw_db.append((bit, (line[0],)))
elif line[0] == "Carry_In_Mux":
continue
elif line[0] == "DspConfig":
line[1] = re.sub(r"MULT\d_bram_cbit_", "CBIT_", line[1])
elif line[0] == "IpConfig":
line[1] = re.sub(r"MULT\d_bram_cbit_", "CBIT_", line[1]) #not a typo, sometimes IP config bits are in DSP tiles and use a MULT prefix...
line[1] = re.sub(r"IPCON_bram_cbit_", "CBIT_", line[1])
else:
print("unsupported statement: %s: %s" % (bit, line))
assert False
@ -149,3 +157,11 @@ for device_class in ["5k", "8k"]:
with open("database_ramt_%s.txt" % (device_class, ), "w") as f:
for entry in read_database("bitdata_ramt_%s.txt" % (device_class, ), "ramt_" + device_class):
print("\t".join(entry), file=f)
if device_class == "5k":
for dsp_idx in range(4):
with open("database_dsp%d_5k.txt" % (dsp_idx, ), "w") as f:
for entry in read_database("bitdata_dsp%d_5k.txt" % (dsp_idx, ), "dsp%d_5" % (dsp_idx, )):
print("\t".join(entry), file=f)
with open("database_ipcon.txt", "w") as f:
for entry in read_database("bitdata_ipcon.txt", "ipcon"):
print("\t".join(entry), file=f)

View File

@ -37,8 +37,24 @@ for filename in sys.argv[1:]:
else:
cur_text_db = text_db.setdefault("ramt_" + device_class if device_class in ["5k", "8k"] else "ramt", set())
ignore = False
elif device_class == "5k" and line.startswith(("IpCon", "DSP")):
ignore = True
elif device_class == "5k" and line.startswith("IpCon"):
cur_text_db = text_db.setdefault("ipcon_5k", set())
ignore = False
elif device_class == "5k" and line.startswith("DSP"):
match = re.match(r"DSP_Tile_\d+_(\d+)", line)
ypos = int(match.group(1))
dsp_idx = None
if ypos in [5, 10, 15, 23]:
dsp_idx = 0
if ypos in [6, 11, 16, 24]:
dsp_idx = 1
if ypos in [7, 12, 17, 25]:
dsp_idx = 2
if ypos in [8, 13, 18, 26]:
dsp_idx = 3
assert dsp_idx != None
cur_text_db = text_db.setdefault("dsp%d_5k" % dsp_idx, set())
ignore = False
elif not ignore:
print("'" + line + "'")
assert line.startswith(" ")

View File

@ -703,7 +703,7 @@ void FpgaConfig::read_ascii(std::istream &ifs)
continue;
}
if (command == ".io_tile" || command == ".logic_tile" || command == ".ramb_tile" || command == ".ramt_tile" || command.substr(0, 4) == ".dsp" || command == ".ipconn_tile")
if (command == ".io_tile" || command == ".logic_tile" || command == ".ramb_tile" || command == ".ramt_tile" || command.substr(0, 4) == ".dsp" || command == ".ipcon_tile")
{
if (!got_device)
error("Missing .device statement before %s.\n", command.c_str());
@ -1013,7 +1013,7 @@ vector<int> FpgaConfig::chip_cols() const
{
if (this->device == "384") return vector<int>({18, 54, 54, 54, 54});
if (this->device == "1k") return vector<int>({18, 54, 54, 42, 54, 54, 54});
// Its IPConnect or Mutiplier block, five logic, ram, six logic.
// Its ipconect or Mutiplier block, five logic, ram, six logic.
if (this->device == "5k") return vector<int>({54, 54, 54, 54, 54, 54, 42, 54, 54, 54, 54, 54, 54});
if (this->device == "8k") return vector<int>({18, 54, 54, 54, 54, 54, 54, 54, 42, 54, 54, 54, 54, 54, 54, 54, 54});
panic("Unknown chip type '%s'.\n", this->device.c_str());
@ -1022,7 +1022,7 @@ vector<int> FpgaConfig::chip_cols() const
string FpgaConfig::tile_type(int x, int y) const
{
if ((x == 0 || x == this->chip_width()+1) && (y == 0 || y == this->chip_height()+1)) return "corner";
// The sides on the 5k devices are IPConnect or DSP tiles
// The sides on the 5k devices are ipconect or DSP tiles
if (this->device == "5k" && (x == 0 || x == this->chip_width()+1)) {
if( (y == 5) || (y == 10) || (y == 15) || (y == 23)) //check ordering here, tile 23-26 might be reversed
return "dsp0";
@ -1032,7 +1032,7 @@ string FpgaConfig::tile_type(int x, int y) const
return "dsp2";
if( (y == 8) || (y == 13) || (y == 18) || (y == 26))
return "dsp3";
return "ipconn";
return "ipcon";
}
if ((x == 0 || x == this->chip_width()+1) || (y == 0 || y == this->chip_height()+1)) return "io";
@ -1064,7 +1064,7 @@ int FpgaConfig::tile_width(const string &type) const
if (type == "ramt") return 42;
if (type == "io") return 18;
if (type.substr(0, 3) == "dsp") return 54;
if (type == "ipconn") return 54;
if (type == "ipcon") return 54;
panic("Unknown tile type '%s'.\n", type.c_str());
}