tgt-vlog95: Handle signed return types

The vlog95 backend currently ignores the sign of a function return value.

Check for it and if `-pallowsigned=1` was specified emit the `signed`
keyword. Otherwise report an error.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-12-27 19:50:34 -08:00
parent 5cd8bb3a88
commit 50d7d66043
1 changed files with 13 additions and 0 deletions

View File

@ -40,6 +40,19 @@ static void emit_func_return(ivl_signal_t sig)
} else if (ivl_signal_data_type(sig) == IVL_VT_REAL) { } else if (ivl_signal_data_type(sig) == IVL_VT_REAL) {
fprintf(vlog_out, " real"); fprintf(vlog_out, " real");
} else { } else {
if (ivl_signal_signed(sig)) {
if (allow_signed) {
fprintf(vlog_out, " signed");
} else {
fprintf(stderr, "%s:%u: vlog95 error: Signed return "
"value for function `%s` is not "
"supported.\n",
ivl_signal_file(sig),
ivl_signal_lineno(sig),
ivl_signal_basename(sig));
vlog_errors += 1;
}
}
int msb, lsb; int msb, lsb;
get_sig_msb_lsb(sig, &msb, &lsb); get_sig_msb_lsb(sig, &msb, &lsb);
if (msb != 0 || lsb != 0) fprintf(vlog_out, " [%d:%d]", msb, lsb); if (msb != 0 || lsb != 0) fprintf(vlog_out, " [%d:%d]", msb, lsb);