|
|
@ -16,42 +16,26 @@ class MyMem() extends Component { |
|
|
|
val bus = slave(Apb3(MyMem.getApb3Config)) |
|
|
|
} |
|
|
|
|
|
|
|
val myReg = Reg(Bits(128 bit)) |
|
|
|
val myStatus = Reg(Bits(32 bit)) |
|
|
|
// val myReg = Mem(Bits(32 bit), 4) |
|
|
|
val busCtrl = Apb3SlaveFactory(io.bus) |
|
|
|
|
|
|
|
// myStatus := U"32'h1A".asBits |
|
|
|
|
|
|
|
// busCtrl.readAndWrite(myReg,address = 0x30000,bitOffset = 0) |
|
|
|
|
|
|
|
busCtrl.readMultiWord(myReg,address = 0x30000) |
|
|
|
busCtrl.writeMultiWord(myReg,address = 0x30000) |
|
|
|
|
|
|
|
// busCtrl.readAndWrite(myStatus,address = 0x30128) |
|
|
|
// busCtrl.readMultiWord(myStatus,address = 0x30128) |
|
|
|
// busCtrl.writeMultiWord(myStatus,address = 0x30128) |
|
|
|
|
|
|
|
|
|
|
|
// Define a bundle "mapMem" for the state and the status |
|
|
|
case object mapMem extends Bundle { |
|
|
|
val state = Reg(Bits(64 bit)) |
|
|
|
val key = Reg(Bits(64 bit)) |
|
|
|
val status = Reg(Bits(32 bit)) |
|
|
|
// val myKey = Reg(Bits(32 bit)) |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
val busReady = Reg(Bool) init(false) |
|
|
|
val busAccess = io.bus.PENABLE && io.bus.PSEL(0) |
|
|
|
io.bus.PRDATA := 0 |
|
|
|
busReady := busAccess && !busReady |
|
|
|
io.bus.PREADY := busReady |
|
|
|
// Create a BusslaveFactory on the io.bus |
|
|
|
val busCtrl = Apb3SlaveFactory(io.bus) |
|
|
|
|
|
|
|
// Register the bundle "myReg" to the BusSlaveFactory at address 0x30000 |
|
|
|
busCtrl.readMultiWord(mapMem,address = 0x30000) |
|
|
|
busCtrl.writeMultiWord(mapMem,address = 0x30000) |
|
|
|
|
|
|
|
when(busReady) { |
|
|
|
when(io.bus.PWRITE) { |
|
|
|
start := io.bus.PWDATA(0) // Set flags on write, will trigger the coprocessor |
|
|
|
interruptEn := io.bus.PWDATA(2) |
|
|
|
} otherwise { |
|
|
|
io.bus.PRDATA(0) := busy // Assemble flags for read |
|
|
|
io.bus.PRDATA(1) := interrupt |
|
|
|
io.bus.PRDATA(2) := interruptEn |
|
|
|
interrupt := False |
|
|
|
} |
|
|
|
// When state and key are loaded, the status becomes 1 |
|
|
|
// and the calculation can start (state = state XOR key). |
|
|
|
// After the calcualtion is finished, the status is set to 0. |
|
|
|
when (mapMem.status === 1){ |
|
|
|
mapMem.state := mapMem.state ^ mapMem.key |
|
|
|
mapMem.status := 0 |
|
|
|
} |
|
|
|
**/ |
|
|
|
} |