Skip to content

Commit e1b3cf6

Browse files
committed
Add scripts to extract basic architecture and create html
1 parent fd685d9 commit e1b3cf6

File tree

12 files changed

+433
-0
lines changed

12 files changed

+433
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ ispTcl.tcl
77
ispTcl.tcl.*
88
.ispTcl.lock
99
work_*/
10+
/td/
11+
/database/

devices.json

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
{
2+
"architectures": {
3+
"eagle": {
4+
"parts": {
5+
"eagle_15": {
6+
"packages": [
7+
"BGA256X",
8+
"BGA256A"
9+
],
10+
"max_row": 41,
11+
"max_col": 72
12+
},
13+
"eagle_20": {
14+
"packages": [
15+
"BGA256X",
16+
"BGA256A",
17+
"QFN88"
18+
],
19+
"max_row": 41,
20+
"max_col": 72
21+
},
22+
"eagle_s20": {
23+
"packages": [
24+
"EQFP176",
25+
"BG256",
26+
"QFN88"
27+
],
28+
"max_row": 41,
29+
"max_col": 72
30+
}
31+
}
32+
},
33+
"elf": {
34+
"parts": {
35+
"elf_3": {
36+
"packages": [
37+
"LXLQFP100",
38+
"AMLQFP100",
39+
"AMLQFP44"
40+
],
41+
"max_row": 10,
42+
"max_col": 9
43+
},
44+
"elf_6": {
45+
"packages": [
46+
"LXLQFP100",
47+
"LXLQFP144",
48+
"AMLQFP100",
49+
"AMLQFP144"
50+
],
51+
"max_row": 10,
52+
"max_col": 9
53+
}
54+
}
55+
},
56+
"ef2": {
57+
"parts": {
58+
"ef2_1": {
59+
"packages": [
60+
"EF2L15LG100B",
61+
"EF2L15LG144B",
62+
"EF2L15BG256B"
63+
],
64+
"max_row": 25,
65+
"max_col": 30
66+
},
67+
"ef2_2": {
68+
"packages": [
69+
"EF2L25XG42B",
70+
"EF2L25BG256B"
71+
],
72+
"max_row": 25,
73+
"max_col": 30
74+
},
75+
"ef2_4": {
76+
"packages": [
77+
"EF2L45LG144B",
78+
"EF2M45LG64B",
79+
"EF2L45BG256B",
80+
"EF2M45LG48B"
81+
],
82+
"max_row": 25,
83+
"max_col": 30
84+
}
85+
}
86+
},
87+
"al3": {
88+
"parts": {
89+
"al3_6": {
90+
"packages": [
91+
"LQFP144",
92+
"BGA256"
93+
],
94+
"max_row": 35,
95+
"max_col": 38
96+
},
97+
"al3_10": {
98+
"packages": [
99+
"LQFP144",
100+
"BGA256",
101+
"QFN88"
102+
],
103+
"max_row": 35,
104+
"max_col": 38
105+
},
106+
"al3_s10": {
107+
"packages": [
108+
"LQFP144",
109+
"QFN88"
110+
],
111+
"max_row": 35,
112+
"max_col": 38
113+
}
114+
}
115+
}
116+
}
117+
}

environment.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
set SCRIPT_DIR=%~dp0
2+
set PYTHONLIBS_DIR=%SCRIPT_DIR%util;%SCRIPT_DIR%util\common
3+
set PYTHONPATH=%PYTHONLIBS_DIR%

environment.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
# Set up PYTHONPATH and other needed environment variables
4+
# This script will also source user_environment.sh where you can specify
5+
# overrides if required for your system
6+
7+
if [ "$0" = "$_" ]; then
8+
echo This script is intended to be invoked using \"source environment.sh\"
9+
echo Calling it as a standalone script will have no effect.
10+
exit 1
11+
fi
12+
13+
SCRIPT_PATH=$(readlink -f "${BASH_SOURCE:-$0}")
14+
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
15+
PYTHONLIBS_DIR="${SCRIPT_DIR}/util:${SCRIPT_DIR}/util/common"
16+
export PYTHONPATH="${PYTHONLIBS_DIR}:${PYTHONPATH}"

minitests/tilegrid/wire.pnl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
design "top"
2+
{
3+
device
4+
{
5+
part {part};
6+
architecture {architecture};
7+
package {package};
8+
speed ;
9+
}
10+
net "test"
11+
{
12+
route
13+
{
14+
{tiles}
15+
}
16+
}
17+
}

minitests/tilegrid/wire.tcl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import_device {part}.db -package {package}
2+
read_pnl wire.pnl
3+
bitgen -bit "wire.bit" -version 0X00 -g ucode:00000000000000000000000000000000 -info -log_file wire.log

tools/get_tilegrid_all.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env python3
2+
"""
3+
For each architecture and part, obtain a tilegrid and save it in the database
4+
"""
5+
6+
import os
7+
from os import path
8+
import shutil
9+
10+
import database
11+
import tangdinasty
12+
import json
13+
14+
def prepare_tcl(part, package):
15+
file_loc = path.join(database.get_tang_root(), "minitests", "tilegrid", "wire.tcl")
16+
with open(file_loc, "rt") as fin:
17+
with open("work_tilegrid/wire.tcl", "wt") as fout:
18+
for line in fin:
19+
line = line.replace('{part}', part)
20+
line = line.replace('{package}', package)
21+
fout.write(line)
22+
23+
def prepare_pnl(architecture, part, package, max_row, max_col):
24+
tiles = ''
25+
for x in range(max_row):
26+
for y in range(max_col):
27+
tiles += ' x{}y{}_n1end0.x{}y{}_n1beg0\n'.format(x,y,x,y)
28+
file_loc = path.join(database.get_tang_root(), "minitests", "tilegrid", "wire.pnl")
29+
with open(file_loc, "rt") as fin:
30+
with open("work_tilegrid/wire.pnl", "wt") as fout:
31+
for line in fin:
32+
line = line.replace('{architecture}', architecture)
33+
line = line.replace('{part}', part)
34+
line = line.replace('{package}', package)
35+
line = line.replace('{tiles}', tiles)
36+
fout.write(line)
37+
38+
def write_json(infile ,outfile, rows, cols):
39+
tiles = [[0 for x in range(rows)] for y in range(cols)]
40+
with open(infile, "rt") as fin:
41+
for line in fin:
42+
if (line.startswith('//')):
43+
inst = line.split(':')[1].split(',')[0]
44+
type = line.split('type=')[1].split(',')[0]
45+
wl_beg = line.split('wl_beg=')[1].split(',')[0]
46+
bl_beg = line.split('bl_beg=')[1].split(',')[0].rstrip('\n')
47+
loc = inst.split('_')[-1]
48+
val = loc.split('y')
49+
x = int(val[0].lstrip('x'))
50+
y = int(val[1])
51+
current_tile = {
52+
"x": x,
53+
"y": y,
54+
"loc": loc,
55+
"val": []
56+
}
57+
if (tiles[y][x]==0):
58+
tiles[y][x] = current_tile
59+
current_item = {
60+
"inst": inst,
61+
"type": type,
62+
"wl_beg": int(wl_beg),
63+
"bl_beg": int(bl_beg)
64+
}
65+
size = len(tiles[y][x]["val"])
66+
tiles[y][x]["val"].append(current_item)
67+
with open(outfile, "wt") as fout:
68+
json.dump(tiles, fout, sort_keys=True, indent=4)
69+
70+
def main():
71+
shutil.rmtree("work_tilegrid", ignore_errors=True)
72+
os.mkdir("work_tilegrid")
73+
devices = database.get_devices()
74+
for architecture in devices["architectures"].keys():
75+
for part in devices["architectures"][architecture]["parts"].keys():
76+
selected_part = devices["architectures"][architecture]["parts"][part]
77+
package = selected_part["packages"][0]
78+
prepare_tcl(part, package)
79+
prepare_pnl(architecture, part, package, int(selected_part["max_row"]), int(selected_part["max_col"]))
80+
tangdinasty.run("wire.tcl", "work_tilegrid")
81+
output_file = path.join(database.get_db_subdir(architecture, part), "tilegrid.json")
82+
write_json("work_tilegrid/wire.log", output_file, int(selected_part["max_row"]), int(selected_part["max_col"]))
83+
84+
if __name__ == "__main__":
85+
main()

tools/html_all.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python3
2+
"""
3+
For each architecture and part, create tilegrid html
4+
"""
5+
6+
import os
7+
from os import path
8+
9+
import database
10+
import json
11+
import html_tilegrid
12+
import shutil
13+
14+
def main():
15+
devices = database.get_devices()
16+
shutil.rmtree("work_html", ignore_errors=True)
17+
os.mkdir("work_html")
18+
for architecture in devices["architectures"].keys():
19+
for part in devices["architectures"][architecture]["parts"].keys():
20+
html_tilegrid.main(["html_tilegrid", architecture, part, path.join("work_html",part + ".html")])
21+
if __name__ == "__main__":
22+
main()

tools/html_tilegrid.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Convert the tile grid for a given family and device to HTML format
4+
"""
5+
import sys, re
6+
import argparse
7+
import database
8+
9+
parser = argparse.ArgumentParser(description=__doc__)
10+
parser.add_argument('architecture', type=str,
11+
help="FPGA architecture (e.g. ECP5)")
12+
parser.add_argument('part', type=str,
13+
help="FPGA part (e.g. LFE5U-85F)")
14+
parser.add_argument('outfile', type=argparse.FileType('w'),
15+
help="output HTML file")
16+
17+
18+
def get_colour(ttype):
19+
colour = "#FFFFFF"
20+
if ttype.startswith("iol_"):
21+
colour = "#88FF88"
22+
elif ttype.startswith("miscs_mic_io"):
23+
colour = "#88FFFF"
24+
elif ttype.startswith("gclk"):
25+
colour = "#FF8888"
26+
elif ttype.startswith("plb"):
27+
colour = "#8888FF"
28+
elif ttype.startswith("DUMMY"):
29+
colour = "#FFFFFF"
30+
elif ttype.startswith("gclk") or ttype.startswith("gclk_iospine"):
31+
colour = "#FF88FF"
32+
elif ttype.find("DSP") != -1:
33+
colour = "#FFFF88"
34+
elif ttype.find("pib") != -1:
35+
colour = "#DDDDDD"
36+
else:
37+
colour = "#888888"
38+
return colour
39+
40+
41+
def main(argv):
42+
args = parser.parse_args(argv[1:])
43+
tilegrid = database.get_tilegrid(args.architecture, args.part)
44+
device_info = database.get_devices()["architectures"][args.architecture]["parts"][args.part]
45+
46+
max_row = device_info["max_row"]
47+
max_col = device_info["max_col"]
48+
tiles = []
49+
50+
for i in range(max_col ):
51+
row = []
52+
for j in range(max_row):
53+
row.append([])
54+
tiles.append(row)
55+
56+
for row in tilegrid:
57+
for item in row:
58+
x = int(item["x"])
59+
y = int(item["y"])
60+
for data in item["val"]:
61+
colour = get_colour(data["type"])
62+
tiles[y][x].append((data["inst"], data["type"], colour))
63+
64+
f = args.outfile
65+
print(
66+
"""<html>
67+
<head><title>{} Tiles</title></head>
68+
<body>
69+
<h1>{} Tilegrid</h1>
70+
<table style='font-size: 8pt; border: 2px solid black; text-align: center'>
71+
""".format(args.part.upper(), args.part.upper()), file=f)
72+
for trow in tiles:
73+
print("<tr>", file=f)
74+
row_max_height = 0
75+
for tloc in trow:
76+
row_max_height = max(row_max_height, len(tloc))
77+
row_height = max(75, 30 * row_max_height)
78+
for tloc in trow:
79+
print("<td style='border: 2px solid black; height: {}px'>".format(row_height), file=f)
80+
for tile in tloc:
81+
print(
82+
"<div style='height: {}%; background-color: {}'><em>{}</em><br/><strong>{}</strong></div>".format(
83+
100 / len(tloc), tile[2], tile[0], tile[1], tile[1]), file=f)
84+
print("</td>", file=f)
85+
print("</tr>", file=f)
86+
print("</table></body></html>", file=f)
87+
88+
89+
if __name__ == "__main__":
90+
main(sys.argv)

util/common/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)