新主站发送逻辑

This commit is contained in:
RuigeLee
2024-10-09 17:37:15 +08:00
parent 58aecc043f
commit a6068fbda0
6 changed files with 207 additions and 4 deletions

View File

@@ -0,0 +1,29 @@
package BACK
import chisel3._
import chisel3.util._
class Axis8toNIO_Bundle(dw: Int) extends Bundle{
val enq = Flipped(Decoupled(new AxisNto8IO_Bundle(8)))
val deq = Decoupled(new AxisNto8IO_Bundle(dw))
}
class Axis8toN(dw: Int) extends Module{
require( dw == 16 | dw == 32 | dw == 64 )
assert( io.deq.ready === true.B )
val io: Axis8toNIO_Bundle = IO(new Axis8toNIO_Bundle(dw))
val cnt = RegInit( 0.U( log2Ceil(dw/8).W ) )
val fifo = Reg( new AxisNto8IO_Bundle(dw) )
}

View File

@@ -0,0 +1,48 @@
package BACK
import chisel3._
import chisel3.util._
class AxisNto8IO_Bundle(dw: Int) extends Bundle{
val enq = Flipped(Decoupled(new AxisNto8IO_Bundle(dw)))
val deq = Decoupled(new AxisNto8IO_Bundle(8))
}
class AxisNto8(dw: Int) extends Module{
require( dw == 16 | dw == 32 | dw == 64 )
val io: AxisNto8IO_Bundle = IO(new AxisNto8IO_Bundle(dw))
val cnt = RegInit( 0.U( log2Ceil(dw/8).W ) )
val isBusy = RegInit(false.B)
val fifo = RegEnable( io.enq.bits, io.enq.fire )
io.enq.ready := ~isBusy | (io.deq.fire & cnt.andR)
when( io.deq.fire ){
cnt := cnt + 1.U
}
when( io.enq.fire ){
isBusy := true.B
} .elsewhen( io.deq.fire & cnt.andR ){
isBusy := false.B
}
io.deq.valid := isBusy
io.deq.bits.tdata := fifo.tdata >> (cnt << 3)
io.deq.bits.tlast := fifo.tlast & cnt.andR
io.deq.bits.tuser := fifo.tuser & cnt.andR
}

View File

@@ -6,7 +6,7 @@ import chisel3.util._
//work in 100MHZ
class CDRInIO extends Bundle{
val axis = Decoupled(new AXIS_Bundle)
val axis = Decoupled(new AXIS_Bundle(8))
val serDat = Input(Bool())
val overCLK = Input(Bool())
}

View File

@@ -3,15 +3,15 @@ package BACK
import chisel3._
import chisel3.util._
class AXIS_Bundle extends Bundle{
val tdata = UInt(8.W)
class AXIS_Bundle(dw: Int) extends Bundle{
val tdata = UInt(dw.W)
val tlast = Bool()
val tuser = Bool()
}
//work in 100MHZ
class CDROutIO extends Bundle{
val axis = Flipped(Decoupled(new AXIS_Bundle))
val axis = Flipped(Decoupled(new AXIS_Bundle(8)))
val serDat = Output(Bool())
}