mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-13 01:16:16 +00:00
Fixed memory->start_offset handling
This commit is contained in:
parent
17c1c55473
commit
eefe78be09
3 changed files with 12 additions and 6 deletions
|
@ -150,6 +150,8 @@ void ILANG_BACKEND::dump_memory(std::ostream &f, std::string indent, const RTLIL
|
||||||
f << stringf("width %d ", memory->width);
|
f << stringf("width %d ", memory->width);
|
||||||
if (memory->size != 0)
|
if (memory->size != 0)
|
||||||
f << stringf("size %d ", memory->size);
|
f << stringf("size %d ", memory->size);
|
||||||
|
if (memory->start_offset != 0)
|
||||||
|
f << stringf("offset %d ", memory->start_offset);
|
||||||
f << stringf("%s\n", memory->name.c_str());
|
f << stringf("%s\n", memory->name.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -839,14 +839,15 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
|
||||||
memory->attributes["\\src"] = stringf("%s:%d", filename.c_str(), linenum);
|
memory->attributes["\\src"] = stringf("%s:%d", filename.c_str(), linenum);
|
||||||
memory->name = str;
|
memory->name = str;
|
||||||
memory->width = children[0]->range_left - children[0]->range_right + 1;
|
memory->width = children[0]->range_left - children[0]->range_right + 1;
|
||||||
memory->start_offset = children[0]->range_right;
|
if (children[1]->range_right < children[1]->range_left) {
|
||||||
memory->size = children[1]->range_left - children[1]->range_right;
|
memory->start_offset = children[1]->range_right;
|
||||||
|
memory->size = children[1]->range_left - children[1]->range_right + 1;
|
||||||
|
} else {
|
||||||
|
memory->start_offset = children[1]->range_left;
|
||||||
|
memory->size = children[1]->range_right - children[1]->range_left + 1;
|
||||||
|
}
|
||||||
current_module->memories[memory->name] = memory;
|
current_module->memories[memory->name] = memory;
|
||||||
|
|
||||||
if (memory->size < 0)
|
|
||||||
memory->size *= -1;
|
|
||||||
memory->size += std::min(children[1]->range_left, children[1]->range_right) + 1;
|
|
||||||
|
|
||||||
for (auto &attr : attributes) {
|
for (auto &attr : attributes) {
|
||||||
if (attr.second->type != AST_CONSTANT)
|
if (attr.second->type != AST_CONSTANT)
|
||||||
log_error("Attribute `%s' with non-constant value at %s:%d!\n",
|
log_error("Attribute `%s' with non-constant value at %s:%d!\n",
|
||||||
|
|
|
@ -183,6 +183,9 @@ memory_options:
|
||||||
memory_options TOK_SIZE TOK_INT {
|
memory_options TOK_SIZE TOK_INT {
|
||||||
current_memory->size = $3;
|
current_memory->size = $3;
|
||||||
} |
|
} |
|
||||||
|
memory_options TOK_OFFSET TOK_INT {
|
||||||
|
current_memory->start_offset = $3;
|
||||||
|
} |
|
||||||
/* empty */;
|
/* empty */;
|
||||||
|
|
||||||
cell_stmt:
|
cell_stmt:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue