34 lines
601 B
Scala
34 lines
601 B
Scala
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 = RegInit(0.U(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)
|
|
|
|
}
|
|
|