To familiarize ourselves with the Chisel bit-wise operators we will fill in the module CombLogic
that satisfies these specs:
- b: Bool
- x: 6-bit UInt
- y: 6-bit UInt
- out0: Bool
XOR
ofb
and the most-significant bit fromx AND y
- out1: 6-bit UInt (table below)
b | top 3 bits of out1 |
bottom 3 bits of out1 |
---|---|---|
0 | top 3 bits of y |
bottom 3 bits of x |
1 | top 3 bits of x |
bottom 3 bits of y |
We can use Scala to write exhaustive tests for our modules assuming the input space is relatively small. In this problem, we provide Problem2
in the file src/main/scala/hw1/HW1.scala
. Your job is to edit the file src/test/scala/hw1/Problem2Test.scala
and fill in the unimplemented testProblem2
function using Chisel peek
, poke
, and expect
. Make sure to test that the output is correct for all 8 possible input values. You may run your test using the command sbt test
from your terminal. We strongly encourage you to fill in your own tests for the other problems located in src/test/scala/hw1/HW1TestSuite.scala
but they will not be graded.
Given 3 input coefficients c0
, c1
, and c2
and variable x
, fill in the rest of the PolyEval
to implement the module:
- c0: positive Int (<= 5b)
- c1: positive Int (<= 5b)
- c2: positive Int (<= 5b)
- enable: Bool
- x: UInt of width 5
- out: UInt of sufficient width to support growth
- if
enable
is high:c0 * x^0 + c1 * x^1 + c2 * x^2
- if
enable
is low:0
- if
Fill in the module ComplexALU
. It is an adder/subtractor for complex numbers. If the Chisel input doAdd
is high, the module adds the complex numbers, and if it is low, the module subtracts the complex numbers. There is a Scala parameter onlyAdder
, and if it is true, the module should not generate any hardware for subtraction logic (and thus ignore doAdd
). The module's IO is already in the code, and here is a summary of the module's behavior:
- if
doAdd
is high, add the complex numbers (add the real inputs and add the imaginary inputs) - if
doAdd
is low, subtract the complex numbers (find the difference between the real inputs and the difference between the imaginary inputs) - if
onlyAdder
is true, only generate hardware to sum the real inputs and sum the imaginary inputs (ignoredoAdd
)