Skip to content

Commit

Permalink
assertion update
Browse files Browse the repository at this point in the history
  • Loading branch information
Vict0rAH committed Nov 29, 2020
1 parent 711e880 commit 011abbf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
20 changes: 14 additions & 6 deletions assertion/src/main/scala/mainOneHot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@ class mainOneHot extends Module {
val decode :: encode :: Nil = Enum(2)
val stateReg = RegInit(decode)

io.dout := 0.U

when(stateReg === decode) {
io.dout := 1.U << io.data
when(io.enc) {
io.dec := false.B
io.dout := 1.U << io.data
stateReg := encode
}
}. elsewhen (stateReg === encode) {
switch (io.data) {
is ("b0001".U) { io.dout := "b00".U}
is ("b0010".U) { io.dout := "b01".U}
is ("b0100".U) { io.dout := "b10".U}
is ("b1000".U) { io.dout := "b11".U}
}
}.elsewhen(stateReg === encode) {
when(io.dec) {
io.enc := false.B
io.dout := (1.U << 4) >> io.data
stateReg := decode
}
}. otherwise {
}
}
}
1 change: 0 additions & 1 deletion assertion/src/test/scala/fifoConcurrentAssertionTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ it should "writes and reads data concurrently" in {
}
assertEventuallyAlwaysEvent(dut, () => deq.notReady == true.B, enq.busy == true.B)
receiver()

}
}
}
Expand Down
36 changes: 23 additions & 13 deletions assertion/src/test/scala/oneHotTest.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*import org.scalatest._
import org.scalatest._
import assertionTiming._
import chisel3._
import chiseltest._
Expand All @@ -7,29 +7,39 @@ import chiseltest._
class oneHotTest extends FlatSpec with ChiselScalatestTester with Matchers {
behavior of "assertOneHot"

it should "test count of bitset in binary" in {
it should "test decoding" in {
test(new mainOneHot()) {
dut => {
dut.io.s.poke("b10".U)
dut.io.dec.poke(true.B)
dut.io.data.poke("b01".U)
dut.clock.step(1)
assertOneHot("b1000".U, "Error")
dut.io.c.expect("b0100".U)
assertOneHot("b0010".U)
}
}
}
it should "test decoding and FAIL" in {
test(new mainOneHot()) {
dut => {
dut.io.dec.poke(true.B)
dut.io.data.poke("b01".U)
dut.clock.step(1)
assertOneHot("b0110".U, "Decoding yields " + dut.io.dout.peek)
}
}
}

it should "test count of bitset in binary concurrently" in {

it should "test encoding" in {
test(new mainOneHot()) {
dut => {
dut.io.s.poke("b10".U)
dut.io.enc.poke(true.B)
dut.clock.step(1)
dut.io.data.poke("b0100".U)
dut.clock.step(1)
assertAlways(dut, () => assertOneHot(dut.io.c.peek), 10)
dut.clock.step(2)
dut.io.s.poke("b11".U)
dut.clock.step(2)
dut.io.s.poke("b00".U)
dut.io.dout.expect("b10".U)
//assertOneHot("b10".U)
}
}
}
}*/
}

0 comments on commit 011abbf

Please sign in to comment.