Chisel Tutorial 상에서는
총 22개의 예제가 제공되고있고, 이것을 전부 풀어보려고 한다.
-rw-rw-r-- 1 user user 404 Jul 23 20:24 Accumulator.scala
-rw-rw-r-- 1 user user 376 Jul 23 20:24 Adder.scala
-rw-rw-r-- 1 user user 648 Jul 23 20:24 Counter.scala
-rw-rw-r-- 1 user user 1.3K Jul 23 20:24 DynamicMemorySearch.scala
-rw-rw-r-- 1 user user 564 Jul 23 20:24 LFSR16.scala
-rw-rw-r-- 1 user user 413 Jul 23 20:24 Max2.scala
-rw-rw-r-- 1 user user 457 Jul 23 20:24 MaxN.scala
-rw-rw-r-- 1 user user 742 Jul 23 20:24 Memo.scala
-rw-rw-r-- 1 user user 641 Jul 23 20:24 Mul.scala
-rw-rw-r-- 1 user user 1.2K Jul 23 20:24 Mux4.scala
-rw-rw-r-- 1 user user 906 Jul 23 20:24 RealGCD.scala
-rw-rw-r-- 1 user user 1.1K Jul 23 20:24 SingleEvenFilter.scala
-rw-rw-r-- 1 user user 833 Jul 23 20:24 VecShiftRegister.scala
-rw-rw-r-- 1 user user 603 Jul 23 20:24 VecShiftRegisterParam.scala
-rw-rw-r-- 1 user user 541 Jul 23 20:24 VecShiftRegisterSimple.scala
-rw-rw-r-- 1 user user 1.2K Jul 23 20:24 VendingMachine.scala
-rw-rw-r-- 1 user user 1.2K Jul 23 20:24 VendingMachineSwitch.scala
// See LICENSE.txt for license details.
package problems
import chisel3._
// Problem:
//
// Count incoming trues
// (increase counter every clock if 'in' is asserted)
//
class Accumulator extends Module {
val io = IO(
new Bundle {
val in = Input(UInt(1.W))
val out = Output(UInt(8.W))
}
)
// Implement below ----------
val counter = RegInit(0.U(8.W))
counter := counter + io.in
io.out := counter
printf("Accumulator: %d %d\n", io.in, io.out)
println(s"io.out Type: ${io.out.getClass.getSimpleName}")
}
// See LICENSE.txt for license details.
package problems
import chisel3.iotesters.PeekPokeTester
class AccumulatorTests(c: Accumulator) extends PeekPokeTester(c) {
var tot = 0
for (t <- 0 until 16) {
val in = rnd.nextInt(2)
poke(c.io.in, in)
step(1)
if (in == 1) tot += 1
val out = peek(c.io.out).toInt
printf("out: %d\n", out)
expect(c.io.out, tot)
// println("hello world!!!")
// println(s"val in: $in")
// println(s"c.io.out: $c.io.out")
// println("c.io.out: " + c.io.out.peekInt())
// printf("Accumulator: %d %d\n", c.io.in, c.io.out)
// println(s"c.io.out Type: ${c.io.out.getClass.getSimpleName}")
}
}
println(s"io.out Type: ${io.out.getClass.getSimpleName}")
구문은 왜 출력되지 않는 것인지, 의문이다.