diff --git a/src/main/scala/backBoard/ebus/Encryptor.scala b/src/main/scala/backBoard/ebus/Encryptor.scala new file mode 100644 index 0000000..120e397 --- /dev/null +++ b/src/main/scala/backBoard/ebus/Encryptor.scala @@ -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) + +} +