<?xml version="1.0" encoding="UTF-8"?>
<!--
// Description : component.xsd
// Author: The SPIRIT Consortium Schema Working Group
// Version:     $Revision: 1120 $
// Date:        $Date: 2008-01-30 13:32:31 -0800 (Wed, 30 Jan 2008) $
// Tag:         $Name$
//
// Copyright (c) 2005, 2006, 2007 The SPIRIT Consortium.  All rights reserved.
// www.spiritconsortium.org
//
// THIS WORK FORMS PART OF A SPIRIT CONSORTIUM SPECIFICATION.
// USE OF THESE MATERIALS ARE GOVERNED BY
// THE LEGAL TERMS AND CONDITIONS OUTLINED IN THE SPIRIT
// SPECIFICATION DISCLAIMER AVAILABLE FROM
// www.spiritconsortium.org
//
// This source file is provided on an AS IS basis. The SPIRIT Consortium disclaims 
// ANY WARRANTY EXPRESS OR IMPLIED INCLUDING ANY WARRANTY OF
// MERCHANTABILITY AND FITNESS FOR USE FOR A PARTICULAR PURPOSE. 
// The user of the source file shall indemnify and hold The SPIRIT Consortium harmless
// from any damages or liability arising out of the use thereof or the performance or
// implementation or partial implementation of the schema.
-->
<xs:schema xmlns:spirit="http://www.spiritconsortium.org/XMLSchema/SPIRIT/1.4" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.spiritconsortium.org/XMLSchema/SPIRIT/1.4" elementFormDefault="qualified" attributeFormDefault="qualified">
    <xs:include schemaLocation="busInterface.xsd"/>
    <xs:include schemaLocation="identifier.xsd"/>
    <xs:include schemaLocation="generator.xsd"/>
    <xs:include schemaLocation="commonStructures.xsd"/>
    <xs:include schemaLocation="model.xsd"/>
    <xs:include schemaLocation="subInstances.xsd"/>
    <xs:include schemaLocation="constraints.xsd"/>
    <xs:complexType name="componentType">
        <xs:annotation>
            <xs:documentation>Component-specific extension to componentType</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:group ref="spirit:versionedIdentifier"/>
            <xs:element ref="spirit:busInterfaces" minOccurs="0"/>
            <xs:element ref="spirit:channels" minOccurs="0"/>
            <xs:element ref="spirit:remapStates" minOccurs="0"/>
            <xs:element ref="spirit:addressSpaces" minOccurs="0"/>
            <xs:element ref="spirit:memoryMaps" minOccurs="0"/>
            <xs:element ref="spirit:model" minOccurs="0"/>
            <xs:element ref="spirit:componentGenerators" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>Generator list is tools-specific.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element ref="spirit:choices" minOccurs="0"/>
            <xs:element ref="spirit:fileSets" minOccurs="0"/>
            <xs:element name="whiteboxElements" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>A list of whiteboxElements</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="whiteboxElement" type="spirit:whiteboxElementType" maxOccurs="unbounded">
                            <xs:annotation>
                                <xs:documentation>A whiteboxElement is a useful way to identify elements of a component that can not be identified through other means such as internal signals and non-software accessible registers.</xs:documentation>
                            </xs:annotation>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="cpus" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>cpu's in the component</xs:documentation>
                </xs:annotation>
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="cpu" maxOccurs="unbounded">
                            <xs:annotation>
                                <xs:documentation>Describes a processor in this component.</xs:documentation>
                            </xs:annotation>
                            <xs:complexType>
                                <xs:sequence>
                                    <xs:group ref="spirit:nameGroup">
                                        <xs:annotation>
                                            <xs:documentation>The name of the cpu instance relative to the platform core.</xs:documentation>
                                        </xs:annotation>
                                    </xs:group>
                                    <xs:element ref="spirit:addressSpaceRef" maxOccurs="unbounded">
                                        <xs:annotation>
                                            <xs:documentation>Indicates which address space maps into this cpu.</xs:documentation>
                                        </xs:annotation>
                                    </xs:element>
                                    <xs:element ref="spirit:parameters" minOccurs="0">
                                        <xs:annotation>
                                            <xs:documentation>Data specific to the cpu.</xs:documentation>
                                        </xs:annotation>
                                    </xs:element>
                                    <xs:element ref="spirit:vendorExtensions" minOccurs="0"/>
                                </xs:sequence>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="otherClockDrivers" type="spirit:otherClocks" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>Defines a set of clock drivers that are not directly associated with an input port of the component.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="description" type="xs:string" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>String for describing the component to users</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element ref="spirit:parameters" minOccurs="0"/>
            <xs:element ref="spirit:vendorExtensions" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
    <xs:element name="component" type="spirit:componentType">
        <xs:annotation>
            <xs:documentation>This is the root element for all non platform-core components.</xs:documentation>
        </xs:annotation>
        <xs:key name="interfaceKey">
            <xs:selector xpath="spirit:busInterfaces/spirit:busInterface"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:keyref name="interfaceRef" refer="spirit:interfaceKey">
            <xs:selector xpath="spirit:busInterfaces/spirit:busInterface/spirit:slave/spirit:bridge"/>
            <xs:field xpath="@spirit:masterRef"/>
        </xs:keyref>
        <xs:keyref name="channelInterfaceRef" refer="spirit:interfaceKey">
            <xs:selector xpath="spirit:channels/spirit:channel/spirit:busInterfaceRef"/>
            <xs:field xpath="."/>
        </xs:keyref>
        <xs:keyref name="localSubspaceMapRef" refer="spirit:interfaceKey">
            <xs:selector xpath="spirit:addressSpaces/spirit:addressSpace/spirit:localMemoryMap/spirit:subspaceMap"/>
            <xs:field xpath="@spirit:masterRef"/>
        </xs:keyref>
        <xs:key name="addressSpaceKey">
            <xs:selector xpath="spirit:addressSpaces/spirit:addressSpace"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:keyref name="addressSpaceRef" refer="spirit:addressSpaceKey">
            <xs:selector xpath=".//spirit:addressSpaceRef"/>
            <xs:field xpath="@spirit:addressSpaceRef"/>
        </xs:keyref>
        <xs:key name="memoryMapKey">
            <xs:selector xpath="spirit:memoryMaps/spirit:memoryMap"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:keyref name="memoryMapRef" refer="spirit:memoryMapKey">
            <xs:selector xpath=".//spirit:memoryMapRef"/>
            <xs:field xpath="@spirit:memoryMapRef"/>
        </xs:keyref>
        <xs:unique name="cpuNameConstraint">
            <xs:selector xpath="spirit:cpu"/>
            <xs:field xpath="spirit:name"/>
        </xs:unique>
        <xs:key name="componentChoiceKey">
            <xs:selector xpath="spirit:choices/spirit:choice"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:keyref name="componentChoiceRef" refer="spirit:componentChoiceKey">
            <xs:selector xpath=".//*"/>
            <xs:field xpath="@spirit:choiceRef"/>
        </xs:keyref>
        <xs:key name="componentViewKey">
            <xs:selector xpath="spirit:model/spirit:views/spirit:view"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:keyref name="componentTypeDefViewNameRef" refer="spirit:componentViewKey">
            <xs:selector xpath=".//spirit:viewNameRef"/>
            <xs:field xpath="."/>
        </xs:keyref>
        <xs:key name="fileSetKey">
            <xs:selector xpath=".//spirit:fileSet"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:keyref name="fileSetRef" refer="spirit:fileSetKey">
            <xs:selector xpath=".//spirit:fileSetRef"/>
            <xs:field xpath="."/>
        </xs:keyref>
        <xs:key name="remapStateKey">
            <xs:selector xpath="spirit:remapStates/spirit:remapState"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:keyref name="remapStateRef" refer="spirit:remapStateKey">
            <xs:selector xpath="spirit:memoryMaps/spirit:memoryMap/spirit:memoryRemap"/>
            <xs:field xpath="@spirit:state"/>
        </xs:keyref>
        <xs:keyref name="remapStateRefMS" refer="spirit:remapStateKey">
            <xs:selector xpath="spirit:busInterfaces/spirit:busInterface/mirroredSlave/spirit:baseAddresses/spirit:remapAddress"/>
            <xs:field xpath="@spirit:state"/>
        </xs:keyref>
        <xs:key name="portKey">
            <xs:selector xpath="spirit:model/spirit:ports/spirit:port"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:keyref name="portRef" refer="spirit:portKey">
            <xs:selector xpath="spirit:busInterfaces/spirit:busInterface/spirit:portMaps/spirit:portMap/spirit:physicalPort/spirit:name"/>
            <xs:field xpath="."/>
        </xs:keyref>
        <xs:keyref name="remapStatePortRef" refer="spirit:portKey">
            <xs:selector xpath="spirit:remapStates/spirit:remapState/spirit:remapPort"/>
            <xs:field xpath="@spirit:portNameRef"/>
        </xs:keyref>
        <xs:key name="whiteboxKey">
            <xs:selector xpath="spirit:whiteboxElements/spirit:whiteboxElement"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:keyref name="whiteboxRef" refer="spirit:whiteboxKey">
            <xs:selector xpath="spirit:model/spirit:views/spirit:view/spirit:whiteboxElementRefs/spirit:whiteBoxElementRef"/>
            <xs:field xpath="@spirit:name"/>
        </xs:keyref>
        <xs:key name="addressBlockKey">
            <xs:selector xpath=".//spirit:addressBlock"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:key name="memoryRemapKey">
            <xs:selector xpath=".//spirit:memoryRemap"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:key name="localMemoryMapKey">
            <xs:selector xpath=".//spirit:localMemoryMap"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:key name="bankKey">
            <xs:selector xpath=".//spirit:bank"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:key name="subspaceMapKey">
            <xs:selector xpath=".//spirit:subspaceMap"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:key name="componentGeneratorKey">
            <xs:selector xpath="spirit:componentGenerators/spirit:componentGenerator"/>
            <xs:field xpath="spirit:name"/>
        </xs:key>
        <xs:keyref name="componentGeneratorRef" refer="spirit:componentGeneratorKey">
            <xs:selector xpath=".//spirit:generatorRef"/>
            <xs:field xpath="."/>
        </xs:keyref>
    </xs:element>
    <xs:complexType name="whiteboxElementType">
        <xs:annotation>
            <xs:documentation>Defines a white box reference point within the component.</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:group ref="spirit:nameGroup"/>
            <xs:element name="whiteboxType">
                <xs:annotation>
                    <xs:documentation>Indicates the type of the element. The pin and signal types refer to elements within the HDL description. The register type refers to a register in the memory map. The interface type refers to a bus interface in a lower level component definition.</xs:documentation>
                </xs:annotation>
                <xs:simpleType>
                    <xs:restriction base="xs:token">
                        <xs:enumeration value="register"/>
                        <xs:enumeration value="signal"/>
                        <xs:enumeration value="pin"/>
                        <xs:enumeration value="interface"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
            <xs:element name="driveable" type="xs:boolean" default="false" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>If true, indicates that the white box element can be driven (e.g. have a new value forced into it).</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="registerRef" type="xs:string" minOccurs="0">
                <xs:annotation>
                    <xs:documentation>Indicates the name of the register associated with this white box element. The name should be a full hierarchical path from the memory map to the register, using '/' as a hierarchy separator.  When specified, the whiteboxType must be 'register'.</xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element ref="spirit:parameters" minOccurs="0"/>
            <xs:element ref="spirit:vendorExtensions" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>
