From 77da3d050748bbd13ec7e442fc1e4863522f8a95 Mon Sep 17 00:00:00 2001 From: RuigeLee Date: Tue, 2 Sep 2025 18:50:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=A0=A1=E5=87=86+spi=20lvds?= =?UTF-8?q?=E5=86=99=E5=85=A5=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/scala/backBoard/shin/Interface.scala | 64 ++++++++++++------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/src/main/scala/backBoard/shin/Interface.scala b/src/main/scala/backBoard/shin/Interface.scala index 8915054..f1a3611 100644 --- a/src/main/scala/backBoard/shin/Interface.scala +++ b/src/main/scala/backBoard/shin/Interface.scala @@ -788,7 +788,8 @@ trait InterfaceSync{ this: InterfaceBase => cReg.syncWidth(i) := syncWidth(i) } - val syncPoint = RegInit(0.U(64.W)); cReg.syncPoint := syncPoint + val syncPoint = RegInit("hFFFFFFFFFFFFFFFF".U(64.W)); cReg.syncPoint := syncPoint + val syncPoint_WRCopy = RegInit("hFFFFFFFFFFFFFFFF".U(64.W)) val syncPeroid = RegInit(0.U(32.W)); cReg.syncPeroid := syncPeroid val syncOffset = for( i <- 0 until 4 ) yield { RegInit(0.U(32.W)) } //空开0 @@ -810,21 +811,22 @@ trait InterfaceSync{ this: InterfaceBase => } when( addrw === "h130".U ){ - syncPoint := Cat( syncPoint(63,8), dataw ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,8), dataw ) } .elsewhen( addrw === "h131".U ){ - syncPoint := Cat( syncPoint(63,16), dataw, syncPoint(7,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,16), dataw, syncPoint_WRCopy(7,0) ) } .elsewhen( addrw === "h132".U ){ - syncPoint := Cat( syncPoint(63,24), dataw, syncPoint(15,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,24), dataw, syncPoint_WRCopy(15,0) ) } .elsewhen( addrw === "h133".U ){ - syncPoint := Cat( syncPoint(63,32), dataw, syncPoint(23,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,32), dataw, syncPoint_WRCopy(23,0) ) } .elsewhen( addrw === "h134".U ){ - syncPoint := Cat( syncPoint(63,40), dataw, syncPoint(31,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,40), dataw, syncPoint_WRCopy(31,0) ) } .elsewhen( addrw === "h135".U ){ - syncPoint := Cat( syncPoint(63,48), dataw, syncPoint(39,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,48), dataw, syncPoint_WRCopy(39,0) ) } .elsewhen( addrw === "h136".U ){ - syncPoint := Cat( syncPoint(63,56), dataw, syncPoint(47,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,56), dataw, syncPoint_WRCopy(47,0) ) } .elsewhen( addrw === "h137".U ){ - syncPoint := Cat( dataw, syncPoint(55,0) ) + syncPoint_WRCopy := Cat( dataw, syncPoint_WRCopy(55,0) ) + syncPoint := Cat( dataw, syncPoint_WRCopy(55,0) ) } .elsewhen( addrw === "h138".U ){ @@ -870,7 +872,6 @@ trait InterfaceSync{ this: InterfaceBase => } - when( io.lvds.isEnW ){ when( io.lvds.addrw === "h120".U ){ @@ -886,21 +887,22 @@ trait InterfaceSync{ this: InterfaceBase => } .elsewhen( io.lvds.addrw === "h130".U ){ - syncPoint := Cat( syncPoint(63,8), io.lvds.dataw ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,8), io.lvds.dataw ) } .elsewhen( io.lvds.addrw === "h131".U ){ - syncPoint := Cat( syncPoint(63,16), io.lvds.dataw, syncPoint(7,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,16), io.lvds.dataw, syncPoint_WRCopy(7,0) ) } .elsewhen( io.lvds.addrw === "h132".U ){ - syncPoint := Cat( syncPoint(63,24), io.lvds.dataw, syncPoint(15,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,24), io.lvds.dataw, syncPoint_WRCopy(15,0) ) } .elsewhen( io.lvds.addrw === "h133".U ){ - syncPoint := Cat( syncPoint(63,32), io.lvds.dataw, syncPoint(23,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,32), io.lvds.dataw, syncPoint_WRCopy(23,0) ) } .elsewhen( io.lvds.addrw === "h134".U ){ - syncPoint := Cat( syncPoint(63,40), io.lvds.dataw, syncPoint(31,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,40), io.lvds.dataw, syncPoint_WRCopy(31,0) ) } .elsewhen( io.lvds.addrw === "h135".U ){ - syncPoint := Cat( syncPoint(63,48), io.lvds.dataw, syncPoint(39,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,48), io.lvds.dataw, syncPoint_WRCopy(39,0) ) } .elsewhen( io.lvds.addrw === "h136".U ){ - syncPoint := Cat( syncPoint(63,56), io.lvds.dataw, syncPoint(47,0) ) + syncPoint_WRCopy := Cat( syncPoint_WRCopy(63,56), io.lvds.dataw, syncPoint_WRCopy(47,0) ) } .elsewhen( io.lvds.addrw === "h137".U ){ - syncPoint := Cat( io.lvds.dataw, syncPoint(55,0) ) + syncPoint_WRCopy := Cat( io.lvds.dataw, syncPoint_WRCopy(55,0) ) + syncPoint := Cat( io.lvds.dataw, syncPoint_WRCopy(55,0) ) } .elsewhen( io.lvds.addrw === "h138".U ){ @@ -926,7 +928,7 @@ trait InterfaceSync{ this: InterfaceBase => } } - cReg.timeStamp := RegNext( cReg.timeStamp + 1.U, 0.U(64.W) ) + cReg.timeStamp := RegNext( cReg.timeStamp + 1.U, 1.U(64.W) ) cReg.mstDeltaTime := io.mstDeltaTime @@ -941,24 +943,40 @@ trait InterfaceSync{ this: InterfaceBase => val syncOffsetCnt = for( i <- 0 until 4 ) yield { RegInit("hFFFFFFFF".U(32.W)) } //空开第0位 val syncResetCnt = for( i <- 0 until 4 ) yield { RegInit(0.U(16.W)) } //空开第0位 + val recoTimeStamp_Copy = RegInit(1.U(64.W)) - when( cReg.syncPoint === cReg.recoTimeStamp ){ //时间到达sync0时间点 + + when( + cReg.syncPoint === recoTimeStamp_Copy || + (io.lvds.addrw === "h120".U & io.lvds.isEnW) || //写syncCfg + (io.lvds.addrw === "h137".U & io.lvds.isEnW) || //写syncPoint + (io.lvds.addrw === "h13B".U & io.lvds.isEnW) || //写syncPeroid + (addrw === "h120".U & isEnW) || //写syncCfg + (addrw === "h137".U & isEnW) || //写syncPoint + (addrw === "h13B".U & isEnW) //写syncPeroid + ){ + recoTimeStamp_Copy := cReg.timeStamp + sReg.deltaFinal + } .otherwise{ + recoTimeStamp_Copy := recoTimeStamp_Copy + 1.U + } + + + when( cReg.syncPoint === recoTimeStamp_Copy ){ //时间到达sync0时间点 syncSign(0) := true.B - } .elsewhen( ~cReg.syncCfg(4+0) & syncResetCnt(0) === cReg.syncWidth(0) ){ syncSign(0) := false.B } .elsewhen( cReg.syncCfg(4+0) & isEnW & addrw === "h122".U ){ syncSign(0) := false.B } - when( cReg.syncPoint <= cReg.recoTimeStamp ){ + when( cReg.syncPoint <= recoTimeStamp_Copy ){ syncPoint := syncPoint + cReg.syncPeroid } for( i <- 1 until 4 ) { - when( cReg.syncPoint === cReg.recoTimeStamp ){ //时间到达sync0时间点 + when( cReg.syncPoint === recoTimeStamp_Copy ){ //时间到达sync0时间点 syncOffsetCnt(i) := 0.U } .elsewhen( syncOffsetCnt(i) < cReg.syncOffset(i) ){ syncOffsetCnt(i) := syncOffsetCnt(i) + 1.U