@@ -13,6 +13,7 @@ import s4noc.Entry
1313 * 8: write receiver, read sender
1414 * TODO: compare with Chisel book version
1515 * TODO: make it generic and do a subtype for s4noc
16+ * TODO: have some better tests
1617 */
1718class PipeConRV [T <: Data ](private val addrWidth : Int , private val dt : T , s4noc : Boolean = false ) extends PipeCon (addrWidth) {
1819
@@ -22,12 +23,21 @@ class PipeConRV[T <: Data](private val addrWidth: Int, private val dt: T, s4noc:
2223 val rx = rv.rx
2324
2425 val ackReg = RegInit (false .B )
25- cp.ack := ackReg
26+ ackReg := false .B
27+ cpuPort.ack := ackReg
28+ // just look at lower bits
29+ val address = cpuPort.address(3 , 0 )
2630
2731 val status = rx.valid ## tx.ready
2832
29- // Two additional registers, used by S4NOC for addressing of nodes
30- val txDestReg = RegInit (0 .U (8 .W ))
33+ // This is ugly: two different transmit registers for two different types
34+ // dt should be usable here...
35+ val txDataReg = RegInit (0 .U .asTypeOf(dt))
36+ val e = Wire (Entry (UInt (32 .W )))
37+ e.data := 0 .U
38+ e.core := 0 .U
39+ val txS4NocReg = RegInit (e)
40+ // Aditional register, used by S4NOC for addressing of nodes
3141 val rxSourceReg = RegInit (0 .U (8 .W ))
3242 // TODO: detect Entry type
3343 // println("Type: " + dt.isInstanceOf[Entry[UInt(32.W)]])
@@ -36,42 +46,43 @@ class PipeConRV[T <: Data](private val addrWidth: Int, private val dt: T, s4noc:
3646 rx.ready := false .B
3747 tx.valid := false .B
3848 if (s4noc) {
39- val e = Wire (new Entry (UInt (32 .W )))
40- e.data := cp.wrData
41- e.core := txDestReg
42- rv.tx.bits := e
43- cp.rdData := rv.rx.bits.asTypeOf(Entry (UInt (32 .W ))).data
49+ cpuPort.rdData := rx.bits.asTypeOf(Entry (UInt (32 .W ))).data
50+ tx.bits := txS4NocReg
4451 } else {
45- rv.tx.bits := cp.wrData
46- cp.rdData := rv.rx.bits
52+ cpuPort.rdData := rx.bits
53+ tx.bits := txDataReg
4754 }
4855
4956 val idle :: readStatus :: readSource :: readWait :: writeWait :: Nil = Enum (5 )
5057 val stateReg = RegInit (idle)
51- val wrDataReg = Reg (UInt (32 .W ))
5258
5359 def idleReaction () = {
54- when (cp .wr) {
55- // printf("Write %d to %d\n", cp.wrData, cp. address)
56- when (cp. address === 8 .U ) {
57- txDestReg := cp .wrData
60+ when (cpuPort .wr) {
61+ // printf("Write %d to %d\n", cp.wrData, address)
62+ when (address === 8 .U ) {
63+ txS4NocReg.core := cpuPort .wrData
5864 ackReg := true .B
59- } .otherwise {
65+ } .elsewhen (address === 4 .U ) {
66+ /* lets not have this single cycle write for now
6067 tx.valid := true.B
6168 when (tx.ready) {
6269 ackReg := true.B
6370 } .otherwise {
64- wrDataReg := cp .wrData
71+ txReg.data := cpuPort .wrData
6572 stateReg := writeWait
6673 }
74+ */
75+ txDataReg := cpuPort.wrData
76+ txS4NocReg.data := cpuPort.wrData
77+ stateReg := writeWait
6778 }
6879 }
69- when (cp .rd) {
70- // printf("Read from %d\n", cp. address)
71- when (cp. address === 0 .U ) {
80+ when (cpuPort .rd) {
81+ // printf("Read from %d\n", address)
82+ when (address === 0 .U ) {
7283 stateReg := readStatus
7384 ackReg := true .B
74- } .elsewhen (cp. address === 8 .U ) {
85+ } .elsewhen (address === 8 .U ) {
7586 stateReg := readSource
7687 ackReg := true .B
7788 } .otherwise {
@@ -80,19 +91,20 @@ class PipeConRV[T <: Data](private val addrWidth: Int, private val dt: T, s4noc:
8091 }
8192 }
8293
83- ackReg := false .B
8494 switch(stateReg) {
8595 is (idle) {
8696 idleReaction()
8797 }
8898 is (readStatus) {
89- cp .rdData := status
99+ cpuPort .rdData := status
90100 stateReg := idle
101+ ackReg := false .B
91102 idleReaction()
92103 }
93104 is (readSource) {
94- cp .rdData := rxSourceReg
105+ cpuPort .rdData := rxSourceReg
95106 stateReg := idle
107+ ackReg := false .B
96108 idleReaction()
97109 }
98110 is (readWait) {
@@ -103,19 +115,14 @@ class PipeConRV[T <: Data](private val addrWidth: Int, private val dt: T, s4noc:
103115 rxSourceReg := rx.bits.asTypeOf(Entry (UInt (32 .W ))).core
104116 }
105117 // this is different from write - check
106- cp.ack := true .B
118+ cpuPort.ack := true .B
119+ ackReg := false .B
107120 idleReaction()
108121 }
109122 }
110123
111124 is (writeWait) {
112125 tx.valid := true .B
113- if (s4noc) {
114- val e = tx.bits.asTypeOf(Entry (UInt (32 .W )))
115- e.data := wrDataReg
116- } else {
117- tx.bits := wrDataReg
118- }
119126 when (tx.ready) {
120127 stateReg := idle
121128 ackReg := true .B
0 commit comments