Minor tweaks ahead of memory virtualization
Limit memory sizes to whatever fits in unsigned; crash if the conversion from unsigned long to unsigned overflows, instead of just wrapping. I don't know what happens on a 32-bit machine if you ask for an 8 Gig memory, but with a 64-bit machine and this patch, it crashes with an assert. Set direction on PartSelect Links before connecting them. May or may not be considered orthogonal to upcoming memory virtualization patches.
This commit is contained in:
parent
944495b94e
commit
d21cd18e3f
21
netlist.cc
21
netlist.cc
|
|
@ -524,10 +524,14 @@ NetNet::NetNet(NetScope*s, perm_string n, Type t,
|
||||||
|
|
||||||
static unsigned calculate_count(long s, long e)
|
static unsigned calculate_count(long s, long e)
|
||||||
{
|
{
|
||||||
if (s >= e)
|
unsigned long r;
|
||||||
return s - e + 1;
|
if (s >= e) {
|
||||||
else
|
r = s - e + 1;
|
||||||
return e - s + 1;
|
} else {
|
||||||
|
r = e - s + 1;
|
||||||
|
}
|
||||||
|
assert (r <= UINT_MAX);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetNet::NetNet(NetScope*s, perm_string n, Type t,
|
NetNet::NetNet(NetScope*s, perm_string n, Type t,
|
||||||
|
|
@ -810,7 +814,6 @@ NetPartSelect::NetPartSelect(NetNet*sig, unsigned off, unsigned wid,
|
||||||
: NetNode(sig->scope(), sig->scope()->local_symbol(), 2),
|
: NetNode(sig->scope(), sig->scope()->local_symbol(), 2),
|
||||||
off_(off), wid_(wid), dir_(dir__)
|
off_(off), wid_(wid), dir_(dir__)
|
||||||
{
|
{
|
||||||
connect(pin(1), sig->pin(0));
|
|
||||||
set_line(*sig);
|
set_line(*sig);
|
||||||
|
|
||||||
switch (dir_) {
|
switch (dir_) {
|
||||||
|
|
@ -823,6 +826,8 @@ NetPartSelect::NetPartSelect(NetNet*sig, unsigned off, unsigned wid,
|
||||||
pin(1).set_dir(Link::OUTPUT);
|
pin(1).set_dir(Link::OUTPUT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(pin(1), sig->pin(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
NetPartSelect::NetPartSelect(NetNet*sig, NetNet*sel,
|
NetPartSelect::NetPartSelect(NetNet*sig, NetNet*sel,
|
||||||
|
|
@ -830,9 +835,6 @@ NetPartSelect::NetPartSelect(NetNet*sig, NetNet*sel,
|
||||||
: NetNode(sig->scope(), sig->scope()->local_symbol(), 3),
|
: NetNode(sig->scope(), sig->scope()->local_symbol(), 3),
|
||||||
off_(0), wid_(wid), dir_(VP)
|
off_(0), wid_(wid), dir_(VP)
|
||||||
{
|
{
|
||||||
connect(pin(1), sig->pin(0));
|
|
||||||
connect(pin(2), sel->pin(0));
|
|
||||||
|
|
||||||
switch (dir_) {
|
switch (dir_) {
|
||||||
case NetPartSelect::VP:
|
case NetPartSelect::VP:
|
||||||
pin(0).set_dir(Link::OUTPUT);
|
pin(0).set_dir(Link::OUTPUT);
|
||||||
|
|
@ -844,6 +846,9 @@ NetPartSelect::NetPartSelect(NetNet*sig, NetNet*sel,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pin(2).set_dir(Link::INPUT);
|
pin(2).set_dir(Link::INPUT);
|
||||||
|
|
||||||
|
connect(pin(1), sig->pin(0));
|
||||||
|
connect(pin(2), sel->pin(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
NetPartSelect::~NetPartSelect()
|
NetPartSelect::~NetPartSelect()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue