aboutsummaryrefslogtreecommitdiffstats
path: root/backends/verilog
diff options
context:
space:
mode:
authorMarcelina Koƛcielnicka <mwk@0x04.net>2021-07-12 20:43:09 +0200
committerMarcelina Koƛcielnicka <mwk@0x04.net>2021-07-28 23:18:38 +0200
commite9effd58d24afc8470813aec3028e932ea677aa5 (patch)
treed8919d44c7252bab05d0994f07357a79e70f64a6 /backends/verilog
parent19720b970dff017c47805e37745b9fcf29843c45 (diff)
downloadyosys-e9effd58d24afc8470813aec3028e932ea677aa5.tar.gz
yosys-e9effd58d24afc8470813aec3028e932ea677aa5.tar.bz2
yosys-e9effd58d24afc8470813aec3028e932ea677aa5.zip
backends/verilog: Support meminit with mask.
Diffstat (limited to 'backends/verilog')
-rw-r--r--backends/verilog/verilog_backend.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/backends/verilog/verilog_backend.cc b/backends/verilog/verilog_backend.cc
index 800865414..b363bc2fe 100644
--- a/backends/verilog/verilog_backend.cc
+++ b/backends/verilog/verilog_backend.cc
@@ -504,9 +504,24 @@ void dump_memory(std::ostream &f, std::string indent, Mem &mem)
int start = init.addr.as_int();
for (int i=0; i<words; i++)
{
- f << stringf("%s" " %s[%d] = ", indent.c_str(), mem_id.c_str(), i + start);
- dump_const(f, init.data.extract(i*mem.width, mem.width));
- f << stringf(";\n");
+ for (int j = 0; j < mem.width; j++)
+ {
+ if (init.en[j] != State::S1)
+ continue;
+
+ int start_j = j, width = 1;
+
+ while (j+1 < mem.width && init.en[j+1] == State::S1)
+ j++, width++;
+
+ if (width == mem.width) {
+ f << stringf("%s" " %s[%d] = ", indent.c_str(), mem_id.c_str(), i + start);
+ } else {
+ f << stringf("%s" " %s[%d][%d:%d] = ", indent.c_str(), mem_id.c_str(), i + start, j, start_j);
+ }
+ dump_const(f, init.data.extract(i*mem.width+start_j, width));
+ f << stringf(";\n");
+ }
}
}
f << stringf("%s" "end\n", indent.c_str());