Loading src/main/scala/problems/Accumulator.scala +11 −12 Original line number Diff line number Diff line // See LICENSE.txt for license details. // January 20th, 2018 -adapted for Learning Journey package problems import chisel3._ import Chisel._ // Problem: // Loading @@ -9,14 +10,12 @@ import chisel3._ // (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 io = new Bundle { val in = UInt(INPUT, 1) val out = UInt(OUTPUT, 8) } io.out := 0.U // flush this out ... // Implement above ---------- io.out := UInt(0) } src/main/scala/solutions/Accumulator.scala +7 −7 Original line number Diff line number Diff line // See LICENSE.txt for license details. // January 20th, 2018 - adapted for Learning Journey package solutions import chisel3._ import Chisel._ // 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)) }) val accumulator = RegInit(0.U(8.W)) val io = new Bundle { val in = UInt(width = 1, dir = INPUT) val out = UInt(width = 8, dir = OUTPUT) } val accumulator = Reg(init=UInt(0, 8)) accumulator := accumulator + io.in io.out := accumulator } Loading
src/main/scala/problems/Accumulator.scala +11 −12 Original line number Diff line number Diff line // See LICENSE.txt for license details. // January 20th, 2018 -adapted for Learning Journey package problems import chisel3._ import Chisel._ // Problem: // Loading @@ -9,14 +10,12 @@ import chisel3._ // (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 io = new Bundle { val in = UInt(INPUT, 1) val out = UInt(OUTPUT, 8) } io.out := 0.U // flush this out ... // Implement above ---------- io.out := UInt(0) }
src/main/scala/solutions/Accumulator.scala +7 −7 Original line number Diff line number Diff line // See LICENSE.txt for license details. // January 20th, 2018 - adapted for Learning Journey package solutions import chisel3._ import Chisel._ // 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)) }) val accumulator = RegInit(0.U(8.W)) val io = new Bundle { val in = UInt(width = 1, dir = INPUT) val out = UInt(width = 8, dir = OUTPUT) } val accumulator = Reg(init=UInt(0, 8)) accumulator := accumulator + io.in io.out := accumulator }