blob: c0538123da18d1925d7361b098c2f81bd397dd63 (
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
|
// See LICENSE for license details.
package chiselTests
import collection.immutable.ListMap
// Keep Chisel._ separate from chisel3._ below
object CompatibilityComponents {
import Chisel._
import Chisel3Components._
class ChiselBundle extends Bundle {
val a = UInt(width = 32)
val b = UInt(width = 32).flip
}
class ChiselRecord extends Record {
val elements = ListMap("a" -> UInt(width = 32), "b" -> UInt(width = 32).flip)
override def cloneType = (new ChiselRecord).asInstanceOf[this.type]
}
abstract class ChiselDriverModule(_io: => Record) extends Module {
val io = _io
io.elements("a").asUInt := UInt(123)
assert(io.elements("b").asUInt === UInt(123))
}
abstract class ChiselPassthroughModule(_io: => Record) extends Module {
val io = _io
io.elements("b").asUInt := io.elements("a").asUInt
}
class ChiselBundleModuleA extends ChiselDriverModule(new ChiselBundle)
class ChiselBundleModuleB extends ChiselPassthroughModule((new ChiselBundle).flip)
class ChiselRecordModuleA extends ChiselDriverModule(new ChiselRecord)
class ChiselRecordModuleB extends ChiselPassthroughModule((new ChiselRecord).flip)
class ChiselModuleChisel3BundleA extends ChiselDriverModule(new Chisel3Bundle)
class ChiselModuleChisel3BundleB extends ChiselPassthroughModule((new Chisel3Bundle).flip)
class ChiselModuleChisel3RecordA extends ChiselDriverModule(new Chisel3Record)
class ChiselModuleChisel3RecordB extends ChiselPassthroughModule((new Chisel3Record).flip)
}
object Chisel3Components {
import chisel3._
import CompatibilityComponents._
class Chisel3Bundle extends Bundle {
val a = Output(UInt(32.W))
val b = Input(UInt(32.W))
}
class Chisel3Record extends Record {
val elements = ListMap("a" -> Output(UInt(32.W)), "b" -> Input(UInt(32.W)))
override def cloneType = (new Chisel3Record).asInstanceOf[this.type]
}
abstract class Chisel3DriverModule(_io: => Record) extends Module {
val io = IO(_io)
io.elements("a").asUInt := 123.U
assert(io.elements("b").asUInt === 123.U)
}
abstract class Chisel3PassthroughModule(_io: => Record) extends Module {
val io = IO(_io)
io.elements("b").asUInt := io.elements("a").asUInt
}
class Chisel3BundleModuleA extends Chisel3DriverModule(new Chisel3Bundle)
class Chisel3BundleModuleB extends Chisel3PassthroughModule(Flipped(new Chisel3Bundle))
class Chisel3RecordModuleA extends Chisel3DriverModule(new Chisel3Record)
class Chisel3RecordModuleB extends Chisel3PassthroughModule(Flipped(new Chisel3Record))
class Chisel3ModuleChiselBundleA extends Chisel3DriverModule(new ChiselBundle)
class Chisel3ModuleChiselBundleB extends Chisel3PassthroughModule(Flipped(new ChiselBundle))
class Chisel3ModuleChiselRecordA extends Chisel3DriverModule(new ChiselRecord)
class Chisel3ModuleChiselRecordB extends Chisel3PassthroughModule(Flipped(new ChiselRecord))
}
class CompatibiltyInteroperabilitySpec extends ChiselFlatSpec {
"Modules defined in the Chisel._" should "successfully bulk connect in chisel3._" in {
import chisel3._
import chisel3.testers.BasicTester
import CompatibilityComponents._
assertTesterPasses(new BasicTester {
val a = Module(new ChiselBundleModuleA)
val b = Module(new ChiselBundleModuleB)
b.io <> a.io
stop()
})
assertTesterPasses(new BasicTester {
val a = Module(new ChiselRecordModuleA)
val b = Module(new ChiselRecordModuleB)
b.io <> a.io
stop()
})
}
"Moduless defined in the chisel3._" should "successfully bulk connect in Chisel._" in {
import Chisel._
import chisel3.testers.BasicTester
import Chisel3Components._
assertTesterPasses(new BasicTester {
val a = Module(new Chisel3BundleModuleA)
val b = Module(new Chisel3BundleModuleB)
b.io <> a.io
stop()
})
assertTesterPasses(new BasicTester {
val a = Module(new Chisel3RecordModuleA)
val b = Module(new Chisel3RecordModuleB)
b.io <> a.io
stop()
})
}
"Bundles defined in Chisel._" should "work in chisel3._ Modules" in {
import chisel3._
import chisel3.testers.BasicTester
import Chisel3Components._
assertTesterPasses(new BasicTester {
val a = Module(new Chisel3ModuleChiselBundleA)
val b = Module(new Chisel3ModuleChiselBundleB)
b.io <> a.io
stop()
})
assertTesterPasses(new BasicTester {
val a = Module(new Chisel3ModuleChiselRecordA)
val b = Module(new Chisel3ModuleChiselRecordB)
b.io <> a.io
stop()
})
}
"Bundles defined in chisel3._" should "work in Chisel._ Modules" in {
import chisel3._
import chisel3.testers.BasicTester
import CompatibilityComponents._
assertTesterPasses(new BasicTester {
val a = Module(new ChiselModuleChisel3BundleA)
val b = Module(new ChiselModuleChisel3BundleB)
b.io <> a.io
stop()
})
assertTesterPasses(new BasicTester {
val a = Module(new ChiselModuleChisel3RecordA)
val b = Module(new ChiselModuleChisel3RecordB)
b.io <> a.io
stop()
})
}
"Similar Bundles defined in the chisel3._ and Chisel._" should
"successfully bulk connect in chisel3._" in {
import chisel3._
import chisel3.testers.BasicTester
import Chisel3Components._
import CompatibilityComponents._
assertTesterPasses(new BasicTester {
val a = Module(new ChiselBundleModuleA)
val b = Module(new Chisel3BundleModuleB)
b.io <> a.io
stop()
})
assertTesterPasses(new BasicTester {
val a = Module(new Chisel3BundleModuleA)
val b = Module(new ChiselBundleModuleB)
b.io <> a.io
stop()
})
assertTesterPasses(new BasicTester {
val a = Module(new ChiselRecordModuleA)
val b = Module(new Chisel3RecordModuleB)
b.io <> a.io
stop()
})
assertTesterPasses(new BasicTester {
val a = Module(new Chisel3RecordModuleA)
val b = Module(new ChiselRecordModuleB)
b.io <> a.io
stop()
})
}
they should "successfully bulk connect in Chisel._" in {
import Chisel._
import chisel3.testers.BasicTester
import Chisel3Components._
import CompatibilityComponents._
assertTesterPasses(new BasicTester {
val a = Module(new ChiselBundleModuleA)
val b = Module(new Chisel3BundleModuleB)
b.io <> a.io
stop()
})
assertTesterPasses(new BasicTester {
val a = Module(new Chisel3BundleModuleA)
val b = Module(new ChiselBundleModuleB)
b.io <> a.io
stop()
})
assertTesterPasses(new BasicTester {
val a = Module(new ChiselRecordModuleA)
val b = Module(new Chisel3RecordModuleB)
b.io <> a.io
stop()
})
assertTesterPasses(new BasicTester {
val a = Module(new Chisel3RecordModuleA)
val b = Module(new ChiselRecordModuleB)
b.io <> a.io
stop()
})
}
}
|