Skip to content

Commit

Permalink
[t1emu & t1rocketemu] use clocked DPI for axi read
Browse files Browse the repository at this point in the history
  • Loading branch information
FanShupei committed Dec 7, 2024
1 parent 8f5a49e commit b5d34af
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 44 deletions.
48 changes: 27 additions & 21 deletions t1emu/src/AXI4SlaveAgent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package org.chipsalliance.t1.t1emu.dpi

// TODO: upstream to AMBA as VIP
import chisel3._
import chisel3.util.circt.dpi.{RawClockedVoidFunctionCall, RawUnclockedNonVoidFunctionCall}
import chisel3.util.circt.dpi.{RawClockedNonVoidFunctionCall, RawClockedVoidFunctionCall}
import chisel3.util.{isPow2, log2Ceil}
import org.chipsalliance.amba.axi4.bundle.{
ARChannel,
Expand Down Expand Up @@ -189,26 +189,32 @@ class AXI4SlaveAgent(parameter: AXI4SlaveAgentParameter)

// AR
channel.ARREADY := !cam(arPtr).valid
when(channel.ARREADY && channel.ARVALID) {
cam(arPtr).arid := channel.ARID
cam(arPtr).arlen := channel.ARLEN
cam(arPtr).readPayload := RawUnclockedNonVoidFunctionCall(
s"axi_read_${parameter.name}",
new ReadPayload(parameter.readPayloadSize, parameter.axiParameter.dataWidth)
)(
when.cond && !io.gateRead,
io.channelId,
channel.ARID.asTypeOf(UInt(64.W)),
channel.ARADDR.asTypeOf(UInt(64.W)),
channel.ARLEN.asTypeOf(UInt(64.W)),
channel.ARSIZE.asTypeOf(UInt(64.W)),
channel.ARBURST.asTypeOf(UInt(64.W)),
channel.ARLOCK.asTypeOf(UInt(64.W)),
channel.ARCACHE.asTypeOf(UInt(64.W)),
channel.ARPROT.asTypeOf(UInt(64.W)),
channel.ARQOS.asTypeOf(UInt(64.W)),
channel.ARREGION.asTypeOf(UInt(64.W))
)

val arFire = channel.ARREADY && channel.ARVALID
val readPlayload = RawClockedNonVoidFunctionCall(
s"axi_read_${parameter.name}",
new ReadPayload(parameter.readPayloadSize, parameter.axiParameter.dataWidth)
)(
io.clock,
!io.gateRead && arFire,
io.channelId,
parameter.axiParameter.dataWidth.U(64.W),
channel.ARID.asTypeOf(UInt(64.W)),
channel.ARADDR.asTypeOf(UInt(64.W)),
channel.ARLEN.asTypeOf(UInt(64.W)),
channel.ARSIZE.asTypeOf(UInt(64.W)),
channel.ARBURST.asTypeOf(UInt(64.W)),
channel.ARLOCK.asTypeOf(UInt(64.W)),
channel.ARCACHE.asTypeOf(UInt(64.W)),
channel.ARPROT.asTypeOf(UInt(64.W)),
channel.ARQOS.asTypeOf(UInt(64.W)),
channel.ARREGION.asTypeOf(UInt(64.W))
)

when(RegNext(arFire, false.B)) {
cam(arPtr).arid := RegNext(channel.ARID, 0.U)
cam(arPtr).arlen := RegNext(channel.ARLEN, 0.U)
cam(arPtr).readPayload := readPlayload
cam(arPtr).readPayloadIndex := 0.U
cam(arPtr).valid := true.B
arPtr := arPtr + 1.U
Expand Down
51 changes: 28 additions & 23 deletions t1rocketemu/src/AXI4SlaveAgent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package org.chipsalliance.t1.t1rocketemu.dpi

// TODO: upstream to AMBA as VIP
import chisel3._
import chisel3.util.circt.dpi.{RawClockedVoidFunctionCall, RawUnclockedNonVoidFunctionCall}
import chisel3.util.circt.dpi.{RawClockedNonVoidFunctionCall, RawClockedVoidFunctionCall}
import chisel3.util.{isPow2, log2Ceil}
import org.chipsalliance.amba.axi4.bundle.{
ARChannel,
Expand Down Expand Up @@ -189,28 +189,33 @@ class AXI4SlaveAgent(parameter: AXI4SlaveAgentParameter)

// AR
channel.ARREADY := !cam(arPtr).valid
when(channel.ARREADY && channel.ARVALID) {
cam(arPtr).arid := channel.ARID
cam(arPtr).arlen := channel.ARLEN
cam(arPtr).user := channel.ARUSER
cam(arPtr).readPayload := RawUnclockedNonVoidFunctionCall(
s"axi_read_${parameter.name}",
new ReadPayload(parameter.readPayloadSize, parameter.axiParameter.dataWidth)
)(
when.cond && !io.gateRead,
io.channelId,
parameter.axiParameter.dataWidth.U(64.W),
channel.ARID.asTypeOf(UInt(64.W)),
channel.ARADDR.asTypeOf(UInt(64.W)),
channel.ARLEN.asTypeOf(UInt(64.W)),
channel.ARSIZE.asTypeOf(UInt(64.W)),
channel.ARBURST.asTypeOf(UInt(64.W)),
channel.ARLOCK.asTypeOf(UInt(64.W)),
channel.ARCACHE.asTypeOf(UInt(64.W)),
channel.ARPROT.asTypeOf(UInt(64.W)),
channel.ARQOS.asTypeOf(UInt(64.W)),
channel.ARREGION.asTypeOf(UInt(64.W))
)

val arFire = channel.ARREADY && channel.ARVALID
val readPlayload = RawClockedNonVoidFunctionCall(
s"axi_read_${parameter.name}",
new ReadPayload(parameter.readPayloadSize, parameter.axiParameter.dataWidth)
)(
io.clock,
!io.gateRead && arFire,
io.channelId,
parameter.axiParameter.dataWidth.U(64.W),
channel.ARID.asTypeOf(UInt(64.W)),
channel.ARADDR.asTypeOf(UInt(64.W)),
channel.ARLEN.asTypeOf(UInt(64.W)),
channel.ARSIZE.asTypeOf(UInt(64.W)),
channel.ARBURST.asTypeOf(UInt(64.W)),
channel.ARLOCK.asTypeOf(UInt(64.W)),
channel.ARCACHE.asTypeOf(UInt(64.W)),
channel.ARPROT.asTypeOf(UInt(64.W)),
channel.ARQOS.asTypeOf(UInt(64.W)),
channel.ARREGION.asTypeOf(UInt(64.W))
)

when(RegNext(arFire, false.B)) {
cam(arPtr).arid := RegNext(channel.ARID, 0.U)
cam(arPtr).arlen := RegNext(channel.ARLEN, 0.U)
cam(arPtr).user := RegNext(channel.ARUSER, 0.U)
cam(arPtr).readPayload := readPlayload
cam(arPtr).readPayloadIndex := 0.U
cam(arPtr).valid := true.B
arPtr := arPtr + 1.U
Expand Down

0 comments on commit b5d34af

Please sign in to comment.