Elaborate memory references with non-zero bases.

This fixes r-value type references to memory words for memories
that have a non-zero base address. Elaborate the expression
needed to get the canonical word index.
This commit is contained in:
Martin Whitaker 2007-07-21 17:19:24 -07:00 committed by Stephen Williams
parent 3d51810f01
commit 42fe46a7db
1 changed files with 11 additions and 0 deletions

View File

@ -1197,6 +1197,17 @@ NetExpr* PEIdent::elaborate_expr_net_word_(Design*des, NetScope*scope,
delete word_index;
word_index = tmp;
}
} else if (word_index) {
// If there is a non-zero base to the memory, then build an
// expression to calculate the canonical address.
if (long base = net->array_first()) {
word_index = make_add_expr(word_index, 0-base);
if (NetExpr*tmp = word_index->eval_tree()) {
word_index = tmp;
}
}
}
NetESignal*res = new NetESignal(net, word_index);