代码整理

This commit is contained in:
RuigeLee
2025-09-11 11:50:58 +08:00
parent 2969cf70a1
commit d46e06d5b0
15 changed files with 506 additions and 964 deletions

View File

@@ -255,8 +255,6 @@ abstract class InterfaceBase extends Module with RequireAsyncReset{
(addr === ("h10".U(16.W) + i.U) ) -> cReg.uniCode( 8*i+7,8*i+0 )
}) ++
Seq(
(addr === "h8".U ) -> cReg.busRate( 7,0 ),
(addr === "h9".U ) -> cReg.spiSel,
@@ -264,25 +262,14 @@ abstract class InterfaceBase extends Module with RequireAsyncReset{
(addr === "hb".U & isSlvMode) -> sReg.localDevIndex(15,8),
) ++
Seq(
(addr === "h18".U ) -> sReg.lvdsWriteAble.extract(0),
(addr === "h20".U & isMstMode) -> Cat(mReg.rxSM, mReg.txSM, 0.U(1.W) ),
(addr === "h22".U & isMstMode) -> mReg.isRecCRCErr,
//(addr === "h21".U & isMstMode) -> mReg.txLength,
(addr === "h24".U & isMstMode) -> mReg.rplTimeStampTx(7,0),
(addr === "h25".U & isMstMode) -> mReg.rplTimeStampTx(15,8),
) ++
Seq(
(addr === "h40".U ) -> cReg.softResetCode(1),
(addr === "h41".U ) -> cReg.softResetCode(1),
@@ -374,14 +361,9 @@ abstract class InterfaceBase extends Module with RequireAsyncReset{
(addr === "hb6".U ) -> cReg.statUpRecByteCnt(55,48),
(addr === "hb7".U ) -> cReg.statUpRecByteCnt(63,56),
(addr === "hc0".U ) -> Cat( sReg.isDevOnRightModify, sReg.isDevOnRight, 0.U(3.W) ),
(addr === "hc2".U ) -> sReg.indexOfRightDev(7,0),
(addr === "hc3".U ) -> sReg.indexOfRightDev(13,8),
// (addr === "hc4".U ) -> sReg.indexOfLeftDev(7,0),
// (addr === "hc5".U ) -> sReg.indexOfLeftDev(13,8),
) ++
Seq(
@@ -500,18 +482,12 @@ abstract class InterfaceBase extends Module with RequireAsyncReset{
)}.reduce(_++_) ++
( 0 until 8 ).map{ i =>
( addr === ("h301".U(16.W) + (i*4).U) ) -> cReg.smUsedDepth(i)
} ++
( 0 until 8 ).map{ i =>
( addr === ("h302".U(16.W) + (i*4).U) ) -> cReg.smTrigLen(i)(7,0)
} ++
( 0 until 8 ).map{ i =>
( addr === ("h303".U(16.W) + (i*4).U) ) -> cReg.smTrigLen(i)(10,8)
} ++
( 0 until 4 ).map{ i =>
( addr === ("h400".U(16.W) + i.U) ) -> cReg.wdtStatus( 8*i+7, 8*i+0 )
} ++
( 0 until 4 ).map{ i =>
( addr === ("h404".U(16.W) + i.U) ) -> cReg.wdtEnable( 8*i+7, 8*i+0 )
} ++
(for( i <- 0 until 17; j <- 0 until 4 ) yield {
@@ -525,26 +501,12 @@ abstract class InterfaceBase extends Module with RequireAsyncReset{
) ++
( 0 until 8 ).map{ i =>
( addr === ("h508".U(16.W) + i.U) ) -> cReg.event.posedgeTimeStampLatch(0)( 8*i+7, 8*i+0 )
} ++
( 0 until 8 ).map{ i =>
( addr === ("h510".U(16.W) + i.U) ) -> cReg.event.negedgeTimeStampLatch(0)( 8*i+7, 8*i+0 )
} ++
( 0 until 8 ).map{ i =>
( addr === ("h518".U(16.W) + i.U) ) -> cReg.event.posedgeTimeStampLatch(1)( 8*i+7, 8*i+0 )
} ++
( 0 until 8 ).map{ i =>
( addr === ("h520".U(16.W) + i.U) ) -> cReg.event.negedgeTimeStampLatch(1)( 8*i+7, 8*i+0 )
} ++
( 0 until 8 ).map{ i =>
( addr === ("h528".U(16.W) + i.U) ) -> cReg.event.mcuSMTimeStampEnq( 8*i+7, 8*i+0 )
} ++
( 0 until 8 ).map{ i =>
( addr === ("h530".U(16.W) + i.U) ) -> cReg.event.mcuSMTimeStampDeq( 8*i+7, 8*i+0 )
} ++
( 0 until 8 ).map{ i =>
( addr === ("h538".U(16.W) + i.U) ) -> cReg.event.lvdsSMTimeStampEnq( 8*i+7, 8*i+0 )
} ++
( 0 until 8 ).map{ i =>
( addr === ("h540".U(16.W) + i.U) ) -> cReg.event.lvdsSMTimeStampDeq( 8*i+7, 8*i+0 )
} ++
Seq()
@@ -569,12 +531,6 @@ abstract class InterfaceBase extends Module with RequireAsyncReset{
trait InterfaceMCUop{ this: InterfaceBase =>
isEnW := Mux1H(Seq(
( cReg.spiSel === 0.U ) -> iQSpi.io.isEnW,
( cReg.spiSel === 1.U ) -> oSpi.io.isEnW,
@@ -638,7 +594,6 @@ trait InterfaceMCUop{ this: InterfaceBase =>
mReg.txSM := RegEnable( dataw(2,1), 0.U(2.W), isEnW & addrw === "h20".U )
mReg.rxSM := RegEnable( dataw(4,3), 0.U(2.W), isEnW & addrw === "h20".U )
// mReg.txLength := Cat( RegEnable( dataw, 0.U, isEnW & addrw === "h22".U ), RegEnable( dataw, 0.U, isEnW & addrw === "h21".U ) )
val mReg_isRecCRCErr = RegInit(0.U(4.W))
mReg.isRecCRCErr := mReg_isRecCRCErr
@@ -680,7 +635,6 @@ trait InterfaceCheckSM{ this: InterfaceBase =>
for( i <- 0 until 8 ){
io.isSMReset(i) := isEnW & (addrw === ("h300".U(16.W) + (i*4).U))
cReg.smUsedDepth(i) := io.smUsedDepth(i)
@@ -699,10 +653,6 @@ trait InterfaceCheckSM{ this: InterfaceBase =>
smTrigLen_L(i) := io.lvds.dataw
}
}
}
@@ -746,8 +696,6 @@ trait InterfaceEBMMU{ this: InterfaceBase =>
io.lvds.datar := RegEnable(AcquireReg(addr = io.lvds.addrr), 0.U(8.W), io.lvds.isEnR)
( 0 until 16 ).map{ i =>
sReg.ebmmu(i).lAddr := Cat(
RegEnable( io.lvds.dataw(5,0), 0.U(8.W), sReg.isLVDSWriteAble & io.lvds.isEnW & isSlvMode & (io.lvds.addrw === ( "h203".U(16.W) + (10*i).U )) ),
@@ -1040,8 +988,8 @@ trait InterfaceWdt{ this: InterfaceBase =>
cReg.wdtEnable :=
Cat(
RegEnable( dataw(1,0), 0.U(2.W), isEnW & addrw === "h406".U ),
RegEnable( dataw, 0.U(8.W), isEnW & addrw === "h405".U ),
RegEnable( dataw, 0.U(8.W), isEnW & addrw === "h404".U ),
RegEnable( dataw, 0.U(8.W), isEnW & addrw === "h405".U ),
RegEnable( dataw, 0.U(8.W), isEnW & addrw === "h404".U ),
)
for( i <- 0 until 18 ){
@@ -1145,9 +1093,6 @@ trait InterfaceInterrupt{ this: InterfaceBase =>
intStatus(4) := true.B
}
//从站SM请求
for( i <- 0 until 8 ){
when( io.intSlvTrig(i) ){
@@ -1398,11 +1343,6 @@ trait InterfaceStat{ this: InterfaceBase =>
statDownRecByteCnt := statDownRecByteCnt + 1.U
}
when(io.lvds.isEnW & (io.lvds.addrw === "ha0".U )){
statUpRecErrorCnt := 0.U
} .elsewhen( io.upRecStat.isRecError ){
@@ -1475,10 +1415,7 @@ with InterfaceAnalog
io.txReq.bits.txSM := mReg.txSM
io.txReq.bits.rxSM := mReg.rxSM
// io.txReq.bits.txLength := //mReg.txLength
io.txReq.valid := RegNext(isEnW & addrw === "h20".U & dataw.extract(0) === "b1".U, false.B) //& mReg.txLength =/= 0.U
io.txReq.valid := RegNext(isEnW & addrw === "h20".U & dataw.extract(0) === "b1".U, false.B)
sReg.localDevIndex := io.localDevIndex
@@ -1487,6 +1424,5 @@ with InterfaceAnalog
sReg.isDevOnRightModify := io.isDevOnRightModify
sReg.indexOfRightDev := io.indexOfRightDev
}
}