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:
parent
0d2183062d
commit
1b22c6c0ad
|
@ -313,6 +313,10 @@ class EfinityToolchain:
|
|||
if self.ifacewriter.xml_blocks or platform.iobank_info:
|
||||
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
|
||||
if run:
|
||||
# Synthesis/Mapping.
|
||||
|
|
|
@ -36,6 +36,7 @@ class InterfaceWriter:
|
|||
self.efinity_path = efinity_path
|
||||
self.blocks = []
|
||||
self.xml_blocks = []
|
||||
self.fix_xml = []
|
||||
self.filename = ""
|
||||
self.platform = None
|
||||
|
||||
|
@ -43,6 +44,25 @@ class InterfaceWriter:
|
|||
self.filename = build_name
|
||||
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):
|
||||
et.register_namespace("efxpt", "http://www.efinixinc.com/peri_design_db")
|
||||
tree = et.parse(self.filename + ".peri.xml")
|
||||
|
|
Loading…
Reference in New Issue