1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-05-28 23:41:32 +00:00

verilog: fixed silice <ccast> case

This commit is contained in:
Steven Hugg 2021-07-22 09:27:11 -05:00
parent 6a21b467cf
commit bb818c34f8

View File

@ -1018,6 +1018,10 @@ export class HDLModuleWASM implements HDLModuleRunner {
return this.bmod.i64.extend_u(val);
} else if (tsrc.left > 31 && tdst.left <= 31) { // 64 -> 32
return this.bmod.i32.wrap(val);
} else if (tsrc.left < 31 && tdst.left == 31 && tsrc.signed) { // sign extend via shift (silice case)
let inst = this.i3264(tdst);
var shift = inst.const(31 - tsrc.left, 0);
return inst.shr_s(inst.shl(val, shift), shift);
}
throw new HDLError([tsrc, tdst], `cannot cast ${tsrc.left}/${tsrc.signed} to ${tdst.left}/${tdst.signed}`);
}