Skip to content

Commit

Permalink
Handle the new XML format for QSys from version 23.
Browse files Browse the repository at this point in the history
* Parse QSys generated with v23 and newer

* Update tests and ensure new format standard files are matched correctly

---------

Co-authored-by: GCHQDeveloper137 <qchqdeveloper137@outlook.com>
  • Loading branch information
GCHQDeveloper137 and GCHQDeveloper137 authored Mar 8, 2024
1 parent 99cbb50 commit dc95b0b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 27 deletions.
13 changes: 10 additions & 3 deletions edalize/quartus.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,20 @@ def qsys_file_filter(self, f):
try:
qsysTree = ET.parse(os.path.join(self.work_root, f.name))
try:
tool = qsysTree.find("component").attrib["tool"]
if tool == "QsysPro" and self.isPro:
try:
tool = qsysTree.find("component").attrib["tool"]
except AttributeError:
tool = qsysTree.find(".//{http://www.altera.com/XMLSchema/IPXact2014/extensions}tool").text
if tool == "QsysPro":
if self.isPro:
name = f.name
elif not self.isPro:
name = f.name
except (AttributeError, KeyError):
# Either a component wasn't found in the QSYS file, or it
# had no associated tool information. Make the assumption
# it was a Standard edition file
# it is a Standard edition file, as the old formats just
# don't specify.
if not self.isPro:
name = f.name
except (ET.ParseError, IOError):
Expand Down
68 changes: 44 additions & 24 deletions tests/test_quartus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,31 @@
description=""
tags=""
categories="System"
{}
tool="{}"
/>
</system>
"""

qsys_fill = {"Standard": "", "Pro": 'tool="QsysPro"'}
qsys23_file = """<?xml version="1.0" ?>
<ipxact:design xmlns:altera="http://www.altera.com/XMLSchema/IPXact2014/extensions" xmlns:ipxact="http://www.accellera.org/XMLSchema/IPXACT/1685-2014">
<ipxact:vendor>Altera Corporation</ipxact:vendor>
<ipxact:library>sdm_mailbox</ipxact:library>
<ipxact:name>sdm_mailbox</ipxact:name>
<ipxact:version>1.0</ipxact:version>
<ipxact:componentInstances></ipxact:componentInstances>
<ipxact:vendorExtensions>
<altera:catalog_card_info>
<altera:version>1.0</altera:version>
<altera:description></altera:description>
<altera:tags></altera:tags>
<altera:categories></altera:categories>
<altera:tool>{}</altera:tool>
</altera:catalog_card_info>
</ipxact:vendorExtensions>
</ipxact:design>
"""

qsys_fill = {"Standard": "", "Pro": "QsysPro"}

test_sets = {
"Standard": {
Expand Down Expand Up @@ -64,30 +83,31 @@ def test_quartus(make_edalize_test):
# Test each edition of Quartus
for edition in ["Standard", "Pro"]:
for pnr in ["Quartus", "DSE"]:
# Each edition and P&R tool has its own set of representative files
if pnr == "DSE":
_tool_options = {**tool_options, "pnr": "dse"}
else:
_tool_options = {**tool_options}
for qsys_format in [qsys_file, qsys23_file]:
# Each edition and P&R tool has its own set of representative files
if pnr == "DSE":
_tool_options = {**tool_options, "pnr": "dse"}
else:
_tool_options = {**tool_options}

# Ensure we test the edition we intend to, even if quartus_sh is
# present
os.environ["FUSESOC_QUARTUS_EDITION"] = edition
# Ensure we test the edition we intend to, even if quartus_sh is
# not present
os.environ["FUSESOC_QUARTUS_EDITION"] = edition

tf = make_edalize_test(
"quartus",
param_types=["vlogdefine", "vlogparam"],
tool_options=_tool_options,
ref_dir=edition,
)
tf = make_edalize_test(
"quartus",
param_types=["vlogdefine", "vlogparam"],
tool_options=_tool_options,
ref_dir=edition,
)

# Each edition performs checks on the QSYS files present, so
# provide a minimal example
with open(os.path.join(tf.work_root, "qsys_file"), "w") as f:
f.write(qsys_file.format(qsys_fill[edition]))
# Each edition performs checks on the QSYS files present, so
# provide a minimal example
with open(os.path.join(tf.work_root, "qsys_file"), "w") as f:
f.write(qsys_format.format(qsys_fill[edition]))

tf.backend.configure()
tf.compare_files(["Makefile", tf.test_name + ".tcl"])
tf.backend.configure()
tf.compare_files(["Makefile", tf.test_name + ".tcl"])

tf.backend.build()
tf.compare_files(test_sets[edition][pnr])
tf.backend.build()
tf.compare_files(test_sets[edition][pnr])

0 comments on commit dc95b0b

Please sign in to comment.