加密模块
This commit is contained in:
33
src/main/scala/backBoard/ebus/Encryptor.scala
Normal file
33
src/main/scala/backBoard/ebus/Encryptor.scala
Normal 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)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user