> configure(npc)
ysyx_22040000 李心杨 Linux calcite 6.1.69 #1-NixOS SMP PREEMPT_DYNAMIC Wed Dec 20 16:00:29 UTC 2023 x86_64 GNU/Linux 12:59:00 up 1 day 21:45, 2 users, load average: 1.24, 1.19, 0.81
This commit is contained in:
parent
323e36c454
commit
239492c366
4 changed files with 155 additions and 173 deletions
|
@ -25,6 +25,36 @@ class RegisterFile(readPorts: Int) extends Module {
|
|||
}
|
||||
}
|
||||
|
||||
class ALUGenerator(width: Int) extends Module {
|
||||
require(width >= 0)
|
||||
val io = IO(new Bundle {
|
||||
val a = Input(UInt(width.W))
|
||||
val b = Input(UInt(width.W))
|
||||
val op = Input(UInt(4.W))
|
||||
val out = Output(UInt(width.W))
|
||||
})
|
||||
|
||||
val adder_b = fill(width)(io.op(0)) ^ io.b // take (-b) if sub
|
||||
val add = io.a + adder_b
|
||||
val and = io.a & io.b
|
||||
val not = ~io.a
|
||||
val or = io.a | io.b
|
||||
val xor = io.a ^ io.b
|
||||
val slt = io.a < io.b
|
||||
val eq = io.a === io.b
|
||||
|
||||
io.out := MuxLookup(0.U, io.op, Seq(
|
||||
0.U -> add,
|
||||
1.U -> add, // add with b reversed
|
||||
2.U -> not,
|
||||
3.U -> and,
|
||||
4.U -> or,
|
||||
5.U -> xor,
|
||||
6.U -> slt,
|
||||
7.U -> eq,
|
||||
))
|
||||
}
|
||||
|
||||
class MuxGenerator(width: Int, nInput: Int) extends Module {
|
||||
require(width >= 0)
|
||||
require(nInput >= 1)
|
Loading…
Add table
Add a link
Reference in a new issue