mithro / duck2-gsoc

Repository to track things that duck2 will work on for Google Summer of Code
0 stars 0 forks source link

Look at Python libraries for reading / understanding XSD files #18

Closed mithro closed 5 years ago

mithro commented 5 years ago

We need to figure out if we want to use ElementTree on the schema XML files directly or use an existing Python library which might make it easier.

Go through and figure out if there are existing stuff by searching github + pypi.

Find out if any are decent and why it might be worth using them?

duck2 commented 5 years ago

There are validators like xmlschema and lxml.XMLSchema, but I couldn't find anything which assists in reading the XSD files into a data structure which is easier to work with when making a parser.

Searching github for "python xsd" shows a number of empty projects... not very encouraging :P

duck2 commented 5 years ago

in fact, lxml.XMLSchema might be useful. it's used here in a small script creating sample XML files from XSD schemas: xsd2xml.py

mithro commented 5 years ago

That looks pretty useful?

duck2 commented 5 years ago

I could coerce xsd2xml into first working(it was outdated), then into handling attributes, accepting enumerations and recursive elements. I think it made a nice architecture file:

<?xml version="1.0" encoding="UTF-8"?>
<architecture xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <models>
    <model name="lol">
      <input_ports>
        <port name="lol" is_clock="true" clock="lol" combinational_sink_ports="lol">
      </port>
      </input_ports>
      <output_ports>
        <port name="lol" is_clock="true" clock="lol" combinational_sink_ports="lol">
        </port>
      </output_ports>
    </model>
  </models>
  <layout>
    <auto_layout aspect_ratio="+24.3e-3">
      <fill type="lol" priority="109">
      </fill>
      <perimeter type="lol" priority="109">
      </perimeter>
      <corners type="lol" priority="109">
      </corners>
      <single type="lol" priority="109" x="lol" y="lol">
        <metadata>
          <meta name="lol" xoffset="109" x_offset="109" yoffset="109" y_offset="109">
            lol
          </meta>
        </metadata>
      </single>
      <col type="lol" priority="109" startx="lol" repeatx="lol" starty="lol" incry="lol">
      </col>
      <row type="lol" priority="109" starty="lol" repeaty="lol" startx="lol" incrx="lol">
      </row>
      <region type="lol" priority="109" startx="lol" endx="lol" incrx="lol" repeatx="lol" starty="lol" endy="lol" incry="lol" repeaty="lol">
      </region>
    </auto_layout>
    <fixed_layout name="lol" width="109" height="109">
      <fill type="lol" priority="109">
      </fill>
      <perimeter type="lol" priority="109">
      </perimeter>
      <corners type="lol" priority="109">
      </corners>
      <single type="lol" priority="109" x="lol" y="lol">
        <metadata>
          <meta name="lol" xoffset="109" x_offset="109" yoffset="109" y_offset="109">
            lol
          </meta>
        </metadata>
      </single>
      <col type="lol" priority="109" startx="lol" repeatx="lol" starty="lol" incry="lol">
      </col>
      <row type="lol" priority="109" starty="lol" repeaty="lol" startx="lol" incrx="lol">
      </row>
      <region type="lol" priority="109" startx="lol" endx="lol" incrx="lol" repeatx="lol" starty="lol" endy="lol" incry="lol" repeaty="lol">
      </region>
    </fixed_layout>
    <device_layout name="lol" width="109" height="109">
      <fill type="lol" priority="109">
      </fill>
      <perimeter type="lol" priority="109">
      </perimeter>
      <corners type="lol" priority="109">
      </corners>
      <single type="lol" priority="109" x="lol" y="lol">
        <metadata>
          <meta name="lol" xoffset="109" x_offset="109" yoffset="109" y_offset="109">
            lol
          </meta>
        </metadata>
      </single>
      <col type="lol" priority="109" startx="lol" repeatx="lol" starty="lol" incry="lol">
      </col>
      <row type="lol" priority="109" starty="lol" repeaty="lol" startx="lol" incrx="lol">
      </row>
      <region type="lol" priority="109" startx="lol" endx="lol" incrx="lol" repeatx="lol" starty="lol" endy="lol" incry="lol" repeaty="lol">
      </region>
    </device_layout>
  </layout>
  <device>
    <sizing R_minW_nmos="+24.3e-3" R_minW_pmos="+24.3e-3">
    </sizing>
    <connection_block input_switch_name="lol">
    </connection_block>
    <area grid_logic_tile_area="+24.3e-3">
    </area>
    <switch_block type="wilton" fs="109">
    </switch_block>
    <chan_width_distr>
      <x distr="gaussian" peak="+24.3e-3" width="+24.3e-3" xpeak="+24.3e-3" dc="+24.3e-3">
      </x>
      <y distr="gaussian" peak="+24.3e-3" width="+24.3e-3" xpeak="+24.3e-3" dc="+24.3e-3">
      </y>
    </chan_width_distr>
    <default_fc in_type="frac" in_val="+24.3e-3" out_type="frac" out_val="+24.3e-3">
    </default_fc>
  </device>
  <switchlist>
    <switch type="mux" name="lol" R="+24.3e-3" Cin="+24.3e-3" Cinternal="+24.3e-3" Cout="+24.3e-3" Tdel="+24.3e-3" buf_size="A_BCD" mux_trans_size="+24.3e-3" power_buf_size="+24.3e-3">
      <Tdel num_inputs="109" delay="+24.3e-3">
      </Tdel>
    </switch>
  </switchlist>
  <switchblocklist>
    <switchblock name="lol" type="bidir">
      <switchblock_location type="EVERYWHERE">
      </switchblock_location>
      <switchfuncs>
        <func type="lt" formula="lol">
        </func>
      </switchfuncs>
      <wireconn num_conns_type="lol" from_type="lol" to_type="lol" from_switchpoint="lol" to_switchpoint="lol">
        <from type="lol" switchpoint="lol">
        </from>
        <to type="lol" switchpoint="lol">
        </to>
      </wireconn>
    </switchblock>
  </switchblocklist>
  <segmentlist>
    <segment name="lol" length="A_BCD" type="bidir" freq="+24.3e-3" Rmetal="+24.3e-3" Cmetal="+24.3e-3">
      <sb type="lol">
        109
      </sb>
      <cb type="lol">
        109
      </cb>
      <mux name="lol">
      </mux>
      <wire_switch name="lol">
      </wire_switch>
      <opin_switch name="lol">
      </opin_switch>
    </segment>
  </segmentlist>
  <power method="specify-size">
    <local_interconnect C_wire="+24.3e-3" factor="+24.3e-3">
    </local_interconnect>
    <buffers logical_effort_factor="+24.3e-3">
    </buffers>
    <mux_transistor_size mux_transistor_size="+24.3e-3">
    </mux_transistor_size>
    <FF_size FF_size="+24.3e-3">
    </FF_size>
    <LUT_transistor_size LUT_transistor_size="+24.3e-3">
    </LUT_transistor_size>
  </power>
  <clocks>
    <clock C_wire="+24.3e-3" C_wire_per_m="+24.3e-3" buffer_size="A_BCD">
    </clock>
  </clocks>
  <directlist>
    <direct name="lol" from_pin="lol" to_pin="lol" x_offset="109" y_offset="109" z_offset="109" switch_name="lol">
    </direct>
  </directlist>
  <tiles>
    <tile name="lol">
      <equivalent_tiles>
        <mode name="lol">
          <map from="lol" to="lol" num_pins="lol">
          </map>
        </mode>
      </equivalent_tiles>
      <pinlocations pattern="spread">
        <loc side="left" xoffset="109" yoffset="109">
          lol
        </loc>
      </pinlocations>
      <fc in_type="frac" in_val="+24.3e-3" out_type="frac" out_val="+24.3e-3">
        <fc_override fc_type="frac" fc_val="+24.3e-3" port_name="lol" segment_name="lol">
        </fc_override>
      </fc>
      <switchblock_locations pattern="external_full_internal_straight" internal_switch="lol">
        <sb_loc type="full" xoffset="109" yoffset="109" switch_override="lol">
        </sb_loc>
      </switchblock_locations>
    </tile>
  </tiles>
  <complexblocklist>
    <pb_type name="lol" num_pb="109" blif_model="lol" capacity="109" width="109" height="109" area="+24.3e-3" class="lut">
      <input name="lol" equivalent="none" num_pins="109" is_non_clock_global="true" port_class="lol">
      </input>
      <output name="lol" equivalent="none" num_pins="109" port_class="lol">
      </output>
      <clock name="lol" equivalent="none" num_pins="109" port_class="lol">
      </clock>
      <metadata>
        <meta name="lol" xoffset="109" x_offset="109" yoffset="109" y_offset="109">
          lol
        </meta>
      </metadata>
      <mode name="lol">
        <interconnect>
          <complete name="lol" input="lol" output="lol">
            <pack_pattern name="lol" in_port="lol" out_port="lol">
            </pack_pattern>
            <delay_constant max="+24.3e-3" min="+24.3e-3" in_port="lol" out_port="lol">
            </delay_constant>
            <delay_matrix type="min" in_port="lol" out_port="lol">
              +24.3e-3
            </delay_matrix>
            <metadata>
              <meta name="lol" xoffset="109" x_offset="109" yoffset="109" y_offset="109">
                lol
              </meta>
            </metadata>
          </complete>
          <direct name="lol" input="lol" output="lol">
            <pack_pattern name="lol" in_port="lol" out_port="lol">
            </pack_pattern>
            <delay_constant max="+24.3e-3" min="+24.3e-3" in_port="lol" out_port="lol">
            </delay_constant>
            <delay_matrix type="min" in_port="lol" out_port="lol">
              +24.3e-3
            </delay_matrix>
            <metadata>
              <meta name="lol" xoffset="109" x_offset="109" yoffset="109" y_offset="109">
                lol
              </meta>
            </metadata>
          </direct>
          <mux name="lol" input="lol" output="lol">
            <pack_pattern name="lol" in_port="lol" out_port="lol">
            </pack_pattern>
            <delay_constant max="+24.3e-3" min="+24.3e-3" in_port="lol" out_port="lol">
            </delay_constant>
            <delay_matrix type="min" in_port="lol" out_port="lol">
              +24.3e-3
            </delay_matrix>
            <metadata>
              <meta name="lol" xoffset="109" x_offset="109" yoffset="109" y_offset="109">
                lol
              </meta>
            </metadata>
          </mux>
        </interconnect>
        <pinlocations pattern="spread">
          <loc side="left" xoffset="109" yoffset="109">
            lol
          </loc>
        </pinlocations>
        <switchblock_locations pattern="external_full_internal_straight" internal_switch="lol">
          <sb_loc type="full" xoffset="109" yoffset="109" switch_override="lol">
          </sb_loc>
        </switchblock_locations>
        <metadata>
          <meta name="lol" xoffset="109" x_offset="109" yoffset="109" y_offset="109">
            lol
          </meta>
        </metadata>
      </mode>
      <interconnect>
        <complete name="lol" input="lol" output="lol">
          <pack_pattern name="lol" in_port="lol" out_port="lol">
          </pack_pattern>
          <delay_constant max="+24.3e-3" min="+24.3e-3" in_port="lol" out_port="lol">
          </delay_constant>
          <delay_matrix type="min" in_port="lol" out_port="lol">
            +24.3e-3
          </delay_matrix>
          <metadata>
            <meta name="lol" xoffset="109" x_offset="109" yoffset="109" y_offset="109">
              lol
            </meta>
          </metadata>
        </complete>
        <direct name="lol" input="lol" output="lol">
          <pack_pattern name="lol" in_port="lol" out_port="lol">
          </pack_pattern>
          <delay_constant max="+24.3e-3" min="+24.3e-3" in_port="lol" out_port="lol">
          </delay_constant>
          <delay_matrix type="min" in_port="lol" out_port="lol">
            +24.3e-3
          </delay_matrix>
          <metadata>
            <meta name="lol" xoffset="109" x_offset="109" yoffset="109" y_offset="109">
              lol
            </meta>
          </metadata>
        </direct>
        <mux name="lol" input="lol" output="lol">
          <pack_pattern name="lol" in_port="lol" out_port="lol">
          </pack_pattern>
          <delay_constant max="+24.3e-3" min="+24.3e-3" in_port="lol" out_port="lol">
          </delay_constant>
          <delay_matrix type="min" in_port="lol" out_port="lol">
            +24.3e-3
          </delay_matrix>
          <metadata>
            <meta name="lol" xoffset="109" x_offset="109" yoffset="109" y_offset="109">
              lol
            </meta>
          </metadata>
        </mux>
      </interconnect>
      <pinlocations pattern="spread">
        <loc side="left" xoffset="109" yoffset="109">
          lol
        </loc>
      </pinlocations>
      <switchblock_locations pattern="external_full_internal_straight" internal_switch="lol">
        <sb_loc type="full" xoffset="109" yoffset="109" switch_override="lol">
        </sb_loc>
      </switchblock_locations>
      <fc in_type="frac" in_val="+24.3e-3" out_type="frac" out_val="+24.3e-3">
        <fc_override fc_type="frac" fc_val="+24.3e-3" port_name="lol" segment_name="lol">
        </fc_override>
      </fc>
      <delay_constant max="+24.3e-3" min="+24.3e-3" in_port="lol" out_port="lol">
      </delay_constant>
      <delay_matrix type="min" in_port="lol" out_port="lol">
        +24.3e-3
      </delay_matrix>
      <T_setup value="+24.3e-3" port="lol" clock="lol">
      </T_setup>
      <T_hold value="+24.3e-3" port="lol" clock="lol">
      </T_hold>
      <T_clock_to_Q max="+24.3e-3" min="+24.3e-3" port="lol" clock="lol">
      </T_clock_to_Q>
      <power method="specify-size">
        <dynamic_power power_per_instance="+24.3e-3" C_internal="+24.3e-3">
        </dynamic_power>
        <static_power power_per_instance="+24.3e-3">
        </static_power>
        <port name="lol" energy_per_toggle="+24.3e-3" scaled_by_static_prob="lol" scaled_by_static_prob_n="lol">
        </port>
      </power>
    </pb_type>
  </complexblocklist>
</architecture>
mithro commented 5 years ago

LoL :-)

mithro commented 5 years ago

I think we have done this already, so closing.