Skip to content

Commit c39d963

Browse files
committed
Updated the serdes tester
1 parent 4ffba44 commit c39d963

File tree

2 files changed

+136
-5
lines changed

2 files changed

+136
-5
lines changed

src/main/scala/sideband/sidebandNode.scala

+4-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import chisel3.experimental._
77

88
import interfaces._
99

10-
//TODO: 1) L289-290 should be reconsidered
11-
// 2) SidebandLinkDeserializer needs to have CDC crossings
10+
//TODO: 1) SidebandLinkDeserializer needs to have CDC crossings
1211

1312
// import freechips.rocketchip.config.Parameters
1413
import freechips.rocketchip.util._
@@ -318,10 +317,10 @@ class SidebandLinkDeserializer(
318317

319318
val (recvCount, recvDone) = Counter(true.B, dataBeats)
320319

321-
val recvCount_delay = RegInit(0.U(log2Ceil(dataBeats).W))
322-
recvCount_delay := recvCount
320+
//val recvCount_delay = RegInit(0.U(log2Ceil(dataBeats).W))
321+
//recvCount_delay := recvCount
323322

324-
data(recvCount_delay) := io.in.bits
323+
data(recvCount) := io.in.bits
325324
when(recvDone) { receiving := false.B }
326325
when(io.out.fire) { receiving := true.B }
327326
io.out.valid := !receiving
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package edu.berkeley.cs.ucie.digital
2+
package sideband
3+
4+
import chisel3._
5+
import chisel3.util._
6+
import chiseltest._
7+
import org.scalatest.flatspec.AnyFlatSpec
8+
9+
import interfaces._
10+
11+
class SerDesTester extends AnyFlatSpec with ChiselScalatestTester {
12+
behavior of "SerDes"
13+
it should "simple serializer sanity" in {
14+
test(new SidebandSerializer(new SidebandParams(), new FdiParams(width = 8, dllpWidth = 8, sbWidth = 32))) { c =>
15+
// prepare random data generator
16+
println("Test started")
17+
val seed: Int = 0
18+
val rand = new scala.util.Random(seed)
19+
20+
//init
21+
c.io.in.valid.poke(false.B)
22+
c.io.out.credit.poke(false.B)
23+
c.clock.step()
24+
25+
//Send data to serializer
26+
println("Send data")
27+
val data = BigInt(c.msg_w, rand).U
28+
c.io.in.valid.poke(true.B)
29+
c.io.in.bits.poke(data)
30+
c.io.out.valid.expect(false.B)
31+
c.clock.step()
32+
33+
//Check serialized data
34+
c.io.in.valid.poke(false.B)
35+
for(i <- 0 until (c.msg_w / c.sb_w)){
36+
val serialized_data = data((i+1)*c.sb_w-1, i*c.sb_w)
37+
c.io.in.ready.expect(false.B)
38+
c.io.out.valid.expect(true.B)
39+
c.io.out.bits.expect(serialized_data)
40+
c.clock.step()
41+
}
42+
43+
//make sure nothing is there
44+
c.io.in.ready.expect(true.B)
45+
c.io.out.valid.expect(false.B)
46+
}
47+
}
48+
49+
it should "simple deserializer sanity" in {
50+
test(new SidebandDeserializer(new SidebandParams(), new FdiParams(width = 8, dllpWidth = 8, sbWidth = 32))) { c =>
51+
// prepare random data generator
52+
println("Test started")
53+
val seed: Int = 0
54+
val rand = new scala.util.Random(seed)
55+
56+
//init
57+
c.io.in.valid.poke(false.B)
58+
c.io.out.ready.poke(false.B)
59+
c.clock.step()
60+
61+
//Send data to deserializer
62+
println("Send data")
63+
val data = BigInt(c.msg_w, rand).U
64+
for(i <- 0 until (c.msg_w / c.sb_w)){
65+
c.io.in.valid.poke(true.B)
66+
c.io.in.bits.poke(data((i+1)*c.sb_w-1, i*c.sb_w))
67+
c.io.out.valid.expect(false.B)
68+
c.clock.step()
69+
}
70+
71+
//Check deserialized data and credit return
72+
c.io.in.valid.poke(false.B)
73+
c.io.out.ready.poke(true.B)
74+
c.io.out.valid.expect(true.B)
75+
c.io.out.bits.expect(data)
76+
//c.io.in.credit.expect(true.B)
77+
c.clock.step()
78+
79+
//make sure nothing is there
80+
c.io.out.valid.expect(false.B)
81+
}
82+
}
83+
84+
it should "stress serializer sanity" in {
85+
test(new SidebandSerializer(new SidebandParams(), new FdiParams(width = 8, dllpWidth = 8, sbWidth = 32))) { c =>
86+
// prepare random data generator
87+
println("Test started")
88+
val seed: Int = 0
89+
val rand = new scala.util.Random(seed)
90+
91+
//init
92+
c.io.in.valid.poke(false.B)
93+
c.io.out.credit.poke(false.B)
94+
c.clock.step()
95+
96+
//Transfer data 32 times until no credit left
97+
for(i <- 0 until c.cdt_max){
98+
//Send data to serializer
99+
println("Send data")
100+
val data = 1.U
101+
c.io.in.valid.poke(true.B)
102+
c.io.in.bits.poke(data)
103+
c.io.out.valid.expect(false.B)
104+
c.clock.step()
105+
106+
//Check serialized data
107+
c.io.in.valid.poke(false.B)
108+
for(j <- 0 until (c.msg_w / c.sb_w)){
109+
val serialized_data = data((j+1)*c.sb_w-1, j*c.sb_w)
110+
c.io.in.ready.expect(false.B)
111+
c.io.out.valid.expect(true.B)
112+
c.io.out.bits.expect(serialized_data)
113+
c.clock.step()
114+
}
115+
}
116+
117+
//Send data to serializer when no credit
118+
println("Send data")
119+
val data = 1.U
120+
c.io.in.valid.poke(true.B)
121+
c.io.in.bits.poke(data)
122+
c.io.out.valid.expect(false.B)
123+
c.clock.step()
124+
125+
//Check not send out msg when no credit left
126+
c.io.in.valid.poke(false.B)
127+
c.io.out.valid.expect(false.B)
128+
c.io.in.ready.expect(false.B)
129+
c.clock.step()
130+
}
131+
}
132+
}

0 commit comments

Comments
 (0)