Using nbdev, we exported the notebook contents from `ToImport.ipynb` to the Scala script `ModA.sc`. Now we can import the script to this notebook by calling:
Call the load_ivy script.
Located in the source folder, the load_ivy.sc script will use ammonite to download snapshots of the chisel libraries, to be cached on your system. This is necessary for EVERY chisel notebook so we can then import our chisel libraries like we would in an SBT project structure.
Prevent namespace error
- To prevent an ambiguous reference to 'Input' by chisel3.Input and root.almond.input.Input, we have to make sure that we rename our chisel3 Input on import. It suffices to do as follows without requiring to change the name to something like IInput:
import chisel3.{Input => Input}
We can now try and test our module to see if we imported it correctly:
test(new Add) { c =>
c.io.a.poke(1.U)
c.io.b.poke(2.U)
c.clock.step(1)
c.io.out.expect(3.U)
c.io.a.poke(5.U)
c.io.b.poke(2.U)
c.clock.step(1)
c.io.out.expect(7.U)
}
test(new ComposedModule) { c =>
c.io.a.poke(1.U)
c.io.b.poke(2.U)
c.io.c.poke(3.U)
c.clock.step(1)
c.io.out.expect(6.U)
c.io.a.poke(5.U)
c.io.b.poke(2.U)
c.io.c.poke(7.U)
c.clock.step(1)
c.io.out.expect(14.U)
}