vlog95: Rework some of the delay emitting code and enclose unary in ()
This patch reworks the delay emitting code to handle delay expressions better. It also encloses the emitted unary operators in parenthesis to make sequenced unary operators work properly.
This commit is contained in:
parent
28c10311f6
commit
df85a33583
|
|
@ -404,8 +404,9 @@ static void emit_expr_unary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid)
|
|||
case 'N':
|
||||
case 'X':
|
||||
case '!':
|
||||
fprintf(vlog_out, "%s", oper);
|
||||
fprintf(vlog_out, "(%s", oper);
|
||||
emit_expr(scope, ivl_expr_oper1(expr), wid);
|
||||
fprintf(vlog_out, ")");
|
||||
break;
|
||||
case '2':
|
||||
case 'i':
|
||||
|
|
|
|||
|
|
@ -82,7 +82,10 @@ static void emit_delay(ivl_scope_t scope, ivl_expr_t expr, unsigned is_stmt)
|
|||
*/
|
||||
void emit_scaled_delayx(ivl_scope_t scope, ivl_expr_t expr, unsigned is_stmt)
|
||||
{
|
||||
if (ivl_expr_type(expr) == IVL_EX_NUMBER) {
|
||||
ivl_expr_type_t type = ivl_expr_type(expr);
|
||||
if (type == IVL_EX_DELAY) {
|
||||
emit_scaled_delay(scope, ivl_expr_delay_val(expr));
|
||||
} else if (type == IVL_EX_NUMBER) {
|
||||
assert(! ivl_expr_signed(expr));
|
||||
int rtype;
|
||||
uint64_t value = get_uint64_from_number(expr, &rtype);
|
||||
|
|
@ -108,9 +111,10 @@ void emit_scaled_delayx(ivl_scope_t scope, ivl_expr_t expr, unsigned is_stmt)
|
|||
} else {
|
||||
int exponent = ivl_scope_time_units(scope) - sim_precision;
|
||||
assert(exponent >= 0);
|
||||
if (exponent == 0) emit_delay(scope, expr, is_stmt);
|
||||
/* A real delay variable is not scaled by the compiler. */
|
||||
else if (ivl_expr_type(expr) == IVL_EX_SIGNAL) {
|
||||
if ((exponent == 0) && (type == IVL_EX_SIGNAL)) {
|
||||
emit_delay(scope, expr, is_stmt);
|
||||
/* A real delay variable is not scaled by the compiler. */
|
||||
} else if (type == IVL_EX_SIGNAL) {
|
||||
ivl_signal_t sig = ivl_expr_signal(expr);
|
||||
if (ivl_signal_data_type(sig) != IVL_VT_REAL) {
|
||||
fprintf(vlog_out, "<invalid>");
|
||||
|
|
|
|||
|
|
@ -80,9 +80,9 @@ static void emit_stmt_inter_delay(ivl_scope_t scope, ivl_statement_t stmt)
|
|||
}
|
||||
if (delay) {
|
||||
assert(nevents == 0);
|
||||
fprintf(vlog_out, "#");
|
||||
emit_expr(scope, delay, 0);
|
||||
fprintf(vlog_out, " ");
|
||||
fprintf(vlog_out, "#(");
|
||||
emit_scaled_delayx(scope, delay, 1);
|
||||
fprintf(vlog_out, ") ");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue