I am using Xilinx Vivado 2014.4 . i am doing a project to generate Block diagram for custom Architecture on Vivado . For that i want to generate a TCL file using XML document . I have exhausted all the Resource available on the internet but could not find any answer to parse an XML file to TCL Script .
An example XML file to generate Microblaze architecture with UARTLITE peripheral
<?xml version="1.0"?>
<System>
<MicroBlaze id="0">
<Parameter>
<NAME>mb0</NAME>
<ICACHE_BASEADDR>0xa0000000</ICACHE_BASEADDR>
<ICACHE_HIGHADDR>0xafffffff</ICACHE_HIGHADDR>
</Parameter>
<Bus_Interface>
<M_AXI_DP>axiinter0</M_AXI_DP>
</Bus_Interface>
</MicroBlaze>
<AXI_Interconnect id="0">
<Parameter>
<NAME>axiinter0</NAME>
</Parameter>
</AXI_Interconnect>
<Uartlite id="0">
<Parameter>
<NAME>uart0</NAME>
<BASEADDR>0x40600000</BASEADDR>
<HIGHADDR>0x4060ffff</HIGHADDR>
</Parameter>
<Bus_Interface>
<S_AXI>axiinter0</S_AXI>
</Bus_Interface>
</Uartlite>
</System>
How to convert this into working TCL script for Xilinx Vivado
XML is (usually) a general document description language. Tcl is a programming language. They're fairly different.
You can tell Tcl to parse an XML document. The preferred package for doing this is tDOM:
package require tdom
# Parse the XML document
set f [open "theinputfile.xml"]
set doc [dom parse [read $f]]
close $f
# Get the interesting part
set root [$doc documentElement]
# Iterate over the child elements
foreach elem [$root selectNodes "./*"] {
puts "I've got a [$elem nodeName]"
}
Which will produce output like:
I've got a MicroBlaze I've got a AXI_Interconnect I've got a Uartlite
How to transform this into what you actually want… well, you know that better than I do.