summaryrefslogtreecommitdiffstats
path: root/interchange/LogicalNetlist.capnp
blob: eba0feb2b439731a5a8caf73a462a12bb467f28c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Copyright 2020-2021 Xilinx, Inc. and Google, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

@0xcb2ccd67aa912967;
using Java = import "/capnp/java.capnp";
using Ref = import "References.capnp";
$Java.package("com.xilinx.rapidwright.interchange");
$Java.outerClassname("LogicalNetlist");

using Cxx = import "/capnp/c++.capnp";
$Cxx.namespace("LogicalNetlist");

struct HashSet {
    type  @0 : Ref.ImplementationType = enumerator;
    hide  @1 : Bool = true;
}
annotation hashSet(*) :HashSet;

struct StringRef {
    type  @0 :Ref.ReferenceType = rootValue;
    field @1 :Text = "strList";
}
annotation stringRef(*) :StringRef;
using StringIdx = UInt32;

struct PortRef {
    type  @0 :Ref.ReferenceType = parent;
    field @1 :Text = "portList";
    depth @2 :Int32 = 1;
}
annotation portRef(*) :PortRef;
using PortIdx = UInt32;

struct CellRef {
    type  @0 :Ref.ReferenceType = parent;
    field @1 :Text = "cellDecls";
    depth @2 :Int32 = 1;
}
annotation cellRef(*) :CellRef;
using CellIdx = UInt32;

struct InstRef {
    type  @0 :Ref.ReferenceType = parent;
    field @1 :Text = "instList";
    depth @2 :Int32 = 1;
}
annotation instRef(*) :InstRef;
using InstIdx = UInt32;

struct Netlist {

  name      @0 : Text;
  propMap   @1 : PropertyMap;
  strList   @2 : List(Text) $hashSet();
  portList  @3 : List(Port);
  cellDecls @4 : List(CellDeclaration);
  topInst   @5 : CellInstance;
  instList  @6 : List(CellInstance);
  cellList  @7 : List(Cell);

  struct CellDeclaration {
    name     @0 : StringIdx $stringRef();
    propMap  @1 : PropertyMap;
    view     @2 : StringIdx $stringRef();
    lib      @3 : StringIdx $stringRef();
    ports    @4 : List(PortIdx) $portRef();
  }

  struct CellInstance {
    name     @0 : StringIdx $stringRef();
    propMap  @1 : PropertyMap;
    view     @2 : StringIdx $stringRef();
    cell     @3 : CellIdx $cellRef();
  }

  struct Cell {
    index   @0 : CellIdx $cellRef();
    insts   @1 : List(InstIdx) $instRef();
    nets    @2 : List(Net);
  }

  struct Net {
    name      @0 : StringIdx $stringRef();
    propMap   @1 : PropertyMap;
    portInsts @2 : List(PortInstance);
  }

  struct Port {
    name     @0 : StringIdx $stringRef();
    dir      @1 : Direction;
    propMap  @2 : PropertyMap;
    union {
      bit @3 : Void;
      bus @4 : Bus;
    }
  }

  enum Direction {
    input  @0;
    output @1;
    inout  @2;
  }

  struct Bus {
    busStart @0 : UInt32;
    busEnd   @1 : UInt32;
  }

  struct PortInstance {
    port  @0 : PortIdx $portRef(depth = 3);
    busIdx : union {
        singleBit @1 : Void; # Single bit
        idx       @2 : UInt32; # Index within bussed port
    }
    union {
      extPort     @3 : Void;
      inst        @4 : InstIdx $instRef(depth = 3);
    }
  }

  # Arbitrary length bitstring, encoded into array of uint8.
  #
  # width is the width of the bitstring in number of bits.
  # Data is required to ceil(width/8) elements long.
  # Bits are stored in LSB order.  Example.
  #
  # If bits is a bool vector-like, then:
  #
  # bits[0] is storage in the LSB of data[0].
  # bits[8] is storage in the LSB of data[1].
  #
  #   e.g. bit[0] === (data[0] & (1 << 0)) != 0
  #   e.g. bit[1] === (data[0] & (1 << 1)) != 0
  #   e.g. bit[7] === (data[0] & (1 << 7)) != 0
  #   e.g. bit[8] === (data[1] & (1 << 0)) != 0
  #
  struct Bitstring {
    width @0 : UInt32;
    data  @1 : List(UInt8);
  }

  struct PropertyMap {
    entries @0 : List(Entry);
    struct Entry {
      key @0 : StringIdx $stringRef();
      # Some tools may require a particular presentation.  textValue is the
      # most general, and should always be accepted.
      #
      # See DeviceResources.ParameterDefinition for potential string
      # presentations.
      union {
        textValue      @1 : StringIdx $stringRef();
        intValue       @2 : Int32;
        boolValue      @3 : Bool;
        bitstringValue @4 : Bitstring;
      }
    }
  }
}