Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions src/main/scala/amba/ahb/Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import chisel3._

import org.chipsalliance.cde.config.Parameters

import org.chipsalliance.diplomacy.lazymodule.{LazyModule, LazyModuleImp, SimpleLazyModule}
import org.chipsalliance.diplomacy.lazymodule.{InModuleBody, LazyModule, LazyModuleImp, SimpleLazyModule}

import freechips.rocketchip.devices.tilelink.TLTestRAM
import freechips.rocketchip.diplomacy.{AddressSet, BufferParams}
import freechips.rocketchip.regmapper.{RRTest0, RRTest1}
import freechips.rocketchip.tilelink.{TLFuzzer, TLRAMModel, TLToAHB, TLDelayer, TLBuffer, TLErrorEvaluator, TLFragmenter}
import freechips.rocketchip.tilelink.{TLFuzzer, TLRAMModel, TLRAM, TLToAHB, TLDelayer, TLBuffer, TLErrorEvaluator, TLFragmenter}
import freechips.rocketchip.unittest.{UnitTestModule, UnitTest}

class AHBRRTest0(address: BigInt)(implicit p: Parameters)
Expand Down Expand Up @@ -113,3 +113,35 @@ class AHBBridgeTest(aFlow: Boolean, txns: Int = 5000, timeout: Int = 500000)(imp
io.finished := dut.io.finished
dut.io.start := io.start
}

/** Test that AHBToTL elaborates when driven by an AHBSlaveSourceNode. */
class AHBSourceToTLSlave()(implicit p: Parameters) extends SimpleLazyModule {
val ram = LazyModule(new TLRAM(AddressSet(0x0, 0xfff)))

val ahbMaster = AHBSlaveSourceNode(
Seq(AHBMasterPortParameters(masters = Seq(AHBMasterParameters(name = "test_ahb_master"))))
)

(ram.node
:= AHBToTL()
:= ahbMaster)

val idle = InModuleBody {
val (bundle, _) = ahbMaster.out.head
bundle.htrans := 0.U // idle
bundle.hsize := 0.U
bundle.hburst := 0.U
bundle.hwrite := false.B
bundle.hprot := 0.U
bundle.haddr := 0.U
bundle.hwdata := 0.U
bundle.hmastlock := false.B
bundle.hsel := false.B
bundle.hready := true.B
}
}

class AHBSourceToTLSlaveTest(timeout: Int = 500000)(implicit p: Parameters) extends UnitTest(timeout) {
val dut = Module(LazyModule(new AHBSourceToTLSlave()).module)
io.finished := true.B
}
6 changes: 5 additions & 1 deletion src/main/scala/amba/ahb/ToTL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ class AHBToTL()(implicit p: Parameters) extends LazyModule
d_write := in.hwrite
d_addr := in.haddr
d_size := Mux(a_burst_ok, a_burst_size, in.hsize)
d_user :<= in.hauser

Connectable.waiveUnmatched(d_user, in.hauser) match {
case (lhs, rhs) => lhs.squeezeAll :<= rhs.squeezeAll
}

d_user.lift(AMBAProt).foreach { x =>
x.fetch := !in.hprot(0)
x.privileged := in.hprot(1)
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/unittest/Configs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class WithAMBAUnitTests extends Config((site, here, up) => {
Module(new AHBBridgeTest(true, txns=8*txns, timeout=timeout)),
Module(new AHBNativeTest(true, txns=6*txns, timeout=timeout)),
Module(new AHBNativeTest(false, txns=6*txns, timeout=timeout)),
Module(new AHBSourceToTLSlaveTest( timeout=timeout)),
Module(new APBBridgeTest(true, txns=6*txns, timeout=timeout)),
Module(new APBBridgeTest(false, txns=6*txns, timeout=timeout)),
Module(new AXI4LiteFuzzRAMTest( txns=6*txns, timeout=timeout)),
Expand Down
Loading