mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-23 14:23:41 +00:00
ice40_dsp: add unextend_unsigned function
This commit is contained in:
parent
4a178d7cff
commit
163e339c69
1 changed files with 11 additions and 3 deletions
|
@ -23,7 +23,7 @@ match mul
|
||||||
endmatch
|
endmatch
|
||||||
|
|
||||||
code sigA sigB sigH
|
code sigA sigB sigH
|
||||||
auto unextend = [](const SigSpec &sig) {
|
auto unextend_signed = [](const SigSpec &sig) {
|
||||||
int i;
|
int i;
|
||||||
for (i = GetSize(sig)-1; i > 0; i--)
|
for (i = GetSize(sig)-1; i > 0; i--)
|
||||||
if (sig[i] != sig[i-1])
|
if (sig[i] != sig[i-1])
|
||||||
|
@ -32,8 +32,16 @@ code sigA sigB sigH
|
||||||
++i;
|
++i;
|
||||||
return sig.extract(0, i);
|
return sig.extract(0, i);
|
||||||
};
|
};
|
||||||
sigA = param(mul, \A_SIGNED).as_bool() ? unextend(port(mul, \A)) : port(mul, \A);
|
auto unextend_unsigned = [](const SigSpec &sig) {
|
||||||
sigB = param(mul, \B_SIGNED).as_bool() ? unextend(port(mul, \B)) : port(mul, \B);
|
int i;
|
||||||
|
for (i = GetSize(sig)-1; i > 0; i--)
|
||||||
|
if (sig[i] != SigBit(State::S0))
|
||||||
|
break;
|
||||||
|
++i;
|
||||||
|
return sig.extract(0, i);
|
||||||
|
};
|
||||||
|
sigA = param(mul, \A_SIGNED).as_bool() ? unextend_signed(port(mul, \A)) : unextend_unsigned(port(mul, \A));
|
||||||
|
sigB = param(mul, \B_SIGNED).as_bool() ? unextend_signed(port(mul, \B)) : unextend_unsigned(port(mul, \B));
|
||||||
|
|
||||||
SigSpec O;
|
SigSpec O;
|
||||||
if (mul->type == $mul)
|
if (mul->type == $mul)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue