Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Chip ID Pin #212

Merged
merged 2 commits into from
Jan 16, 2024
Merged
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
43 changes: 43 additions & 0 deletions src/main/scala/soc/ChipIdPin.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package testchipip.soc

import chisel3._
import chisel3.util._
import org.chipsalliance.cde.config._
import freechips.rocketchip.tilelink._
import freechips.rocketchip.diplomacy._
import freechips.rocketchip.regmapper._
import freechips.rocketchip.subsystem._

case class ChipIdPinParams (
width: Int = 1,
chipIdAddr: BigInt = 0x2000,
slaveWhere: TLBusWrapperLocation = CBUS
)

case object ChipIdPinKey extends Field[Option[ChipIdPinParams]](None)

trait CanHavePeripheryChipIdPin { this: BaseSubsystem =>
val chip_id_pin = p(ChipIdPinKey).map { params =>
val tlbus = locateTLBusWrapper(params.slaveWhere)
val device = new SimpleDevice("chip-id-reg", Nil)

val inner_io = tlbus {
val node = TLRegisterNode(
address = Seq(AddressSet(params.chipIdAddr, 4096 - 1)),
device = device,
beatBytes=tlbus.beatBytes)
tlbus.coupleTo(s"chip-id-reg"){ node := TLFragmenter(tlbus.beatBytes, tlbus.blockBytes) := _ }
InModuleBody {
val chip_id = IO(Input(UInt(params.width.W))).suggestName("chip_id")
node.regmap(0 -> Seq(RegField.r(64, chip_id)))
chip_id
}
}
val outer_io = InModuleBody {
val chip_id = IO(Input(UInt(params.width.W))).suggestName("chip_id")
inner_io := chip_id
chip_id
}
outer_io
}
}
13 changes: 13 additions & 0 deletions src/main/scala/soc/Configs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ class WithOffchipBusClient(
OffchipBusTopologyConnectionParams(location, blockRange, replicationBase)
})

//-------------------------
// ChipIdPin Configs
//-------------------------

class WithChipIdPin(params: ChipIdPinParams = ChipIdPinParams()) extends Config((site, here, up) => {
case ChipIdPinKey => Some(params)
})

// Used for setting pin width
class WithChipIdPinWidth(width: Int) extends Config((site, here, up) => {
case ChipIdPinKey => up(ChipIdPinKey, site).map(p => p.copy(width = width))
})

// Deprecated: use Constellation's network-on-chip generators instead of this
class WithRingSystemBus(
buffer: TLNetworkBufferParams = TLNetworkBufferParams.default)
Expand Down