@@ -2,6 +2,7 @@ package treecorel2
22
33import chisel3 ._
44import chisel3 .util ._
5+ import treecorel2 .common .ConstVal ._
56
67object AXI4Bridge {
78 // Burst types
@@ -286,7 +287,6 @@ class AXI4Bridge() extends Module with AXI4Config with InstConfig {
286287 protected val ALIGNED_WIDTH = 3 // eval: log2(AxiDataWidth / 8)
287288 protected val OFFSET_WIDTH = 6 // eval: log2(AxiDataWidth)
288289 protected val AXI_INST_SIZE = if (SoCEna ) 2 .U else 3 .U // because the flash only support 4 bytes access
289- protected val AXI_MEM_SIZE = 3 .U
290290 protected val MASK_WIDTH = 128 // eval: AxiDataWidth * 2
291291 protected val TRANS_LEN = 1 // eval: 1
292292 protected val BLOCK_TRANS = false .B
@@ -317,7 +317,7 @@ class AXI4Bridge() extends Module with AXI4Config with InstConfig {
317317
318318 instAxiLen := Mux (instTransAligned.asBool(), (TRANS_LEN - 1 ).U , Cat (Fill (7 , " b0" .U (1 .W )), instOverstep))
319319 protected val instAxiSize = AXI_INST_SIZE
320- protected val instAxiAddr = if (SoCEna ) io.inst.addr else Cat (io.inst.addr(AxiAddrWidth - 1 , ALIGNED_WIDTH ), Fill (ALIGNED_WIDTH , " b0" .U (1 .W )))
320+ protected val instAxiAddr = if (SoCEna ) io.inst.addr else Cat (io.inst.addr(AxiAddrWidth - 1 , ALIGNED_WIDTH ), Fill (ALIGNED_WIDTH , " b0" .U (1 .W )))
321321 protected val instAlignedOffsetLow = Wire (UInt (OFFSET_WIDTH .W ))
322322 protected val instAlignedOffsetHig = Wire (UInt (OFFSET_WIDTH .W ))
323323 protected val instMask = Wire (UInt (MASK_WIDTH .W ))
@@ -373,7 +373,20 @@ class AXI4Bridge() extends Module with AXI4Config with InstConfig {
373373
374374 memAxiLen := Mux (memTransAligned.asBool(), (TRANS_LEN - 1 ).U , Cat (Fill (7 , " b0" .U (1 .W )), memOverstep))
375375
376- protected val memAxiSize = AXI_MEM_SIZE
376+ // flash only support 4 bytes rd(0x3000_0000~0x3fff_ffff)
377+ // periph suport 4 bytes w/r(0x1000_0000~0x1000_1fff)
378+ // chiplink suport 4 bytes w/r(0x4000_0000~0x7fff_ffff)
379+ protected val memAxiSize = Wire (UInt (3 .W ))
380+ when(
381+ (io.mem.addr >= UartBaseAddr && io.mem.addr <= UartBoundAddr ) ||
382+ (io.mem.addr >= SpiBaseAddr && io.mem.addr <= SpiBoundAddr ) ||
383+ (io.mem.addr >= ChiplinkBaseAddr && io.mem.addr <= ChiplinkBoundAddr )
384+ ) {
385+ memAxiSize := 2 .U
386+ }.otherwise {
387+ memAxiSize := 3 .U
388+ }
389+
377390 protected val memAxiAddr = Cat (io.mem.addr(AxiAddrWidth - 1 , ALIGNED_WIDTH ), Fill (ALIGNED_WIDTH , " b0" .U (1 .W )))
378391 protected val memAlignedOffsetLow = Wire (UInt (OFFSET_WIDTH .W ))
379392 protected val memAlignedOffsetHig = Wire (UInt (OFFSET_WIDTH .W ))
0 commit comments