2025-08-26 10:30:12 +08:00
|
|
|
|
package BACK
|
|
|
|
|
|
|
|
|
|
|
|
import chisel3._
|
|
|
|
|
|
import chisel3.util._
|
|
|
|
|
|
|
2025-08-26 17:52:23 +08:00
|
|
|
|
class TopBase_IO_Bundle extends Bundle{
|
2025-08-26 10:30:12 +08:00
|
|
|
|
val dDatIn = Input(Bool())
|
|
|
|
|
|
val dDatOut = Output(Bool())
|
|
|
|
|
|
val uDatIn = Input(Bool())
|
|
|
|
|
|
val uDatOut = Output(Bool())
|
|
|
|
|
|
|
|
|
|
|
|
val iqspi = new QSPIInterfaceIO
|
|
|
|
|
|
val ospi = new SSPIInterfaceIO
|
|
|
|
|
|
val oqspi = new QSPIInterfaceIO
|
|
|
|
|
|
|
|
|
|
|
|
val iSync = Output(Vec(4, Bool()))
|
|
|
|
|
|
|
|
|
|
|
|
val isSoftReset = Output(Bool())
|
|
|
|
|
|
|
|
|
|
|
|
val interrupt = Output(Bool())
|
|
|
|
|
|
|
|
|
|
|
|
val latchPin = Input(Vec(2, Bool()))
|
|
|
|
|
|
val hwSerial = Input(UInt(48.W))
|
|
|
|
|
|
val uniCode = Input(UInt(64.W))
|
|
|
|
|
|
|
|
|
|
|
|
val pllCtrl = Output(UInt(32.W))
|
|
|
|
|
|
val xtal = Output(UInt(12.W))
|
|
|
|
|
|
val anamuxSel = Output(UInt(5.W))
|
|
|
|
|
|
val ldo2p5 = Output(UInt(8.W))
|
|
|
|
|
|
val ldo1p1 = Output(UInt(8.W))
|
|
|
|
|
|
val refTop = Output(UInt(3.W))
|
|
|
|
|
|
val bias = Output(UInt(2.W))
|
|
|
|
|
|
|
|
|
|
|
|
val spiSel = Output(UInt(2.W))
|
2025-08-27 15:20:43 +08:00
|
|
|
|
val isPllCfg = Output(Bool())
|
2025-08-26 10:30:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-26 17:52:23 +08:00
|
|
|
|
class MstSlvSwitchIO extends TopBase_IO_Bundle{
|
|
|
|
|
|
|
|
|
|
|
|
val downCDROut = Flipped(new CDROutIO)
|
|
|
|
|
|
val upCDROut = Flipped(new CDROutIO)
|
|
|
|
|
|
val downCDRIn = Flipped(new CDRInIO)
|
|
|
|
|
|
val upCDRIn = Flipped(new CDRInIO)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract class MstSlvSwitchBase extends Module with RequireAsyncReset{
|
|
|
|
|
|
|
|
|
|
|
|
val io: MstSlvSwitchIO = IO(new MstSlvSwitchIO)
|
|
|
|
|
|
|
|
|
|
|
|
val slaveParser = Module(new SlaveParser )
|
|
|
|
|
|
val masterParser = Module(new MasterParser)
|
|
|
|
|
|
|
2025-09-05 12:55:32 +08:00
|
|
|
|
val b4b5DownEncoder = Module(new b4b5DualEncode)
|
|
|
|
|
|
val b4b5DownDecoder = Module(new b4b5DualDecode)
|
|
|
|
|
|
val b4b5UpEncoder = Module(new b4b5DualEncode)
|
|
|
|
|
|
val b4b5UpDecoder = Module(new b4b5DualDecode)
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
2025-09-05 12:55:32 +08:00
|
|
|
|
val b8b10DownEncoder = Module(new b8b10Encode)
|
|
|
|
|
|
val b8b10DownDecoder = Module(new b8b10Decode)
|
|
|
|
|
|
val b8b10UpEncoder = Module(new b8b10Encode)
|
|
|
|
|
|
val b8b10UpDecoder = Module(new b8b10Decode)
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val interface = Module(new Interface)
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.latchPin := io.latchPin
|
|
|
|
|
|
interface.io.uniCode := io.uniCode
|
|
|
|
|
|
interface.io.hwSerial := io.hwSerial
|
|
|
|
|
|
|
2025-08-26 17:52:23 +08:00
|
|
|
|
interface.io.intTransEnd(0) := io.downCDRIn.axis.fire & io.downCDRIn.axis.bits.tlast
|
|
|
|
|
|
interface.io.intTransEnd(1) := io.downCDROut.axis.fire & io.downCDROut.axis.bits.tlast
|
|
|
|
|
|
interface.io.intTransEnd(2) := io.upCDRIn.axis.fire & io.upCDRIn.axis.bits.tlast
|
|
|
|
|
|
interface.io.intTransEnd(3) := io.upCDROut.axis.fire & io.upCDROut.axis.bits.tlast
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
io.isSoftReset := interface.io.isSoftReset
|
|
|
|
|
|
io.interrupt := interface.io.interrupt
|
|
|
|
|
|
|
|
|
|
|
|
io.ospi <> interface.io.ospi
|
|
|
|
|
|
io.iqspi <> interface.io.iqspi
|
|
|
|
|
|
io.oqspi <> interface.io.oqspi
|
|
|
|
|
|
|
|
|
|
|
|
io.iSync := interface.io.sync
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
io.pllCtrl := interface.io.cReg.pllCtrl
|
|
|
|
|
|
io.xtal := interface.io.cReg.xtal
|
|
|
|
|
|
io.anamuxSel := interface.io.cReg.anamuxSel
|
|
|
|
|
|
io.ldo2p5 := interface.io.cReg.ldo2p5
|
|
|
|
|
|
io.ldo1p1 := interface.io.cReg.ldo1p1
|
|
|
|
|
|
io.refTop := interface.io.cReg.refTop
|
|
|
|
|
|
io.bias := interface.io.cReg.bias
|
|
|
|
|
|
|
2025-08-27 15:20:43 +08:00
|
|
|
|
io.spiSel := interface.io.cReg.spiSel
|
|
|
|
|
|
io.isPllCfg := interface.io.isPllCfg
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
val sram = Seq(
|
|
|
|
|
|
for( _ <- 0 until 4 ) yield { Module(new ShareSRAM2k) },
|
|
|
|
|
|
for( _ <- 0 until 4 ) yield { Module(new ShareSRAM2k) },
|
|
|
|
|
|
for( _ <- 0 until 4 ) yield { Module(new ShareSRAM2k) },
|
|
|
|
|
|
for( _ <- 0 until 4 ) yield { Module(new ShareSRAM2k) },
|
|
|
|
|
|
for( _ <- 0 until 2 ) yield { Module(new ShareSRAM2k) },
|
|
|
|
|
|
for( _ <- 0 until 2 ) yield { Module(new ShareSRAM2k) },
|
|
|
|
|
|
for( _ <- 0 until 2 ) yield { Module(new ShareSRAM2k) },
|
|
|
|
|
|
for( _ <- 0 until 2 ) yield { Module(new ShareSRAM2k) },
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val smUnit = Seq(
|
|
|
|
|
|
Module( new SMUnit(depth = 4) ),
|
|
|
|
|
|
Module( new SMUnit(depth = 4) ),
|
|
|
|
|
|
Module( new SMUnit(depth = 4) ),
|
|
|
|
|
|
Module( new SMUnit(depth = 4) ),
|
|
|
|
|
|
Module( new SMUnit(depth = 2) ),
|
|
|
|
|
|
Module( new SMUnit(depth = 2) ),
|
|
|
|
|
|
Module( new SMUnit(depth = 2) ),
|
|
|
|
|
|
Module( new SMUnit(depth = 2) ),
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
val lvdsSMEnq = for( i <- 0 until 4 ) yield WireDefault(false.B); interface.io.lvdsSMEnq := lvdsSMEnq
|
|
|
|
|
|
val lvdsSMDeq = for( i <- 0 until 4 ) yield WireDefault(false.B); interface.io.lvdsSMDeq := lvdsSMDeq
|
2025-09-03 18:04:10 +08:00
|
|
|
|
val lvdsSMComf = for( i <- 0 until 4 ) yield WireDefault(false.B)
|
|
|
|
|
|
val lvdsSMAbrt = for( i <- 0 until 4 ) yield WireDefault(false.B)
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
smUnit(0).io.enq := lvdsSMEnq(0)
|
|
|
|
|
|
smUnit(2).io.enq := lvdsSMEnq(1)
|
|
|
|
|
|
smUnit(4).io.enq := lvdsSMEnq(2)
|
|
|
|
|
|
smUnit(6).io.enq := lvdsSMEnq(3)
|
|
|
|
|
|
|
2025-09-03 18:04:10 +08:00
|
|
|
|
smUnit(0).io.isComf := lvdsSMComf(0)
|
|
|
|
|
|
smUnit(2).io.isComf := lvdsSMComf(1)
|
|
|
|
|
|
smUnit(4).io.isComf := lvdsSMComf(2)
|
|
|
|
|
|
smUnit(6).io.isComf := lvdsSMComf(3)
|
|
|
|
|
|
|
|
|
|
|
|
smUnit(0).io.isAbrt := lvdsSMAbrt(0)
|
|
|
|
|
|
smUnit(2).io.isAbrt := lvdsSMAbrt(1)
|
|
|
|
|
|
smUnit(4).io.isAbrt := lvdsSMAbrt(2)
|
|
|
|
|
|
smUnit(6).io.isAbrt := lvdsSMAbrt(3)
|
|
|
|
|
|
|
2025-08-26 10:30:12 +08:00
|
|
|
|
smUnit(1).io.deq := lvdsSMDeq(0)
|
|
|
|
|
|
smUnit(3).io.deq := lvdsSMDeq(1)
|
|
|
|
|
|
smUnit(5).io.deq := lvdsSMDeq(2)
|
|
|
|
|
|
smUnit(7).io.deq := lvdsSMDeq(3)
|
|
|
|
|
|
|
|
|
|
|
|
smUnit(0).io.sram_r <> interface.io.sram_r(0)
|
|
|
|
|
|
smUnit(2).io.sram_r <> interface.io.sram_r(1)
|
|
|
|
|
|
smUnit(4).io.sram_r <> interface.io.sram_r(2)
|
|
|
|
|
|
smUnit(6).io.sram_r <> interface.io.sram_r(3)
|
|
|
|
|
|
|
|
|
|
|
|
smUnit(1).io.sram_w := interface.io.sram_w(0)
|
|
|
|
|
|
smUnit(3).io.sram_w := interface.io.sram_w(1)
|
|
|
|
|
|
smUnit(5).io.sram_w := interface.io.sram_w(2)
|
|
|
|
|
|
smUnit(7).io.sram_w := interface.io.sram_w(3)
|
|
|
|
|
|
|
|
|
|
|
|
smUnit(0).io.deq := interface.io.dSMdeq(0)
|
|
|
|
|
|
smUnit(2).io.deq := interface.io.dSMdeq(1)
|
|
|
|
|
|
smUnit(4).io.deq := interface.io.dSMdeq(2)
|
|
|
|
|
|
smUnit(6).io.deq := interface.io.dSMdeq(3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
smUnit(1).io.enq := interface.io.uSMenq(0)
|
|
|
|
|
|
smUnit(3).io.enq := interface.io.uSMenq(1)
|
|
|
|
|
|
smUnit(5).io.enq := interface.io.uSMenq(2)
|
|
|
|
|
|
smUnit(7).io.enq := interface.io.uSMenq(3)
|
|
|
|
|
|
|
2025-09-03 18:04:10 +08:00
|
|
|
|
smUnit(1).io.isComf := RegNext( smUnit(1).io.enq, false.B )
|
|
|
|
|
|
smUnit(3).io.isComf := RegNext( smUnit(3).io.enq, false.B )
|
|
|
|
|
|
smUnit(5).io.isComf := RegNext( smUnit(5).io.enq, false.B )
|
|
|
|
|
|
smUnit(7).io.isComf := RegNext( smUnit(7).io.enq, false.B )
|
|
|
|
|
|
|
|
|
|
|
|
smUnit(1).io.isAbrt := false.B
|
|
|
|
|
|
smUnit(3).io.isAbrt := false.B
|
|
|
|
|
|
smUnit(5).io.isAbrt := false.B
|
|
|
|
|
|
smUnit(7).io.isAbrt := false.B
|
|
|
|
|
|
|
2025-08-26 10:30:12 +08:00
|
|
|
|
for( i <- 0 until 8 ){
|
|
|
|
|
|
interface.io.smUsedDepth(i) := smUnit(i).io.cnt
|
|
|
|
|
|
smUnit(i).io.flush := interface.io.isSMReset(i)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for( i <- 0 until 4 ){
|
|
|
|
|
|
for( j <- 0 until 4 ){
|
|
|
|
|
|
sram(i)(j).io.clockr := clock.asBool
|
|
|
|
|
|
sram(i)(j).io.clockw := clock.asBool
|
|
|
|
|
|
|
|
|
|
|
|
smUnit(i).io.sram(j).rd.datar := sram(i)(j).io.datar
|
|
|
|
|
|
sram(i)(j).io.dataw := smUnit(i).io.sram(j).wr.dataw
|
|
|
|
|
|
sram(i)(j).io.addrw := smUnit(i).io.sram(j).wr.addrw
|
|
|
|
|
|
sram(i)(j).io.enw := smUnit(i).io.sram(j).wr.enw
|
|
|
|
|
|
sram(i)(j).io.addrr := smUnit(i).io.sram(j).rd.addrr
|
|
|
|
|
|
sram(i)(j).io.enr := smUnit(i).io.sram(j).rd.enr
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for( i <- 4 until 8 ){
|
|
|
|
|
|
for( j <- 0 until 2 ){
|
|
|
|
|
|
sram(i)(j).io.clockr := clock.asBool
|
|
|
|
|
|
sram(i)(j).io.clockw := clock.asBool
|
|
|
|
|
|
|
|
|
|
|
|
smUnit(i).io.sram(j).rd.datar := sram(i)(j).io.datar
|
|
|
|
|
|
sram(i)(j).io.dataw := smUnit(i).io.sram(j).wr.dataw
|
|
|
|
|
|
sram(i)(j).io.addrw := smUnit(i).io.sram(j).wr.addrw
|
|
|
|
|
|
sram(i)(j).io.enw := smUnit(i).io.sram(j).wr.enw
|
|
|
|
|
|
sram(i)(j).io.addrr := smUnit(i).io.sram(j).rd.addrr
|
|
|
|
|
|
sram(i)(j).io.enr := smUnit(i).io.sram(j).rd.enr
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//default
|
|
|
|
|
|
{
|
|
|
|
|
|
smUnit(0).io.sram_w := 0.U.asTypeOf(new SRAM2kWRIO)
|
|
|
|
|
|
smUnit(2).io.sram_w := 0.U.asTypeOf(new SRAM2kWRIO)
|
|
|
|
|
|
smUnit(4).io.sram_w := 0.U.asTypeOf(new SRAM2kWRIO)
|
|
|
|
|
|
smUnit(6).io.sram_w := 0.U.asTypeOf(new SRAM2kWRIO)
|
|
|
|
|
|
|
|
|
|
|
|
smUnit(1).io.sram_r.enr := false.B
|
|
|
|
|
|
smUnit(3).io.sram_r.enr := false.B
|
|
|
|
|
|
smUnit(5).io.sram_r.enr := false.B
|
|
|
|
|
|
smUnit(7).io.sram_r.enr := false.B
|
|
|
|
|
|
smUnit(1).io.sram_r.addrr := 0.U
|
|
|
|
|
|
smUnit(3).io.sram_r.addrr := 0.U
|
|
|
|
|
|
smUnit(5).io.sram_r.addrr := 0.U
|
|
|
|
|
|
smUnit(7).io.sram_r.addrr := 0.U
|
|
|
|
|
|
|
|
|
|
|
|
slaveParser.io.sram_r(0).datar := 0.U
|
|
|
|
|
|
slaveParser.io.sram_r(1).datar := 0.U
|
|
|
|
|
|
slaveParser.io.sram_r(2).datar := 0.U
|
|
|
|
|
|
slaveParser.io.sram_r(3).datar := 0.U
|
|
|
|
|
|
masterParser.io.sram_r.datar := 0.U
|
|
|
|
|
|
|
2025-08-26 17:52:23 +08:00
|
|
|
|
io.downCDRIn.axis.ready := false.B
|
2025-08-26 10:30:12 +08:00
|
|
|
|
slaveParser.io.downIn.valid := false.B
|
|
|
|
|
|
slaveParser.io.downIn.bits := 0.U.asTypeOf(new AXIS_Bundle(8))
|
|
|
|
|
|
|
|
|
|
|
|
slaveParser.io.downOut.ready := false.B
|
|
|
|
|
|
masterParser.io.downOut.ready := false.B
|
2025-08-26 17:52:23 +08:00
|
|
|
|
io.downCDROut.axis.valid := false.B
|
|
|
|
|
|
io.downCDROut.axis.bits := 0.U.asTypeOf(new AXIS_Bundle(8))
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
2025-08-26 17:52:23 +08:00
|
|
|
|
io.upCDRIn.axis.ready := false.B
|
2025-08-26 10:30:12 +08:00
|
|
|
|
slaveParser.io.upIn.valid := false.B
|
|
|
|
|
|
slaveParser.io.upIn.bits := 0.U.asTypeOf(new AXIS_Bundle(8))
|
|
|
|
|
|
masterParser.io.upIn.valid := false.B
|
|
|
|
|
|
masterParser.io.upIn.bits := 0.U.asTypeOf(new AXIS_Bundle(8))
|
|
|
|
|
|
|
|
|
|
|
|
slaveParser.io.upOut.ready := false.B
|
2025-08-26 17:52:23 +08:00
|
|
|
|
io.upCDROut.axis.valid := false.B
|
|
|
|
|
|
io.upCDROut.axis.bits := 0.U.asTypeOf(new AXIS_Bundle(8))
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
interface.io.mstDeltaTime := 0.U
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.slvDeltaTime := 0.U
|
|
|
|
|
|
interface.io.deltaFinal := 0.U
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.intMstTrig(0) := false.B
|
|
|
|
|
|
interface.io.intMstTrig(1) := false.B
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.intSlvTrig(0) := false.B
|
|
|
|
|
|
interface.io.intSlvTrig(1) := false.B
|
|
|
|
|
|
interface.io.intSlvTrig(2) := false.B
|
|
|
|
|
|
interface.io.intSlvTrig(3) := false.B
|
|
|
|
|
|
interface.io.intSlvTrig(4) := false.B
|
|
|
|
|
|
interface.io.intSlvTrig(5) := false.B
|
|
|
|
|
|
interface.io.intSlvTrig(6) := false.B
|
|
|
|
|
|
interface.io.intSlvTrig(7) := false.B
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.intHWTrig(0) := false.B
|
|
|
|
|
|
interface.io.intHWTrig(1) := false.B
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.downRecStat := 0.U.asTypeOf(new Stat_IO_Bundle)
|
|
|
|
|
|
interface.io.upRecStat := 0.U.asTypeOf(new Stat_IO_Bundle)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trait MstSlvSwitchMaster{ this: MstSlvSwitchBase =>
|
|
|
|
|
|
|
|
|
|
|
|
when( interface.io.cReg.modeSel === true.B ){
|
2025-08-26 17:52:23 +08:00
|
|
|
|
masterParser.io.downOut <> io.downCDROut.axis
|
|
|
|
|
|
masterParser.io.upIn <> io.upCDRIn.axis
|
2025-08-26 10:30:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
when( interface.io.cReg.modeSel === true.B ){
|
|
|
|
|
|
|
|
|
|
|
|
when( interface.io.txReq.bits.rxSM === 0.U ){
|
|
|
|
|
|
smUnit(0).io.sram_w := masterParser.io.sram_w
|
2025-09-03 18:04:10 +08:00
|
|
|
|
lvdsSMEnq(0) := masterParser.io.rxEnq
|
|
|
|
|
|
lvdsSMComf(0) := RegNext(masterParser.io.rxEnq, false.B)
|
|
|
|
|
|
lvdsSMAbrt(0) := false.B
|
2025-08-26 10:30:12 +08:00
|
|
|
|
} .elsewhen( interface.io.txReq.bits.rxSM === 1.U ){
|
|
|
|
|
|
smUnit(2).io.sram_w := masterParser.io.sram_w
|
2025-09-03 18:04:10 +08:00
|
|
|
|
lvdsSMEnq(1) := masterParser.io.rxEnq
|
|
|
|
|
|
lvdsSMComf(1) := RegNext(masterParser.io.rxEnq, false.B)
|
|
|
|
|
|
lvdsSMAbrt(1) := false.B
|
2025-08-26 10:30:12 +08:00
|
|
|
|
} .elsewhen( interface.io.txReq.bits.rxSM === 2.U ){
|
|
|
|
|
|
smUnit(4).io.sram_w := masterParser.io.sram_w
|
2025-09-03 18:04:10 +08:00
|
|
|
|
lvdsSMEnq(2) := masterParser.io.rxEnq
|
|
|
|
|
|
lvdsSMComf(2) := RegNext(masterParser.io.rxEnq, false.B)
|
|
|
|
|
|
lvdsSMAbrt(2) := false.B
|
2025-08-26 10:30:12 +08:00
|
|
|
|
} .elsewhen( interface.io.txReq.bits.rxSM === 3.U ){
|
|
|
|
|
|
smUnit(6).io.sram_w := masterParser.io.sram_w
|
2025-09-03 18:04:10 +08:00
|
|
|
|
lvdsSMEnq(3) := masterParser.io.rxEnq
|
|
|
|
|
|
lvdsSMComf(3) := RegNext(masterParser.io.rxEnq, false.B)
|
|
|
|
|
|
lvdsSMAbrt(3) := false.B
|
2025-08-26 10:30:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
when( interface.io.txReq.bits.txSM === 0.U ){
|
|
|
|
|
|
smUnit(1).io.sram_r <> masterParser.io.sram_r
|
|
|
|
|
|
lvdsSMDeq(0) := masterParser.io.txDeq
|
|
|
|
|
|
} .elsewhen( interface.io.txReq.bits.txSM === 1.U ){
|
|
|
|
|
|
smUnit(3).io.sram_r <> masterParser.io.sram_r
|
|
|
|
|
|
lvdsSMDeq(1) := masterParser.io.txDeq
|
|
|
|
|
|
} .elsewhen( interface.io.txReq.bits.txSM === 2.U ){
|
|
|
|
|
|
smUnit(5).io.sram_r <> masterParser.io.sram_r
|
|
|
|
|
|
lvdsSMDeq(2) := masterParser.io.txDeq
|
|
|
|
|
|
} .elsewhen( interface.io.txReq.bits.txSM === 3.U ){
|
|
|
|
|
|
smUnit(7).io.sram_r <> masterParser.io.sram_r
|
|
|
|
|
|
lvdsSMDeq(3) := masterParser.io.txDeq
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.mstDeltaTime := masterParser.io.deltaTimeStamp
|
|
|
|
|
|
interface.io.intMstTrig(0) := masterParser.io.txDeq
|
|
|
|
|
|
interface.io.intMstTrig(1) := masterParser.io.rxEnq
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.downRecStat := 0.U.asTypeOf(new Stat_IO_Bundle)
|
|
|
|
|
|
interface.io.upRecStat := masterParser.io.upRecStat
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
masterParser.io.req := interface.io.txReq.valid
|
|
|
|
|
|
// masterParser.io.req.bits.txLength := interface.io.txReq.bits.txLength
|
|
|
|
|
|
|
|
|
|
|
|
// io.rsp := masterParser.io.rsp
|
|
|
|
|
|
|
|
|
|
|
|
masterParser.io.cReg := interface.io.cReg
|
|
|
|
|
|
masterParser.io.mReg := interface.io.mReg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trait MstSlvSwitchSlave{ this: MstSlvSwitchBase =>
|
|
|
|
|
|
|
|
|
|
|
|
when( interface.io.cReg.modeSel === false.B ){
|
2025-08-26 17:52:23 +08:00
|
|
|
|
slaveParser.io.downIn <> io.downCDRIn.axis
|
|
|
|
|
|
io.downCDROut.axis <> slaveParser.io.downOut
|
|
|
|
|
|
slaveParser.io.upIn <> io.upCDRIn.axis
|
|
|
|
|
|
io.upCDROut.axis <> slaveParser.io.upOut
|
2025-08-26 10:30:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
slaveParser.io.cReg := interface.io.cReg
|
|
|
|
|
|
slaveParser.io.sReg := interface.io.sReg
|
|
|
|
|
|
|
|
|
|
|
|
when( interface.io.cReg.modeSel === false.B ){
|
|
|
|
|
|
smUnit(0).io.sram_w := slaveParser.io.sram_w(0)
|
|
|
|
|
|
smUnit(2).io.sram_w := slaveParser.io.sram_w(1)
|
|
|
|
|
|
smUnit(4).io.sram_w := slaveParser.io.sram_w(2)
|
|
|
|
|
|
smUnit(6).io.sram_w := slaveParser.io.sram_w(3)
|
|
|
|
|
|
|
|
|
|
|
|
smUnit(1).io.sram_r <> slaveParser.io.sram_r(0)
|
|
|
|
|
|
smUnit(3).io.sram_r <> slaveParser.io.sram_r(1)
|
|
|
|
|
|
smUnit(5).io.sram_r <> slaveParser.io.sram_r(2)
|
|
|
|
|
|
smUnit(7).io.sram_r <> slaveParser.io.sram_r(3)
|
|
|
|
|
|
|
|
|
|
|
|
lvdsSMEnq(0) := slaveParser.io.dSMenq(0)
|
|
|
|
|
|
lvdsSMEnq(1) := slaveParser.io.dSMenq(1)
|
|
|
|
|
|
lvdsSMEnq(2) := slaveParser.io.dSMenq(2)
|
|
|
|
|
|
lvdsSMEnq(3) := slaveParser.io.dSMenq(3)
|
|
|
|
|
|
|
2025-09-03 18:04:10 +08:00
|
|
|
|
lvdsSMComf(0) := slaveParser.io.downRecStat.isFinish
|
|
|
|
|
|
lvdsSMComf(1) := slaveParser.io.downRecStat.isFinish
|
|
|
|
|
|
lvdsSMComf(2) := slaveParser.io.downRecStat.isFinish
|
|
|
|
|
|
lvdsSMComf(3) := slaveParser.io.downRecStat.isFinish
|
|
|
|
|
|
|
|
|
|
|
|
lvdsSMAbrt(0) := slaveParser.io.downRecStat.isRecError
|
|
|
|
|
|
lvdsSMAbrt(1) := slaveParser.io.downRecStat.isRecError
|
|
|
|
|
|
lvdsSMAbrt(2) := slaveParser.io.downRecStat.isRecError
|
|
|
|
|
|
lvdsSMAbrt(3) := slaveParser.io.downRecStat.isRecError
|
|
|
|
|
|
|
2025-08-26 10:30:12 +08:00
|
|
|
|
lvdsSMDeq(0) := slaveParser.io.uSMdeq(0)
|
|
|
|
|
|
lvdsSMDeq(1) := slaveParser.io.uSMdeq(1)
|
|
|
|
|
|
lvdsSMDeq(2) := slaveParser.io.uSMdeq(2)
|
|
|
|
|
|
lvdsSMDeq(3) := slaveParser.io.uSMdeq(3)
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.mstDeltaTime := slaveParser.io.mstDeltaTimeStamp
|
|
|
|
|
|
interface.io.slvDeltaTime := slaveParser.io.slvDeltaTime
|
|
|
|
|
|
interface.io.deltaFinal := slaveParser.io.deltaFinal
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.intSlvTrig(0) := slaveParser.io.dSMenq(0)
|
|
|
|
|
|
interface.io.intSlvTrig(1) := slaveParser.io.uSMdeq(0)
|
|
|
|
|
|
interface.io.intSlvTrig(2) := slaveParser.io.dSMenq(1)
|
|
|
|
|
|
interface.io.intSlvTrig(3) := slaveParser.io.uSMdeq(1)
|
|
|
|
|
|
interface.io.intSlvTrig(4) := slaveParser.io.dSMenq(2)
|
|
|
|
|
|
interface.io.intSlvTrig(5) := slaveParser.io.uSMdeq(2)
|
|
|
|
|
|
interface.io.intSlvTrig(6) := slaveParser.io.dSMenq(3)
|
|
|
|
|
|
interface.io.intSlvTrig(7) := slaveParser.io.uSMdeq(3)
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.intHWTrig(0) := slaveParser.io.intHWTrig(0)
|
|
|
|
|
|
interface.io.intHWTrig(1) := slaveParser.io.intHWTrig(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.downRecStat := slaveParser.io.downRecStat
|
|
|
|
|
|
interface.io.upRecStat := slaveParser.io.upRecStat
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
slaveParser.io.intHWClr(0) := interface.io.intHWTrig(0) & interface.io.intHWClr(0)
|
|
|
|
|
|
slaveParser.io.intHWClr(1) := interface.io.intHWTrig(1) & interface.io.intHWClr(1)
|
2025-09-02 16:22:27 +08:00
|
|
|
|
io.downCDRIn.flush := RegNext( interface.io.intHWTrig(0) & interface.io.intHWClr(0), false.B )
|
|
|
|
|
|
io.upCDRIn.flush := RegNext( interface.io.intHWTrig(1) & interface.io.intHWClr(1), false.B )
|
|
|
|
|
|
io.downCDROut.flush := RegNext( interface.io.intHWTrig(0) & interface.io.intHWClr(0), false.B )
|
|
|
|
|
|
io.upCDROut.flush := RegNext( interface.io.intHWTrig(1) & interface.io.intHWClr(1), false.B )
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
interface.io.lvds <> slaveParser.io.lvds
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.localDevIndex := slaveParser.io.localDevIndex
|
|
|
|
|
|
|
|
|
|
|
|
//从站链路寄存器
|
|
|
|
|
|
// interface.io.isDevOnLeft := slaveParser.io.isDevOnLeft
|
|
|
|
|
|
// interface.io.isDevOnLeftModify := slaveParser.io.isDevOnLeftModify
|
|
|
|
|
|
// interface.io.indexOfLeftDev := slaveParser.io.indexOfLeftDev
|
|
|
|
|
|
interface.io.isDevOnRight := slaveParser.io.isDevOnRight
|
|
|
|
|
|
interface.io.isDevOnRightModify := slaveParser.io.isDevOnRightModify
|
|
|
|
|
|
interface.io.indexOfRightDev := slaveParser.io.indexOfRightDev
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-26 17:52:23 +08:00
|
|
|
|
trait MstSlvSwitchWatchDog{ this: MstSlvSwitchBase =>
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
//看门狗1~16,SM监控
|
|
|
|
|
|
val isWdtSMEnable = for( _ <- 0 until 16 ) yield { RegInit(false.B) }
|
2025-09-02 16:22:27 +08:00
|
|
|
|
val wdtSMCnt = for( _ <- 0 until 16 ) yield { RegInit(0.U(32.W)) }
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
for( i <- 0 until 8 ){
|
|
|
|
|
|
when( smUnit(i).io.enq ){
|
|
|
|
|
|
isWdtSMEnable(2*i) := false.B
|
|
|
|
|
|
} .elsewhen( ~isWdtSMEnable(2*i) & smUnit(i).io.sram_w.enw & interface.io.cReg.wdtEnable.extract(i+1) ){
|
|
|
|
|
|
isWdtSMEnable(2*i) := true.B
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
when( smUnit(i).io.deq ){
|
|
|
|
|
|
isWdtSMEnable(2*i + 1) := false.B
|
|
|
|
|
|
} .elsewhen( ~isWdtSMEnable(2*i + 1) & smUnit(i).io.sram_r.enr & interface.io.cReg.wdtEnable.extract(i+1) ){
|
|
|
|
|
|
isWdtSMEnable(2*i + 1) := true.B
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for( i <- 0 until 16 ){
|
|
|
|
|
|
when( isWdtSMEnable(i) & (wdtSMCnt(i) < interface.io.cReg.wdtTarCnt(i+1)) ){
|
|
|
|
|
|
wdtSMCnt(i) := wdtSMCnt(i) + 1.U
|
|
|
|
|
|
} .elsewhen( ~isWdtSMEnable(i) || (wdtSMCnt(i) >= interface.io.cReg.wdtTarCnt(i+1)) ){
|
|
|
|
|
|
wdtSMCnt(i) := 0.U
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// assert( wdtSMCnt(i) <= interface.io.cReg.wdtTarCnt(i+1), s"Assert Failed! wdtSMCnt($i) is larger than wdtTarCnt, Special situation?" )
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.wdtTrigger(i+1) := wdtSMCnt(i) === interface.io.cReg.wdtTarCnt(i+1)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//看门狗0 发送后回包是否超时
|
|
|
|
|
|
val isWdtRec2RtnEnable = RegInit(false.B)
|
2025-09-02 16:22:27 +08:00
|
|
|
|
val wdtRec2RtnCnt = RegInit(0.U(32.W))
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
when(
|
2025-08-26 17:52:23 +08:00
|
|
|
|
(io.upCDRIn.axis.fire & io.upCDRIn.axis.bits.tlast) |
|
2025-08-26 10:30:12 +08:00
|
|
|
|
~interface.io.cReg.wdtEnable.extract(0)
|
|
|
|
|
|
){
|
|
|
|
|
|
isWdtRec2RtnEnable := false.B
|
2025-08-26 17:52:23 +08:00
|
|
|
|
} .elsewhen( ~isWdtRec2RtnEnable & io.downCDROut.axis.fire & interface.io.cReg.wdtEnable.extract(0) ){
|
2025-08-26 10:30:12 +08:00
|
|
|
|
isWdtRec2RtnEnable := true.B
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
when( isWdtRec2RtnEnable & (wdtRec2RtnCnt < interface.io.cReg.wdtTarCnt(0)) ){
|
|
|
|
|
|
wdtRec2RtnCnt := wdtRec2RtnCnt + 1.U
|
|
|
|
|
|
} .elsewhen( ~isWdtRec2RtnEnable || (wdtRec2RtnCnt >= interface.io.cReg.wdtTarCnt(0)) ){
|
|
|
|
|
|
wdtRec2RtnCnt := 0.U
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// assert( wdtRecCnt < interface.io.cReg.wdtTarCnt(0), "Assert Failed! wdtRecCnt is larger than wdtTarCnt, Special situation?" )
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.wdtTrigger(0) := wdtRec2RtnCnt === interface.io.cReg.wdtTarCnt(0)
|
|
|
|
|
|
|
|
|
|
|
|
//看门狗17
|
2025-09-02 16:22:27 +08:00
|
|
|
|
val wdtRec2RecCnt = RegInit(0.U(32.W))
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
when( interface.io.cReg.wdtEnable.extract(17) & (wdtRec2RecCnt < interface.io.cReg.wdtTarCnt(17)) ){
|
|
|
|
|
|
wdtRec2RecCnt := wdtRec2RecCnt + 1.U
|
|
|
|
|
|
} .elsewhen(
|
|
|
|
|
|
~interface.io.cReg.wdtEnable.extract(17) ||
|
2025-08-26 17:52:23 +08:00
|
|
|
|
io.downCDRIn.axis.fire ||
|
2025-08-26 10:30:12 +08:00
|
|
|
|
(wdtRec2RecCnt >= interface.io.cReg.wdtTarCnt(17))
|
|
|
|
|
|
){
|
|
|
|
|
|
wdtRec2RecCnt := 0.U
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
interface.io.wdtTrigger(17) := wdtRec2RecCnt === interface.io.cReg.wdtTarCnt(17)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-05 12:55:32 +08:00
|
|
|
|
trait MstSlvSwitchDataPath{ this: MstSlvSwitchBase =>
|
2025-08-29 15:37:29 +08:00
|
|
|
|
val isDwUpEx = interface.io.cReg.dwupEx(15,8) === "h58".U && interface.io.cReg.dwupEx.extract(0)
|
|
|
|
|
|
|
|
|
|
|
|
when( ~isDwUpEx ){ //未交叉
|
|
|
|
|
|
when( interface.io.cReg.modeSel === false.B ){ //slave
|
|
|
|
|
|
when( (slaveParser.io.intHWTrig(0) | slaveParser.io.intHWTrig(1)) | interface.io.isPoReset ){ //硬件错误
|
|
|
|
|
|
io.downCDRIn.serDat := false.B
|
|
|
|
|
|
io.upCDRIn.serDat := false.B
|
|
|
|
|
|
when( slaveParser.io.isLoop ){ //回环
|
|
|
|
|
|
io.dDatOut := false.B
|
|
|
|
|
|
io.uDatOut := io.dDatIn
|
|
|
|
|
|
} .otherwise{ //非回环
|
|
|
|
|
|
io.dDatOut := io.dDatIn
|
|
|
|
|
|
io.uDatOut := io.uDatIn
|
|
|
|
|
|
}
|
|
|
|
|
|
} .otherwise{ //无硬件错误
|
|
|
|
|
|
when( slaveParser.io.isLoop ){ //回环
|
|
|
|
|
|
io.downCDRIn.serDat := io.dDatIn
|
|
|
|
|
|
io.upCDRIn.serDat := io.downCDROut.serDat
|
|
|
|
|
|
io.dDatOut := false.B
|
|
|
|
|
|
io.uDatOut := io.upCDROut.serDat
|
|
|
|
|
|
} .otherwise{ //非回环
|
|
|
|
|
|
io.downCDRIn.serDat := io.dDatIn
|
|
|
|
|
|
io.upCDRIn.serDat := io.uDatIn
|
|
|
|
|
|
io.dDatOut := io.downCDROut.serDat
|
|
|
|
|
|
io.uDatOut := io.upCDROut.serDat
|
|
|
|
|
|
}
|
2025-08-26 17:52:23 +08:00
|
|
|
|
}
|
2025-08-29 15:37:29 +08:00
|
|
|
|
} .otherwise{ //master
|
|
|
|
|
|
io.downCDRIn.serDat := false.B
|
|
|
|
|
|
io.upCDRIn.serDat := io.uDatIn
|
|
|
|
|
|
io.dDatOut := io.downCDROut.serDat
|
|
|
|
|
|
io.uDatOut := false.B
|
|
|
|
|
|
}
|
|
|
|
|
|
} .otherwise{ //交叉
|
|
|
|
|
|
when( interface.io.cReg.modeSel === false.B ){ //slave
|
|
|
|
|
|
when( (slaveParser.io.intHWTrig(0) | slaveParser.io.intHWTrig(1)) | interface.io.isPoReset ){ //硬件错误
|
|
|
|
|
|
|
|
|
|
|
|
when( slaveParser.io.isLoop ){ //回环
|
|
|
|
|
|
io.dDatOut := io.uDatIn
|
|
|
|
|
|
io.uDatOut := false.B
|
|
|
|
|
|
io.downCDRIn.serDat := false.B
|
|
|
|
|
|
io.upCDRIn.serDat := false.B
|
|
|
|
|
|
} .otherwise{ //非回环
|
|
|
|
|
|
io.dDatOut := io.dDatIn
|
|
|
|
|
|
io.uDatOut := io.uDatIn
|
|
|
|
|
|
io.downCDRIn.serDat := false.B
|
|
|
|
|
|
io.upCDRIn.serDat := false.B
|
|
|
|
|
|
}
|
|
|
|
|
|
} .otherwise{ //无硬件错误
|
|
|
|
|
|
when( slaveParser.io.isLoop ){ //回环
|
|
|
|
|
|
io.downCDRIn.serDat := io.uDatIn
|
|
|
|
|
|
io.upCDRIn.serDat := io.downCDROut.serDat
|
|
|
|
|
|
io.uDatOut := false.B
|
|
|
|
|
|
io.dDatOut := io.upCDROut.serDat
|
|
|
|
|
|
} .otherwise{ //非回环
|
|
|
|
|
|
io.downCDRIn.serDat := io.uDatIn
|
|
|
|
|
|
io.upCDRIn.serDat := io.dDatIn
|
|
|
|
|
|
io.dDatOut := io.upCDROut.serDat
|
|
|
|
|
|
io.uDatOut := io.downCDROut.serDat
|
|
|
|
|
|
}
|
2025-08-26 17:52:23 +08:00
|
|
|
|
}
|
2025-08-29 15:37:29 +08:00
|
|
|
|
} .otherwise{ //master
|
|
|
|
|
|
io.downCDRIn.serDat := false.B
|
|
|
|
|
|
io.upCDRIn.serDat := io.dDatIn
|
|
|
|
|
|
io.uDatOut := io.downCDROut.serDat
|
|
|
|
|
|
io.dDatOut := false.B
|
2025-08-26 17:52:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-09-05 12:55:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trait MstSlvSwitchB8B4{ this: MstSlvSwitchBase =>
|
|
|
|
|
|
val isUsing8b10b = interface.io.cReg.b8b4Sel(15,8) === "h59".U && interface.io.cReg.b8b4Sel.extract(0)
|
|
|
|
|
|
|
|
|
|
|
|
when( isUsing8b10b ){
|
|
|
|
|
|
b8b10DownEncoder.io <> io.downCDROut.encode
|
|
|
|
|
|
b8b10DownDecoder.io <> io.downCDRIn.decode
|
|
|
|
|
|
b8b10UpEncoder.io <> io.upCDROut.encode
|
|
|
|
|
|
b8b10UpDecoder.io <> io.upCDRIn.decode
|
|
|
|
|
|
|
|
|
|
|
|
b4b5DownEncoder.io.isEnable := false.B
|
|
|
|
|
|
b4b5DownEncoder.io.dataIn := 0.U
|
|
|
|
|
|
b4b5DownDecoder.io.dataIn := 0.U
|
|
|
|
|
|
b4b5UpEncoder.io.isEnable := false.B
|
|
|
|
|
|
b4b5UpEncoder.io.dataIn := 0.U
|
|
|
|
|
|
b4b5UpDecoder.io.dataIn := 0.U
|
|
|
|
|
|
} .otherwise{
|
|
|
|
|
|
b4b5DownEncoder.io <> io.downCDROut.encode
|
|
|
|
|
|
b4b5DownDecoder.io <> io.downCDRIn.decode
|
|
|
|
|
|
b4b5UpEncoder.io <> io.upCDROut.encode
|
|
|
|
|
|
b4b5UpDecoder.io <> io.upCDRIn.decode
|
|
|
|
|
|
|
|
|
|
|
|
b8b10DownEncoder.io.isEnable := false.B
|
|
|
|
|
|
b8b10DownEncoder.io.dataIn := 0.U
|
|
|
|
|
|
b8b10DownDecoder.io.dataIn := 0.U
|
|
|
|
|
|
b8b10UpEncoder.io.isEnable := false.B
|
|
|
|
|
|
b8b10UpEncoder.io.dataIn := 0.U
|
|
|
|
|
|
b8b10UpDecoder.io.dataIn := 0.U
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class MstSlvSwitch extends MstSlvSwitchBase
|
|
|
|
|
|
with MstSlvSwitchMaster
|
|
|
|
|
|
with MstSlvSwitchSlave
|
|
|
|
|
|
with MstSlvSwitchWatchDog
|
|
|
|
|
|
with MstSlvSwitchDataPath
|
|
|
|
|
|
with MstSlvSwitchB8B4{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-26 17:52:23 +08:00
|
|
|
|
|
2025-08-26 10:30:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-29 15:37:29 +08:00
|
|
|
|
|
2025-08-26 10:30:12 +08:00
|
|
|
|
}
|