From 36f2e6504c7f0c0e57abb0bd5c02c1afb19baa7a Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 3 Mar 2016 16:56:53 -0800 Subject: [PATCH] Fix width of NastiROM rows, preventing out-of-range extraction --- uncore/src/main/scala/NastiROM.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uncore/src/main/scala/NastiROM.scala b/uncore/src/main/scala/NastiROM.scala index ba1cef66..2c68340f 100644 --- a/uncore/src/main/scala/NastiROM.scala +++ b/uncore/src/main/scala/NastiROM.scala @@ -20,7 +20,7 @@ class NastiROM(contents: Seq[Byte])(implicit p: Parameters) extends Module { val rows = (contents.size + byteWidth - 1)/byteWidth + 1 val rom = Vec.tabulate(rows) { i => val slice = contents.slice(i*byteWidth, (i+1)*byteWidth) - UInt(slice.foldRight(BigInt(0)) { case (x,y) => (y << 8) + (x.toInt & 0xFF) }) + UInt(slice.foldRight(BigInt(0)) { case (x,y) => (y << 8) + (x.toInt & 0xFF) }, byteWidth*8) } val rdata_word = rom(if (rows == 1) UInt(0) else ar.bits.addr(log2Up(contents.size)-1,log2Up(byteWidth))) val rdata = new LoadGen(Cat(UInt(1), ar.bits.size), ar.bits.addr, rdata_word, Bool(false), byteWidth).data