vlog95: translate darray and class assignments/references
These are not supported in vlog95, but they are easy to translate into something that looks correct.
This commit is contained in:
parent
1929cfc4f9
commit
41c7aa9e83
|
|
@ -398,6 +398,16 @@ static void emit_expr_select(ivl_scope_t scope, ivl_expr_t expr, unsigned wid)
|
|||
ivl_expr_t sel_expr = ivl_expr_oper2(expr);
|
||||
ivl_expr_t sig_expr = ivl_expr_oper1(expr);
|
||||
ivl_select_type_t sel_type = ivl_expr_sel_type(expr);
|
||||
/* If this is a dynamic array select, translate it differently. */
|
||||
if ((ivl_expr_type(sig_expr) == IVL_EX_SIGNAL) &&
|
||||
(ivl_signal_data_type(ivl_expr_signal(sig_expr)) == IVL_VT_DARRAY)) {
|
||||
assert(sel_expr);
|
||||
emit_select_name(scope, sig_expr, wid);
|
||||
fprintf(vlog_out, "[");
|
||||
emit_expr(scope, sel_expr, 0);
|
||||
fprintf(vlog_out, "]");
|
||||
return;
|
||||
}
|
||||
if (sel_expr) {
|
||||
unsigned width = ivl_expr_width(expr);
|
||||
ivl_expr_type_t type = ivl_expr_type(sig_expr);
|
||||
|
|
@ -605,6 +615,17 @@ static void emit_expr_unary(ivl_scope_t scope, ivl_expr_t expr, unsigned wid)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class properties are not supported in vlog95, but they can be translated.
|
||||
*/
|
||||
void emit_class_property(ivl_scope_t scope, ivl_expr_t expr, unsigned wid)
|
||||
{
|
||||
ivl_signal_t sig = ivl_expr_signal(expr);
|
||||
emit_scope_call_path(scope, ivl_signal_scope(sig));
|
||||
emit_id(ivl_signal_basename(sig));
|
||||
fprintf(vlog_out, ".%s", ivl_expr_name(expr));
|
||||
}
|
||||
|
||||
void emit_expr(ivl_scope_t scope, ivl_expr_t expr, unsigned wid)
|
||||
{
|
||||
switch (ivl_expr_type(expr)) {
|
||||
|
|
@ -653,12 +674,7 @@ void emit_expr(ivl_scope_t scope, ivl_expr_t expr, unsigned wid)
|
|||
ivl_expr_lineno(expr));
|
||||
break;
|
||||
case IVL_EX_PROPERTY:
|
||||
fprintf(vlog_out, "<class property>");
|
||||
fprintf(stderr, "%s:%u: vlog95 error: Class property expression "
|
||||
"is not supported.\n",
|
||||
ivl_expr_file(expr),
|
||||
ivl_expr_lineno(expr));
|
||||
vlog_errors += 1;
|
||||
emit_class_property(scope, expr, wid);
|
||||
break;
|
||||
case IVL_EX_REALNUM:
|
||||
emit_real_number(ivl_expr_dvalue(expr));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2011-2012 Cary R. (cygcary@yahoo.com)
|
||||
* Copyright (C) 2011-2013 Cary R. (cygcary@yahoo.com)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -174,6 +174,39 @@ static void emit_stmt_lval_ips(ivl_scope_t scope, ivl_lval_t lval,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Dynamic arrays are not supported in vlog95, but this assignment can be
|
||||
* translated correctly.
|
||||
*/
|
||||
static void emit_stmt_lval_darray(ivl_scope_t scope, ivl_lval_t lval,
|
||||
ivl_signal_t sig)
|
||||
{
|
||||
ivl_expr_t idx = ivl_lval_idx(lval);
|
||||
emit_scope_call_path(scope, ivl_signal_scope(sig));
|
||||
emit_id(ivl_signal_basename(sig));
|
||||
if (idx) {
|
||||
fprintf(vlog_out, "[");
|
||||
emit_expr(scope, idx, 0);
|
||||
fprintf(vlog_out, "]");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Class or class properties are not supported in vlog95, but this assignment
|
||||
* can be translated correctly.
|
||||
*/
|
||||
static void emit_stmt_lval_class(ivl_scope_t scope, ivl_lval_t lval,
|
||||
ivl_signal_t sig)
|
||||
{
|
||||
int idx = ivl_lval_property_idx(lval);
|
||||
emit_scope_call_path(scope, ivl_signal_scope(sig));
|
||||
emit_id(ivl_signal_basename(sig));
|
||||
if (idx >= 0) {
|
||||
ivl_type_t sig_type = ivl_signal_net_type(sig);
|
||||
fprintf(vlog_out, ".%s", ivl_type_prop_name(sig_type, idx));
|
||||
}
|
||||
}
|
||||
|
||||
static void emit_stmt_lval_piece(ivl_scope_t scope, ivl_lval_t lval)
|
||||
{
|
||||
ivl_signal_t sig = ivl_lval_sig(lval);
|
||||
|
|
@ -182,6 +215,18 @@ static void emit_stmt_lval_piece(ivl_scope_t scope, ivl_lval_t lval)
|
|||
unsigned width = ivl_lval_width(lval);
|
||||
int msb, lsb;
|
||||
assert(width > 0);
|
||||
assert(sig);
|
||||
|
||||
switch (ivl_signal_data_type(sig)) {
|
||||
case IVL_VT_DARRAY:
|
||||
emit_stmt_lval_darray(scope, lval, sig);
|
||||
return;
|
||||
case IVL_VT_CLASS:
|
||||
emit_stmt_lval_class(scope, lval, sig);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* If there are no selects then just print the name. */
|
||||
sel_expr = ivl_lval_part_off(lval);
|
||||
|
|
|
|||
Loading…
Reference in New Issue