-
Notifications
You must be signed in to change notification settings - Fork 317
/
Copy pathgrand-central.mlir
1065 lines (1014 loc) · 35.7 KB
/
grand-central.mlir
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
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// RUN: circt-opt -pass-pipeline='builtin.module(firrtl.circuit(firrtl-grand-central,symbol-dce))' -split-input-file %s | FileCheck %s
// This is the main test that includes different interfaces of different
// types. All the interfaces share a common, simple circuit that provides two
// RefType signals, "foo" and "bar".
firrtl.circuit "InterfaceGroundType" attributes {
annotations = [
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "GroundView",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
description = "description of foo",
name = "foo",
id = 1 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
description = "multi\nline\ndescription\nof\nbar",
name = "bar",
id = 2 : i64
}
],
id = 0 : i64,
name = "GroundView"
},
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "VectorView",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedVectorType",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "foo",
id = 4 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "bar",
id = 5 : i64
}
],
name = "vector"
}
],
id = 3 : i64,
name = "VectorView"
},
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "BundleView",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "Bundle",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "foo",
id = 7 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "bar",
id = 8 : i64
}
],
name = "bundle"
}
],
id = 6 : i64,
name = "BundleView"
},
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "VectorOfBundleView",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedVectorType",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "Bundle2",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "foo",
id = 10 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "bar",
id = 11 : i64
}
],
name = "bundle2"
}
],
name = "vector"
}
],
id = 9 : i64,
name = "VectorOfBundleView"
},
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "VectorOfVectorView",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedVectorType",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedVectorType",
defName = "Vector2",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "foo",
id = 13 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "bar",
id = 14 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "baz",
id = 15 : i64
}
],
name = "vector2"
},
{
class = "sifive.enterprise.grandcentral.AugmentedVectorType",
defName = "Vector2",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "foo",
id = 16 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "bar",
id = 17 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "baz",
id = 18 : i64
}
],
name = "vector2"
}
],
name = "vector"
}
],
id = 12 : i64,
name = "VectorOfVectorView"
},
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "ZeroWidthView",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 20 : i64,
name = "zerowidth"
}
],
id = 19 : i64,
name = "ZeroWidthView"
},
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "ConstantView",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "foo",
id = 22 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "bar",
id = 23 : i64
}
],
id = 21 : i64,
name = "ConstantView"
},
{
class = "sifive.enterprise.grandcentral.ExtractGrandCentralAnnotation",
directory = "gct-dir",
filename = "bindings.sv"
},
{
class = "sifive.enterprise.grandcentral.GrandCentralHierarchyFileAnnotation",
filename = "gct.yaml"
}
]
} {
firrtl.module @Companion() attributes {
annotations = [
{
class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
defName = "GroundView",
id = 0 : i64,
name = "GroundView"
},
{
class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
defName = "VectorView",
id = 3 : i64,
name = "VectorView"
},
{
class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
defName = "BundleView",
id = 6 : i64,
name = "BundleView"
},
{
class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
defName = "VectorOfBundleView",
id = 9 : i64,
name = "VectorOfBundleView"
},
{
class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
defName = "VectorOfVectorView",
id = 12 : i64,
name = "VectorOfVectorView"
},
{
class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
defName = "ZeroWidthView",
id = 19 : i64,
name = "ZeroWidthView"
},
{
class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
defName = "ConstantView",
id = 21 : i64,
name = "ConstantView"
}
]
} {
// These are dummy references created for the purposes of the test.
%_ui0 = firrtl.verbatim.expr "???" : () -> !firrtl.uint<0>
%_ui1 = firrtl.verbatim.expr "???" : () -> !firrtl.uint<1>
%_ui2 = firrtl.verbatim.expr "???" : () -> !firrtl.uint<2>
%ref_ui0 = firrtl.ref.send %_ui0 : !firrtl.uint<0>
%ref_ui1 = firrtl.ref.send %_ui1 : !firrtl.uint<1>
%ref_ui2 = firrtl.ref.send %_ui2 : !firrtl.uint<2>
%ui1 = firrtl.ref.resolve %ref_ui1 : !firrtl.probe<uint<1>>
%foo = firrtl.node %ui1 {
annotations = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 1 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 4 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 5 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 7 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 10 : i64
}
]
} : !firrtl.uint<1>
%ui2 = firrtl.ref.resolve %ref_ui2 : !firrtl.probe<uint<2>>
%bar = firrtl.node %ui2 {
annotations = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 2 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 8 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 11 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 13 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 14 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 15 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 16 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 17 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 18 : i64
}
]
} : !firrtl.uint<2>
%ui0 = firrtl.ref.resolve %ref_ui0 : !firrtl.probe<uint<0>>
%baz = firrtl.node %ui0 {
annotations = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 20 : i64
}
]
} : !firrtl.uint<0>
%c0_ui1 = firrtl.constant 0 : !firrtl.uint<1>
%c-1_si2 = firrtl.constant -1 : !firrtl.sint<2>
%node_c0_ui1 = firrtl.node %c0_ui1 {
annotations = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 22 : i64
}
]
} : !firrtl.uint<1>
%node_c-1_si2 = firrtl.node %c-1_si2 {
annotations = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 23 : i64
}
]
} : !firrtl.sint<2>
}
firrtl.module @InterfaceGroundType() {
firrtl.instance companion @Companion()
}
}
// All AugmentedBundleType annotations are removed from the circuit.
//
// CHECK-LABEL: firrtl.circuit "InterfaceGroundType" {{.+}} {annotations =
// CHECK-SAME: class = "sifive.enterprise.grandcentral.ExtractGrandCentralAnnotation"
// CHECK-NOT: class = "sifive.enterprise.grandcentral.AugmentedBundleType"
// CHECK-SAME: {
// Check YAML Output.
//
// Note: Built-in vector serialization works slightly differently than
// user-defined vector serialization. This results in the verbose "[ ]" for the
// empty dimensions vector, and the terse "[]" for the empty instances vector.
//
// CHECK: sv.verbatim
// CHECK-SAME: - name: GroundView
// CHECK-SAME: fields:
// CHECK-SAME: - name: foo
// CHECK-SAME: description: description of foo
// CHECK-SAME: dimensions: [ ]
// CHECK-SAME: width: 1
// CHECK-SAME: - name: bar
// CHECK-SAME: description: \22multi\\nline\\ndescription\\nof\\nbar\22
// CHECK-SAME: dimensions: [ ]
// CHECK-SAME: width: 2
// CHECK-SAME: instances: []
// CHECK-SAME: - name: VectorView
// CHECK-SAME: fields:
// CHECK-SAME: - name: vector
// CHECK-SAME: dimensions: [ 2 ]
// CHECK-SAME: width: 1
// CHECK-SAME: instances: []
// CHECK-SAME: - name: BundleView
// CHECK-SAME: fields: []
// CHECK-SAME: instances:
// CHECK-SAME: - name: bundle
// CHECK-SAME: dimensions: [ ]
// CHECK-SAME: interface:
// CHECK-SAME: name: Bundle
// CHECK-SAME: fields:
// CHECK-SAME: - name: foo
// CHECK-SAME: dimensions: [ ]
// CHECK-SAME: width: 1
// CHECK-SAME: - name: bar
// CHECK-SAME: dimensions: [ ]
// CHECK-SAME: width: 2
// CHECK-SAME: instances: []
// CHECK-SAME: - name: VectorOfBundleView
// CHECK-SAME: fields: []
// CHECK-SAME: instances:
// CHECK-SAME: - name: vector
// CHECK-SAME: dimensions: [ 1 ]
// CHECK-SAME: interface:
// CHECK-SAME: name: Bundle2
// CHECK-SAME: fields:
// CHECK-SAME: - name: foo
// CHECK-SAME: dimensions: [ ]
// CHECK-SAME: width: 1
// CHECK-SAME: - name: bar
// CHECK-SAME: dimensions: [ ]
// CHECK-SAME: width: 2
// CHECK-SAME: instances: []
// CHECK-SAME: - name: VectorOfVectorView
// CHECK-SAME: fields:
// CHECK-SAME: - name: vector
// CHECK-SAME: dimensions: [ 3, 2 ]
// CHECK-SAME: width: 2
// CHECK-SAME: instances: []
// CHECK-SAME: - name: ZeroWidthView
// CHECK-SAME: fields:
// CHECK-SAME: - name: zerowidth
// CHECK-SAME: dimensions: [ ]
// CHECK-SAME: width: 0
// CHECK-SAME: instances: []
// CHECK-SAME: - name: ConstantView
// CHECK-SAME: fields:
// CHECK-SAME: - name: foo
// CHECK-SAME: dimensions: [ ]
// CHECK-SAME: width: 1
// CHECK-SAME: - name: bar
// CHECK-SAME: dimensions: [ ]
// CHECK-SAME: width: 2
// CHECK-SAME: instances: []
// The shared companion contains all instantiated interfaces.
// AugmentedGroundType annotations are removed. Interface is driven via XMRs
// directly from ref resolve ops.
//
// CHECK: firrtl.module @Companion
// CHECK-SAME: output_file = #hw.output_file<"gct-dir{{/|\\\\}}"
//
// CHECK-NEXT: %ConstantView = sv.interface.instance sym @[[constantSym:[a-zA-Z0-9_]+]] : !sv.interface<@ConstantView>
// CHECK-NEXT: %ZeroWidthView = sv.interface.instance sym @[[zeroWidthSym:[a-zA-Z0-9_]+]] : !sv.interface<@ZeroWidthView>
// CHECK-NEXT: %VectorOfVectorView = sv.interface.instance sym @[[vectorOfVectorSym:[a-zA-Z0-9_]+]] : !sv.interface<@VectorOfVectorView>
// CHECK-NEXT: %VectorOfBundleView = sv.interface.instance sym @[[vectorOfBundleSym:[a-zA-Z0-9_]+]] : !sv.interface<@VectorOfBundleView>
// CHECK-NEXT: %BundleView = sv.interface.instance sym @[[bundleSym:[a-zA-Z0-9_]+]] : !sv.interface<@BundleView>
// CHECK-NEXT: %VectorView = sv.interface.instance sym @[[vectorSym:[a-zA-Z0-9_]+]] : !sv.interface<@VectorView>
// CHECK-NEXT: %GroundView = sv.interface.instance sym @[[groundSym:[a-zA-Z0-9_]+]] : !sv.interface<@GroundView>
//
// CHECK: %[[foo_ref:[a-zA-Z0-9_]+]] = firrtl.ref.resolve {{.+}} : !firrtl.probe<uint<1>>
// CHECK-NOT: sifive.enterprise.grandcentral.AugmentedGroundType
// CHECK: %[[bar_ref:[a-zA-Z0-9_]+]] = firrtl.ref.resolve {{.+}} : !firrtl.probe<uint<2>>
// CHECK-NOT: sifive.enterprise.grandcentral.AugmentedGroundType
//
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.foo = {{0}};"
// CHECK-SAME: (%[[foo_ref]]) : !firrtl.uint<1>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[groundSym]]>]}
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.bar = {{0}};"
// CHECK-SAME: (%[[bar_ref]]) : !firrtl.uint<2>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[groundSym]]>]}
//
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.vector[0] = {{0}};"
// CHECK-SAME: (%[[foo_ref]]) : !firrtl.uint<1>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[vectorSym]]>]}
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.vector[1] = {{0}};"
// CHECK-SAME: (%[[foo_ref]]) : !firrtl.uint<1>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[vectorSym]]>]}
//
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.bundle.foo = {{0}};"
// CHECK-SAME: (%[[foo_ref]]) : !firrtl.uint<1>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[bundleSym]]>]}
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.bundle.bar = {{0}};"
// CHECK-SAME: (%[[bar_ref]]) : !firrtl.uint<2>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[bundleSym]]>]}
//
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.vector[0].foo = {{0}};"
// CHECK-SAME: (%[[foo_ref]]) : !firrtl.uint<1>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[vectorOfBundleSym]]>]}
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.vector[0].bar = {{0}};"
// CHECK-SAME: (%[[bar_ref]]) : !firrtl.uint<2>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[vectorOfBundleSym]]>]}
//
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.vector[0][0] = {{0}};"
// CHECK-SAME: (%[[bar_ref]]) : !firrtl.uint<2>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[vectorOfVectorSym]]>]}
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.vector[0][1] = {{0}};"
// CHECK-SAME: (%[[bar_ref]]) : !firrtl.uint<2>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[vectorOfVectorSym]]>]}
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.vector[0][2] = {{0}};"
// CHECK-SAME: (%[[bar_ref]]) : !firrtl.uint<2>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[vectorOfVectorSym]]>]}
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.vector[1][0] = {{0}};"
// CHECK-SAME: (%[[bar_ref]]) : !firrtl.uint<2>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[vectorOfVectorSym]]>]}
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.vector[1][1] = {{0}};"
// CHECK-SAME: (%[[bar_ref]]) : !firrtl.uint<2>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[vectorOfVectorSym]]>]}
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.vector[1][2] = {{0}};"
// CHECK-SAME: (%[[bar_ref]]) : !firrtl.uint<2>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[vectorOfVectorSym]]>]}
//
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.foo = {{0}};"
// CHECK-SAME: (%c0_ui1) : !firrtl.uint<1>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[constantSym]]>]}
// CHECK{LITERAL}: sv.verbatim "assign {{1}}.bar = {{0}};"
// CHECK-SAME: (%c-1_si2) : !firrtl.sint<2>
// CHECK-SAME: {symbols = [#hw.innerNameRef<@Companion::@[[constantSym]]>]}
//
// There are no more verbatim assigns after this.
// Zero-width views are not given XMR's.
//
// CHECK-NOT: sv.verbatim "assign
// The companion instance is marked "lowerToBind" in the parent. This instance
// gets the correct output file.
//
// CHECK: firrtl.module @InterfaceGroundType()
// CHECK: firrtl.instance companion
// CHECK-SAME: lowerToBind
// CHECK-SAME: output_file = #hw.output_file<"bindings.sv", excludeFromFileList>}
// The body of all interfaces are populated with the correct signals, names,
// comments, and types.
//
// CHECK: sv.interface @GroundView
// CHECK-SAME: comment = "VCS coverage exclude_file"
// CHECK-SAME: output_file = #hw.output_file<"gct-dir{{/|\\\\}}"
// CHECK-NEXT: sv.verbatim "// description of foo"
// CHECK-NEXT: sv.interface.signal @foo : i1
// CHECK-NEXT: sv.verbatim "// multi\0A// line\0A// description\0A// of\0A// bar"
// CHECK-NEXT: sv.interface.signal @bar : i2
//
// CHECK: sv.interface @VectorView
// CHECK-NEXT: sv.interface.signal @vector : !hw.uarray<2xi1>
//
// CHECK: sv.interface @BundleView
// CHECK-NEXT: sv.verbatim "Bundle bundle();"
//
// CHECK: sv.interface @Bundle
// CHECK-NEXT: sv.interface.signal @foo : i1
// CHECK-NEXT: sv.interface.signal @bar : i2
//
// CHECK: sv.interface @VectorOfBundleView
// CHECK-NEXT: sv.verbatim "Bundle2 vector[1]();"
//
// CHECK: sv.interface @Bundle2
// CHECK-NEXT: sv.interface.signal @foo : i1
// CHECK-NEXT: sv.interface.signal @bar : i2
//
// CHECK: sv.interface @VectorOfVectorView
// CHECK-NEXT: sv.interface.signal @vector : !hw.uarray<2xuarray<3xi2>>
//
// CHECK: sv.interface @ZeroWidthView
// CHECK-NEXT: sv.interface.signal @zerowidth : i0
//
// CHECK: sv.interface @ConstantView
// CHECK-NEXT: sv.interface.signal @foo : i1
// CHECK-NEXT: sv.interface.signal @bar : i2
// -----
firrtl.circuit "DirectoryBehaviorWithDUT" attributes {
annotations = [
{class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "Foo",
elements = [],
id = 0 : i64,
name = "View"},
{class = "sifive.enterprise.grandcentral.ExtractGrandCentralAnnotation",
directory = "gct-dir",
filename = "bindings.sv"}]} {
// Each of these modules is instantiated in a different location. A leading
// "E" indicates that this is an external module. A leading "M" indicates
// that this is a module. The instantiation location is indicated by three
// binary bits with an "_" indicating the absence of instantiation:
// 1) "T" indicates this is instantiated in the "Top" (above the DUT)
// 2) "D" indicates this is instantiated in the "DUT"
// 3) "C" indicates this is instantiated in the "Companion"
// E.g., "ET_C" is an external module instantiated above the DUT and in the
// Companion.
firrtl.module @MT__() {}
firrtl.module @M_D_() {}
firrtl.module @M__C() {}
firrtl.module @MTD_() {}
firrtl.module @M_DC() {}
firrtl.module @MT_C() {}
firrtl.module @MTDC() {}
firrtl.extmodule @ET__() attributes {annotations = [
{class = "firrtl.transforms.BlackBoxInlineAnno", name = "ET__.v", text = ""}
]}
firrtl.extmodule @E_D_() attributes {annotations = [
{class = "firrtl.transforms.BlackBoxInlineAnno", name = "E_D_.v", text = ""}
]}
firrtl.extmodule @E__C() attributes {annotations = [
{class = "firrtl.transforms.BlackBoxInlineAnno", name = "E__C.v", text = ""}
]}
firrtl.extmodule @ETD_() attributes {annotations = [
{class = "firrtl.transforms.BlackBoxInlineAnno", name = "ETD_.v", text = ""}
]}
firrtl.extmodule @E_DC() attributes {annotations = [
{class = "firrtl.transforms.BlackBoxInlineAnno", name = "E_DC.v", text = ""}
]}
firrtl.extmodule @ET_C() attributes {annotations = [
{class = "firrtl.transforms.BlackBoxInlineAnno", name = "ET_C.v", text = ""}
]}
firrtl.extmodule @ETDC() attributes {annotations = [
{class = "firrtl.transforms.BlackBoxInlineAnno", name = "ETDC.v", text = ""}
]}
// The Grand Central Companion module.
firrtl.module private @Companion() attributes {
annotations = [
{class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
defName = "Foo",
id = 0 : i64,
name = "View"}]} {
firrtl.instance m__c @M__C()
firrtl.instance m_dc @M_DC()
firrtl.instance mt_c @MT_C()
firrtl.instance mtdc @MTDC()
firrtl.instance e__c @E__C()
firrtl.instance e_dc @E_DC()
firrtl.instance et_c @ET_C()
firrtl.instance etdc @ETDC()
}
// The Design-under-test as indicated by the MarkDUTAnnotation
firrtl.module private @DUT() attributes {
annotations = [
{class = "sifive.enterprise.firrtl.MarkDUTAnnotation"}
]
} {
firrtl.instance companion @Companion()
firrtl.instance m_d_ @M_D_()
firrtl.instance mtd_ @MTD_()
firrtl.instance m_dc @M_DC()
firrtl.instance mtdc @MTDC()
firrtl.instance e_d_ @E_D_()
firrtl.instance etd_ @ETD_()
firrtl.instance e_dc @E_DC()
firrtl.instance etdc @ETDC()
}
// The Top module that instantiates the DUT
firrtl.module @DirectoryBehaviorWithDUT() {
firrtl.instance dut @DUT()
firrtl.instance mt__ @MT__()
firrtl.instance mtd_ @MTD_()
firrtl.instance mt_c @MT_C()
firrtl.instance mtdc @MTDC()
firrtl.instance et__ @ET__()
firrtl.instance etd_ @ETD_()
firrtl.instance et_c @ET_C()
firrtl.instance etdc @ETDC()
}
}
// Any module instantiated by the Companion, but not instantiated by the DUT is
// moved to the same directory as the Companion. I.e., only "*__C" and "*T_C"
// modules should be moved into the "gct-dir".
//
// CHECK-LABEL: "DirectoryBehaviorWithDUT"
//
// CHECK-NOT: output_file
// CHECK: firrtl.module @M__C
// CHECK-SAME: output_file = #hw.output_file<"gct-dir{{/|\\\\}}"
// CHECK-NOT: output_file
// CHECK: firrtl.module @MT_C
// CHECK-SAME: output_file = #hw.output_file<"gct-dir{{/|\\\\}}"
//
// CHECK-NOT: output_file
// CHECK: firrtl.extmodule @E__C
// CHECK-SAME: output_file = #hw.output_file<"gct-dir{{/|\\\\}}">
// CHECK-NOT: output_file
// CHECK: firrtl.extmodule @ET_C
// CHECK-SAME: output_file = #hw.output_file<"gct-dir{{/|\\\\}}">
// CHECK-NOT: output_file
//
// CHECK: firrtl.module
// -----
firrtl.circuit "DirectoryBehaviorWithoutDUT" attributes {
annotations = [
{class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "Foo",
elements = [],
id = 0 : i64,
name = "View"},
{class = "sifive.enterprise.grandcentral.ExtractGrandCentralAnnotation",
directory = "gct-dir",
filename = "bindings.sv"}]} {
// Each of these modules is instantiated in a different location. A leading
// "E" indicates that this is an external module. A leading "M" indicates
// that this is a module. The instantiation location is indicated by three
// binary bits with an "_" indicating the absence of instantiation:
// 1) "T" indicates this is instantiated in the "Top"
// 2) "C" indicates this is instantiated in the "Companion"
// E.g., "E_C" is an external module instantiated only in the Companion.
firrtl.module @MT_() {}
firrtl.module @M_C() {}
firrtl.module @MTC() {}
firrtl.extmodule @ET_() attributes {annotations = [
{class = "firrtl.transforms.BlackBoxInlineAnno", name = "ET_.v", text = ""}
]}
firrtl.extmodule @E_C() attributes {annotations = [
{class = "firrtl.transforms.BlackBoxInlineAnno", name = "E_C.v", text = ""}
]}
firrtl.extmodule @ETC() attributes {annotations = [
{class = "firrtl.transforms.BlackBoxInlineAnno", name = "ETC.v", text = ""}
]}
// The Grand Central Companion module.
firrtl.module private @Companion() attributes {
annotations = [
{class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
defName = "Foo",
id = 0 : i64,
name = "View"}]} {
firrtl.instance m__c @M_C()
firrtl.instance m_dc @MTC()
firrtl.instance e__c @E_C()
firrtl.instance e_dc @ETC()
}
// This is the DUT in the previous example, but is no longer marked as the
// DUT.
firrtl.module @DirectoryBehaviorWithoutDUT() {
firrtl.instance companion @Companion()
firrtl.instance m_d_ @MT_()
firrtl.instance m_dc @MTC()
firrtl.instance e_d_ @ET_()
firrtl.instance e_dc @ETC()
}
}
// Any module instantiated by the Companion, but not instantiated by the DUT is
// moved to the same directory as the Companion. I.e., only "*_C" modules
// should be moved into the "gct-dir".
//
// CHECK-LABEL: "DirectoryBehaviorWithoutDUT"
//
// CHECK-NOT: output_file
// CHECK: firrtl.module @M_C
// CHECK-SAME: output_file = #hw.output_file<"gct-dir{{/|\\\\}}"
// CHECK-NOT: output_file
//
// CHECK: firrtl.extmodule @E_C
// CHECK-SAME: output_file = #hw.output_file<"gct-dir{{/|\\\\}}">
// CHECK-NOT: output_file
//
// CHECK: firrtl.module
// -----
firrtl.circuit "Top" attributes {
annotations = [
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "MyInterface_w1",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "SameName",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 1 : i64,
name = "uint"
}
],
name = "SameName"
}
],
id = 0 : i64,
name = "View_w1"
},
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "MyInterface_w2",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "SameName",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 3 : i64,
name = "uint"
}
],
name = "SameName"
}
],
id = 2 : i64,
name = "View_w2"
},
{
class = "sifive.enterprise.grandcentral.ExtractGrandCentralAnnotation",
directory = ".",
filename = "bindings.sv"
}
]
} {
firrtl.module private @Companion_w1(in %_gen_uint: !firrtl.uint<1>) attributes {
annotations = [
{
class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
id = 0 : i64,
name = "View_w1"
}
]
} {
%view_uintrefPort = firrtl.node %_gen_uint {
annotations = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 1 : i64
}
]
} : !firrtl.uint<1>
}
firrtl.module private @Companion_w2(in %_gen_uint: !firrtl.uint<2>) attributes {
annotations = [
{
class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
id = 2 : i64,
name = "View_w2"
}
]
} {
%view_uintrefPort = firrtl.node %_gen_uint {
annotations = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
id = 3 : i64
}
]
} : !firrtl.uint<2>
}
firrtl.module private @DUT() {
%c0_ui2 = firrtl.constant 0 : !firrtl.uint<2>
%c0_ui1 = firrtl.constant 0 : !firrtl.uint<1>
%a_w1 = firrtl.wire {annotations = [{class = "firrtl.transforms.DontTouchAnnotation"}]} : !firrtl.uint<1>
firrtl.matchingconnect %a_w1, %c0_ui1 : !firrtl.uint<1>
%a_w2 = firrtl.wire {annotations = [{class = "firrtl.transforms.DontTouchAnnotation"}]} : !firrtl.uint<2>
firrtl.matchingconnect %a_w2, %c0_ui2 : !firrtl.uint<2>
%companion_w1__gen_uint = firrtl.instance companion_w1 @Companion_w1(in _gen_uint: !firrtl.uint<1>)
%companion_w2__gen_uint = firrtl.instance companion_w2 @Companion_w2(in _gen_uint: !firrtl.uint<2>)
firrtl.matchingconnect %companion_w1__gen_uint, %a_w1 : !firrtl.uint<1>
firrtl.matchingconnect %companion_w2__gen_uint, %a_w2 : !firrtl.uint<2>
}
firrtl.module @Top() {
firrtl.instance dut @DUT()
}
}
// Check that the correct subinterface name is used when aliasing is possible.
// Here, SameName is used twice as a sub-interface name and we need to make sure
// that MyInterface_w2 uses the uniqued name of SameName.
//
// See: https://github.com/llvm/circt/issues/4234
// CHECK-LABEL: sv.interface @MyInterface_w1 {{.+}} {
// CHECK-NEXT: sv.verbatim "SameName SameName();"
// CHECK-NEXT: }
// CHECK-LABEL: sv.interface @MyInterface_w2 {{.+}} {
// CHECK-NEXT: sv.verbatim "SameName_0 SameName();"
// CHECK-NEXT: }
// -----
firrtl.circuit "NoInterfaces" attributes {
annotations = [
{class = "sifive.enterprise.grandcentral.GrandCentralHierarchyFileAnnotation",
filename = "gct.yaml"}]} {
firrtl.module @NoInterfaces() {}
}
// CHECK-LABEL: module {
// CHECK: sv.verbatim
// CHECK-SAME: []
// -----
// Check that nonlocal duplicate views are dropped.
firrtl.circuit "Top" attributes {
annotations = [
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "VectorOfBundleView",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedVectorType",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "Bundle2",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "foo",
id = 10 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "bar",
id = 11 : i64
}
],
name = "bundle2"
}
],
name = "vector"
}
],
id = 9 : i64,
name = "VectorOfBundleView"
},
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "VectorOfBundleView",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedVectorType",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedBundleType",
defName = "Bundle2",
elements = [
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "foo",
id = 110 : i64
},
{
class = "sifive.enterprise.grandcentral.AugmentedGroundType",
name = "bar",
id = 111 : i64
}
],
name = "bundle2"
}
],
name = "vector"
}
],
id = 19 : i64,
name = "VectorOfBundleView"
},
{
class = "sifive.enterprise.grandcentral.ExtractGrandCentralAnnotation",
directory = "gct-dir",
filename = "bindings.sv"
},
{
class = "sifive.enterprise.grandcentral.GrandCentralHierarchyFileAnnotation",
filename = "gct.yaml"
}
]
} {
hw.hierpath private @nla_0 [@Top::@t1, @Dut::@s1]
hw.hierpath private @nla [@Top::@t1, @Dut::@s1]
firrtl.module @Companion() attributes {
annotations = [
{
circt.nonlocal = @nla,
class = "sifive.enterprise.grandcentral.ViewAnnotation.companion",
defName = "VectorOfBundleView",