Working on porting bootcamp to chiseltest#121
Conversation
Questionable import of scalatest in load-ivy.sc but it seems to work at moment. Worksheets done: 2.1, 2.2, 2.6
2.3 and 2.4
ducky64
left a comment
There was a problem hiding this comment.
Some suggestions inline in the comments, but looks good as a direct translation so far!
It might be useful to clear the cells before committing to GitHub, the output cells are bloating the diff.
| } | ||
| ], | ||
| "source": [ | ||
| "// Scala Code: Calling Driver to instantiate Passthrough + PeekPokeTester and execute the test.\n", |
There was a problem hiding this comment.
This comment can go away now because of test magic
| "If all `expect` statements are true, then our boilerplate code will return pass.\n", | ||
| "\n", | ||
| ">Note that the `poke` and `expect` use chisel hardware literal notation. Both operations expect literals of the correct type.\n", | ||
| "If `poke`ing a `UInt()` you must supply a `UInt` literal (example: `c.io.in.poke(10.U)`, likewise if the input is a `Bool()` the `poke` would expect either `true.B` or `false.B`.\n", |
There was a problem hiding this comment.
Might also be useful to provide a negative example for each, eg for UInt, "this is distinct from a Scala number, eg 10, which will not work and type-error"
| " c.io.in.poke(1.U) // Set our input to value 1\n", | ||
| " c.io.out.expect(1.U) // Assert that the output correctly has 1\n", | ||
| " c.io.in.poke(2.U) // Set our input to value 2\n", | ||
| " c.io.out.expect(2.U) // Assert that the output correctly has 2\n", |
There was a problem hiding this comment.
Do we have an example anywhere of an expect that fails? Because the current system doesn't return a test success / failure value, it might be useful to demonstrate what happens (exception), and maybe also have a side note on integration w/ ScalaTest
| " for (i <- 0 until cycles) {\n", | ||
| " val in_a = Random.nextInt(16)\n", | ||
| " val in_b = Random.nextInt(16)\n", | ||
| " c.io.in_a.poke(in_a.U)\n", |
There was a problem hiding this comment.
This could be a good candidate for abstracting this poke-and-expect operation into a test helper function.
| " import scala.util.Random\n", | ||
| " val data = Random.nextInt(65536)\n", | ||
| " poke(c.io.fifo_data, data)\n", | ||
| " c.io.fifo_data.poke(data.U)\n", |
There was a problem hiding this comment.
Possibly use Decoupled operations here, eg .enqueue and friends?
| " poke(c.io.in_b, in_b)\n", | ||
| " poke(c.io.in_c, in_c)\n", | ||
| " expect(c.io.out, in_a*in_b+in_c)\n", | ||
| " c.io.in_a.poke(in_a.U)\n", |
There was a problem hiding this comment.
Potentially a place to introduce a test helper function
but gets really tiny when circuit is large
2.3 and 2.4
Cleaned up page to page links
2.6 -> 3.1 2.7 remove for now, broken because of rocket issue 3.1 -> 2.6
IN PROGRESS CONVERSION
Questionable import of scalatest in load-ivy.sc
but it seems to work at moment.
Worksheets done: 2.1, 2.2, 2.6