SM sram化改造,探针改造,写接口
This commit is contained in:
@@ -41,8 +41,14 @@ class SlaveParserIO extends Bundle{
|
||||
// val sram_r = Flipped(new ShareSRAMIO)
|
||||
// val sram_w = Flipped(new ShareSRAMIO)
|
||||
|
||||
val dSMenq = Vec(4, Decoupled(UInt(8.W)))
|
||||
val uSMdeq = Vec(4, Flipped(Decoupled(UInt(8.W))))
|
||||
// val dSMenq = Vec(4, Decoupled(UInt(8.W)))
|
||||
// val uSMdeq = Vec(4, Flipped(Decoupled(UInt(8.W))))
|
||||
|
||||
val sram_w = Vec( 4, Flipped(new SRAM2kWRIO) )
|
||||
val sram_r = Vec( 4, Flipped(new SRAM2kRDIO) )
|
||||
|
||||
val dSMenq = Input( Vec(4, Bool()) )
|
||||
val uSMdeq = Input( Vec(4, Bool()) )
|
||||
|
||||
val timeStamp = Input(UInt(64.W))
|
||||
}
|
||||
@@ -357,8 +363,14 @@ trait SlaveParserIndex{ this: SlaveParserBase =>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
trait SlaveParserRW{ this: SlaveParserBase =>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//下行接收
|
||||
when( downRecParser.io.subMsgReq.fire ){
|
||||
when( isDownRecPing ){
|
||||
@@ -377,50 +389,47 @@ trait SlaveParserRW{ this: SlaveParserBase =>
|
||||
|
||||
|
||||
|
||||
//写入SM
|
||||
//写入 SM或寄存器空间
|
||||
|
||||
val addrw = Reg(UInt(15.W))
|
||||
|
||||
val isWRRegister = (addrw(14,11) === "b0000".U)
|
||||
val isWRSM0 = (addrw(14,11) === "b0001".U)
|
||||
val isWRSM2 = (addrw(14,11) === "b0011".U)
|
||||
val isWRSM4 = (addrw(14,11) === "b0101".U)
|
||||
val isWRSM6 = (addrw(14,11) === "b0111".U)
|
||||
|
||||
|
||||
|
||||
when( downRecParser.io.subMsgReq.fire ){
|
||||
when( downRecParser.io.subMsgReq.bits.devIndex === localDevIndex ){
|
||||
addrw := downRecParser.io.subMsgReq.bits.address
|
||||
}
|
||||
}
|
||||
|
||||
val isWriteSM := (downRecParser.io.stateCurr === STATE_PAYLOAD_DATA) & ( //req fire 后 已经反相
|
||||
val isWrite := (downRecParser.io.stateCurr === STATE_PAYLOAD_DATA) & ( //req fire 后 已经反相
|
||||
( ~isDownRecPing & downSubMsgInfo(0).devIndex === localDevIndex & (downSubMsgInfo(0).operator === 1.U | downSubMsgInfo(0).operator === 3.U)) |
|
||||
( isDownRecPing & downSubMsgInfo(1).devIndex === localDevIndex & (downSubMsgInfo(1).operator === 1.U | downSubMsgInfo(1).operator === 3.U))
|
||||
)
|
||||
|
||||
|
||||
val isTermSM = Seq[Bool]
|
||||
|
||||
io.dSMenq(0).valid := isWriteSM & addrw === 0.U
|
||||
io.dSMenq(0).bits := downRecParser.io.data.bits
|
||||
when( io.dSMenq(0).valid & ~io.dSMenq(0).ready ){
|
||||
printf("An Error occur at dSMenq0!\n")
|
||||
}
|
||||
|
||||
io.dSMenq(1).valid := isWriteSM & addrw === 1.U
|
||||
io.dSMenq(1).bits := downRecParser.io.data.bits
|
||||
when( io.dSMenq(1).valid & ~io.dSMenq(1).ready ){
|
||||
printf("An Error occur at dSMenq1!\n")
|
||||
}
|
||||
|
||||
io.dSMenq(2).valid := isWriteSM & addrw === 2.U
|
||||
io.dSMenq(2).bits := downRecParser.io.data.bits
|
||||
when( io.dSMenq(2).valid & ~io.dSMenq(2).ready ){
|
||||
printf("An Error occur at dSMenq2!\n")
|
||||
}
|
||||
|
||||
io.dSMenq(3).valid := isWriteSM & addrw === 3.U
|
||||
io.dSMenq(3).bits := downRecParser.io.data.bits
|
||||
when( io.dSMenq(3).valid & ~io.dSMenq(3).ready ){
|
||||
printf("An Error occur at dSMenq3!\n")
|
||||
}
|
||||
|
||||
io.sram_w(0).enw := isWrite & isWRSM0
|
||||
io.sram_w(0).addrw := addrw(10,0)
|
||||
io.sram_w(0).dataw := downRecParser.io.data.bits
|
||||
|
||||
io.sram_w(1).enw := isWrite & isWRSM2
|
||||
io.sram_w(1).addrw := addrw(10,0)
|
||||
io.sram_w(1).dataw := downRecParser.io.data.bits
|
||||
|
||||
io.sram_w(2).enw := isWrite & isWRSM4
|
||||
io.sram_w(2).addrw := addrw(10,0)
|
||||
io.sram_w(2).dataw := downRecParser.io.data.bits
|
||||
|
||||
io.sram_w(3).enw := isWrite & isWRSM6
|
||||
io.sram_w(3).addrw := addrw(10,0)
|
||||
io.sram_w(3).dataw := downRecParser.io.data.bits
|
||||
|
||||
|
||||
//上行接收
|
||||
@@ -444,7 +453,7 @@ trait SlaveParserRW{ this: SlaveParserBase =>
|
||||
|
||||
|
||||
//读出uSM
|
||||
val isReadSM =
|
||||
val isRead =
|
||||
((upRecParser.io.stateCurr === STATE_PAYLOAD_DATA) & (upSubMsgInfo(0).devIndex === localDevIndex) & (upSubMsgInfo(0).operator === 2.U | upSubMsgInfo(0).operator === 3.U)) |
|
||||
((upRecParser.io.stateNext === STATE_PAYLOAD_DATA) & (upRecParser.io.subMsgReq.bits.devIndex === localDevIndex) & (upRecParser.io.subMsgReq.bits.operator === 2.U | upRecParser.io.subMsgReq.bits.operator === 3.U))
|
||||
|
||||
@@ -454,24 +463,29 @@ trait SlaveParserRW{ this: SlaveParserBase =>
|
||||
( upRecParser.io.stateCurr === STATE_PAYLOAD_DATA ) -> addrr,
|
||||
))
|
||||
|
||||
|
||||
val isRDRegister = (readSMAddr(14,11) === "b0000".U)
|
||||
val isRDSM1 = (readSMAddr(14,11) === "b0010".U)
|
||||
val isRDSM3 = (readSMAddr(14,11) === "b0100".U)
|
||||
val isRDSM5 = (readSMAddr(14,11) === "b0110".U)
|
||||
val isRDSM7 = (readSMAddr(14,11) === "b1000".U)
|
||||
|
||||
when( upRecParser.io.subMsgReq.fire & upRecParser.io.subMsgReq.bits.devIndex === localDevIndex ){
|
||||
addrr := upRecParser.io.subMsgReq.bits.address
|
||||
}
|
||||
|
||||
val uSMData = Mux1H(Seq(
|
||||
(readSMAddr === 0.U) -> io.uSMdeq(0).bits,
|
||||
(readSMAddr === 1.U) -> io.uSMdeq(1).bits,
|
||||
(readSMAddr === 2.U) -> io.uSMdeq(2).bits,
|
||||
(readSMAddr === 3.U) -> io.uSMdeq(3).bits,
|
||||
val upStreamData = Mux1H(Seq(
|
||||
isRDRegister -> ,
|
||||
isRDSM1 -> io.sram_r(0).datar,
|
||||
isRDSM3 -> io.sram_r(1).datar,
|
||||
isRDSM5 -> io.sram_r(2).datar,
|
||||
isRDSM7 -> io.sram_r(3).datar,
|
||||
))
|
||||
|
||||
when( ~isUpRecPing ){ //req fire 后 已经反相
|
||||
upRecFifo(0).io.enq.valid := upRecParser.io.data.valid
|
||||
upRecFifo(0).io.enq.bits :=
|
||||
Mux( upSubMsgInfo(0).devIndex === localDevIndex & (upSubMsgInfo(0).operator === 2.U | upSubMsgInfo(0).operator === 3.U),
|
||||
uSMData, upRecParser.io.data.bits)
|
||||
upStreamData, upRecParser.io.data.bits)
|
||||
upRecParser.io.data.ready := upRecFifo(0).io.enq.ready
|
||||
|
||||
upRecFifo(1).io.enq.valid := false.B
|
||||
@@ -483,17 +497,20 @@ trait SlaveParserRW{ this: SlaveParserBase =>
|
||||
upRecFifo(1).io.enq.valid := upRecParser.io.data.valid
|
||||
upRecFifo(1).io.enq.bits :=
|
||||
Mux( upSubMsgInfo(1).devIndex === localDevIndex & (upSubMsgInfo(1).operator === 2.U | upSubMsgInfo(1).operator === 3.U),
|
||||
uSMData, upRecParser.io.data.bits)
|
||||
upStreamData, upRecParser.io.data.bits)
|
||||
upRecParser.io.data.ready := upRecFifo(1).io.enq.ready
|
||||
|
||||
}
|
||||
|
||||
io.sram_r(0).enr := isRead & isRDSM1
|
||||
io.sram_r(1).enr := isRead & isRDSM3
|
||||
io.sram_r(2).enr := isRead & isRDSM5
|
||||
io.sram_r(3).enr := isRead & isRDSM7
|
||||
|
||||
io.uSMdeq(0).ready := isReadSM & ( upRecParser.io.stateNext === STATE_PAYLOAD_DATA ) & ( readSMAddr === 0.U )
|
||||
io.uSMdeq(1).ready := isReadSM & ( upRecParser.io.stateNext === STATE_PAYLOAD_DATA ) & ( readSMAddr === 1.U )
|
||||
io.uSMdeq(2).ready := isReadSM & ( upRecParser.io.stateNext === STATE_PAYLOAD_DATA ) & ( readSMAddr === 2.U )
|
||||
io.uSMdeq(3).ready := isReadSM & ( upRecParser.io.stateNext === STATE_PAYLOAD_DATA ) & ( readSMAddr === 3.U )
|
||||
|
||||
io.sram_r(0).addrr := readSMAddr(10,0)
|
||||
io.sram_r(1).addrr := readSMAddr(10,0)
|
||||
io.sram_r(2).addrr := readSMAddr(10,0)
|
||||
io.sram_r(3).addrr := readSMAddr(10,0)
|
||||
}
|
||||
|
||||
|
||||
@@ -584,32 +601,47 @@ trait SlaveParserSync{ this: SlaveParserBase =>
|
||||
|
||||
trait SlaveParserProbe{ this: SlaveParserBase =>
|
||||
|
||||
val ProbeSendAim = 10000.U
|
||||
|
||||
val ProbeRecAim = 20000.U
|
||||
|
||||
|
||||
val probeSendCnt = RegInit(0.U(32.W))
|
||||
val probeRecCnt = RegInit(0.U(32.W))
|
||||
|
||||
|
||||
val isReadyToProbe = probeSendCnt === ProbeSendAim
|
||||
val isWatchDogOverflow = probeRecCnt === ProbeRecAim
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
val isReadyToProbe = RegInit(false.B)
|
||||
|
||||
when( downRecParser.io.frameReq.fire & downRecParser.io.frameReq.bits.frameStyle === FRAME_STYLE_PROBE ){ //下行来了一个嗅探包
|
||||
isReadyToProbe := true.B
|
||||
} .elsewhen( upRecParser.io.frameReq.fire & upRecParser.io.frameReq.bits.frameStyle === FRAME_STYLE_PROBE ){ //上行来了一个嗅探包
|
||||
isReadyToProbe := false.B
|
||||
} .elsewhen( isWatchDogOverflow ){
|
||||
isReadyToProbe := false.B
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
val isLastDevice: Bool = RegInit(false.B)
|
||||
val isDeviceModified: Bool = RegInit(true.B)
|
||||
|
||||
when( upRecParser.io.frameReq.fire ){ //上行来了一个嗅探包
|
||||
when( upRecParser.io.frameReq.fire & upRecParser.io.frameReq.bits.frameStyle === FRAME_STYLE_PROBE ){ //上行来了一个嗅探包
|
||||
probeRecCnt := 0.U
|
||||
isLastDevice := false.B
|
||||
} .elsewhen( isWatchDogOverflow ){
|
||||
probeRecCnt := 0.U
|
||||
isLastDevice := true.B
|
||||
} .otherwise{
|
||||
} .elsewhen( isReadyToProbe ){
|
||||
probeRecCnt := probeRecCnt + 1.U
|
||||
}
|
||||
|
||||
|
||||
when( upRecParser.io.frameReq.fire & upRecParser.io.frameReq.bits.frameStyle === FRAME_STYLE_PROBE ){ //上行来了一个嗅探包
|
||||
when( upRecParser.io.frameReq.bits.frameInfo =/= localDevIndex + 1.U ){
|
||||
when( upRecParser.io.frameReq.bits.frameInfo =/= localDevIndex + 1.U ){ //索引不对
|
||||
isDeviceModified := true.B
|
||||
}
|
||||
}
|
||||
@@ -619,15 +651,15 @@ trait SlaveParserProbe{ this: SlaveParserBase =>
|
||||
io.upOut <> upSendGen.io.send
|
||||
io.downIn <> downRecParser.io.rec
|
||||
|
||||
when( isLastDevice & isReadyToProbe ){
|
||||
downSendGen.io.send <> upRecParser.io.rec
|
||||
when( isLastDevice & ~isReadyToProbe ){ //最后一个设备且不是探测模式
|
||||
downSendGen.io.send <> upRecParser.io.rec //axis短接
|
||||
|
||||
io.downOut.valid := false.B
|
||||
io.downOut.valid := false.B //对外下级io开路
|
||||
io.downOut.bits := 0.U.asTypeOf(new AXIS_Bundle(8))
|
||||
io.upIn.ready := false.B
|
||||
|
||||
} .otherwise{
|
||||
|
||||
|
||||
io.downOut <> downSendGen.io.send
|
||||
io.upIn <> upRecParser.io.rec
|
||||
|
||||
|
||||
Reference in New Issue
Block a user