Skip to content

Commit 6fc7271

Browse files
authored
Merge pull request #63 from alaindargelas/memory_size_check
Memory size check
2 parents a3a9e79 + 8821131 commit 6fc7271

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

frontends/verific/verific.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,21 +1662,22 @@ void VerificImporter::import_netlist(RTLIL::Design *design, Netlist *nl, std::ma
16621662
module->memories[memory->name] = memory;
16631663
import_attributes(memory->attributes, net, nl);
16641664

1665-
int number_of_bits = net->Size();
1666-
int bits_in_word = number_of_bits;
1665+
uint64_t number_of_bits = net->Size();
1666+
uint64_t bits_in_word = number_of_bits;
16671667
FOREACH_PORTREF_OF_NET(net, si, pr) {
16681668
if (pr->GetInst()->Type() == OPER_READ_PORT) {
1669-
bits_in_word = min<int>(bits_in_word, pr->GetInst()->OutputSize());
1669+
bits_in_word = min<uint64_t>(bits_in_word, pr->GetInst()->OutputSize());
16701670
continue;
16711671
}
16721672
if (pr->GetInst()->Type() == OPER_WRITE_PORT || pr->GetInst()->Type() == OPER_CLOCKED_WRITE_PORT) {
1673-
bits_in_word = min<int>(bits_in_word, pr->GetInst()->Input2Size());
1673+
bits_in_word = min<uint64_t>(bits_in_word, pr->GetInst()->Input2Size());
16741674
continue;
16751675
}
16761676
log_error("Verific RamNet %s is connected to unsupported instance type %s (%s).\n",
16771677
net->Name(), pr->GetInst()->View()->Owner()->Name(), pr->GetInst()->Name());
16781678
}
1679-
1679+
if ((bits_in_word * number_of_bits) > (1 << 23))
1680+
log_error("Memory %s size is larger than 2**23 bits\n", net->Name());
16801681
memory->width = bits_in_word;
16811682
memory->size = number_of_bits / bits_in_word;
16821683

0 commit comments

Comments
 (0)