Skip to content

Instantly share code, notes, and snippets.

@allexoll
Created August 5, 2021 10:52
Show Gist options
  • Save allexoll/e0691d170bf9cce81e033c006446820c to your computer and use it in GitHub Desktop.
Save allexoll/e0691d170bf9cce81e033c006446820c to your computer and use it in GitHub Desktop.
object Apb3Decoder{
def getOutputConfig(inputConfig: Apb3Config, decodings: Seq[SizeMapping]) = inputConfig.copy(selWidth = decodings.size)
def apply(inputConfig: Apb3Config, decodings: Seq[SizeMapping]): Apb3Decoder = new Apb3Decoder(inputConfig, decodings)
def apply(master: Apb3, slaves: Seq[(Apb3, SizeMapping)]): Apb3Decoder = {
// proposal
for(slave <- slaves)
{
assert(master.config.addressWidth > slave._1.config.addressWidth,f"Mapping at 0x${slave._2.base}%x has an address width bigger than the decoder can allow")
}
//======
val decoder = new Apb3Decoder(master.config, slaves.map(_._2))
val router = new Apb3Router(decoder.io.output.config)
decoder.io.input <> master
router.io.input <> decoder.io.output
(slaves.map(_._1), router.io.outputs).zipped.map(_ << _)
decoder.setPartialName(master, "decoder")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment