summaryrefslogtreecommitdiff
path: root/frontends
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2015-01-01 12:56:01 +0100
committerClifford Wolf <clifford@clifford.at>2015-01-01 12:56:01 +0100
commiteefe78be094f8009cdb4a7a0e657e86b9624adf1 (patch)
tree6bda1ad89e9b4a01b288d3193d23771e17a4190e /frontends
parent17c1c5547365ae9ec58a1600a67c2b878449de1f (diff)
Fixed memory->start_offset handling
Diffstat (limited to 'frontends')
-rw-r--r--frontends/ast/genrtlil.cc13
-rw-r--r--frontends/ilang/ilang_parser.y3
2 files changed, 10 insertions, 6 deletions
diff --git a/frontends/ast/genrtlil.cc b/frontends/ast/genrtlil.cc
index a86d08d5..17d62d4d 100644
--- a/frontends/ast/genrtlil.cc
+++ b/frontends/ast/genrtlil.cc
@@ -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->name = str;
memory->width = children[0]->range_left - children[0]->range_right + 1;
- memory->start_offset = children[0]->range_right;
- memory->size = children[1]->range_left - children[1]->range_right;
+ if (children[1]->range_right < children[1]->range_left) {
+ 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;
- if (memory->size < 0)
- memory->size *= -1;
- memory->size += std::min(children[1]->range_left, children[1]->range_right) + 1;
-
for (auto &attr : attributes) {
if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n",
diff --git a/frontends/ilang/ilang_parser.y b/frontends/ilang/ilang_parser.y
index 4e0981b5..4661d577 100644
--- a/frontends/ilang/ilang_parser.y
+++ b/frontends/ilang/ilang_parser.y
@@ -183,6 +183,9 @@ memory_options:
memory_options TOK_SIZE TOK_INT {
current_memory->size = $3;
} |
+ memory_options TOK_OFFSET TOK_INT {
+ current_memory->start_offset = $3;
+ } |
/* empty */;
cell_stmt: