From 8733e1923a0dd0de727dd791dc4bcbf194b56b29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelina=20Ko=C5=9Bcielnicka?= Date: Tue, 3 Aug 2021 14:28:10 +0200 Subject: memory_bram: Move init data swizzling before other swizzling. Fixes #2907. --- passes/memory/memory_bram.cc | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/passes/memory/memory_bram.cc b/passes/memory/memory_bram.cc index 31fd769b0..af8137ada 100644 --- a/passes/memory/memory_bram.cc +++ b/passes/memory/memory_bram.cc @@ -798,6 +798,24 @@ grow_read_ports:; for (int j = 0; j < i; j++) mem.emulate_priority(j, i); + // Swizzle the init data. Do this before changing mem.width, so that get_init_data works. + bool cell_init = !mem.inits.empty(); + vector initdata; + if (cell_init) { + Const initparam = mem.get_init_data(); + initdata.reserve(mem.size); + for (int i = 0; i < mem.size; i++) { + std::vector val; + for (auto idx : shuffle_map) { + if (idx == -1) + val.push_back(State::Sx); + else + val.push_back(initparam[mem.width * i + idx]); + } + initdata.push_back(Const(val)); + } + } + // Now the big swizzle. mem.width = GetSize(shuffle_map); @@ -837,24 +855,6 @@ grow_read_ports:; port.srst_value = new_srst_value; } - // Swizzle the init data. - bool cell_init = !mem.inits.empty(); - vector initdata; - if (cell_init) { - Const initparam = mem.get_init_data(); - initdata.reserve(mem.size); - for (int i = 0; i < mem.size; i++) { - std::vector val; - for (auto idx : shuffle_map) { - if (idx == -1) - val.push_back(State::Sx); - else - val.push_back(initparam[mem.width * i + idx]); - } - initdata.push_back(Const(val)); - } - } - // prepare variant parameters dict variant_params; -- cgit v1.2.3