Skip to content

Commit

Permalink
Merge pull request #119 from daveshah1/up5k_improve
Browse files Browse the repository at this point in the history
UltraPlus Timing Analysis Improvements
  • Loading branch information
cliffordwolf authored Jan 30, 2018
2 parents 479467a + 6efb7f7 commit 722790a
Show file tree
Hide file tree
Showing 12 changed files with 18,362 additions and 3,503 deletions.
1 change: 1 addition & 0 deletions icefuzz/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ bitdata_*.txt
data_*.txt
database_*.txt
timings_*.html
tmedges_unrenamed.tmp
2 changes: 1 addition & 1 deletion icefuzz/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ endif
timings:
ifeq ($(DEVICECLASS),5k)
cp tmedges.txt tmedges.tmp
set -e; for f in work_$(DEVICECLASS)_*/*.vsb; do echo $$f; sed '/defparam/d' < $$f > $$f.fixed; yosys -q -f verilog -s tmedges.ys $$f.fixed; done
set -e; for f in work_$(DEVICECLASS)_*/*.vsb; do echo $$f; sed '/defparam/d' < $$f > $$f.fixed; yosys -q -f verilog -s tmedges.ys $$f.fixed; python3 rename_dsps.py $$f; done
sort -u tmedges.tmp > tmedges.txt && rm -f tmedges.tmp
python3 timings.py -t timings_up5k.txt work_*/*.sdf > timings_up5k.new
mv timings_up5k.new timings_up5k.txt
Expand Down
9 changes: 6 additions & 3 deletions icefuzz/icecube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ case "${ICEDEV:-hx1k-tq144}" in
iCEPACKAGE="SG48"
iCE40DEV="iCE40UP5K"
;;
up5k-uwg30)
iCEPACKAGE="UWG30"
iCE40DEV="iCE40UP5K"
;;
*)
echo "ERROR: Invalid \$ICEDEV device config '$ICEDEV'."
exit 1
Expand Down Expand Up @@ -379,8 +383,8 @@ cat > foobar_sbt.project << EOT
Implementations=foobar_Implmnt
[foobar_Implmnt]
DeviceFamily=$( echo $iCE40DEV | sed -re 's,(HX).*,,'; )
Device=$( echo $iCE40DEV | sed -re 's,iCE40,,'; )
DeviceFamily=$( echo $iCE40DEV | sed -re 's,(HX|5K).*,,'; )
Device=$( echo $iCE40DEV | sed -re 's,iCE40(UP)?,,'; )
DevicePackage=$iCEPACKAGE
Devicevoltage=1.14
DevicevoltagePerformance=+/-5%(datasheet default)
Expand Down Expand Up @@ -419,4 +423,3 @@ fi

export LD_LIBRARY_PATH=""
$scriptdir/../icepack/iceunpack "$1.bin" "$1.asc"

45 changes: 39 additions & 6 deletions icefuzz/make_dsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,41 @@ def randbin(n):
#Only certain combinations are allowed in icecube, list them here
#This is not a complete set, but enough to cover all bits except cbit13, which
#is not set in any allowed config (?)
allowed_configs = ["0010000010000001001110110", "1110000010000001001110110", "0010000010000001000000000", "1110000010000001000000000",
"0000000011000001111110110", "1100000011000001111110110", "0000000011000001110000110", "0010000101000010111111111",
"0000001001100100111111111", "0001001001100100111111111", "0001101001100100111111111", "0001111000101100000000000"]
allowed_configs = [("0010000010000001001110110", "SB_MAC16_MUL_U_8X8_ALL_PIPELINE"),
("1110000010000001001110110", "SB_MAC16_MUL_S_8X8_ALL_PIPELINE"),
("0010000010000001000000000", "SB_MAC16_MUL_U_8X8_BYPASS"),
("1110000010000001000000000", "SB_MAC16_MUL_S_8X8_BYPASS"),
("0000000011000001111110110", "SB_MAC16_MUL_U_16X16_ALL_PIPELINE"),
("1100000011000001111110110", "SB_MAC16_MUL_S_16X16_ALL_PIPELINE"),
("0000000011000001110000110", "SB_MAC16_MUL_U_16X16_IM_BYPASS"),
("1100000011000001110000110", "SB_MAC16_MUL_S_16X16_IM_BYPASS"),
("0000000011000001100000000", "SB_MAC16_MUL_U_16X16_BYPASS"),
("1100000011000001100000000", "SB_MAC16_MUL_S_16X16_BYPASS"),
("0010000101000010111111111", "SB_MAC16_MAC_U_8X8_ALL_PIPELINE"),
("0010000101000010100001111", "SB_MAC16_MAC_U_8X8_IM_BYPASS"),
("0010000101000010100000000", "SB_MAC16_MAC_U_8X8_BYPASS"),
("0000001001100100111111111", "SB_MAC16_MAC_U_16X16_ALL_PIPELINE"),
("0001001001100100111111111", "SB_MAC16_MAC_U_16X16_CASC_ALL_PIPELINE"),
("0001101001100100111111111", "SB_MAC16_MAC_U_16X16_CIN_ALL_PIPELINE"),
("0000001001100100110001111", "SB_MAC16_MAC_U_16X16_IM_BYPASS"),
("0000001001100100100000000", "SB_MAC16_MAC_U_16X16_BYPASS"),
("1100001001100100110001111", "SB_MAC16_MAC_S_16X16_IM_BYPASS"),
("0010000001000000100001111", "SB_MAC16_ACC_U_16P16_ALL_PIPELINE"),
("0010000001000000100000000", "SB_MAC16_ACC_U_16P16_BYPASS"),
("0010000001100000100001111", "SB_MAC16_ACC_U_32P32_ALL_PIPELINE"),
("0010000001100000100000000", "SB_MAC16_ACC_U_32P32_BYPASS"),
("0010010001001000100001111", "SB_MAC16_ADS_U_16P16_ALL_PIPELINE"),
("0010010000001000000000000", "SB_MAC16_ADS_U_16P16_BYPASS"),
("0010010001101000100001111", "SB_MAC16_ADS_U_32P32_ALL_PIPELINE"),
("0010010000101000000000000", "SB_MAC16_ADS_U_32P32_BYPASS"),
("0010010101001010111111111", "SB_MAC16_MAS_U_8X8_ALL_PIPELINE")]


coverage = set()
for c in allowed_configs:
cfg, name = c
for i in range(25):
if c[i] == "1":
if cfg[i] == "1":
coverage.add(i)

assert len(coverage) >= 24
Expand All @@ -37,6 +64,13 @@ def randbin(n):
for idx in range(num):
with open(working_dir + "/dsp_%02d.v" % idx, "w") as f:
glbs = ["glb[%d]" % i for i in range(np.random.randint(8)+1)]

config = allowed_configs[np.random.randint(len(allowed_configs))]
params, cfgname = config
with open(working_dir + "/dsp_%02d.dsp" % idx, "w") as dspf:
dspf.write(cfgname + "\n")
params = params[::-1]

# TODO: ce should be on this list, but causes routing failures
glbs_choice = ["clk", "a", "b", "c", "d,", "ah", "bh", "ch", "dh", "irt", "irb", "ort", "orb", "olt", "olb", "ast", "asb", "oht", "ohb", "sei"]
print("""
Expand Down Expand Up @@ -118,8 +152,7 @@ def randbin(n):
bits_d = "{%s}" % ", ".join(bits_d)

negclk = randbin(1)
params = np.random.choice(allowed_configs)
params = params[::-1]

print("""
wire [34:0] out_%d;
SB_MAC16 #(
Expand Down
19 changes: 19 additions & 0 deletions icefuzz/rename_dsps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python3

import sys, os

dsptype = None
dsppath = sys.argv[1].replace(".vsb", ".dsp")

if os.path.exists(dsppath):
with open(dsppath, 'r') as f:
dsptype = f.readline().strip()

with open("tmedges.tmp", "a") as outfile:
with open("tmedges_unrenamed.tmp", "r") as infile:
for line in infile:
if "SB_MAC16" in line:
if dsptype is not None:
outfile.write(line.replace("SB_MAC16", dsptype))
else:
outfile.write(line)
6 changes: 6 additions & 0 deletions icefuzz/timings.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ def add_entry(celltype, entry):
for stmt in cell:
if stmt[0] == "CELLTYPE":
celltype = rewrite_celltype(stmt[1][1:-1])
if celltype == "SB_MAC16":
try:
with open(filename.replace(".sdf", ".dsp"), "r") as dspf:
celltype = dspf.readline().strip()
except:
break
database.setdefault(celltype, set())

if stmt[0] == "DELAY":
Expand Down
5 changes: 5 additions & 0 deletions icefuzz/timings_loop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
while true; do
rm -rf data_5k_*.txt work_5k_*
make DEVICECLASS=5k -j3
make DEVICECLASS=5k timings
done
Loading

0 comments on commit 722790a

Please sign in to comment.