From eb2bb40fd3b5eeafefc1a0bdc82514e723e6bc9c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 15 Sep 2024 00:04:32 -0700 Subject: [PATCH] lib/ECP5_RAM: fix wiring of address bits When using more than 1 bit data words, you have to use a subset of the 14 address bits that the primitive offers. I was feeding addresses into the lower N bits of the primitive (e.g. lower 12 bits for a 4-bit memory), but it turns out you're supposed to use the _upper_ N address bits. --- lib/ECP5_RAM.bsv | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/ECP5_RAM.bsv b/lib/ECP5_RAM.bsv index def3a66..7feba56 100644 --- a/lib/ECP5_RAM.bsv +++ b/lib/ECP5_RAM.bsv @@ -457,7 +457,10 @@ module mkEBRCore#(EBRPortConfig cfgA, if (!rcfgA.enabled) noAction; else - vEBR.portA.put(chip_select, write, zeroExtend(pack(address)), zeroExtend(pack(datain))); + vEBR.portA.put(chip_select, + write, + zeroExtend(pack(address)) << valueOf(addr_a_pad), + zeroExtend(pack(datain))); endmethod method data_a read(); if (!rcfgA.enabled) @@ -472,7 +475,10 @@ module mkEBRCore#(EBRPortConfig cfgA, if (!rcfgB.enabled) noAction; else - vEBR.portB.put(chip_select, write, zeroExtend(pack(address)), zeroExtend(pack(datain))); + vEBR.portB.put(chip_select, + write, + zeroExtend(pack(address)) << valueOf(addr_b_pad), + zeroExtend(pack(datain))); endmethod method data_b read(); if (!rcfgB.enabled)