add uxsdcxx

This commit is contained in:
Lin 2024-10-08 11:21:04 +08:00
parent be3546f7e3
commit 1ba3298dbe
3 changed files with 102 additions and 3 deletions

View File

@ -35,10 +35,10 @@ find_program(WGET wget REQUIRED)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
# Add Java schema # Add Java schema
set(JAVA_SCHEMA ${CMAKE_CURRENT_BINARY_DIR}/../../vtr-verilog-to-routing/libs/libvtrcapnproto/schema/capnp/java.capnp) set(JAVA_SCHEMA ${CMAKE_CURRENT_BINARY_DIR}/schema/capnp/java.capnp)
add_custom_command( add_custom_command(
OUTPUT ${JAVA_SCHEMA} OUTPUT ${JAVA_SCHEMA}
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/../../vtr-verilog-to-routing/libs/libvtrcapnproto/schema/capnp/ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/schema/capnp/
COMMAND ${WGET} COMMAND ${WGET}
https://raw.githubusercontent.com/capnproto/capnproto-java/master/compiler/src/main/schema/capnp/java.capnp https://raw.githubusercontent.com/capnproto/capnproto-java/master/compiler/src/main/schema/capnp/java.capnp
-O ${JAVA_SCHEMA} -O ${JAVA_SCHEMA}
@ -46,7 +46,7 @@ add_custom_command(
set(CAPNPC_IMPORT_DIRS) set(CAPNPC_IMPORT_DIRS)
list(APPEND CAPNPC_IMPORT_DIRS ${CMAKE_CURRENT_BINARY_DIR}/../../vtr-verilog-to-routing/libs/libvtrcapnproto/schema) list(APPEND CAPNPC_IMPORT_DIRS ${CMAKE_CURRENT_BINARY_DIR}/schema)
set(IC_PROTOS) set(IC_PROTOS)
set(IC_SRCS) set(IC_SRCS)
@ -88,3 +88,21 @@ target_link_libraries(libopenfpgacapnproto
libopenfpgautil libopenfpgautil
CapnProto::capnp CapnProto::capnp
) )
add_custom_target(
generate_unique_block_capnp
COMMAND ${CMAKE_COMMAND} -E remove_directory unique_blocks_capnproto_generate
COMMAND ${CMAKE_COMMAND} -E make_directory unique_blocks_capnproto_generate
COMMAND ${CMAKE_COMMAND} -E chdir unique_blocks_capnproto_generate git clone https://github.com/duck2/uxsdcxx
COMMAND python3 -mpip install --user -r unique_blocks_capnproto_generate/uxsdcxx/requirements.txt
COMMAND ${CMAKE_COMMAND} -E chdir unique_blocks_capnproto_generate python3 uxsdcxx/uxsdcxx.py ${CMAKE_CURRENT_SOURCE_DIR}/gen/unique_blocks.xsd
COMMAND ${CMAKE_COMMAND} -E copy
unique_blocks_capnproto_generate/unique_blocks_uxsdcxx.h
unique_blocks_capnproto_generate/unique_blocks_uxsdcxx_capnp.h
unique_blocks_capnproto_generate/unique_blocks_uxsdcxx_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/gen
COMMAND ${CMAKE_COMMAND} -E copy unique_blocks_capnproto_generate/unique_blocks_uxsdcxx.capnp ${CMAKE_CURRENT_SOURCE_DIR}/gen
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen/unique_blocks.xsd
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

View File

@ -0,0 +1,81 @@
<?xml version="1.0"?>
<!--
Copyright 2018 Jeppe Johansen
XML 1.0 Schema for unique blocks data structure developed based on documentation here:
-->
<!--
The root of the XSD file is the xs:schema. With the xs:schema are 3 types
relevant to the code generated:
- xs:complexType : This defines a child tag within the schema. Most of the
schema is made of these.
- xs:simpleType : These define string enumerations (e.g. the "switch" tag
"type" enumeration).
- xs:element : There is one xs:element that is the direct child of the root
xs:schema, and this the definition of the root tag.
In addition to being used for code generation, this schema can be used to
validate whether an unique block XML conforms to this schema.
Additional documentation is available at
https://github.com/duck2/uxsdcxx/blob/master/README.md
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Enumeration for BlockType -->
<xs:simpleType name="BlockType">
<xs:restriction base="xs:string">
<xs:enumeration value="cbx"/>
<xs:enumeration value="cby"/>
<xs:enumeration value="sb"/>
</xs:restriction>
</xs:simpleType>
<!-- BlockInfo Structure -->
<xs:complexType name="BlockInfo">
<xs:sequence>
<xs:element name="type" type="BlockType"/>
<xs:element name="x" type="xs:unsignedInt"/>
<xs:element name="y" type="xs:unsignedInt"/>
</xs:sequence>
</xs:complexType>
<!-- InstanceInfo Structure -->
<xs:complexType name="InstanceInfo">
<xs:sequence>
<xs:element name="x" type="xs:unsignedInt"/>
<xs:element name="y" type="xs:unsignedInt"/>
</xs:sequence>
</xs:complexType>
<!-- UniqueBlockPacked Structure -->
<xs:complexType name="UniqueBlockPacked">
<xs:sequence>
<xs:element name="blockInfo" type="BlockInfo"/>
<xs:element name="instanceList">
<xs:complexType>
<xs:sequence>
<xs:element name="instance" type="InstanceInfo" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType> <!-- A list of IncetanceInfo -->
</xs:element>
</xs:sequence>
</xs:complexType>
<!-- UniqueBlockCompactInfo Structure -->
<xs:complexType name="UniqueBlockCompactInfo">
<xs:sequence>
<xs:element name="atomInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="uniqueBlockPacked" type="UniqueBlockPacked" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType> <!-- A list of uniqueBlockPacked -->
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:schema>