From 7319f430d0ddee5eac8928d074720cdbb43ace41 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Sat, 27 Feb 2016 10:35:22 -0800 Subject: [PATCH] Fix the backup memory port on multiple-channel configs The backup memory port doesn't work on multi-channel configurations, it just screws up the Nasti tag bits. This patch always instantiates a single-channel backup memory port, which relies on the memory channel selector to only enable a single memory channel when the backup memory port is enabled. There are some assertions to make sure this happens, as otherwise memory gets silently corrupted. While this is a bit of a hack, the backup memory port will be going away soon so I don't want to spend a whole lot of time fixing it. The generated hardware is actually very similar: we used to elaborate a Nasti arbiter inside the backup memory support, now there's one outside of it instead. --- src/main/scala/RocketChip.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/scala/RocketChip.scala b/src/main/scala/RocketChip.scala index 2dcda621..11ac09ce 100644 --- a/src/main/scala/RocketChip.scala +++ b/src/main/scala/RocketChip.scala @@ -334,6 +334,13 @@ class OuterMemorySystem(implicit val p: Parameters) extends Module with HasTopLe if(p(UseBackupMemoryPort)) { VLSIUtils.doOuterMemorySystemSerdes( mem_channels, io.mem, io.mem_backup, io.mem_backup_en, - nMemChannels, htifW, p(CacheBlockOffsetBits)) + 1, htifW, p(CacheBlockOffsetBits)) + for (i <- 1 until nMemChannels) { io.mem(i) <> mem_channels(i) } + assert(!Vec(mem_channels.map{ io => io.r.valid }).toBits.orR || + !io.mem_backup_en || + Vec(channelConfigs.map{i => UInt(i)})(io.memory_channel_mux_select) === UInt(1), + "Backup memory port only works when 1 memory channel is enabled") + Predef.assert(channelConfigs.sortWith(_ < _)(0) == 1, + "Backup memory port requires a single memory port mux config") } else { io.mem <> mem_channels } }