-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTydiComplianceTest.scala
71 lines (59 loc) · 2.46 KB
/
TydiComplianceTest.scala
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
package nl.tudelft.tydi_chisel
import chisel3._
import chisel3.experimental.BundleLiterals.AddBundleLiteralConstructor
import chisel3.experimental.VecLiterals.AddObjectLiteralConstructor
import chiseltest._
import org.scalatest.flatspec.AnyFlatSpec
class TydiComplianceTest extends AnyFlatSpec with ChiselScalatestTester {
def byteType: UInt = UInt(8.W)
class DataType extends Group {
val value1: UInt = byteType
val value2: UInt = byteType
}
val dataType = new DataType()
class PassThroughModule extends TydiModule {
val n = 2
val d = 8
val c = 8
val in: PhysicalStreamDetailed[DataType, Null] = IO(
Flipped(new PhysicalStreamDetailed(new DataType(), n = n, d = d, c = c).flip)
)
val out: PhysicalStreamDetailed[DataType, Null] = IO(
new PhysicalStreamDetailed(new DataType(), n = n, d = d, c = c)
)
val mid: PhysicalStream = Wire(PhysicalStream(new DataType, n = n, d = d, c = c))
val mid_out: PhysicalStream = IO(PhysicalStream(new DataType, n = n, d = d, c = c))
val laneValidityVec: Vec[Bool] = IO(in.laneValidityVec.cloneType)
laneValidityVec := in.laneValidityVec
val strbVec: Vec[Bool] = IO(in.strbVec.cloneType)
strbVec := in.strbVec
mid := in
out := mid
mid_out := mid
}
def dataLit(value1: UInt, value2: UInt): DataType = dataType.Lit(_.value1 -> value1, _.value2 -> value2)
behavior of "nl.tudelft.tydi_chisel.TydiComplianceTest"
// test class body here
it should "be tydi-compliant" in {
test(new PassThroughModule()) { c =>
// Set data values to {00000000, 01010101}, {11111111, 10101010}
c.in.data.poke(Vec.Lit(dataLit(0.U, 85.U), dataLit(255.U, 170.U)))
// Set last values to 00000000, 11111111
c.in.last.poke(Vec.Lit(0.U, 255.U))
// Strb set second lane valid
c.in.strb.poke("b10".U)
c.in.endi.poke(1.U)
// Least (first) element ends up right in tydi standard.
// Ordering of items in datatype is not specified, but do least (first) item right as well.
c.mid_out.data.expect("xAAFF5500".U)
// Same order for the last signal
c.mid_out.last.expect("xFF00".U)
// Check if vectorify functions work well
c.laneValidityVec.expect(Vec.Lit(0.B, 1.B))
c.strbVec.expect(Vec.Lit(0.B, 1.B))
// Check if elements end up at the right place again
c.out.data.expect(Vec.Lit(dataLit(0.U, 85.U), dataLit(255.U, 170.U)))
c.out.last.expect(Vec.Lit(0.U, 255.U))
}
}
}