add xsd file and modified cmakelist

This commit is contained in:
Lin 2024-10-08 16:26:35 +08:00
parent 1ba3298dbe
commit f0a9ca8b02
5 changed files with 29 additions and 98 deletions

View File

@ -44,6 +44,10 @@ add_custom_command(
-O ${JAVA_SCHEMA}
)
add_custom_target(
get_java_capnp_schema_openfpga
DEPENDS ${JAVA_SCHEMA}
)
set(CAPNPC_IMPORT_DIRS)
list(APPEND CAPNPC_IMPORT_DIRS ${CMAKE_CURRENT_BINARY_DIR}/schema)
@ -76,7 +80,9 @@ add_library(libopenfpgacapnproto STATIC
add_dependencies(libopenfpgacapnproto
get_java_capnp_schema)
get_java_capnp_schema_openfpga
generate_unique_block_capnp
)
target_include_directories(libopenfpgacapnproto PUBLIC
@ -97,7 +103,7 @@ add_custom_target(
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
COMMAND ${CMAKE_COMMAND} -E chdir unique_blocks_capnproto_generate python3 uxsdcxx/uxsdcap.py ${CMAKE_CURRENT_SOURCE_DIR}/gen/unique_blocks.xsd
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

View File

@ -1,30 +1,6 @@
<?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">
@ -34,48 +10,35 @@
</xs:restriction>
</xs:simpleType>
<!-- BlockInfo Structure -->
<!-- BlockInfo Structure (using attributes for type, x, and y) -->
<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:attribute name="type" type="BlockType"/>
<xs:attribute name="x" type="xs:unsignedInt"/>
<xs:attribute name="y" type="xs:unsignedInt"/>
</xs:complexType>
<!-- InstanceInfo Structure -->
<!-- InstanceInfo Structure (using attributes for x and y) -->
<xs:complexType name="InstanceInfo">
<xs:sequence>
<xs:element name="x" type="xs:unsignedInt"/>
<xs:element name="y" type="xs:unsignedInt"/>
</xs:sequence>
<xs:attribute name="x" type="xs:unsignedInt"/>
<xs:attribute name="y" type="xs:unsignedInt"/>
</xs:complexType>
<!-- UniqueBlockPacked Structure -->
<!-- UniqueBlockPacked Structure (blockInfo as element, instance list as sequence) -->
<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:element name="instance" type="InstanceInfo" maxOccurs="unbounded"/>
</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>
<!-- Root element definition combined with UniqueBlockCompactInfo structure -->
<xs:element name="unique_blocks">
<xs:complexType>
<xs:sequence>
<!-- Directly include atomInfo (previously part of UniqueBlockCompactInfo) -->
<xs:element name="atomInfo" type="UniqueBlockPacked" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@ -1,38 +0,0 @@
# This file is generated by uxsdcap 0.1.0.
# https://github.com/duck2/uxsdcxx
# Modify only if your build process doesn't involve regenerating this file.
#
# Cmdline: /home/talaeikh/uxsdcxx/uxsdcap.py /home/talaeikh/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd
# Input file: /home/talaeikh/vtr-verilog-to-routing/libs/librrgraph/src/io/rr_graph.xsd
# md5sum of input file: 9c14a0ddd3c6bc1e690ca6abf467bae6
@0xa136dddfdd48783b;
using Cxx = import "/capnp/c++.capnp";
$Cxx.namespace("uniqueblockcap");
enum BlockType {
cbx @0;
cby @1;
sb @2;
}
struct BlockInfo {
type @0: BlockType;
x @1: UInt32;
y @2: UInt32;
}
struct InstanceInfo {
x @0: UInt32;
y @1: UInt32;
}
struct UniqueBlockPacked {
blockInfo @0: BlockInfo;
instanceList @1: List(InstanceInfo);
}
struct UniqueBlockCompactInfo {
atomInfo @0: List(UniqueBlockPacked);
}

View File

@ -196,7 +196,7 @@ int read_bin_unique_blocks(DeviceRRGSB& device_rr_gsb, const char* file_name,
device_rr_gsb.reserve_unique_modules();
MmapFile f(file_name);
::capnp::FlatArrayMessageReader reader(f.getData());
auto root = reader.getRoot<uniqueblockcap::UniqueBlockCompactInfo>();
auto root = reader.getRoot<uniqueblockcap::UniqueBlocks>();
if (root.hasAtomInfo()) {
auto block_list = root.getAtomInfo();
for (auto unique_block : block_list) {

View File

@ -212,7 +212,7 @@ int write_bin_unique_blocks(const DeviceRRGSB& device_rr_gsb, const char* fname,
bool verbose_output) {
::capnp::MallocMessageBuilder builder;
auto unique_blocks =
builder.initRoot<uniqueblockcap::UniqueBlockCompactInfo>();
builder.initRoot<uniqueblockcap::UniqueBlocks>();
int num_unique_blocks = device_rr_gsb.get_num_sb_unique_module() +
device_rr_gsb.get_num_cb_unique_module(CHANX) +
device_rr_gsb.get_num_cb_unique_module(CHANY);