Skip to content

Commit 1d0a555

Browse files
committed
soc: fix tests and PipeConRV
1 parent 6864d09 commit 1d0a555

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ To analyze memory issues (e.g., increase the heap size with Xmx) use a ```.sbtop
204204
* [ ] Get one-way memory back in here
205205
* [ ] AXI wrapper
206206

207-
OCP Wrapper like this:
207+
OCP Wrapper like this (we have a different one, should check the difference)
208208

209209
```scala
210210
class S4nocOCPWrapper(nrCores: Int, txFifo: Int, rxFifo: Int) extends CmpDevice(nrCores) {

src/main/scala/s4noc/S4NoCTop.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import soc._
1313
*/
1414
class S4NoCTop(conf: Config) extends Module {
1515
val io = IO(new Bundle {
16-
val cpuPorts = Vec(conf.n, new PipeConIO(conf.width))
16+
val cpuPorts = Vec(conf.n, new PipeConIO(4)) // TODO: shall we use MultiCoreDevice here?
1717
val cycCnt = Output(UInt(32.W))
1818
})
1919

2020
val s4noc = Module(new S4NoC(conf))
2121
for (i <- 0 until conf.n) {
22-
val ci = Module(new PipeConS4NoC(conf.width, Entry(UInt(conf.width.W))))
22+
val ci = Module(new PipeConS4NoC(4, Entry(UInt(conf.width.W))))
2323
s4noc.io.networkPort(i) <> ci.rv
2424
io.cpuPorts(i) <> ci.cpuPort
2525
}

src/main/scala/soc/PipeConRV.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ class PipeConRV[T <: Data](private val addrWidth: Int, private val dt: T, s4noc:
7272
stateReg := writeWait
7373
}
7474
*/
75-
txDataReg := cpuPort.wrData
76-
txS4NocReg.data := cpuPort.wrData
75+
if (s4noc) {
76+
txS4NocReg.data := cpuPort.wrData
77+
} else {
78+
txDataReg := cpuPort.wrData
79+
}
7780
stateReg := writeWait
7881
}
7982
}

src/test/scala/soc/PipeConRVTest.scala

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class PipeConRVTest() extends AnyFlatSpec with ChiselScalatestTester {
1111
behavior of "The CpuInterfaceRV"
1212

1313
it should "do something" in {
14-
test(new PipeConRV(4, UInt(32.W))) {
14+
test(new PipeConRV(4, UInt(32.W))).withAnnotations(Seq(WriteVcdAnnotation)) {
1515
d => {
1616

1717
def step() = d.clock.step()
@@ -25,6 +25,9 @@ class PipeConRVTest() extends AnyFlatSpec with ChiselScalatestTester {
2525
step()
2626
cp.ack.expect(false.B)
2727

28+
// useful default
29+
cp.wrMask.poke(0xf.U)
30+
2831
// two cycle write into tx register
2932
// TODO: should be a single cycle operation when the tx channel is ready
3033
cp.address.poke(4.U)
@@ -67,12 +70,13 @@ class PipeConRVTest() extends AnyFlatSpec with ChiselScalatestTester {
6770
assert(helper.read(0) == 2)
6871
tx.ready.poke(true.B)
6972
assert(helper.read(0) == 3)
73+
step()
7074

71-
helper.write(0, 0xcafe)
75+
helper.write(4, 0xcafe)
7276
tx.bits.expect(0xcafe)
7377

7478
rx.bits.poke(123)
75-
assert(helper.read(1) == 123)
79+
assert(helper.read(4) == 123)
7680
}
7781
}
7882
}
@@ -92,11 +96,11 @@ class PipeConRVTest() extends AnyFlatSpec with ChiselScalatestTester {
9296
val helper = new MemoryMappedIOHelper(d.cpuPort, d.clock)
9397

9498
// should get back the data at some time
95-
helper.write(1, 0x1234)
99+
helper.write(4, 0x1234)
96100
var ok = false
97101
for (i <- 0 until 10 if !ok) {
98102
if (helper.rxAvail) {
99-
assert(helper.read(1) == 0x1234)
103+
assert(helper.read(4) == 0x1234)
100104
ok = true
101105
}
102106
}
@@ -204,8 +208,8 @@ class PipeConRVTest() extends AnyFlatSpec with ChiselScalatestTester {
204208
cpif.rx <> fifo.io.deq
205209
}
206210

207-
it should "do work with a S4NOC Entry" in {
208-
test(new MyModule3()).withAnnotations(Seq(WriteVcdAnnotation)) {
211+
it should "work with a S4NOC Entry" in {
212+
test(new MyModule3()) {
209213
d => {
210214
val helper = new MemoryMappedIOHelper(d.cpuPort, d.clock)
211215

0 commit comments

Comments
 (0)