Merge pull request #1562 from dnltz/WIP/dnltz/new_parts

Populate all parts
This commit is contained in:
litghost 2021-03-18 13:07:02 -07:00 committed by GitHub
commit 086f9a1714
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 335 additions and 205 deletions

View File

@ -29,6 +29,15 @@ echo "----------------------------------------"
)
echo "----------------------------------------"
echo
echo "========================================"
echo "Preparing database"
echo "----------------------------------------"
(
make db-prepare-${XRAY_SETTINGS}
)
echo "----------------------------------------"
source settings/$XRAY_SETTINGS.sh
echo

View File

@ -29,6 +29,15 @@ echo "----------------------------------------"
)
echo "----------------------------------------"
echo
echo "========================================"
echo "Preparing database"
echo "----------------------------------------"
(
make db-prepare-${XRAY_SETTINGS}
)
echo "----------------------------------------"
source settings/$XRAY_SETTINGS.sh
echo

17
.gitignore vendored
View File

@ -2,19 +2,8 @@ env
build
build_*
logs_*
database/*
!database/artix7
database/artix7/*
!database/artix7/mapping
!database/kintex7
database/kintex7/*
!database/kintex7/mapping
!database/zynq7
database/zynq7/*
!database/zynq7/mapping
!database/spartan7
database/spartan7/*
!database/spartan7/mapping
database
settings/*/resources.yaml
.Xil
**/specimen_*
**/output
@ -24,3 +13,5 @@ __pycache__
*.pyc
*.swp
*.egg-info
*vivado*.jou
*vivado*.log

View File

@ -138,8 +138,18 @@ define database
# $(1) - Database name
db-prepare-$(1):
@echo
@echo "Preparing $(1) files"
@echo "============================"
@mkdir -p database/$(1)/mapping
@cp settings/$(1)/devices.yaml database/$(1)/mapping/
@+source settings/$(1).sh && $(IN_ENV) ./utils/update_parts.py $(1)
@+source settings/$(1).sh && $(IN_ENV) ./utils/update_resources.py $(1)
db-$(1):
+source settings/$(1).sh && $$(MAKE) -C fuzzers
+source settings/$(1).sh && $(IN_ENV) ./utils/roi_all.py
db-check-$(1):
@echo
@ -154,12 +164,13 @@ db-format-$(1):
@$(IN_ENV) cd database/$(1); python3 ../../utils/sort_db.py
@if [ -e database/Info.md ]; then $(IN_ENV) ./utils/info_md.py --keep; fi
.PHONY: db-$(1) db-check-$(1) db-format-$(1) db-extras-$(1) db-extras-$(1)-parts db-extras-$(1)-harness
.PHONY: db-prepare-$(1) db-$(1) db-check-$(1) db-format-$(1) db-extras-$(1) db-extras-$(1)-parts db-extra-$(1)-roi db-extras-$(1)-harness
db-extras-$(1): db-extras-$(1)-parts db-extras-$(1)-harness
db-extras-$(1): db-extras-$(1)-parts db-extras-$(1)-roi db-extras-$(1)-harness
db-$(1)-all: db-$(1) db-extras-$(1)-parts
# Build harnesses after database is complete
$$(MAKE) db-extras-$(1)-roi
$$(MAKE) db-extras-$(1)-harness
db-check: db-check-$(1)
@ -174,7 +185,7 @@ $(foreach DB,$(DATABASES),$(eval $(call database,$(DB))))
ARTIX_PARTS=artix7_50t artix7_200t
ZYNQ_PARTS=zynq7010
KINTEX_PARTS=kintex70t
KINTEX_PARTS=
XRAY_PARTS=${ARTIX_PARTS} ${ZYNQ_PARTS} ${KINTEX_PARTS}
@ -185,6 +196,9 @@ define multiple-parts
db-part-only-$(1):
+source settings/$(1).sh && $$(MAKE) -C fuzzers part_only
db-roi-only-$(1):
+source settings/$(1).sh && $(IN_ENV) ./utils/roi_all.py
endef
$(foreach PART,$(XRAY_PARTS),$(eval $(call multiple-parts,$(PART))))
@ -192,20 +206,14 @@ $(foreach PART,$(XRAY_PARTS),$(eval $(call multiple-parts,$(PART))))
db-extras-artix7-parts: $(addprefix db-part-only-,$(ARTIX_PARTS))
db-extras-artix7-roi: $(addprefix db-roi-only-,$(ARTIX_PARTS))
# This explicitly sources each settings script as needed so that
# you don't need to worry about manually sourcing the right script before making.
# Some of these commands handle additional parts/packages that are *not* fully bonded.
# For any pin defined in settings/*.sh that is *not* bonded in this part/package,
# override the XRAY_PIN_0X setting below to pick a pin that *is* bonded.
db-extras-artix7-harness:
+source settings/artix7.sh && \
XRAY_PART=xc7a100tcsg324-1 $(MAKE) -C fuzzers roi_only
+source settings/artix7.sh && \
XRAY_PART=xc7a100tfgg484-2 $(MAKE) -C fuzzers roi_only
+source settings/artix7_50t.sh && \
XRAY_PART=xc7a35tftg256-1 $(MAKE) -C fuzzers roi_only
+source settings/artix7_200t.sh && \
XRAY_PART=xc7a200tsbg484-1 $(MAKE) -C fuzzers roi_only
+source minitests/roi_harness/basys3-swbut.sh && $(MAKE) -C fuzzers roi_only
+source minitests/roi_harness/arty-uart.sh && $(MAKE) -C fuzzers roi_only
+source minitests/roi_harness/basys3-swbut.sh && \
@ -225,17 +233,20 @@ db-extras-artix7-harness:
$(MAKE) -C minitests/roi_harness \
HARNESS_DIR=$(XRAY_DATABASE_DIR)/artix7/harness/arty-a7/swbut copy
db-extras-kintex7-parts:
@true
db-extras-kintex7-parts: $(addprefix db-part-only-,$(KINTEX_PARTS))
db-extras-kintex7-roi: $(addprefix db-roi-only-,$(KINTEX_PARTS))
db-extras-kintex7-harness:
@true
db-extras-zynq7-parts: $(addprefix db-part-only-,$(ZYNQ_PARTS))
db-extras-zynq7-roi: $(addprefix db-roi-only-,$(ZYNQ_PARTS))
db-extras-zynq7-harness:
+source settings/zynq7.sh && \
XRAY_PART=xc7z020clg400-1 $(MAKE) -C fuzzers roi_only
@true
db-check:
@true
@ -245,6 +256,8 @@ db-format:
db-info:
$(IN_ENV) ./utils/info_md.py
db-prepare-parts: $(addprefix db-prepare-,$(DATABASES))
.PHONY: db-check db-format
clean:

View File

@ -89,6 +89,16 @@ running any other commands:
source settings/artix7.sh
### Step 7: ###
Prepare the database with static part information, which are needed by the
fuzzers, either for all device families
make db-prepare-parts
or only for a selected one
make db-prepare-artix7
### Step 8: ###
(Option 1, recommended) - Download a current stable version (you can use the
Python API with a pre-generated database)
@ -99,13 +109,13 @@ Python API with a pre-generated database)
cd fuzzers
make -j$(nproc)
### Step 8: ###
### Step 9: ###
Pick a fuzzer (or write your own) and run:
cd fuzzers/010-clb-lutinit
make -j$(nproc) run
### Step 9: ###
### Step 10: ###
Create HTML documentation:
cd htmlgen

View File

@ -1,37 +0,0 @@
# part number to device, package and speed grade mapping
"xc7a200tffg1156-1":
device: "xc7a200t"
package: "ffg1156"
speedgrade: "1"
"xc7a200tsbg484-1":
device: "xc7a200t"
package: "sbg484"
speedgrade: "1"
"xc7a100tfgg676-1":
device: "xc7a100t"
package: "fgg676"
speedgrade: "1"
"xc7a100tfgg484-2":
device: "xc7a100t"
package: "fgg484"
speedgrade: "2"
"xc7a100tcsg324-1":
device: "xc7a100t"
package: "csg324"
speedgrade: "1"
"xc7a50tfgg484-1":
device: "xc7a50t"
package: "fgg484"
speedgrade: "1"
"xc7a35tcsg324-1":
device: "xc7a35t"
package: "csg324"
speedgrade: "1"
"xc7a35tftg256-1":
device: "xc7a35t"
package: "ftg256"
speedgrade: "1"
"xc7a35tcpg236-1":
device: "xc7a35t"
package: "cpg236"
speedgrade: "1"

View File

@ -1,5 +0,0 @@
# part number to device, package and speed grade mapping
"xc7k70tfbg676-2":
device: "xc7k70t"
package: "fbg676"
speedgrade: "2"

View File

@ -1,5 +0,0 @@
# device to fabric mapping
"xc7z020s":
fabric: "xc7z020s"
"xc7z010s":
fabric: "xc7z010s"

View File

@ -1,13 +0,0 @@
# part number to device, package and speed grade mapping
"xc7z020clg484-1":
device: "xc7z020s"
package: "clg481"
speedgrade: "1"
"xc7z020clg400-1":
device: "xc7z020s"
package: "clg400"
speedgrade: "1"
"xc7z010clg400-1":
device: "xc7z010s"
package: "clg400"
speedgrade: "1"

View File

@ -168,7 +168,7 @@ def run():
def bitfilter(frame, bit):
# rw_width_tags() aliasing interconnect on large widths
return frame not in (20, 21)
return frame not in (0, 20, 21)
segmk.compile(bitfilter=bitfilter)
segmk.write()

View File

@ -49,6 +49,14 @@ def get_part_information(db_root, part):
return part
def set_part_information(db_root, information):
filename = os.path.join(db_root, "mapping", "parts.yaml")
with open(filename, 'w+') as stream:
yaml.dump(information, stream)
assert os.path.isfile(filename), \
"Mapping file {} does not exists".format(filename)
def get_part_resources(file_path, part):
filename = os.path.join(file_path, "resources.yaml")
assert os.path.isfile(filename), \
@ -60,6 +68,14 @@ def get_part_resources(file_path, part):
return res
def set_part_resources(file_path, information):
filename = os.path.join(file_path, "resources.yaml")
with open(filename, 'w+') as stream:
yaml.dump(information, stream)
assert os.path.isfile(filename), \
"Mapping file {} does not exists".format(filename)
def get_fabric_for_part(db_root, part):
filename = os.path.join(db_root, "mapping", "devices.yaml")
assert os.path.isfile(filename), \
@ -73,6 +89,24 @@ def get_fabric_for_part(db_root, part):
return device['fabric']
def get_devices(db_root):
filename = os.path.join(db_root, "mapping", "devices.yaml")
assert os.path.isfile(filename), \
"Mapping file {} does not exists".format(filename)
with open(filename, 'r') as stream:
device_mapping = yaml.load(stream, Loader=yaml.FullLoader)
return device_mapping
def get_parts(db_root):
filename = os.path.join(db_root, "mapping", "parts.yaml")
assert os.path.isfile(filename), \
"Mapping file {} does not exists".format(filename)
with open(filename, 'r') as stream:
part_mapping = yaml.load(stream, Loader=yaml.FullLoader)
return part_mapping
def roi_xy():
x1 = int(os.getenv('XRAY_ROI_GRID_X1', 0))
x2 = int(os.getenv('XRAY_ROI_GRID_X2', 58))

View File

@ -1,82 +0,0 @@
# part number to pins
"xc7a200tffg1156-1":
pins:
0: "R26"
1: "P26"
2: "N26"
3: "M27"
4: "U25"
5: "T25"
6: "P24"
"xc7a200tsbg484-1":
pins:
0: "V10"
1: "W10"
2: "Y11"
3: "Y12"
4: "U25"
5: "T25"
6: "P24"
"xc7a100tfgg676-1":
pins:
0: "Y22"
1: "U17"
2: "V17"
3: "V16"
4: "V14"
5: "U14"
6: "U16"
"xc7a100tfgg484-2":
pins:
0: "J19"
1: "E14"
2: "E13"
3: "U6"
4: "V4"
5: "W5"
6: "V5"
"xc7a100tcsg324-1":
pins:
0: "N15"
1: "U17"
2: "V17"
3: "V16"
4: "V14"
5: "U14"
6: "U16"
"xc7a50tfgg484-1":
pins:
0: "E22"
1: "D22"
2: "E21"
3: "D21"
4: "G21"
5: "G22"
6: "F21"
"xc7a35tcsg324-1":
pins:
0: "G13"
1: "B11"
2: "E15"
3: "U12"
4: "D13"
5: "J17"
6: "U14"
"xc7a35tftg256-1":
pins:
0: "J13"
1: "J14"
2: "K15"
3: "K16"
4: "G21"
5: "G22"
6: "F21"
"xc7a35tcpg236-1":
pins:
0: "V17"
1: "V16"
2: "W16"
3: "W17"
4: "W15"
5: "V15"
6: "W14"

View File

@ -1,10 +0,0 @@
# part number to pins
"xc7k70tfbg676-2":
pins:
0: "K25"
1: "K26"
2: "L24"
3: "L25"
4: "M19"
5: "M20"
6: "M21"

View File

@ -0,0 +1,5 @@
# device to fabric mapping
"xc7z020":
fabric: "xc7z020"
"xc7z010":
fabric: "xc7z010"

View File

@ -1,22 +0,0 @@
# part number to pins
"xc7z020clg484-1":
pins:
0: "Y9"
1: "U10"
2: "N17"
3: "P18"
"xc7z020clg400-1":
pins:
0: "T9"
1: "P14"
2: "T14"
3: "R18"
"xc7z010clg400-1":
pins:
0: "L14"
1: "L15"
2: "M14"
3: "M15"
4: "K16"
5: "J16"
6: "J15"

48
utils/roi_all.py Executable file
View File

@ -0,0 +1,48 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2017-2021 The Project X-Ray Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC
import argparse
import yaml
import subprocess
import os
import re
from prjxray import util
def main():
"""Rois all parts for a family by calling "make roi_only" over all parts
with the same device as XRAY_PART.
Example:
prjxray$ ./utils/roi_all.py --db-root database/artix7/ --part xc7a100tfgg676-1
"""
env = os.environ.copy()
db_root = util.get_db_root()
assert db_root
part = util.get_part()
assert part
information = util.get_part_information(db_root, part)
valid_devices = []
for name, device in util.get_devices(db_root).items():
if device['fabric'] == information['device']:
valid_devices.append(name)
for part, data in util.get_parts(db_root).items():
if data['device'] in valid_devices:
command = "make roi_only"
env['XRAY_PART'] = part
cwd = os.getenv('XRAY_FUZZERS_DIR')
subprocess.run(command.split(' '), check=True, env=env, cwd=cwd)
if __name__ == '__main__':
main()

74
utils/update_parts.py Executable file
View File

@ -0,0 +1,74 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2017-2021 The Project X-Ray Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC
import argparse
import yaml
import subprocess
import os
import re
from prjxray import util
def main():
"""Tool to update all supported, available parts in a mapping file for the
given family. It will read all parts from Vivado, filter them by the family,
and will only add these where a device exists for.
Example:
prjxray$ ./utils/update_parts.py artix7 --db-root database/artix7/
"""
parser = argparse.ArgumentParser(
description="Saves all supported parts for a family.")
parser.add_argument(
'family',
help="Name of the device family.",
choices=['artix7', 'kintex7', 'zynq7'])
util.db_root_arg(parser)
args = parser.parse_args()
env = os.environ.copy()
# Vivado does not use the suffix 7 for zynq
env['FILTER'] = "zynq" if args.family == "zynq7" else args.family
cwd = os.path.dirname(os.path.abspath(__file__))
information = {}
# Read all supported devices
supported_devices = util.get_devices(args.db_root).keys()
# Fetch all parts for a family (FILTER = family)
command = "{} -mode batch -source update_parts.tcl".format(
env['XRAY_VIVADO'])
result = subprocess.run(
command.split(' '),
check=True,
env=env,
cwd=cwd,
stdout=subprocess.PIPE)
parts = result.stdout.decode('utf-8').split('# }\n')[1].splitlines()[:-1]
# Splits up the part number and checks if the device is supported
for part in parts:
part, device, package, speed = part.split(',')
if device in supported_devices:
information[part] = {
'device': device,
'package': package,
'speedgrade': speed[1:]
}
else:
print("Part {} has an unsupported device {}".format(part, device))
# Overwrites the <family>/parts.yaml file completly with new data
util.set_part_information(args.db_root, information)
if __name__ == '__main__':
main()

14
utils/update_parts.tcl Normal file
View File

@ -0,0 +1,14 @@
# Copyright (C) 2017-2021 The Project X-Ray Authors
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC
# Writes a JSON5 to filename containing timing for current design.
# This can be used with create_timing_worksheet_db.py to compare prjxray model
# with Vivado timing model outputs.
set parts [get_parts -filter "FAMILY == $::env(FILTER)"]
foreach part $parts {
puts "$part,[get_property DEVICE $part],[get_property PACKAGE $part],[get_property SPEED $part]"
}

72
utils/update_resources.py Executable file
View File

@ -0,0 +1,72 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (C) 2017-2021 The Project X-Ray Authors.
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC
import argparse
import yaml
import subprocess
import os
import re
from prjxray import util
def main():
"""Tool to update the used resources by the fuzzers for each available part.
Example:
prjxray$ ./utils/update_resources.py artix7 --db-root database/artix7/
"""
parser = argparse.ArgumentParser(
description="Saves all resource information for a family.")
parser.add_argument(
'family',
help="Name of the device family.",
choices=['artix7', 'kintex7', 'zynq7'])
util.db_root_arg(parser)
args = parser.parse_args()
env = os.environ.copy()
cwd = os.path.dirname(os.path.abspath(__file__))
resource_path = os.path.join(
os.getenv('XRAY_DIR'), 'settings', args.family)
information = {}
parts = util.get_parts(args.db_root)
for part in parts.keys():
print("Find pins for {}".format(part))
env['XRAY_PART'] = part
# Asks with get_package_pins and different filters for pins with
# specific properties.
command = "{} -mode batch -source update_resources.tcl".format(
env['XRAY_VIVADO'])
result = subprocess.run(
command.split(' '),
check=True,
env=env,
cwd=cwd,
stdout=subprocess.PIPE)
# Formats the output and stores the pins
output = result.stdout.decode('utf-8').splitlines()
clk_pins = output[-4].split(' ')
data_pins = output[-2].strip().split(' ')
pins = {
0: clk_pins[0],
1: data_pins[0],
2: data_pins[int(len(data_pins) / 2)],
3: data_pins[-1]
}
information[part] = {'pins': pins}
# Overwrites the <family>/resources.yaml file completly with new data
util.set_part_resources(resource_path, information)
if __name__ == '__main__':
main()

View File

@ -0,0 +1,25 @@
# Copyright (C) 2017-2021 The Project X-Ray Authors
#
# Use of this source code is governed by a ISC-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/ISC
#
# SPDX-License-Identifier: ISC
# Writes a JSON5 to filename containing timing for current design.
# This can be used with create_timing_worksheet_db.py to compare prjxray model
# with Vivado timing model outputs.
link_design -part $::env(XRAY_PART)
# one pin -> 0
set clk_pins [get_package_pins -filter "IS_CLK_CAPABLE"]
# three pins -> 1, 2, 3 on HR banks only
set banks [get_iobanks -filter "BANK_TYPE==BT_HIGH_RANGE"]
set data_pins ""
foreach bank [split $banks " "] {
append data_pins " " [get_package_pins -filter "IS_GENERAL_PURPOSE && BANK==$bank"]
}
puts $clk_pins
puts $data_pins