Skip to content

Commit 93498e2

Browse files
committed
Change to byte addressing
1 parent 7d2ba69 commit 93498e2

File tree

11 files changed

+45
-34
lines changed

11 files changed

+45
-34
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ provide a standard mapping for the ```PipeCon```, the ```PipeConRV```:
135135
* CPU interface to two ready/valid channels (one for transmit/tx, one for receive/rx).
136136
* IO mapping as in the classic PC serial port (UART)
137137
* 0: status (control): bit 0 tx ready, bit 1 rx data available
138-
* 1: write into txd and read from rxd
138+
* 4: write into txd and read from rxd
139139

140140
Additionally, for the S4NOC we provide following port:
141141

142-
* 2: write receiver, read sender (S4NOC specific)
142+
* 8: write receiver, read sender (S4NOC specific)
143143

144144

145145

@@ -193,7 +193,7 @@ To analyze memory issues (e.g., increase the heap size with Xmx) use a ```.sbtop
193193
## TODO
194194

195195
* [x] Use and document the PipeCon, direction from slave
196-
* Or stick to the CpuInterface as it is and rename it
196+
* [ ] Use a better name for the PipeCon interface (not io)
197197
* [ ] Wrapper for OCP (in Patmos)
198198
* [ ] Integrate a simple multicore device with T-CREST
199199
* A multicore "Hello World"
@@ -221,7 +221,7 @@ class S4nocOCPWrapper(nrCores: Int, txFifo: Int, rxFifo: Int) extends CmpDevice(
221221
OcpResp.DVA, OcpResp.NULL)
222222

223223
// addresses are in words
224-
s4noc.io.cpuPorts(i).addr := io.cores(i).M.Addr >> 2
224+
s4noc.io.cpuPorts(i).addr := io.cores(i).M.Addr
225225
s4noc.io.cpuPorts(i).wrData := io.cores(i).M.Data
226226
s4noc.io.cpuPorts(i).wr := io.cores(i).M.Cmd === OcpCmd.WR
227227
s4noc.io.cpuPorts(i).rd := io.cores(i).M.Cmd === OcpCmd.RD
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package s4noc
2+
3+
import chisel3._
4+
5+
import soc._
6+
7+
class PipeConS4NoC[T <: Data](private val addrWidth: Int, private val dt: T) extends PipeConRV(addrWidth, dt, true){
8+
9+
}

src/main/scala/s4noc/S4NoCTop.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import soc._
55

66

77
/**
8-
* Top level of the S4NOC with CPU interfaces.
8+
* Top level of the S4NOC with PipeCon CPU interfaces.
99
*
1010
* Author: Martin Schoeberl ([email protected])
1111
* license see LICENSE
@@ -19,7 +19,7 @@ class S4NoCTop(conf: Config) extends Module {
1919

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

src/main/scala/soc/HardwareLock.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import chisel3._
1313
*
1414
* Could be extended to a multicore lock.
1515
*/
16-
class HardwareLock() extends PipeCon(0) {
16+
class HardwareLock() extends PipeCon(2) {
1717

1818
val lockReg = RegInit(false.B)
1919
val ackReg = RegInit(false.B)

src/main/scala/soc/HelloDevice.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import chisel3._
55
/**
66
* An minimal IO device.
77
* It contains a single register to write and read at address 0
8-
* and the read-only core ID at address 1.
8+
* and the read-only core ID at address 4.
99
*
1010
* @param coreId
1111
*/
12-
class HelloDevice(coreId: Int) extends PipeCon(2) {
12+
class HelloDevice(coreId: Int) extends PipeCon(3) {
1313

14-
// TODO: following five lines are duplicated in CpuInterfaceRV, back to CpuInterface?
15-
val addrReg = RegInit(0.U(2.W))
14+
// TODO: following five lines are duplicated in PipeConRV, back to PipeCon class?
15+
val addrReg = RegInit(0.U(3.W))
1616
val ackReg = RegInit(false.B)
1717
when (cp.rd) {
1818
addrReg := cp.address
@@ -25,10 +25,10 @@ class HelloDevice(coreId: Int) extends PipeCon(2) {
2525
reg := cp.wrData
2626
}
2727
ackReg := cp.wr || cp.rd
28-
cp.rdData := Mux(addrReg === 1.U, nr, reg)
28+
cp.rdData := Mux(addrReg === 4.U, nr, reg)
2929
}
3030

31-
class MultiCoreHello(nrCores: Int) extends MultiCoreDevice(nrCores, 2) {
31+
class MultiCoreHello(nrCores: Int) extends MultiCoreDevice(nrCores, 3) {
3232

3333
for(i <- 0 until nrCores) {
3434
val d = Module(new HelloDevice(i))

src/main/scala/soc/PipeCon.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ abstract class PipeCon(addrWidth: Int) extends Module {
1111
val cpuPort = new PipeConIO(addrWidth)
1212
})
1313
val cp = io.cpuPort
14+
assert(addrWidth >= 2, "Address width needs some size for byte addresses")
1415
}
1516

1617

src/main/scala/soc/PipeConRV.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import s4noc.Entry
88
* CPU interface to two ready/valid channels.
99
* IO mapping as in classic PC serial port
1010
* 0: status (control): bit 0 transmit ready, bit 1 rx data available
11-
* 1: txd and rxd
12-
* 2: write receiver, read sender
11+
* 4: txd and rxd
12+
* S4NOC:
13+
* 8: write receiver, read sender
1314
* TODO: compare with Chisel book version
1415
* TODO: make it generic and do a subtype for s4noc
1516
*/
16-
class PipeConRV[T <: Data](private val addrWidth: Int, private val dt: T, s4noc: Boolean = false ) extends PipeCon(addrWidth) {
17+
class PipeConRV[T <: Data](private val addrWidth: Int, private val dt: T, s4noc: Boolean = false) extends PipeCon(addrWidth) {
1718

1819
val rv = IO(new ReadyValidChannelsIO(dt))
1920

@@ -52,7 +53,7 @@ class PipeConRV[T <: Data](private val addrWidth: Int, private val dt: T, s4noc:
5253
def idleReaction() = {
5354
when (cp.wr) {
5455
// printf("Write %d to %d\n", cp.wrData, cp.address)
55-
when (cp.address === 2.U) {
56+
when (cp.address === 8.U) {
5657
txDestReg := cp.wrData
5758
ackReg := true.B
5859
} .otherwise {
@@ -70,7 +71,7 @@ class PipeConRV[T <: Data](private val addrWidth: Int, private val dt: T, s4noc:
7071
when (cp.address === 0.U) {
7172
stateReg := readStatus
7273
ackReg := true.B
73-
} .elsewhen (cp.address === 2.U) {
74+
} .elsewhen (cp.address === 8.U) {
7475
stateReg := readSource
7576
ackReg := true.B
7677
} .otherwise {

src/main/scala/wishbone/Wrapper.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ class Wrapper(addrWidth: Int) extends WishboneDevice(addrWidth) {
1111

1212
// TODO: rename to PipeConIO at some point
1313
val cpuIf = IO(new Bundle {
14-
val cpuPort = Flipped(new PipeConIO(addrWidth-2))
14+
val cpuPort = Flipped(new PipeConIO(addrWidth))
1515
})
1616
val cp = cpuIf.cpuPort
1717
val wb = io.port
1818

19-
cp.address := wb.addr >> 2
19+
cp.address := wb.addr
2020
cp.wrData := wb.wrData
2121
cp.wrMask := "b1111".U
2222
wb.rdData := cp.rdData

src/test/scala/soc/HelloTest.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class HelloTest extends AnyFlatSpec with ChiselScalatestTester {
5959
cp.ack.expect(true.B)
6060
cp.rdData.expect(0xabcd.U)
6161
//test CPU ID
62-
cp.address.poke(0x1.U)
62+
cp.address.poke(0x4.U)
6363
step()
6464
cp.rdData.expect(3.U)
6565
cp.ack.expect(true.B)
@@ -114,9 +114,9 @@ class HelloTest extends AnyFlatSpec with ChiselScalatestTester {
114114
cp(0).rdData.expect(123.U)
115115
cp(1).rdData.expect(456.U)
116116
cp(2).rdData.expect(789.U)
117-
cp(0).address.poke(1.U)
118-
cp(1).address.poke(1.U)
119-
cp(2).address.poke(1.U)
117+
cp(0).address.poke(4.U)
118+
cp(1).address.poke(4.U)
119+
cp(2).address.poke(4.U)
120120
step()
121121
cp(0).rdData.expect(0.U)
122122
cp(1).rdData.expect(1.U)
@@ -133,11 +133,11 @@ class HelloTest extends AnyFlatSpec with ChiselScalatestTester {
133133
val helper = new MemoryMappedIOHelper(dut.cp, dut.clock)
134134

135135
helper.setTimeOut(10)
136-
helper.read(1)
136+
helper.read(4)
137137
step()
138138
step()
139139
// println(helper.read(0))
140-
// println(helper.read(1))
140+
// println(helper.read(4))
141141
step()
142142
step()
143143
helper.write(0, 123)

src/test/scala/soc/MemoryMappedIOHelper.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ class MemoryMappedIOHelper(mmio: PipeConIO, clock: Clock) {
5151
waitForAck()
5252
}
5353

54-
def setDest(n: Int) = write(2, n)
55-
def getSender() = read(2)
54+
def setDest(n: Int) = write(8, n)
55+
def getSender() = read(8)
5656

5757
// send and receive without status check, may block
58-
def send(data: BigInt) = write(1, data)
59-
def receive = read(1)
58+
def send(data: BigInt) = write(4, data)
59+
def receive = read(4)
6060

6161
// The following functions use the IO mapping with status bits add address 0 and data at address 1
6262
def txRdy = (read(0) & 0x01) != 0

0 commit comments

Comments
 (0)