aboutsummaryrefslogtreecommitdiff
path: root/src/main/proto/firrtl.proto
blob: 6ce1c10822456ccaca257a65e387323fb03107d4 (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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
// SPDX-License-Identifier: Apache-2.0

syntax = "proto3";

package firrtl;

option java_package = "firrtl";
option java_outer_classname = "FirrtlProtos";

message Firrtl {
  repeated Circuit circuit = 1;

  message SourceInfo {
    message None {
      enum Reason {
        NONE_SOURCE_INFO_REASON_UNKNOWN = 0;
        NONE_SOURCE_INFO_REASON_UNLOCATABLE = 1;
        NONE_SOURCE_INFO_REASON_SUPPRESSED = 2;
        NONE_SOURCE_INFO_REASON_DEPRECATED = 3;
      }

      // Required.
      Reason reason = 1;
    }

    message Position {
      // Required.
      string filename = 1;
      // Required.
      uint32 line = 2;
      // Required.
      uint32 column = 3;
    }

    // Required.
    oneof source_info {
      None none = 1;
      Position position = 2;
      string text = 3;
    }
  }

  message BigInt {
    // 2's complement binary representation
    bytes value = 1;
  }

  message Top {
    // Required.
    string name = 1;
  }

  message Circuit {
    repeated Module module = 1;
    repeated Top top = 2;
  }

  message Module {
    message ExternalModule {
      message Parameter {
        string id = 1;
        oneof value {
          BigInt integer = 2;
          double double = 3;
          string string = 4;
          string raw_string = 5;
        }
      }
      // Required.
      string id = 1;
      repeated Port port = 2;
      string defined_name = 3;
      repeated Parameter parameter = 4;
    }

    message UserModule {
      // Required.
      string id = 1;
      repeated Port port = 2;
      repeated Statement statement = 3;
    }

    // Required.
    oneof module {
      ExternalModule external_module = 1;
      UserModule user_module = 2;
    }
  }

  message Statement {
    message Wire {
      // Required.
      string id = 1;
      // Required.
      Type type = 2;
    }

    message Register {
      // Required.
      string id = 1;
      // Required.
      Type type = 2;
      // Required.
      Expression clock = 3;
      Expression reset = 4;
      Expression init = 5;
    }

    enum ReadUnderWrite {
      UNDEFINED = 0;
      OLD = 1;
      NEW = 2;
    }

    message Memory {
      // Required.
      string id = 1;
      // Required.
      Type type = 2;
      // Required.
      oneof depth {
        uint32 uint_depth = 3;
        BigInt bigint_depth = 9;
      }
      // Required.
      uint32 write_latency = 4;
      // Required.
      uint32 read_latency = 5;
      repeated string reader_id = 6;
      repeated string writer_id = 7;
      repeated string readwriter_id = 8;
      ReadUnderWrite read_under_write = 10;
    }

    message CMemory {
      // As alternative to using VectorType as type
      message TypeAndDepth {
        Type data_type = 1;
        BigInt depth = 2;
      }
      // Required.
      string id = 1;
      // Required.
      oneof type {
        Type.VectorType vector_type = 2;
        TypeAndDepth type_and_depth = 4;
      }
      // Required.
      bool sync_read = 3;
      ReadUnderWrite read_under_write = 5;
    }

    message Instance {
      // Required.
      string id = 1;
      // Required.
      string module_id = 2;
    }

    message Node {
      // Required.
      string id = 1;
      // Required.
      Expression expression = 2;
    }

    message When {
      // Required.
      Expression predicate = 1;
      repeated Statement consequent = 2;
      repeated Statement otherwise = 3;
    }

    message Stop {
      // Required.
      int32 return_value = 1;
      // Required.
      Expression clk = 2;
      // Required.
      Expression en = 3;
    }

    message Printf {
      // Required.
      string value = 1;
      repeated Expression arg = 2;
      // Required.
      Expression clk = 3;
      // Required.
      Expression en = 4;
    }

    enum Formal {
      ASSERT = 0;
      ASSUME = 1;
      COVER = 2;
    }

    message Verification {
      // Required.
      Formal op = 1;
      // Required.
      Expression clk = 2;
      // Required.
      Expression cond = 3;
      // Required.
      Expression en = 4;
      // Required.
      string msg = 5;
    }

    message Skip {
      // Empty
    }

    message Connect {
      // This should be limited to Reference, SubField, SubIndex, or SubAccess.
      // Required.
      Expression location = 1;
      // Required.
      Expression expression = 2;
    }

    message PartialConnect {
      // This should be limited to Reference, SubField, SubIndex, or SubAccess.
      // Required.
      Expression location = 1;
      // Required.
      Expression expression = 2;
    }

    message IsInvalid {
      // Required.
      Expression expression = 1;
    }

    message MemoryPort {
      enum Direction {
        MEMORY_PORT_DIRECTION_UNKNOWN = 0;
        MEMORY_PORT_DIRECTION_INFER = 1;
        MEMORY_PORT_DIRECTION_READ = 2;
        MEMORY_PORT_DIRECTION_WRITE = 3;
        MEMORY_PORT_DIRECTION_READ_WRITE = 4;
      }

      // Required.
      Direction direction = 1;
      // Required.
      string id = 2;
      // Required.
      string memory_id = 3;
      // Required.
      Expression memory_index = 4;
      // Required.
      Expression expression = 5;
    }

    message Attach {
      repeated Expression expression = 1;
    }

    // Required.
    oneof statement {
      Wire wire = 1;
      Register register = 2;
      Memory memory = 3;
      CMemory cmemory = 4;
      Instance instance = 5;
      Node node = 6;
      When when = 7;
      Stop stop = 8;
      Printf printf = 10;
      Skip skip = 14;
      Connect connect = 15;
      PartialConnect partial_connect = 16;
      IsInvalid is_invalid = 17;
      MemoryPort memory_port = 18;
      Attach attach = 20;
      Verification verification = 21;
    }

    SourceInfo source_info = 19;
  }

  // Using proto3 means that there is no has* method for primitives. This
  // necesitates boxing width values because there are cases where a width of
  // zero (the default value of uint32) is a valid width.
  message Width {
    // Required
    uint32 value = 1;
  }

  message Type {
    message UIntType {
      Width width = 1;
    }

    message SIntType {
      Width width = 1;
    }

    message ClockType {
      // Empty.
    }

    message AsyncResetType {
      // Empty.
    }

    message ResetType {
      // Empty.
    }

    message BundleType {
      message Field {
        // Required.
        bool is_flipped = 1;
        // Required.
        string id = 2;
        // Required.
        Type type = 3;
      }
      repeated Field field = 1;
    }

    message VectorType {
      // Required.
      Type type = 1;
      // Required.
      uint32 size = 2;
    }

    message FixedType {
      Width width = 1;
      Width point = 2;
    }

    message AnalogType {
      Width width = 3;
    }

    // Required.
    oneof type {
      UIntType uint_type = 2;
      SIntType sint_type = 3;
      ClockType clock_type = 4;
      BundleType bundle_type = 5;
      VectorType vector_type = 6;
      FixedType fixed_type = 7;
      AnalogType analog_type = 8;
      AsyncResetType async_reset_type = 9;
      ResetType reset_type = 10;
    }
  }

  message Port {
    enum Direction {
      PORT_DIRECTION_UNKNOWN = 0;
      PORT_DIRECTION_IN = 1;
      PORT_DIRECTION_OUT = 2;
    }

    // Required.
    string id = 1;
    // Required.
    Direction direction = 2;
    // Required.
    Type type = 3;
  }

  message Expression {
    message Reference {
      // Required.
      string id = 1;
    }

    message IntegerLiteral {
      // Base 10 value. May begin with a sign (+|-). Only zero can begin with a
      // '0'.
      // Required
      string value = 1;
    }

    message UIntLiteral {
      // Required.
      IntegerLiteral value = 1;
      Width width = 2;
    }

    message SIntLiteral {
      // Required.
      IntegerLiteral value = 1;
      Width width = 2;
    }

    message FixedLiteral {
      BigInt value = 1;
      Width width = 2;
      Width point = 3;
    }

    message ValidIf {
      // Required.
      Expression condition = 1;
      // Required.
      Expression value = 2;
    }

    message Mux {
      // Required.
      Expression condition = 1;
      // Required.
      Expression t_value = 2;
      // Required.
      Expression f_value = 3;
    }

    message SubField {
      // Required.
      Expression expression = 1;
      // Required.
      string field = 2;
    }

    message SubIndex {
      // Required.
      Expression expression = 1;
      // Required.
      IntegerLiteral index = 2;
    }

    message SubAccess {
      // Required.
      Expression expression = 1;
      // Required.
      Expression index = 2;
    }

    message PrimOp {

      enum Op {
        OP_UNKNOWN = 0;
        OP_ADD = 1;
        OP_SUB = 2;
        OP_TAIL = 3;
        OP_HEAD = 4;
        OP_TIMES = 5;
        OP_DIVIDE = 6;
        OP_REM = 7;
        OP_SHIFT_LEFT = 8;
        OP_SHIFT_RIGHT = 9;
        OP_DYNAMIC_SHIFT_LEFT = 10;
        OP_DYNAMIC_SHIFT_RIGHT = 11;
        OP_BIT_AND = 12;
        OP_BIT_OR = 13;
        OP_BIT_XOR = 14;
        OP_BIT_NOT = 15;
        OP_CONCAT = 16;
        OP_LESS = 17;
        OP_LESS_EQ = 18;
        OP_GREATER = 19;
        OP_GREATER_EQ = 20;
        OP_EQUAL = 21;
        OP_PAD = 22;
        OP_NOT_EQUAL = 23;
        OP_NEG = 24;
        OP_XOR_REDUCE = 26;
        OP_CONVERT = 27;
        OP_AS_UINT = 28;
        OP_AS_SINT = 29;
        OP_EXTRACT_BITS = 30;
        OP_AS_CLOCK = 31;
        OP_AS_FIXED_POINT = 32;
        OP_AND_REDUCE = 33;
        OP_OR_REDUCE = 34;
        OP_INCREASE_PRECISION = 35;
        OP_DECREASE_PRECISION = 36;
        OP_SET_PRECISION = 37;
        OP_AS_ASYNC_RESET = 38;
        OP_WRAP = 39;
        OP_CLIP = 40;
        OP_SQUEEZE = 41;
        OP_AS_INTERVAL = 42;
      }

      // Required.
      Op op = 1;
      repeated Expression arg = 2;
      repeated IntegerLiteral const = 3;
    }

    reserved 5;

    // Required.
    oneof expression {
      Reference reference = 1;
      UIntLiteral uint_literal = 2;
      SIntLiteral sint_literal = 3;
      FixedLiteral fixed_literal = 11;
      ValidIf valid_if = 4;
      //ExtractBits extract_bits = 5;
      Mux mux = 6;
      SubField sub_field = 7;
      SubIndex sub_index = 8;
      SubAccess sub_access = 9;
      PrimOp prim_op = 10;
    }
  }
}