Loading .gitignore +2 −0 Original line number Diff line number Diff line Loading @@ -2,3 +2,5 @@ *.inProgress *.modComents *.commented *.chisel2 rename.sh README.md +0 −2 Original line number Diff line number Diff line Loading @@ -6,8 +6,6 @@ Welcome to the Chisel Learning Journey! This Journey is built around the examples provided by the creators of Chisel, within their [tutorial](https://github.com/ucb-bar/chisel-tutorial). However, ... Please clone the Learning Journey: ``` Loading src/main/scala/examples/Adder.scala +15 −15 Original line number Diff line number Diff line // See LICENSE.txt for license details. // January 23rd, 2018 - Adapting to Learning Journey package examples import Chisel._ import chisel3.core.VecInit import chisel3._ //A n-bit adder with carry in and carry out class Adder(val n:Int) extends Module { val io = new Bundle { val A = UInt(INPUT, n) val B = UInt(INPUT, n) val Cin = UInt(INPUT, 1) val Sum = UInt(OUTPUT, n) val Cout = UInt(OUTPUT, 1) } //create a vector of FullAdders val FAs = VecInit(Seq.fill(n)(Module(new FullAdder()).io)) val carry = Wire(Vec(n+1, UInt(width = 1))) val io = IO(new Bundle { val A = Input(UInt(n.W)) val B = Input(UInt(n.W)) val Cin = Input(UInt(1.W)) val Sum = Output(UInt(n.W)) val Cout = Output(UInt(1.W)) }) //create an Array of FullAdders // NOTE: Since we do all the wiring during elaboration and not at run-time, // i.e., we don't need to dynamically index into the data structure at run-time, // we use an Array instead of a Vec. val FAs = Array.fill(n)(Module(new FullAdder()).io) val carry = Wire(Vec(n+1, UInt(1.W))) val sum = Wire(Vec(n, Bool())) //first carry is the top level carry in Loading @@ -30,7 +31,6 @@ class Adder(val n:Int) extends Module { carry(i+1) := FAs(i).cout sum(i) := FAs(i).sum.toBool() } io.Sum := sum.asUInt() io.Sum := sum.asUInt io.Cout := carry(n) } src/main/scala/examples/Adder4.scala +11 −11 Original line number Diff line number Diff line // See LICENSE.txt for license details. // January 22nd, 2018 - adapting to Learning Journey package examples import Chisel._ import chisel3._ import chisel3.util._ //A 4-bit adder with carry in and carry out class Adder4 extends Module { val io = new Bundle { val A = UInt(INPUT, 4) val B = UInt(INPUT, 4) val Cin = UInt(INPUT, 1) val Sum = UInt(OUTPUT, 4) val Cout = UInt(OUTPUT, 1) } val io = IO(new Bundle { val A = Input(UInt(4.W)) val B = Input(UInt(4.W)) val Cin = Input(UInt(1.W)) val Sum = Output(UInt(4.W)) val Cout = Output(UInt(1.W)) }) //Adder for bit 0 val Adder0 = Module(new FullAdder()) Adder0.io.a := io.A(0) Loading @@ -36,6 +36,6 @@ class Adder4 extends Module { Adder3.io.a := io.A(3) Adder3.io.b := io.B(3) Adder3.io.cin := Adder2.io.cout io.Sum := Cat(Adder3.io.sum, s2).asUInt() io.Sum := Cat(Adder3.io.sum, s2).asUInt io.Cout := Adder3.io.cout } src/main/scala/examples/ByteSelector.scala +17 −19 Original line number Diff line number Diff line // See LICENSE.txt for license details. // January 21st, 2018 - adapting to Learning Journey package examples import Chisel._ import chisel3._ class ByteSelector extends Module { val io = new Bundle { val in = UInt(INPUT, 32) val offset = UInt(INPUT, 2) val out = UInt(OUTPUT, 8) } io.out := UInt(0, width = 8) when (io.offset === UInt(0)) { io.out := io.in(7,0) // pull out lowest byte } .elsewhen (io.offset === UInt(1)) { io.out := io.in(15,8) // pull out second byte } .elsewhen (io.offset === UInt(2)) { io.out := io.in(23,16) // pull out third byte val io = IO(new Bundle { val in = Input(UInt(32.W)) val offset = Input(UInt(2.W)) val out = Output(UInt(8.W)) }) io.out := 0.U(8.W) when (io.offset === 0.U(2.W)) { io.out := io.in(7,0) } .elsewhen (io.offset === 1.U) { io.out := io.in(15,8) } .elsewhen (io.offset === 2.U) { io.out := io.in(23,16) } .otherwise { io.out := io.in(31,24) // pull out highest byte io.out := io.in(31,24) } } Loading
.gitignore +2 −0 Original line number Diff line number Diff line Loading @@ -2,3 +2,5 @@ *.inProgress *.modComents *.commented *.chisel2 rename.sh
README.md +0 −2 Original line number Diff line number Diff line Loading @@ -6,8 +6,6 @@ Welcome to the Chisel Learning Journey! This Journey is built around the examples provided by the creators of Chisel, within their [tutorial](https://github.com/ucb-bar/chisel-tutorial). However, ... Please clone the Learning Journey: ``` Loading
src/main/scala/examples/Adder.scala +15 −15 Original line number Diff line number Diff line // See LICENSE.txt for license details. // January 23rd, 2018 - Adapting to Learning Journey package examples import Chisel._ import chisel3.core.VecInit import chisel3._ //A n-bit adder with carry in and carry out class Adder(val n:Int) extends Module { val io = new Bundle { val A = UInt(INPUT, n) val B = UInt(INPUT, n) val Cin = UInt(INPUT, 1) val Sum = UInt(OUTPUT, n) val Cout = UInt(OUTPUT, 1) } //create a vector of FullAdders val FAs = VecInit(Seq.fill(n)(Module(new FullAdder()).io)) val carry = Wire(Vec(n+1, UInt(width = 1))) val io = IO(new Bundle { val A = Input(UInt(n.W)) val B = Input(UInt(n.W)) val Cin = Input(UInt(1.W)) val Sum = Output(UInt(n.W)) val Cout = Output(UInt(1.W)) }) //create an Array of FullAdders // NOTE: Since we do all the wiring during elaboration and not at run-time, // i.e., we don't need to dynamically index into the data structure at run-time, // we use an Array instead of a Vec. val FAs = Array.fill(n)(Module(new FullAdder()).io) val carry = Wire(Vec(n+1, UInt(1.W))) val sum = Wire(Vec(n, Bool())) //first carry is the top level carry in Loading @@ -30,7 +31,6 @@ class Adder(val n:Int) extends Module { carry(i+1) := FAs(i).cout sum(i) := FAs(i).sum.toBool() } io.Sum := sum.asUInt() io.Sum := sum.asUInt io.Cout := carry(n) }
src/main/scala/examples/Adder4.scala +11 −11 Original line number Diff line number Diff line // See LICENSE.txt for license details. // January 22nd, 2018 - adapting to Learning Journey package examples import Chisel._ import chisel3._ import chisel3.util._ //A 4-bit adder with carry in and carry out class Adder4 extends Module { val io = new Bundle { val A = UInt(INPUT, 4) val B = UInt(INPUT, 4) val Cin = UInt(INPUT, 1) val Sum = UInt(OUTPUT, 4) val Cout = UInt(OUTPUT, 1) } val io = IO(new Bundle { val A = Input(UInt(4.W)) val B = Input(UInt(4.W)) val Cin = Input(UInt(1.W)) val Sum = Output(UInt(4.W)) val Cout = Output(UInt(1.W)) }) //Adder for bit 0 val Adder0 = Module(new FullAdder()) Adder0.io.a := io.A(0) Loading @@ -36,6 +36,6 @@ class Adder4 extends Module { Adder3.io.a := io.A(3) Adder3.io.b := io.B(3) Adder3.io.cin := Adder2.io.cout io.Sum := Cat(Adder3.io.sum, s2).asUInt() io.Sum := Cat(Adder3.io.sum, s2).asUInt io.Cout := Adder3.io.cout }
src/main/scala/examples/ByteSelector.scala +17 −19 Original line number Diff line number Diff line // See LICENSE.txt for license details. // January 21st, 2018 - adapting to Learning Journey package examples import Chisel._ import chisel3._ class ByteSelector extends Module { val io = new Bundle { val in = UInt(INPUT, 32) val offset = UInt(INPUT, 2) val out = UInt(OUTPUT, 8) } io.out := UInt(0, width = 8) when (io.offset === UInt(0)) { io.out := io.in(7,0) // pull out lowest byte } .elsewhen (io.offset === UInt(1)) { io.out := io.in(15,8) // pull out second byte } .elsewhen (io.offset === UInt(2)) { io.out := io.in(23,16) // pull out third byte val io = IO(new Bundle { val in = Input(UInt(32.W)) val offset = Input(UInt(2.W)) val out = Output(UInt(8.W)) }) io.out := 0.U(8.W) when (io.offset === 0.U(2.W)) { io.out := io.in(7,0) } .elsewhen (io.offset === 1.U) { io.out := io.in(15,8) } .elsewhen (io.offset === 2.U) { io.out := io.in(23,16) } .otherwise { io.out := io.in(31,24) // pull out highest byte io.out := io.in(31,24) } }