aboutsummaryrefslogtreecommitdiff
path: root/src/main/stanza/firrtl-ir.stanza
blob: 259bba10e61cba82033796c3c1d1bcc6ebe3e967 (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
defpackage firrtl.ir2 :
   import core
   import verse
   
public definterface Direction
public val INPUT = new Direction
public val OUTPUT = new Direction
public val UNKNOWN-DIR = new Direction

public definterface Width
public defstruct UnknownWidth <: Width
public defstruct IntWidth <: Width :
   width: Int

public defstruct PrimOp
public val ADD-OP = PrimOp()
public val ADD-MOD-OP = PrimOp()
public val SUB-OP = PrimOp()
public val SUB-MOD-OP = PrimOp()
public val TIMES-OP = PrimOp()
public val DIVIDE-OP = PrimOp()
public val MOD-OP = PrimOp()
public val SHIFT-LEFT-OP = PrimOp()
public val SHIFT-RIGHT-OP = PrimOp()
public val PAD-OP = PrimOp()
public val BIT-AND-OP = PrimOp()
public val BIT-OR-OP = PrimOp()
public val BIT-XOR-OP = PrimOp()
public val CONCAT-OP = PrimOp()
public val BIT-SELECT-OP = PrimOp()
public val BITS-SELECT-OP = PrimOp()
public val MULTIPLEX-OP = PrimOp()
public val LESS-OP = PrimOp()
public val LESS-EQ-OP = PrimOp()
public val GREATER-OP = PrimOp()
public val GREATER-EQ-OP = PrimOp()
public val EQUAL-OP = PrimOp()

public definterface Expression
public defmulti type (e:Expression) -> Type

public defstruct Ref <: Expression :
   name: Symbol
   type: Type [multi => false]
public defstruct Field <: Expression :
   exp: Expression
   name: Symbol
   type: Type [multi => false]
public defstruct Index <: Expression :
   exp: Expression
   value: Int
   type: Type [multi => false]
public defstruct UIntValue <: Expression :
   value: Int
   width: Width
public defstruct SIntValue <: Expression :
   value: Int
   width: Width
public defstruct DoPrim <: Expression :
   op: PrimOp
   args: List<Expression>
   consts: List<Int>
   type: Type [multi => false]
public defstruct ReadPort <: Expression :
   mem: Expression
   index: Expression
   type: Type [multi => false]
public defstruct Null <: Expression

public definterface Stmt
public defstruct LetRec <: Stmt :
   entries: List<KeyValue<Symbol, Element>>
   body: Stmt
public defstruct DefWire <: Stmt :
   name: Symbol
   type: Type
public defstruct DefRegister <: Stmt :
   name: Symbol
   type: Type
public defstruct DefInstance <: Stmt :
   name: Symbol
   module: Expression
public defstruct DefMemory <: Stmt :
   name: Symbol
   type: VectorType
public defstruct DefNode <: Stmt :
   name: Symbol
   value: Expression
public defstruct DefAccessor <: Stmt :
   name: Symbol
   source: Expression
   index: Expression
public defstruct Conditionally <: Stmt :
   pred: Expression
   conseq: Stmt
   alt: Stmt
public defstruct Begin <: Stmt :
   body: List<Stmt>
public defstruct Connect <: Stmt :
   loc: Expression
   exp: Expression
public defstruct EmptyStmt <: Stmt

public definterface Element
public defmulti type (e:Element) -> Type

public defstruct Register <: Element :
   type: Type [multi => false]
   value: Expression
   enable: Expression
public defstruct Memory <: Element :
   type: Type [multi => false]
   writers: List<WritePort>
public defstruct WritePort :
   index: Expression
   value: Expression
   enable: Expression
public defstruct Node <: Element :
   type: Type [multi => false]
   value: Expression
public defstruct Instance <: Element :
   type: Type [multi => false]
   module: Expression
   ports: List<KeyValue<Symbol,Expression>>

public definterface Type
public defstruct UIntType <: Type :
   width: Width
public defstruct SIntType <: Type :
   width: Width
public defstruct BundleType <: Type :
   ports: List<Port>
public defstruct VectorType <: Type :
   type: Type
   size: Int
public defstruct UnknownType <: Type

public defstruct Port :
   name: Symbol
   direction: Direction
   type: Type

public defstruct Module :
   name: Symbol
   ports: List<Port>
   body: Stmt

public defstruct Circuit :
   modules: List<Module>
   main: Symbol