加密模块

This commit is contained in:
Ruige Lee
2025-05-22 16:54:17 +08:00
parent f7346d4e18
commit 8f59ef55ac

View File

@@ -0,0 +1,33 @@
package BACK
import chisel3._
import chisel3.util._
class Encryptor_IO_Bundle extends Bundle{
val init = Flipped(Valid(UInt(128.W)))
val op = Decoupled(UInt(8.W))
}
class Encryptor extends Module{
val io: Encryptor_IO_Bundle = IO(new Encryptor_IO_Bundle)
val encryptReg = Reg(UInt(128.W))
when( io.init.valid ){
encryptReg := io.init.bits
} .elsewhen( io.op.fire ){
encryptReg := Cat(encryptReg(119,0), io.op.bits)
}
val opValid = RegInit(false.B)
when( io.init.fire ){
opValid := true.B
}
io.op.valid := opValid
io.op.bits := encryptReg(127, 120)
}