1
votes

I am learning chisel now so I get lots of questions.

I know import chsel3._ can add Chisel library files into the codes.

And I see the chisel codes in chisel-tutorial that have import chisel3._ as well as import chisel3.util._

My question is when do I need to add import chisel3.util._ or something excludes import chisel3_?

Another question is when I write testbench ,What should I extend?

class XXTests(c:XX) extends PeekPokeTester(c){....}

or

class XXTests(c:XX) extends Tester(c){....}

When should I add import chisel3.iotesters.{PeekPokeTester, Driver, ChiselFlatSpec}?

Thanks in advance.

`

1

1 Answers

1
votes

Basically, package chisel3 contains the main Chisel primitives like Module, UInt, and Reg while chisel3.util contains useful utilities like Arbiter, Queue, and PriorityEncoder. The distinction isn't always obvious, so it's best to look at the API documentation to see what is available in each: https://chisel.eecs.berkeley.edu/api/index.html (Note that package chisel3 actually points to members that are mostly in chisel3.core).

For your second question, take a look at the chisel-template (which is a good starting point for new Chisel projects). The design is located in src/main/scala/example/GCD.scala. You may note that it only imports chisel3._ because it doesn't use anything in chisel3.util. The test is located in src/test/scala/examples/test/GCDUnitTest.scala and it imports Chisel.iotesters (it should be chisel3.iotesters--this is a dated import but it still works). The test uses the PeekPokeTester to test the design. You should be extending PeekPokeTester or other testers located in the chisel-testers. I believe that extending Tester is old Chisel 2 API but I'm not certain.