efinix: add a list of values to fix in xml

Sometimes the Python API of the interface designer produce a wrong XML
file. Values can be changed in the XML file with this new list.
For example:

fix_pll = [
	#      Tag              name                    properties / values
	("comp_output_clock", "mipi_clk",             [("out_divider", "20")]),
        ("comp_output_clock", "mipi_tx_clk_fastclk",  [("out_divider", "4"), ("phase_setting", "3")]),
        ("comp_output_clock", "mipi_tx_data_fastclk", [("out_divider", "4"), ("phase_setting", "1")]),
        ("comp_output_clock", "mipi_tx_slowclk",      [("out_divider", "16")])
]

platform.toolchain.ifacewriter.fix_xml += fix_pll
This commit is contained in:
Franck Jullien 2022-02-24 21:28:34 +01:00
parent 0d2183062d
commit 1b22c6c0ad
2 changed files with 24 additions and 0 deletions

View File

@ -313,6 +313,10 @@ class EfinityToolchain:
if self.ifacewriter.xml_blocks or platform.iobank_info: if self.ifacewriter.xml_blocks or platform.iobank_info:
self.ifacewriter.generate_xml_blocks() self.ifacewriter.generate_xml_blocks()
# Because the Python API is sometimes bugged, we need to tweak the generated xml
if self.ifacewriter.fix_xml:
self.ifacewriter.fix_xml_values()
# Run # Run
if run: if run:
# Synthesis/Mapping. # Synthesis/Mapping.

View File

@ -36,6 +36,7 @@ class InterfaceWriter:
self.efinity_path = efinity_path self.efinity_path = efinity_path
self.blocks = [] self.blocks = []
self.xml_blocks = [] self.xml_blocks = []
self.fix_xml = []
self.filename = "" self.filename = ""
self.platform = None self.platform = None
@ -43,6 +44,25 @@ class InterfaceWriter:
self.filename = build_name self.filename = build_name
self.platform = platform self.platform = platform
def fix_xml_values(self):
et.register_namespace("efxpt", "http://www.efinixinc.com/peri_design_db")
tree = et.parse(self.filename + ".peri.xml")
root = tree.getroot()
for tag, name, values in self.fix_xml:
for e in tree.iter():
if (tag in e.tag) and (name == e.get("name")):
for n, v in values:
e.set(n, v)
xml_string = et.tostring(root, "utf-8")
reparsed = expatbuilder.parseString(xml_string, False)
print_string = reparsed.toprettyxml(indent=" ")
# Remove lines with only whitespaces. Not sure why they are here
print_string = os.linesep.join([s for s in print_string.splitlines() if s.strip()])
tools.write_to_file("{}.peri.xml".format(self.filename), print_string)
def generate_xml_blocks(self): def generate_xml_blocks(self):
et.register_namespace("efxpt", "http://www.efinixinc.com/peri_design_db") et.register_namespace("efxpt", "http://www.efinixinc.com/peri_design_db")
tree = et.parse(self.filename + ".peri.xml") tree = et.parse(self.filename + ".peri.xml")