@@ -3,7 +3,7 @@ package wbplumbing
3
3
import chisel3 ._
4
4
import chisel3 .experimental .BundleLiterals ._
5
5
import chisel3 .simulator .EphemeralSimulator ._
6
- import org .scalatest .freespec . AnyFreeSpec
6
+ import org .scalatest .flatspec . AnyFlatSpec
7
7
import org .scalatest .matchers .must .Matchers
8
8
9
9
object general {
@@ -13,13 +13,15 @@ object general {
13
13
)
14
14
}
15
15
16
- class WbInterconPTSpec extends AnyFreeSpec with Matchers {
16
+ class WbInterconPTSpec extends AnyFlatSpec with Matchers {
17
17
18
- " WbInterconPT should read and write wishbone value on one slave" in {
18
+ behavior of " WbInterconPT"
19
+
20
+ it should " read and write wishbone value on one slave" in {
19
21
val args = general.optn
20
22
val dataWidth = 16
21
- val wbm = new WbMaster (dataWidth, 2 )
22
- val wbs = new WbSlave (dataWidth, 2 )
23
+ val wbm = new WbMaster (dataWidth, 2 , feature_err = true )
24
+ val wbs = new WbSlave (dataWidth, 2 , feature_err = true )
23
25
24
26
simulate(new WbInterconPT (wbm, wbs)){ dut =>
25
27
// just a stupid testbench that verify point to point connexion
@@ -29,6 +31,7 @@ class WbInterconPTSpec extends AnyFreeSpec with Matchers {
29
31
dut.io.wbm.stb_o.poke(true .B )
30
32
dut.io.wbm.cyc_o.poke(true .B )
31
33
dut.io.wbs.ack_o.poke(true .B )
34
+ dut.io.wbs.err_o.get.poke(true .B )
32
35
dut.io.wbs.dat_o.poke(1 .U )
33
36
dut.clock.step(1 )
34
37
dut.io.wbm.adr_o.expect(1 .U , " Wrong value read on wbm.adr_o" )
@@ -37,13 +40,15 @@ class WbInterconPTSpec extends AnyFreeSpec with Matchers {
37
40
dut.io.wbm.stb_o.expect(true .B , " Wrong value read on wbm.stb_o" )
38
41
dut.io.wbm.cyc_o.expect(true .B , " Wrong value read on wbm.cyc_o" )
39
42
dut.io.wbs.ack_o.expect(true .B , " Wrong value read on wbs.ack_o" )
43
+ dut.io.wbs.err_o.get.expect(true .B , " Wrong value read on wbs.err_o" )
40
44
dut.io.wbs.dat_o.expect(1 .U , " Wrong value read on wbs.dat_o" )
41
45
dut.io.wbm.adr_o.poke(0 .U )
42
46
dut.io.wbm.dat_o.poke(0 .U )
43
47
dut.io.wbm.we_o.poke(false .B )
44
48
dut.io.wbm.stb_o.poke(false .B )
45
49
dut.io.wbm.cyc_o.poke(false .B )
46
50
dut.io.wbs.ack_o.poke(false .B )
51
+ dut.io.wbs.err_o.get.poke(false .B )
47
52
dut.io.wbs.dat_o.poke(0 .U )
48
53
dut.clock.step(1 )
49
54
dut.io.wbm.adr_o.expect(0 .U , " Wrong value read on wbm.adr_o" )
@@ -52,14 +57,17 @@ class WbInterconPTSpec extends AnyFreeSpec with Matchers {
52
57
dut.io.wbm.stb_o.expect(false .B , " Wrong value read on wbm.stb_o" )
53
58
dut.io.wbm.cyc_o.expect(false .B , " Wrong value read on wbm.cyc_o" )
54
59
dut.io.wbs.ack_o.expect(false .B , " Wrong value read on wbs.ack_o" )
60
+ dut.io.wbs.err_o.get.expect(false .B , " Wrong value read on wbs.err_o" )
55
61
dut.io.wbs.dat_o.expect(0 .U , " Wrong value read on wbs.dat_o" )
56
62
}
57
63
}
58
64
}
59
65
60
- class WbInterconOneMasterSpec extends AnyFreeSpec with Matchers {
66
+ class WbInterconOneMasterSpec extends AnyFlatSpec with Matchers {
67
+
68
+ behavior of " WbInterconOneMaster"
61
69
62
- " A WbInterconOneMaster should read and write wishbone value on two slaves" in {
70
+ it should " read and write wishbone value on two slaves" in {
63
71
val args = general.optn
64
72
val dataWidth = 16
65
73
val wbm = new WbMaster (dataWidth, 7 , " Spi2WbMaster" )
@@ -93,4 +101,80 @@ class WbInterconOneMasterSpec extends AnyFreeSpec with Matchers {
93
101
94
102
}
95
103
}
104
+
105
+ it should " raise the err_i line of the master if read address is unmapped" in {
106
+ val dataWidth = 16
107
+ val wbm = new WbMaster (dataWidth, 3 , " Spi2WbMaster" , feature_err= true )
108
+ val wbs1 = new WbSlave (dataWidth, 2 , " Ksz1" )
109
+
110
+ simulate(new WbInterconOneMaster (wbm, Seq (wbs1))) { dut =>
111
+ dut.io.wbm.err_i.get.expect(false .B , " bad init of err_i" )
112
+
113
+ // Read on unmapped address
114
+ dut.io.wbm.adr_o.poke(0x4 )
115
+ dut.io.wbm.we_o.poke(false .B )
116
+ dut.io.wbm.cyc_o.poke(true .B )
117
+ dut.io.wbm.stb_o.poke(true .B )
118
+ dut.clock.step(1 )
119
+ dut.io.wbm.err_i.get.expect(true .B , " err_i not raised" )
120
+
121
+ // Stop transaction
122
+ dut.io.wbm.cyc_o.poke(false .B )
123
+ dut.io.wbm.stb_o.poke(false .B )
124
+ dut.clock.step(1 )
125
+ dut.io.wbm.err_i.get.expect(false .B , " err_i not resetted correctly" )
126
+ }
127
+ }
128
+
129
+ it should " raise the err_i line of the master if write address is unmapped" in {
130
+ val dataWidth = 16
131
+ val wbm = new WbMaster (dataWidth, 3 , " Spi2WbMaster" , feature_err= true )
132
+ val wbs1 = new WbSlave (dataWidth, 2 , " Ksz1" )
133
+
134
+ simulate(new WbInterconOneMaster (wbm, Seq (wbs1))) { dut =>
135
+ dut.io.wbm.err_i.get.expect(false .B , " bad init of err_i" )
136
+
137
+ // Write on unmapped address
138
+ dut.io.wbm.adr_o.poke(0x4 )
139
+ dut.io.wbm.we_o.poke(true .B )
140
+ dut.io.wbm.cyc_o.poke(true .B )
141
+ dut.io.wbm.stb_o.poke(true .B )
142
+ dut.clock.step(1 )
143
+ dut.io.wbm.err_i.get.expect(true .B , " err_i not raised" )
144
+
145
+ // Stop transaction
146
+ dut.io.wbm.we_o.poke(false .B )
147
+ dut.io.wbm.cyc_o.poke(false .B )
148
+ dut.io.wbm.stb_o.poke(false .B )
149
+ dut.clock.step(1 )
150
+ dut.io.wbm.err_i.get.expect(false .B , " err_i not resetted correctly" )
151
+ }
152
+ }
153
+
154
+ it should " pass through the err_o line of the slave to the err_i line of the master" in {
155
+ val dataWidth = 16
156
+ val wbm = new WbMaster (dataWidth, 3 , " Spi2WbMaster" , feature_err= true )
157
+ val wbs1 = new WbSlave (dataWidth, 2 , " Ksz1" , feature_err= true )
158
+
159
+ simulate(new WbInterconOneMaster (wbm, Seq (wbs1))) { dut =>
160
+ dut.io.wbm.err_i.get.expect(false .B , " bad init of err_i" )
161
+
162
+ // Write on unmapped address
163
+ dut.io.wbm.adr_o.poke(0x0 )
164
+ dut.io.wbm.we_o.poke(false .B )
165
+ dut.io.wbm.cyc_o.poke(true .B )
166
+ dut.io.wbm.stb_o.poke(true .B )
167
+ dut.clock.step(1 )
168
+ dut.io.wbs(0 ).err_o.get.poke(true .B )
169
+ dut.io.wbm.err_i.get.expect(true .B , " err_i not raised" )
170
+
171
+ // Reset err_o
172
+ dut.io.wbm.we_o.poke(false .B )
173
+ dut.io.wbm.cyc_o.poke(false .B )
174
+ dut.io.wbm.stb_o.poke(false .B )
175
+ dut.io.wbs(0 ).err_o.get.poke(false .B )
176
+ dut.clock.step(1 )
177
+ dut.io.wbm.err_i.get.expect(false .B , " err_i not resetted correctly" )
178
+ }
179
+ }
96
180
}
0 commit comments