<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:xml="http://www.w3.org/XML/1998/namespace"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:xi="http://www.w3.org/2001/XInclude"
           targetNamespace="http://pdaflow.org/ns/OptoCompiler"
           xmlns="http://pdaflow.org/ns/OptoCompiler"
           xmlns:pda="http://pdaflow.org/ns/xPDK"
           elementFormDefault="qualified">
  <xs:annotation>
   <xs:appinfo>xPDK schema format extensions for OptoCompiler</xs:appinfo>
   <xs:documentation xml:lang="en">
   This schema defines a few OptoCompiler extensions for different items.

   The schema is located at: http://pdaflow.org/xsd/ per instance of the standard.

<br/>
The schema is located at: <tt>http://pdaflow.org/xsd/</tt> per instance of the standard.
<br/>
<ul>
  <li>License for <b>general users / automation / ...</b>:<br/>
   Use unmodified.
  </li>
  <li>License for <b>PDAFlow members</b>:<br/>
   Allow to extend / modify / update in alignment with the other PDAFlow members.
   </li>
</ul>
   </xs:documentation>
  </xs:annotation>

  <xs:import schemaLocation="xPDK_Base.xsd" namespace="http://pdaflow.org/ns/xPDK" />
  <xs:attribute name="techIncludeElectricalTag"  type="techIncludeElectricalTag"/>
  <xs:attribute name="techPurpose"               type="techPurpose"/>
  <xs:attribute name="techLayerID"               type="techLayerID"/>
  <xs:attribute name="techLayerFunction"         type="techLayerFunction"/>
  <xs:attribute name="techLayerRouting"          type="techLayerRouting"/>
  <xs:element name="techLayerConnection"         type="techLayerConnection"/>
  <xs:attribute name="pcellFail"                 type="pcellFail"/>
  <xs:attribute name="symbolView"                type="symbolView"/>
  <xs:attribute name="symbolViewReorderPorts"        type="symbolViewReorderPorts"/>
  <xs:attribute name="symbolLibName"             type="symbolLibName"/>
  <xs:attribute name="symbolViewTemplate"        type="symbolViewTemplate"/>
  <xs:attribute name="maskNumber"                type="maskNumber"/>
  <xs:attribute name="mcsAnnotateWaveguide"      type="mcsAnnotateWaveguide"/>

<xs:simpleType name="techIncludeElectricalTag">
 <xs:annotation>
  <xs:documentation xml:lang="en">
   Specify that the <i>electrical tag library</i> will be added to the OptoDesigner 02-file/<br/>
   This pcell library will be used in the BBs to generate a spt-based side-file for mask assembly.
  </xs:documentation>
  </xs:annotation>
  <xs:restriction base="xs:boolean"/>
</xs:simpleType>



<xs:simpleType name="techPurpose">
 <xs:annotation>
  <xs:documentation xml:lang="en">
  Define the 'OpenAccess' purpose for a layer.<br/>
  This will be used in writing to the tech-file and if a layer does not have it specified, it will be used as <i>drawing</i>.<br/>
  You can add your own values in addition to the standard provided names:
  <ul>
   <li>redundant</li>
   <li>gapFill</li>
   <li>annotation</li>
   <li>OPCAntiSerif</li>
   <li>OPCSerif</li>
   <li>slot</li>
   <li>fill</li>
   <li>drawing</li>
   <li>fatal</li>
   <li>critical</li>
   <li>soCritical</li>
   <li>soError</li>
   <li>ackWarn</li>
   <li>info</li>
   <li>track</li>
   <li>blockage</li>
   <li>warning</li>
   <li>tool1</li>
   <li>tool0</li>
   <li>label</li>
   <li>flight</li>
   <li>error</li>
   <li>annotate</li>
   <li>drawing1</li>
   <li>drawing2</li>
   <li>drawing3</li>
   <li>drawing4</li>
   <li>drawing5</li>
   <li>drawing6</li>
   <li>drawing7</li>
   <li>drawing8</li>
   <li>drawing9</li>
   <li>boundary</li>
   <li>pin</li>
   <li>net</li>
   <li>cell</li>
   <li>all</li>
  </ul>
  </xs:documentation>
  </xs:annotation>
  <xs:restriction base="xs:string">
    <xs:pattern value="[a-zA-Z]([a-zA-Z0-9])*"/>
  </xs:restriction>
</xs:simpleType>

<xs:simpleType name="techLayerFunction">
 <xs:annotation>
  <xs:documentation xml:lang="en">
   Define the function value in OptoCompiler tech file, section 'function'
  </xs:documentation>
  </xs:annotation>
  <xs:restriction base="xs:string">
    <xs:pattern value="[a-zA-Z]([a-zA-Z0-9])*"/>
  </xs:restriction>
</xs:simpleType>

<xs:simpleType name="techLayerRouting">
 <xs:annotation>
  <xs:documentation xml:lang="en">
  Mark for routing in in OptoCompiler tech file, section 'constraintGroups'
  </xs:documentation>
  </xs:annotation>
  <xs:restriction base="xs:boolean"/>
</xs:simpleType>

<xs:simpleType name="pcellFail">
 <xs:annotation>
  <xs:documentation xml:lang="en">
   This pcell fails in OptoCompiler PyCell; reason is listed in the string.<br/>
   The BB definition needs to be fixed.
  </xs:documentation>
  </xs:annotation>
  <xs:restriction base="xs:string"/>
</xs:simpleType>

<xs:simpleType name="symbolView">
 <xs:annotation>
  <xs:documentation xml:lang="en">
   Define the symbol view to copy.<br/>
   For pcells it is handy to start with an existing <i>symbol</i> view in the OA database. Using an existing view saves errors and
   makes life easier. The default library to search in is the photonicLib; you can use the <i>symbolLibName</i> to select another
   library. Another option is to use the <i>symbolViewTemplate</i> field to create a symbol view based on a template.
  </xs:documentation>
  </xs:annotation>
  <!--<xs:restriction base="xs:QName"/>-->
  <xs:restriction base="xs:string"/>
</xs:simpleType>

<xs:simpleType name="symbolViewReorderPorts">
 <xs:annotation>
    <xs:documentation xml:lang="en">
     </xs:documentation>
  </xs:annotation>
  <!--<xs:restriction base="xs:QName"/>-->
  <xs:restriction base="xs:boolean"/>
</xs:simpleType>


<xs:simpleType name="symbolLibName">
 <xs:annotation>
  <xs:documentation xml:lang="en">
   Define the library to copy the symbol view from.<br/>
   See symbolView.
  </xs:documentation>
  </xs:annotation>
  <!--<xs:restriction base="xs:QName"/>-->
  <xs:restriction base="xs:string"/>
</xs:simpleType>

<xs:simpleType name="symbolViewTemplate">
 <xs:annotation>
  <xs:documentation xml:lang="en">
   Define the symbol view to use as basis.<br/>
   When using this field, the OptoCompiler PDK will use this shape as template and generate the symbol based on the
   pre-defined template. This is an alternative of using the <i>symbolView</i> use.
  </xs:documentation>
  </xs:annotation>
  <xs:restriction base="xs:string">
    <xs:enumeration value="Empty"/>
    <xs:enumeration value="straight"/>
    <xs:enumeration value="arc"/>
    <xs:enumeration value="Sbend"/>
    <xs:enumeration value="directionalCoupler"/>
    <xs:enumeration value="mmi1x2"/>
    <xs:enumeration value="mmi2x1"/>
    <xs:enumeration value="mmi2x2"/>
    <xs:enumeration value="mmi1x4"/>
    <xs:enumeration value="attenuator"/>
    <xs:enumeration value="heater"/>
    <xs:enumeration value="wgTerminator"/>
    <xs:enumeration value="AWG"/>
    <xs:enumeration value="connectorU"/>
    <xs:enumeration value="connectorL"/>
    <xs:enumeration value="polRotator"/>
    <xs:enumeration value="polSplitter"/>
    <xs:enumeration value="highOrderModeFilter"/>
    <xs:enumeration value="Ysplitter"/>
    <xs:enumeration value="verticalCoupler"/>
    <xs:enumeration value="2DgratingCoupler"/>
    <xs:enumeration value="edgeCoupler"/>
    <xs:enumeration value="diffractionGrating"/>
    <xs:enumeration value="braggGrating"/>
    <xs:enumeration value="strip2rib"/>
    <xs:enumeration value="rib2strip"/>
    <xs:enumeration value="taper"/>
    <xs:enumeration value="crossing"/>
    <xs:enumeration value="crossingWGRF"/>
    <xs:enumeration value="connectorStraight"/>
    <xs:enumeration value="connectorSine"/>
    <xs:enumeration value="connectorCurve"/>
    <xs:enumeration value="connectorManhattan"/>
    <xs:enumeration value="connectorManhattanFlex"/>
    <xs:enumeration value="compositeWaveguide"/>
    <xs:enumeration value="squareSpiral"/>
    <xs:enumeration value="circularSpiral"/>
    <xs:enumeration value="meanderDelay"/>
    <xs:enumeration value="tunableFilter"/>
    <xs:enumeration value="unbalancedMZI"/>
    <xs:enumeration value="modulatorEAM"/>
    <xs:enumeration value="modulatorMZI"/>
    <xs:enumeration value="modulatorPhase"/>
    <xs:enumeration value="cwLaser"/>
    <xs:enumeration value="multiWavelengthLaser"/>
    <xs:enumeration value="photodiode"/>

    <xs:enumeration value="isolation"/>
    <xs:enumeration value="reflector"/>
    <xs:enumeration value="modefilter"/>
    <xs:enumeration value="dfbLaser"/>
    <xs:enumeration value="dbrLaser"/>
    <xs:enumeration value="soa"/>
    <xs:enumeration value="polConverter"/>

    <!-- Added by Epiphany -->
    <xs:enumeration value="dieTemplate">
     <xs:annotation>
      <xs:documentation xml:lang="en">
      Use this for BBs that describe a die-template
      as (p)cell.
      </xs:documentation>
     </xs:annotation>
    </xs:enumeration>
    <xs:enumeration value="dieLogo">
     <xs:annotation>
      <xs:documentation xml:lang="en">
      Use this for BBs that describe a logo
      as (p)cell.
      </xs:documentation>
     </xs:annotation>
    </xs:enumeration>
    <xs:enumeration value="SupplierInfo">
     <xs:annotation>
      <xs:documentation xml:lang="en">
      Use this for BBs that is intended for the service supplier but can be placed by the designer. Typical examples are alignment loops, process control monitors or die-markers like cell numbers.
      </xs:documentation>
     </xs:annotation>
    </xs:enumeration>
    <xs:enumeration value="modulatorSensor">
     <xs:annotation>
      <xs:documentation xml:lang="en">
      This BB is a bio/gas/... type of sensor, normally a phase-change aspect.
      </xs:documentation>
     </xs:annotation>
    </xs:enumeration>
    <xs:enumeration value="bondpad">
     <xs:annotation>
      <xs:documentation xml:lang="en">
      This BB is an electrical IO, can be DC or RF.
      </xs:documentation>
     </xs:annotation>
    </xs:enumeration>



    </xs:restriction>

</xs:simpleType>


<xs:simpleType name="techLayerID">
 <xs:annotation>
  <xs:documentation xml:lang="en">
  Define OA-Tech ID.<br/>
  The OA Tech file needs to have unique numbers that are PDK version constant for design migration. The default behavior is to use for <i>layer</i> definitions <i>65536*gds_number+gds_datatype</i> and for the <i>xsection</i> the value <i>10000+N</i> with N being the index in the xsection list.<br/>
  Those values are very likely to be unique per PDK, but the xsection numbers are unlikely to be PDK version constant (adding or removing xsection's will fail this).<br/>
  You can overrule the Tech ID with this field; the range is 256-10000 to avoid overlapping the default range. The number is free within this range, but as guideline:
  <ul>
   <li><b>1000 - 1999</b> use this range for optical layers</li>
   <li><b>2000 - 2999</b> use this range for electrical layers</li>
   <li><b>3000 - 3999</b> use this range for mask annotations</li>
   <li><b>4000 - 4999</b> use this range for LVS recognition</li>
  </ul>
  </xs:documentation>
  </xs:annotation>
  <xs:restriction base="xs:int">
    <xs:minInclusive value="256"/>
    <xs:maxInclusive value="10000"/>
  </xs:restriction>
</xs:simpleType>

<xs:complexType name="techLayerConnection">
 <xs:annotation>
  <xs:documentation xml:lang="en">
  Define OA-Tech layer connection.<br/>
  This field can be used to link <i>layer</i>s and/or <i>xsection</i>s; this tells that routing-wise ('design intent') they are directly connecting, possibly with a <i>byLayer</i> value.<br/>
  You can define the connection in either layer/xsection, no need to define it twice.<br/>
  For layer/xsection's that connect to more than one, define them from one layer, otherwise multiple lines will be written in the tech file.<br/>
  Only use this for layers that have at least one of techLayerRouting='true' or techIncludeElectricalTag='true'.
  </xs:documentation>
 </xs:annotation>
 <xs:simpleContent>
  <xs:extension base="xs:string">
   <xs:attribute name="byLayer" use="optional" type="xs:string">
    <xs:annotation>
     <xs:documentation xml:lang="en">
     Define a byLayer, see OA-Tech docu.
     </xs:documentation>
    </xs:annotation>
   </xs:attribute>
  </xs:extension>
 </xs:simpleContent>
</xs:complexType>


<xs:simpleType name="maskNumber">
 <xs:annotation>
  <xs:documentation xml:lang="en">
  Define tech maskNumber.<br/>
  This number somewhat reflects the layerstack and is used in LVS. The lower numbers should be the lower layers in the chip. The range does not need to be continous.
  </xs:documentation>
  </xs:annotation>
  <xs:restriction base="xs:int">
    <xs:minInclusive value="0"/>
    <xs:maxInclusive value="10000"/>
  </xs:restriction>
</xs:simpleType>


<xs:simpleType name="mcsAnnotateWaveguide">
 <xs:annotation>
  <xs:documentation xml:lang="en">MCS annotation to specify this xsection/layer/applayer is marking all waveguides.<br/>
  This information is intended for Layout-vs-Schematic (LVS) with ICvalidator in OptoCompiler.
</xs:documentation>
  </xs:annotation>
  <xs:restriction base="xs:boolean"/>
</xs:simpleType>


</xs:schema>
