diff --git a/libveriuser/getsimtime.c b/libveriuser/getsimtime.c index 580f8bc9e..5791ac13a 100644 --- a/libveriuser/getsimtime.c +++ b/libveriuser/getsimtime.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2009 Michael Ruff (mruff at chiaro.com) + * Copyright (c) 2002-2010 Michael Ruff (mruff at chiaro.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -45,34 +45,34 @@ scale(int high, int low, void*obj) { PLI_INT32 tf_gettime(void) { - s_vpi_time time; - time.type = vpiSimTime; - vpi_get_time (0, &time); - return scale(time.high, time.low, 0) & 0xffffffff; + s_vpi_time timerec; + timerec.type = vpiSimTime; + vpi_get_time (0, &timerec); + return scale(timerec.high, timerec.low, 0) & 0xffffffff; } char *tf_strgettime(void) { static char buf[32]; - s_vpi_time time; + s_vpi_time timerec; - time.type = vpiSimTime; - vpi_get_time (0, &time); - if (time.high) - snprintf(buf, sizeof(buf)-1, "%u%08u", (unsigned int)time.high, - (unsigned int)time.low); + timerec.type = vpiSimTime; + vpi_get_time (0, &timerec); + if (timerec.high) + snprintf(buf, sizeof(buf)-1, "%u%08u", (unsigned int)timerec.high, + (unsigned int)timerec.low); else - snprintf(buf, sizeof(buf)-1, "%u", (unsigned int)time.low); + snprintf(buf, sizeof(buf)-1, "%u", (unsigned int)timerec.low); return buf; } PLI_INT32 tf_igetlongtime(PLI_INT32 *high, void*obj) { - s_vpi_time time; + s_vpi_time timerec; ivl_u64_t scaled; - time.type = vpiSimTime; - vpi_get_time ((vpiHandle)obj, &time); - scaled = scale(time.high, time.low, obj); + timerec.type = vpiSimTime; + vpi_get_time ((vpiHandle)obj, &timerec); + scaled = scale(timerec.high, timerec.low, obj); *high = (scaled >> 32) & 0xffffffff; return scaled & 0xffffffff; diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index 0cb08660c..fcc5eb9f4 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2010 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -1145,7 +1145,7 @@ static void show_nexus_details(ivl_signal_t net, ivl_nexus_t nex) for (idx = 0 ; idx < ivl_nexus_ptrs(nex) ; idx += 1) { ivl_net_const_t con; - ivl_net_logic_t log; + ivl_net_logic_t logic; ivl_lpm_t lpm; ivl_signal_t sig; ivl_switch_t swt; @@ -1172,10 +1172,10 @@ static void show_nexus_details(ivl_signal_t net, ivl_nexus_t nex) fprintf(out, "\n"); - } else if ((log = ivl_nexus_ptr_log(ptr))) { + } else if ((logic = ivl_nexus_ptr_log(ptr))) { fprintf(out, " LOG %s.%s[%u] (%s0, %s1)\n", - ivl_scope_name(ivl_logic_scope(log)), - ivl_logic_basename(log), + ivl_scope_name(ivl_logic_scope(logic)), + ivl_logic_basename(logic), ivl_nexus_ptr_pin(ptr), dr0, dr1); } else if ((lpm = ivl_nexus_ptr_lpm(ptr))) { @@ -1343,9 +1343,9 @@ static void show_signal(ivl_signal_t net) } -static void test_expr_is_delay(ivl_expr_t exp) +static void test_expr_is_delay(ivl_expr_t expr) { - switch (ivl_expr_type(exp)) { + switch (ivl_expr_type(expr)) { case IVL_EX_ULONG: return; case IVL_EX_NUMBER: diff --git a/tgt-vvp/draw_ufunc.c b/tgt-vvp/draw_ufunc.c index 55b3c2a63..4f5450ac9 100644 --- a/tgt-vvp/draw_ufunc.c +++ b/tgt-vvp/draw_ufunc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2005-2010 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -25,7 +25,7 @@ # include # include -static void function_argument_logic(ivl_signal_t port, ivl_expr_t exp) +static void function_argument_logic(ivl_signal_t port, ivl_expr_t expr) { struct vector_info res; unsigned ewidth, pwidth; @@ -33,13 +33,13 @@ static void function_argument_logic(ivl_signal_t port, ivl_expr_t exp) /* ports cannot be arrays. */ assert(ivl_signal_dimensions(port) == 0); - ewidth = ivl_expr_width(exp); + ewidth = ivl_expr_width(expr); pwidth = ivl_signal_width(port); /* Just like a normal assignment the function arguments need to * be evaluated at either their width or the argument width if * it is larger. */ if (ewidth < pwidth) ewidth = pwidth; - res = draw_eval_expr_wid(exp, ewidth, 0); + res = draw_eval_expr_wid(expr, ewidth, 0); /* We could have extra bits so only select the ones we need. */ fprintf(vvp_out, " %%set/v v%p_0, %u, %u;\n", port, res.base, pwidth); @@ -47,9 +47,9 @@ static void function_argument_logic(ivl_signal_t port, ivl_expr_t exp) clr_vector(res); } -static void function_argument_real(ivl_signal_t port, ivl_expr_t exp) +static void function_argument_real(ivl_signal_t port, ivl_expr_t expr) { - int res = draw_eval_real(exp); + int res = draw_eval_real(expr); /* ports cannot be arrays. */ assert(ivl_signal_dimensions(port) == 0); @@ -58,15 +58,15 @@ static void function_argument_real(ivl_signal_t port, ivl_expr_t exp) clr_word(res); } -static void draw_function_argument(ivl_signal_t port, ivl_expr_t exp) +static void draw_function_argument(ivl_signal_t port, ivl_expr_t expr) { ivl_variable_type_t dtype = ivl_signal_data_type(port); switch (dtype) { case IVL_VT_LOGIC: - function_argument_logic(port, exp); + function_argument_logic(port, expr); break; case IVL_VT_REAL: - function_argument_real(port, exp); + function_argument_real(port, expr); break; default: fprintf(stderr, "XXXX function argument %s type=%d?!\n", @@ -86,11 +86,11 @@ static void draw_function_argument(ivl_signal_t port, ivl_expr_t exp) * parameter 0 of the function definition. */ -struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid) +struct vector_info draw_ufunc_expr(ivl_expr_t expr, unsigned wid) { unsigned idx; - unsigned swid = ivl_expr_width(exp); - ivl_scope_t def = ivl_expr_def(exp); + unsigned swid = ivl_expr_width(expr); + ivl_scope_t def = ivl_expr_def(expr); ivl_signal_t retval = ivl_scope_port(def, 0); struct vector_info res; unsigned load_wid; @@ -103,10 +103,10 @@ struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid) /* evaluate the expressions and send the results to the function ports. */ - assert(ivl_expr_parms(exp) == (ivl_scope_ports(def)-1)); - for (idx = 0 ; idx < ivl_expr_parms(exp) ; idx += 1) { + assert(ivl_expr_parms(expr) == (ivl_scope_ports(def)-1)); + for (idx = 0 ; idx < ivl_expr_parms(expr) ; idx += 1) { ivl_signal_t port = ivl_scope_port(def, idx+1); - draw_function_argument(port, ivl_expr_parm(exp,idx)); + draw_function_argument(port, ivl_expr_parm(expr, idx)); } @@ -127,7 +127,7 @@ struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid) if (res.base == 0) { fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits for function result.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; return res; } @@ -144,7 +144,7 @@ struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid) /* Pad the signal value with zeros. */ if (load_wid < wid) - pad_expr_in_place(exp, res, swid); + pad_expr_in_place(expr, res, swid); /* If this is an automatic function, free the local storage. */ if (ivl_scope_is_auto(def)) { @@ -154,9 +154,9 @@ struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid) return res; } -int draw_ufunc_real(ivl_expr_t exp) +int draw_ufunc_real(ivl_expr_t expr) { - ivl_scope_t def = ivl_expr_def(exp); + ivl_scope_t def = ivl_expr_def(expr); ivl_signal_t retval = ivl_scope_port(def, 0); int res = 0; int idx; @@ -166,10 +166,10 @@ int draw_ufunc_real(ivl_expr_t exp) fprintf(vvp_out, " %%alloc S_%p;\n", def); } - assert(ivl_expr_parms(exp) == (ivl_scope_ports(def)-1)); - for (idx = 0 ; idx < ivl_expr_parms(exp) ; idx += 1) { + assert(ivl_expr_parms(expr) == (ivl_scope_ports(def)-1)); + for (idx = 0 ; idx < ivl_expr_parms(expr) ; idx += 1) { ivl_signal_t port = ivl_scope_port(def, idx+1); - draw_function_argument(port, ivl_expr_parm(exp,idx)); + draw_function_argument(port, ivl_expr_parm(expr, idx)); } diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 93f45c988..f54ba7528 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -25,23 +25,23 @@ # include # include -static void draw_eval_expr_dest(ivl_expr_t exp, struct vector_info dest, +static void draw_eval_expr_dest(ivl_expr_t expr, struct vector_info dest, int ok_flags); -static void draw_signal_dest(ivl_expr_t exp, struct vector_info res, +static void draw_signal_dest(ivl_expr_t expr, struct vector_info res, int add_index, long immediate); -int number_is_unknown(ivl_expr_t ex) +int number_is_unknown(ivl_expr_t expr) { const char*bits; unsigned idx; - if (ivl_expr_type(ex) == IVL_EX_ULONG) + if (ivl_expr_type(expr) == IVL_EX_ULONG) return 0; - assert(ivl_expr_type(ex) == IVL_EX_NUMBER); + assert(ivl_expr_type(expr) == IVL_EX_NUMBER); - bits = ivl_expr_bits(ex); - for (idx = 0 ; idx < ivl_expr_width(ex) ; idx += 1) + bits = ivl_expr_bits(expr); + for (idx = 0 ; idx < ivl_expr_width(expr) ; idx += 1) if ((bits[idx] != '0') && (bits[idx] != '1')) return 1; @@ -56,17 +56,17 @@ int number_is_unknown(ivl_expr_t ex) * code generator always emits positive values, hence the negation * requirement. */ -int number_is_immediate(ivl_expr_t ex, unsigned lim_wid, int negative_ok_flag) +int number_is_immediate(ivl_expr_t expr, unsigned lim_wid, int negative_ok_flag) { const char *bits; - unsigned nbits = ivl_expr_width(ex); + unsigned nbits = ivl_expr_width(expr); char pad_bit = '0'; unsigned idx; /* We can only convert numbers to an immediate value. */ - if (ivl_expr_type(ex) != IVL_EX_NUMBER - && ivl_expr_type(ex) != IVL_EX_ULONG - && ivl_expr_type(ex) != IVL_EX_DELAY) + if (ivl_expr_type(expr) != IVL_EX_NUMBER + && ivl_expr_type(expr) != IVL_EX_ULONG + && ivl_expr_type(expr) != IVL_EX_DELAY) return 0; /* If a negative value is OK, then we really have one less @@ -74,30 +74,30 @@ int number_is_immediate(ivl_expr_t ex, unsigned lim_wid, int negative_ok_flag) if (negative_ok_flag) lim_wid -= 1; /* This is an unsigned value so it can not have the -2**N problem. */ - if (ivl_expr_type(ex) == IVL_EX_ULONG) { + if (ivl_expr_type(expr) == IVL_EX_ULONG) { unsigned long imm; if (lim_wid >= 8*sizeof(unsigned long)) return 1; /* At this point we know that lim_wid is smaller than an * unsigned long variable. */ - imm = ivl_expr_uvalue(ex); + imm = ivl_expr_uvalue(expr); if (imm < (1UL << lim_wid)) return 1; else return 0; } /* This is an unsigned value so it can not have the -2**N problem. */ - if (ivl_expr_type(ex) == IVL_EX_DELAY) { + if (ivl_expr_type(expr) == IVL_EX_DELAY) { uint64_t imm; if (lim_wid >= 8*sizeof(uint64_t)) return 1; /* At this point we know that lim_wid is smaller than a * uint64_t variable. */ - imm = ivl_expr_delay_val(ex); + imm = ivl_expr_delay_val(expr); if (imm < ((uint64_t)1 << lim_wid)) return 1; else return 0; } - bits = ivl_expr_bits(ex); + bits = ivl_expr_bits(expr); - if (ivl_expr_signed(ex) && bits[nbits-1]=='1') pad_bit = '1'; + if (ivl_expr_signed(expr) && bits[nbits-1]=='1') pad_bit = '1'; if (pad_bit == '1' && !negative_ok_flag) return 0; @@ -119,19 +119,19 @@ int number_is_immediate(ivl_expr_t ex, unsigned lim_wid, int negative_ok_flag) * number is not unknown (number_is_unknown) and is small enough * (number_is_immediate). */ -long get_number_immediate(ivl_expr_t ex) +long get_number_immediate(ivl_expr_t expr) { long imm = 0; unsigned idx; - switch (ivl_expr_type(ex)) { + switch (ivl_expr_type(expr)) { case IVL_EX_ULONG: - imm = ivl_expr_uvalue(ex); + imm = ivl_expr_uvalue(expr); break; case IVL_EX_NUMBER: { - const char*bits = ivl_expr_bits(ex); - unsigned nbits = ivl_expr_width(ex); + const char*bits = ivl_expr_bits(expr); + unsigned nbits = ivl_expr_width(expr); /* We can not copy more bits than fit into a long. */ if (nbits > 8*sizeof(long)) nbits = 8*sizeof(long); for (idx = 0 ; idx < nbits ; idx += 1) switch (bits[idx]){ @@ -143,7 +143,7 @@ long get_number_immediate(ivl_expr_t ex) default: assert(0); } - if (ivl_expr_signed(ex) && bits[nbits-1]=='1' && + if (ivl_expr_signed(expr) && bits[nbits-1]=='1' && nbits < 8*sizeof(long)) imm |= -1L << nbits; break; } @@ -155,19 +155,19 @@ long get_number_immediate(ivl_expr_t ex) return imm; } -uint64_t get_number_immediate64(ivl_expr_t ex) +uint64_t get_number_immediate64(ivl_expr_t expr) { uint64_t imm = 0; unsigned idx; - switch (ivl_expr_type(ex)) { + switch (ivl_expr_type(expr)) { case IVL_EX_ULONG: - imm = ivl_expr_uvalue(ex); + imm = ivl_expr_uvalue(expr); break; case IVL_EX_NUMBER: { - const char*bits = ivl_expr_bits(ex); - unsigned nbits = ivl_expr_width(ex); + const char*bits = ivl_expr_bits(expr); + unsigned nbits = ivl_expr_width(expr); for (idx = 0 ; idx < nbits ; idx += 1) switch (bits[idx]){ case '0': break; @@ -178,7 +178,7 @@ uint64_t get_number_immediate64(ivl_expr_t ex) default: assert(0); } - if (ivl_expr_signed(ex) && bits[nbits-1]=='1' && nbits < 64) + if (ivl_expr_signed(expr) && bits[nbits-1]=='1' && nbits < 64) imm |= (-UINT64_C(1)) << nbits; break; } @@ -305,7 +305,7 @@ void draw_eval_expr_into_integer(ivl_expr_t expr, unsigned ix) * processed so that x and z values are equivalent. This may allow for * new optimizations. */ -static struct vector_info draw_eq_immediate(ivl_expr_t exp, unsigned ewid, +static struct vector_info draw_eq_immediate(ivl_expr_t expr, unsigned ewid, ivl_expr_t le, ivl_expr_t re, int stuff_ok_flag) @@ -320,7 +320,7 @@ static struct vector_info draw_eq_immediate(ivl_expr_t exp, unsigned ewid, wid = ivl_expr_width(le); lv = draw_eval_expr_wid(le, wid, stuff_ok_flag); - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case 'E': /* === */ fprintf(vvp_out, " %%cmpi/u %u, %lu, %u;\n", lv.base, imm, wid); @@ -389,7 +389,7 @@ static struct vector_info draw_eq_immediate(ivl_expr_t exp, unsigned ewid, fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of equality compare.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } @@ -405,7 +405,7 @@ static struct vector_info draw_eq_immediate(ivl_expr_t exp, unsigned ewid, fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of equality compare.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } @@ -426,7 +426,7 @@ static struct vector_info draw_eq_immediate(ivl_expr_t exp, unsigned ewid, * This handles the special case that the operands of the comparison * are real valued expressions. */ -static struct vector_info draw_binary_expr_eq_real(ivl_expr_t exp) +static struct vector_info draw_binary_expr_eq_real(ivl_expr_t expr) { struct vector_info res; int lword, rword; @@ -435,14 +435,14 @@ static struct vector_info draw_binary_expr_eq_real(ivl_expr_t exp) res.wid = 1; assert(res.base); - lword = draw_eval_real(ivl_expr_oper1(exp)); - rword = draw_eval_real(ivl_expr_oper2(exp)); + lword = draw_eval_real(ivl_expr_oper1(expr)); + rword = draw_eval_real(ivl_expr_oper2(expr)); clr_word(lword); clr_word(rword); fprintf(vvp_out, " %%cmp/wr %d, %d;\n", lword, rword); - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case 'e': fprintf(vvp_out, " %%mov %u, 4, 1;\n", res.base); @@ -460,12 +460,12 @@ static struct vector_info draw_binary_expr_eq_real(ivl_expr_t exp) return res; } -static struct vector_info draw_binary_expr_eq(ivl_expr_t exp, +static struct vector_info draw_binary_expr_eq(ivl_expr_t expr, unsigned ewid, int stuff_ok_flag) { - ivl_expr_t le = ivl_expr_oper1(exp); - ivl_expr_t re = ivl_expr_oper2(exp); + ivl_expr_t le = ivl_expr_oper1(expr); + ivl_expr_t re = ivl_expr_oper2(expr); unsigned wid; @@ -474,11 +474,11 @@ static struct vector_info draw_binary_expr_eq(ivl_expr_t exp, if ((ivl_expr_value(le) == IVL_VT_REAL) ||(ivl_expr_value(re) == IVL_VT_REAL)) { - return draw_binary_expr_eq_real(exp); + return draw_binary_expr_eq_real(expr); } if (number_is_immediate(re,16,0) && !number_is_unknown(re)) - return draw_eq_immediate(exp, ewid, le, re, stuff_ok_flag); + return draw_eq_immediate(expr, ewid, le, re, stuff_ok_flag); assert(ivl_expr_value(le) == IVL_VT_LOGIC || ivl_expr_value(le) == IVL_VT_BOOL); @@ -492,7 +492,7 @@ static struct vector_info draw_binary_expr_eq(ivl_expr_t exp, lv = draw_eval_expr_wid(le, wid, stuff_ok_flag&~STUFF_OK_47); rv = draw_eval_expr_wid(re, wid, stuff_ok_flag&~STUFF_OK_47); - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case 'E': /* === */ assert(lv.wid == rv.wid); fprintf(vvp_out, " %%cmp/u %u, %u, %u;\n", lv.base, @@ -570,7 +570,7 @@ static struct vector_info draw_binary_expr_eq(ivl_expr_t exp, fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of equality compare.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } @@ -584,10 +584,10 @@ static struct vector_info draw_binary_expr_eq(ivl_expr_t exp, return lv; } -static struct vector_info draw_binary_expr_land(ivl_expr_t exp, unsigned wid) +static struct vector_info draw_binary_expr_land(ivl_expr_t expr, unsigned wid) { - ivl_expr_t le = ivl_expr_oper1(exp); - ivl_expr_t re = ivl_expr_oper2(exp); + ivl_expr_t le = ivl_expr_oper1(expr); + ivl_expr_t re = ivl_expr_oper2(expr); struct vector_info lv; struct vector_info rv; @@ -653,7 +653,7 @@ static struct vector_info draw_binary_expr_land(ivl_expr_t exp, unsigned wid) fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of padded logical AND.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } @@ -667,11 +667,11 @@ static struct vector_info draw_binary_expr_land(ivl_expr_t exp, unsigned wid) return lv; } -static struct vector_info draw_binary_expr_lor(ivl_expr_t exp, unsigned wid, +static struct vector_info draw_binary_expr_lor(ivl_expr_t expr, unsigned wid, int stuff_ok_flag) { - ivl_expr_t le = ivl_expr_oper1(exp); - ivl_expr_t re = ivl_expr_oper2(exp); + ivl_expr_t le = ivl_expr_oper1(expr); + ivl_expr_t re = ivl_expr_oper2(expr); struct vector_info lv; struct vector_info rv; @@ -764,7 +764,7 @@ static struct vector_info draw_binary_expr_lor(ivl_expr_t exp, unsigned wid, fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of padded logical OR.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } @@ -778,12 +778,12 @@ static struct vector_info draw_binary_expr_lor(ivl_expr_t exp, unsigned wid, return lv; } -static struct vector_info draw_binary_expr_le_real(ivl_expr_t exp) +static struct vector_info draw_binary_expr_le_real(ivl_expr_t expr) { struct vector_info res; - ivl_expr_t le = ivl_expr_oper1(exp); - ivl_expr_t re = ivl_expr_oper2(exp); + ivl_expr_t le = ivl_expr_oper1(expr); + ivl_expr_t re = ivl_expr_oper2(expr); int lword = draw_eval_real(le); int rword = draw_eval_real(re); @@ -796,7 +796,7 @@ static struct vector_info draw_binary_expr_le_real(ivl_expr_t exp) clr_word(lword); clr_word(rword); - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case '<': fprintf(vvp_out, " %%cmp/wr %d, %d;\n", lword, rword); fprintf(vvp_out, " %%mov %u, 5, 1;\n", res.base); @@ -826,11 +826,11 @@ static struct vector_info draw_binary_expr_le_real(ivl_expr_t exp) return res; } -static struct vector_info draw_binary_expr_le_bool(ivl_expr_t exp, +static struct vector_info draw_binary_expr_le_bool(ivl_expr_t expr, unsigned wid) { - ivl_expr_t le = ivl_expr_oper1(exp); - ivl_expr_t re = ivl_expr_oper2(exp); + ivl_expr_t le = ivl_expr_oper1(expr); + ivl_expr_t re = ivl_expr_oper2(expr); int lw, rw; struct vector_info tmp; @@ -843,7 +843,7 @@ static struct vector_info draw_binary_expr_le_bool(ivl_expr_t exp, lw = draw_eval_bool64(le); rw = draw_eval_bool64(re); - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case 'G': fprintf(vvp_out, " %%cmp/w%c %u, %u;\n", s_flag, rw, lw); fprintf(vvp_out, " %%or 5, 4, 1;\n"); @@ -877,7 +877,7 @@ static struct vector_info draw_binary_expr_le_bool(ivl_expr_t exp, fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of padded inequality compare.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } @@ -891,12 +891,12 @@ static struct vector_info draw_binary_expr_le_bool(ivl_expr_t exp, return tmp; } -static struct vector_info draw_binary_expr_le(ivl_expr_t exp, +static struct vector_info draw_binary_expr_le(ivl_expr_t expr, unsigned wid, int stuff_ok_flag) { - ivl_expr_t le = ivl_expr_oper1(exp); - ivl_expr_t re = ivl_expr_oper2(exp); + ivl_expr_t le = ivl_expr_oper1(expr); + ivl_expr_t re = ivl_expr_oper2(expr); struct vector_info lv; struct vector_info rv; @@ -908,16 +908,16 @@ static struct vector_info draw_binary_expr_le(ivl_expr_t exp, owid = ivl_expr_width(re); if (ivl_expr_value(le) == IVL_VT_REAL) - return draw_binary_expr_le_real(exp); + return draw_binary_expr_le_real(expr); if (ivl_expr_value(re) == IVL_VT_REAL) - return draw_binary_expr_le_real(exp); + return draw_binary_expr_le_real(expr); /* Detect the special case that we can do this with integers. */ if (ivl_expr_value(le) == IVL_VT_BOOL && ivl_expr_value(re) == IVL_VT_BOOL && owid < 64) { - return draw_binary_expr_le_bool(exp, wid); + return draw_binary_expr_le_bool(expr, wid); } assert(ivl_expr_value(le) == IVL_VT_LOGIC @@ -928,7 +928,7 @@ static struct vector_info draw_binary_expr_le(ivl_expr_t exp, lv.wid = 0; lv.base=0; rv.wid = 0; rv.base=0; - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case 'G': rv = draw_eval_expr_wid(re, owid, STUFF_OK_XZ); if (number_is_immediate(le,16,0) && !number_is_unknown(le)) { @@ -1012,7 +1012,7 @@ static struct vector_info draw_binary_expr_le(ivl_expr_t exp, fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of padded inequality compare.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } @@ -1026,7 +1026,7 @@ static struct vector_info draw_binary_expr_le(ivl_expr_t exp, return lv; } -static struct vector_info draw_logic_immediate(ivl_expr_t exp, +static struct vector_info draw_logic_immediate(ivl_expr_t expr, ivl_expr_t le, ivl_expr_t re, unsigned wid) @@ -1038,7 +1038,7 @@ static struct vector_info draw_logic_immediate(ivl_expr_t exp, assert(lv.base >= 4); - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case '&': fprintf(vvp_out, " %%andi %u, %lu, %u;\n", lv.base, imm, lv.wid); @@ -1052,19 +1052,19 @@ static struct vector_info draw_logic_immediate(ivl_expr_t exp, return lv; } -static struct vector_info draw_binary_expr_logic(ivl_expr_t exp, +static struct vector_info draw_binary_expr_logic(ivl_expr_t expr, unsigned wid) { - ivl_expr_t le = ivl_expr_oper1(exp); - ivl_expr_t re = ivl_expr_oper2(exp); + ivl_expr_t le = ivl_expr_oper1(expr); + ivl_expr_t re = ivl_expr_oper2(expr); struct vector_info lv; struct vector_info rv; - if (ivl_expr_opcode(exp) == '&') { + if (ivl_expr_opcode(expr) == '&') { if (number_is_immediate(re, IMM_WID, 0) && !number_is_unknown(re)) - return draw_logic_immediate(exp, le, re, wid); + return draw_logic_immediate(expr, le, re, wid); if (number_is_immediate(le, IMM_WID, 0) && !number_is_unknown(le)) - return draw_logic_immediate(exp, re, le, wid); + return draw_logic_immediate(expr, re, le, wid); } lv = draw_eval_expr_wid(le, wid, STUFF_OK_XZ); @@ -1088,7 +1088,8 @@ static struct vector_info draw_binary_expr_logic(ivl_expr_t exp, fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of binary logic.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), + wid); vvp_errors += 1; } @@ -1098,7 +1099,7 @@ static struct vector_info draw_binary_expr_logic(ivl_expr_t exp, } } - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case '&': fprintf(vvp_out, " %%and %u, %u, %u;\n", @@ -1145,16 +1146,16 @@ static struct vector_info draw_binary_expr_logic(ivl_expr_t exp, * function, with the only difference the opcode I generate at the * end. */ -static struct vector_info draw_binary_expr_lrs(ivl_expr_t exp, unsigned wid) +static struct vector_info draw_binary_expr_lrs(ivl_expr_t expr, unsigned wid) { - ivl_expr_t le = ivl_expr_oper1(exp); - ivl_expr_t re = ivl_expr_oper2(exp); + ivl_expr_t le = ivl_expr_oper1(expr); + ivl_expr_t re = ivl_expr_oper2(expr); const char*opcode = "?"; struct vector_info lv; /* Evaluate the expression that is to be shifted. */ - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case 'l': /* << (left shift) */ lv = draw_eval_expr_wid(le, wid, 0); @@ -1171,7 +1172,8 @@ static struct vector_info draw_binary_expr_lrs(ivl_expr_t exp, unsigned wid) fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of left shift (<<).\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), + wid); vvp_errors += 1; } @@ -1206,7 +1208,8 @@ static struct vector_info draw_binary_expr_lrs(ivl_expr_t exp, unsigned wid) fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of right shift (>>).\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), lv.wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), + lv.wid); vvp_errors += 1; } @@ -1235,7 +1238,7 @@ static struct vector_info draw_binary_expr_lrs(ivl_expr_t exp, unsigned wid) /* Sign extend any constant begets itself, if this expression is signed. */ - if ((lv.base < 4) && (ivl_expr_signed(exp))) + if ((lv.base < 4) && (ivl_expr_signed(expr))) return lv; if (lv.base < 4) { @@ -1246,7 +1249,8 @@ static struct vector_info draw_binary_expr_lrs(ivl_expr_t exp, unsigned wid) fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of right shift (>>>).\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), lv.wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), + lv.wid); vvp_errors += 1; } @@ -1255,7 +1259,7 @@ static struct vector_info draw_binary_expr_lrs(ivl_expr_t exp, unsigned wid) lv = tmp; } - if (ivl_expr_signed(exp)) + if (ivl_expr_signed(expr)) opcode = "%shiftr/s"; else opcode = "%shiftr"; @@ -1273,7 +1277,7 @@ static struct vector_info draw_binary_expr_lrs(ivl_expr_t exp, unsigned wid) fprintf(vvp_out, " %s/i0 %u, %u;\n", opcode, lv.base, lv.wid); if (lv.base >= 8) - save_expression_lookaside(lv.base, exp, lv.wid); + save_expression_lookaside(lv.base, expr, lv.wid); return lv; } @@ -1439,10 +1443,10 @@ static struct vector_info draw_mul_immediate(ivl_expr_t le, return lv; } -static struct vector_info draw_binary_expr_arith(ivl_expr_t exp, unsigned wid) +static struct vector_info draw_binary_expr_arith(ivl_expr_t expr, unsigned wid) { - ivl_expr_t le = ivl_expr_oper1(exp); - ivl_expr_t re = ivl_expr_oper2(exp); + ivl_expr_t le = ivl_expr_oper1(expr); + ivl_expr_t re = ivl_expr_oper2(expr); struct vector_info lv; struct vector_info rv; @@ -1451,55 +1455,55 @@ static struct vector_info draw_binary_expr_arith(ivl_expr_t exp, unsigned wid) const char*sign_string = signed_flag ? "/s" : ""; - if ((ivl_expr_opcode(exp) == '+') + if ((ivl_expr_opcode(expr) == '+') && (ivl_expr_type(le) == IVL_EX_SIGNAL) && (ivl_expr_type(re) == IVL_EX_ULONG) && number_is_immediate(re, IMM_WID, 1)) return draw_load_add_immediate(le, re, wid, signed_flag); - if ((ivl_expr_opcode(exp) == '+') + if ((ivl_expr_opcode(expr) == '+') && (ivl_expr_type(le) == IVL_EX_SIGNAL) && (ivl_expr_type(re) == IVL_EX_NUMBER) && (! number_is_unknown(re)) && number_is_immediate(re, IMM_WID, 1)) return draw_load_add_immediate(le, re, wid, signed_flag); - if ((ivl_expr_opcode(exp) == '+') + if ((ivl_expr_opcode(expr) == '+') && (ivl_expr_type(re) == IVL_EX_SIGNAL) && (ivl_expr_type(le) == IVL_EX_ULONG) && number_is_immediate(re, IMM_WID, 1)) return draw_load_add_immediate(re, le, wid, signed_flag); - if ((ivl_expr_opcode(exp) == '+') + if ((ivl_expr_opcode(expr) == '+') && (ivl_expr_type(re) == IVL_EX_SIGNAL) && (ivl_expr_type(le) == IVL_EX_NUMBER) && (! number_is_unknown(le)) && number_is_immediate(le, IMM_WID, 1)) return draw_load_add_immediate(re, le, wid, signed_flag); - if ((ivl_expr_opcode(exp) == '+') + if ((ivl_expr_opcode(expr) == '+') && (ivl_expr_type(re) == IVL_EX_ULONG) && number_is_immediate(re, IMM_WID, 0)) return draw_add_immediate(le, re, wid); - if ((ivl_expr_opcode(exp) == '+') + if ((ivl_expr_opcode(expr) == '+') && (ivl_expr_type(re) == IVL_EX_NUMBER) && (! number_is_unknown(re)) && number_is_immediate(re, IMM_WID, 0)) return draw_add_immediate(le, re, wid); - if ((ivl_expr_opcode(exp) == '-') + if ((ivl_expr_opcode(expr) == '-') && (ivl_expr_type(re) == IVL_EX_ULONG) && number_is_immediate(re, IMM_WID, 0)) return draw_sub_immediate(le, re, wid); - if ((ivl_expr_opcode(exp) == '-') + if ((ivl_expr_opcode(expr) == '-') && (ivl_expr_type(re) == IVL_EX_NUMBER) && (! number_is_unknown(re)) && number_is_immediate(re, IMM_WID, 0)) return draw_sub_immediate(le, re, wid); - if ((ivl_expr_opcode(exp) == '*') + if ((ivl_expr_opcode(expr) == '*') && (ivl_expr_type(re) == IVL_EX_NUMBER) && (! number_is_unknown(re)) && number_is_immediate(re, IMM_WID, 0)) @@ -1509,8 +1513,8 @@ static struct vector_info draw_binary_expr_arith(ivl_expr_t exp, unsigned wid) rv = draw_eval_expr_wid(re, wid, STUFF_OK_XZ|STUFF_OK_RO); if (lv.wid != wid) { - fprintf(stderr, "XXXX ivl_expr_opcode(exp) = %c," - " lv.wid=%u, wid=%u\n", ivl_expr_opcode(exp), + fprintf(stderr, "XXXX ivl_expr_opcode(expr) = %c," + " lv.wid=%u, wid=%u\n", ivl_expr_opcode(expr), lv.wid, wid); } @@ -1530,7 +1534,7 @@ static struct vector_info draw_binary_expr_arith(ivl_expr_t exp, unsigned wid) fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of arithmetic expression.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } @@ -1539,7 +1543,7 @@ static struct vector_info draw_binary_expr_arith(ivl_expr_t exp, unsigned wid) lv = tmp; } - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case '+': fprintf(vvp_out, " %%add %u, %u, %u;\n", lv.base, rv.base, wid); break; @@ -1581,23 +1585,23 @@ static struct vector_info draw_binary_expr_arith(ivl_expr_t exp, unsigned wid) return lv; } -static struct vector_info draw_binary_expr(ivl_expr_t exp, +static struct vector_info draw_binary_expr(ivl_expr_t expr, unsigned wid, int stuff_ok_flag) { struct vector_info rv; int stuff_ok_used_flag = 0; - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case 'a': /* && (logical and) */ - rv = draw_binary_expr_land(exp, wid); + rv = draw_binary_expr_land(expr, wid); break; case 'E': /* === */ case 'e': /* == */ case 'N': /* !== */ case 'n': /* != */ - rv = draw_binary_expr_eq(exp, wid, stuff_ok_flag); + rv = draw_binary_expr_eq(expr, wid, stuff_ok_flag); stuff_ok_used_flag = 1; break; @@ -1605,7 +1609,7 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, case '>': case 'L': /* <= */ case 'G': /* >= */ - rv = draw_binary_expr_le(exp, wid, stuff_ok_flag); + rv = draw_binary_expr_le(expr, wid, stuff_ok_flag); stuff_ok_used_flag = 1; break; @@ -1615,17 +1619,17 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, case '/': case '%': case 'p': - rv = draw_binary_expr_arith(exp, wid); + rv = draw_binary_expr_arith(expr, wid); break; case 'l': /* << */ case 'r': /* >> */ case 'R': /* >>> */ - rv = draw_binary_expr_lrs(exp, wid); + rv = draw_binary_expr_lrs(expr, wid); break; case 'o': /* || (logical or) */ - rv = draw_binary_expr_lor(exp, wid, stuff_ok_flag); + rv = draw_binary_expr_lor(expr, wid, stuff_ok_flag); stuff_ok_used_flag = 1; break; @@ -1635,12 +1639,12 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, case 'A': /* NAND (~&) */ case 'O': /* NOR (~|) */ case 'X': /* XNOR (~^) */ - rv = draw_binary_expr_logic(exp, wid); + rv = draw_binary_expr_logic(expr, wid); break; default: fprintf(stderr, "vvp.tgt error: unsupported binary (%c)\n", - ivl_expr_opcode(exp)); + ivl_expr_opcode(expr)); assert(0); } @@ -1656,7 +1660,7 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, if (stuff_ok_used_flag && (stuff_ok_flag & ~STUFF_OK_47)) save_expression_lookaside(rv.base, 0, wid); else - save_expression_lookaside(rv.base, exp, wid); + save_expression_lookaside(rv.base, expr, wid); } return rv; @@ -1667,7 +1671,7 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, * expression, then copying it into the contiguous vector of the * result. Do this until the result vector is filled. */ -static struct vector_info draw_concat_expr(ivl_expr_t exp, unsigned wid, +static struct vector_info draw_concat_expr(ivl_expr_t expr, unsigned wid, int stuff_ok_flag) { unsigned rep, expr_wid, concat_wid, num_sube, idx; @@ -1676,16 +1680,16 @@ static struct vector_info draw_concat_expr(ivl_expr_t exp, unsigned wid, int alloc_exclusive = (stuff_ok_flag&STUFF_OK_RO) ? 0 : 1; /* Find out how wide the base concatenation expression is. */ - num_sube = ivl_expr_parms(exp); + num_sube = ivl_expr_parms(expr); expr_wid = 0; for (idx = 0 ; idx < num_sube; idx += 1) { - expr_wid += ivl_expr_width(ivl_expr_parm(exp, idx)); + expr_wid += ivl_expr_width(ivl_expr_parm(expr, idx)); } /* Get the repeat count. This must be a constant that has been evaluated at compile time. The operands will be repeated to form the result. */ - rep = ivl_expr_repeat(exp); + rep = ivl_expr_repeat(expr); /* Allocate a vector to hold the result. */ if (rep == 0) { @@ -1701,7 +1705,7 @@ static struct vector_info draw_concat_expr(ivl_expr_t exp, unsigned wid, fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for result of concatenation.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), + ivl_expr_file(expr), ivl_expr_lineno(expr), rep ? wid : expr_wid); vvp_errors += 1; } @@ -1712,7 +1716,7 @@ static struct vector_info draw_concat_expr(ivl_expr_t exp, unsigned wid, unsigned off = 0; /* Evaluate the base expression. */ for (idx = num_sube; idx > 0; idx -= 1) { - ivl_expr_t arg = ivl_expr_parm(exp, idx-1); + ivl_expr_t arg = ivl_expr_parm(expr, idx-1); unsigned awid = ivl_expr_width(arg); struct vector_info avec; @@ -1761,7 +1765,7 @@ static struct vector_info draw_concat_expr(ivl_expr_t exp, unsigned wid, /* Pad the expression when needed. */ if (wid > concat_wid) { /* We can get a signed concatenation with $signed({...}). */ - if (ivl_expr_signed(exp)) { + if (ivl_expr_signed(expr)) { unsigned base = res.base+concat_wid-1; for (idx = 1; idx <= wid-concat_wid; idx += 1) { fprintf(vvp_out, " %%mov %u, %u, 1;\n", @@ -1776,7 +1780,7 @@ static struct vector_info draw_concat_expr(ivl_expr_t exp, unsigned wid, /* The concatenation is too big for the result so draw it * at full width and then copy the bits that are needed. */ struct vector_info full_res; - full_res = draw_concat_expr(exp, concat_wid, stuff_ok_flag); + full_res = draw_concat_expr(expr, concat_wid, stuff_ok_flag); assert(full_res.base); fprintf(vvp_out, " %%mov %u, %u, %u;\n", res.base, @@ -1786,7 +1790,7 @@ static struct vector_info draw_concat_expr(ivl_expr_t exp, unsigned wid, /* Save the accumulated result in the lookaside map. */ if (res.base >= 8) - save_expression_lookaside(res.base, exp, wid); + save_expression_lookaside(res.base, expr, wid); return res; } @@ -1795,12 +1799,12 @@ static struct vector_info draw_concat_expr(ivl_expr_t exp, unsigned wid, * A number in an expression is made up by copying constant bits into * the allocated vector. */ -static struct vector_info draw_number_expr(ivl_expr_t exp, unsigned wid) +static struct vector_info draw_number_expr(ivl_expr_t expr, unsigned wid) { unsigned idx; unsigned nwid; struct vector_info res; - const char*bits = ivl_expr_bits(exp); + const char*bits = ivl_expr_bits(expr); unsigned long val; unsigned val_bits; unsigned val_addr; @@ -1808,8 +1812,8 @@ static struct vector_info draw_number_expr(ivl_expr_t exp, unsigned wid) res.wid = wid; nwid = wid; - if (ivl_expr_width(exp) < nwid) - nwid = ivl_expr_width(exp); + if (ivl_expr_width(expr) < nwid) + nwid = ivl_expr_width(expr); /* If all the bits of the number have the same value, then we can use a constant bit. There is no need to allocate wr @@ -1849,15 +1853,15 @@ static struct vector_info draw_number_expr(ivl_expr_t exp, unsigned wid) fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for number value.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } /* Detect the special case that the entire number fits in an immediate. In this case we generate a single %movi instruction. */ - if ((!number_is_unknown(exp)) && number_is_immediate(exp, IMM_WID,0)) { - unsigned long val2 = get_number_immediate(exp); + if ((!number_is_unknown(expr)) && number_is_immediate(expr, IMM_WID,0)) { + unsigned long val2 = get_number_immediate(expr); fprintf(vvp_out, " %%movi %u, %lu, %u;\n", res.base, val2, wid); return res; } @@ -1915,7 +1919,7 @@ static struct vector_info draw_number_expr(ivl_expr_t exp, unsigned wid) /* Pad the number up to the expression width. */ if (idx < wid) { - if (ivl_expr_signed(exp) && bits[nwid-1] == '1') + if (ivl_expr_signed(expr) && bits[nwid-1] == '1') fprintf(vvp_out, " %%mov %u, 1, %u;\n", res.base+idx, wid-idx); @@ -1933,7 +1937,7 @@ static struct vector_info draw_number_expr(ivl_expr_t exp, unsigned wid) } if (res.base >= 8) - save_expression_lookaside(res.base, exp, wid); + save_expression_lookaside(res.base, expr, wid); return res; } @@ -1962,12 +1966,12 @@ static void pad_in_place(struct vector_info dest, unsigned sub_width, int signed * value. It will zero extend or sign extend depending on the * signedness of the expression. */ -static struct vector_info draw_pad_expr(ivl_expr_t exp, unsigned wid) +static struct vector_info draw_pad_expr(ivl_expr_t expr, unsigned wid) { struct vector_info subv; struct vector_info res; - ivl_expr_t subexpr = ivl_expr_oper1(exp); + ivl_expr_t subexpr = ivl_expr_oper1(expr); /* If the sub-expression is at least as wide as the target width, then instead of pad, we truncate. Evaluate the @@ -1979,7 +1983,7 @@ static struct vector_info draw_pad_expr(ivl_expr_t exp, unsigned wid) res.base = subv.base; res.wid = wid; if (subv.base >= 8) - save_expression_lookaside(subv.base, exp, subv.wid); + save_expression_lookaside(subv.base, expr, subv.wid); return res; } @@ -1992,7 +1996,7 @@ static struct vector_info draw_pad_expr(ivl_expr_t exp, unsigned wid) fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "to pad expression.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } @@ -2002,16 +2006,16 @@ static struct vector_info draw_pad_expr(ivl_expr_t exp, unsigned wid) subv.wid = ivl_expr_width(subexpr); draw_eval_expr_dest(subexpr, subv, 0); - pad_in_place(res, subv.wid, ivl_expr_signed(exp)); + pad_in_place(res, subv.wid, ivl_expr_signed(expr)); - save_expression_lookaside(res.base, exp, wid); + save_expression_lookaside(res.base, expr, wid); return res; } -static struct vector_info draw_realnum_expr(ivl_expr_t exp, unsigned wid) +static struct vector_info draw_realnum_expr(ivl_expr_t expr, unsigned wid) { struct vector_info res; - double val = ivl_expr_dvalue(exp); + double val = ivl_expr_dvalue(expr); long ival = val; assert(wid <= 8*sizeof(long)); @@ -2086,7 +2090,7 @@ static char *process_octal_codes(const char *in, unsigned width) * A string in an expression is made up by copying constant bits into * the allocated vector. */ -static struct vector_info draw_string_expr(ivl_expr_t exp, unsigned wid) +static struct vector_info draw_string_expr(ivl_expr_t expr, unsigned wid) { struct vector_info res; char *p, *fp; @@ -2095,13 +2099,13 @@ static struct vector_info draw_string_expr(ivl_expr_t exp, unsigned wid) res.wid = wid; nwid = wid; - ewid = ivl_expr_width(exp); + ewid = ivl_expr_width(expr); if (ewid < nwid) nwid = ewid; /* Our string may have embedded \xxx sequences so they need to be removed before we proceed. Returns a new string. */ - fp = process_octal_codes(ivl_expr_string(exp), ewid); + fp = process_octal_codes(ivl_expr_string(expr), ewid); p = fp; p += (ewid / 8) - 1; @@ -2114,7 +2118,7 @@ static struct vector_info draw_string_expr(ivl_expr_t exp, unsigned wid) fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "for string value.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } @@ -2153,7 +2157,7 @@ static struct vector_info draw_string_expr(ivl_expr_t exp, unsigned wid) fprintf(vvp_out, " %%mov %u, 0, %u;\n", res.base+idx, wid-idx); if (res.base >= 8) - save_expression_lookaside(res.base, exp, wid); + save_expression_lookaside(res.base, expr, wid); free(fp); return res; @@ -2166,12 +2170,12 @@ static struct vector_info draw_string_expr(ivl_expr_t exp, unsigned wid) * the res vector. This function just calculates the pad to fill out * the res area. */ -void pad_expr_in_place(ivl_expr_t exp, struct vector_info res, unsigned swid) +void pad_expr_in_place(ivl_expr_t expr, struct vector_info res, unsigned swid) { if (res.wid <= swid) return; - if (ivl_expr_signed(exp)) { + if (ivl_expr_signed(expr)) { unsigned idx; for (idx = swid ; idx < res.wid ; idx += 1) fprintf(vvp_out, " %%mov %u, %u, 1;\n", @@ -2200,11 +2204,11 @@ void pad_expr_in_place(ivl_expr_t exp, struct vector_info res, unsigned swid) * destination. If the add_index is 1, then generate a %load/vp0/s to * do a signed load. */ -static void draw_signal_dest(ivl_expr_t exp, struct vector_info res, +static void draw_signal_dest(ivl_expr_t expr, struct vector_info res, int add_index, long immediate) { - unsigned swid = ivl_expr_width(exp); - ivl_signal_t sig = ivl_expr_signal(exp); + unsigned swid = ivl_expr_width(expr); + ivl_signal_t sig = ivl_expr_signal(expr); unsigned word = 0; @@ -2214,13 +2218,13 @@ static void draw_signal_dest(ivl_expr_t exp, struct vector_info res, /* If this is an access to an array, handle that by emitting a load/av instruction. */ if (ivl_signal_dimensions(sig) > 0) { - ivl_expr_t ix = ivl_expr_oper1(exp); + ivl_expr_t ix = ivl_expr_oper1(expr); draw_eval_expr_into_integer(ix, 3); if (add_index < 0) { fprintf(vvp_out, " %%load/av %u, v%p, %u;\n", res.base, sig, swid); - pad_expr_in_place(exp, res, swid); + pad_expr_in_place(expr, res, swid); } else { const char*sign_flag = (add_index>0)? "/s" : ""; @@ -2265,10 +2269,10 @@ static void draw_signal_dest(ivl_expr_t exp, struct vector_info res, } - pad_expr_in_place(exp, res, swid); + pad_expr_in_place(expr, res, swid); } -static struct vector_info draw_signal_expr(ivl_expr_t exp, unsigned wid, +static struct vector_info draw_signal_expr(ivl_expr_t expr, unsigned wid, int stuff_ok_flag) { struct vector_info res; @@ -2276,7 +2280,7 @@ static struct vector_info draw_signal_expr(ivl_expr_t exp, unsigned wid, int alloc_exclusive = (stuff_ok_flag&STUFF_OK_RO) ? 0 : 1; /* Already in the vector lookaside? */ - res.base = allocate_vector_exp(exp, wid, alloc_exclusive); + res.base = allocate_vector_exp(expr, wid, alloc_exclusive); res.wid = wid; if (res.base != 0) { fprintf(vvp_out, "; Reuse signal base=%u wid=%u from lookaside.\n", @@ -2290,13 +2294,13 @@ static struct vector_info draw_signal_expr(ivl_expr_t exp, unsigned wid, fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "to load variable/wire.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), wid); vvp_errors += 1; } - save_expression_lookaside(res.base, exp, wid); + save_expression_lookaside(res.base, expr, wid); - draw_signal_dest(exp, res, -1, 0L); + draw_signal_dest(expr, res, -1, 0L); return res; } @@ -2347,7 +2351,7 @@ static struct vector_info draw_select_array(ivl_expr_t sube, return res; } -static struct vector_info draw_select_signal(ivl_expr_t exp, +static struct vector_info draw_select_signal(ivl_expr_t expr, ivl_expr_t sube, ivl_expr_t bit_idx, unsigned bit_wid, @@ -2396,7 +2400,7 @@ static struct vector_info draw_select_signal(ivl_expr_t exp, save_signal_lookaside(res.base, sig, use_word, bit_wid); /* Pad the part select to the desired width. Because of $signed() this may be signed or unsigned (default). */ - pad_expr_in_place(exp, res, bit_wid); + pad_expr_in_place(expr, res, bit_wid); return res; } @@ -2422,7 +2426,7 @@ static struct vector_info draw_select_signal(ivl_expr_t exp, res.base, sig, use_word, use_wid); /* Pad the part select to the desired width. Because of $signed() this may be signed or unsigned (default). */ - pad_expr_in_place(exp, res, use_wid); + pad_expr_in_place(expr, res, use_wid); fprintf(vvp_out, " %%jmp T_%d.%d;\n", thread_count, lab_end); fprintf(vvp_out, "T_%d.%d ;\n", thread_count, lab_x); @@ -2432,7 +2436,7 @@ static struct vector_info draw_select_signal(ivl_expr_t exp, return res; } -static void draw_select_signal_dest(ivl_expr_t exp, +static void draw_select_signal_dest(ivl_expr_t expr, ivl_expr_t sube, ivl_expr_t bit_idx, struct vector_info dest, @@ -2459,7 +2463,7 @@ static void draw_select_signal_dest(ivl_expr_t exp, /* Fallback, just draw the expression and copy the result into the destination. */ - tmp = draw_select_signal(exp, sube, bit_idx, dest.wid, dest.wid); + tmp = draw_select_signal(expr, sube, bit_idx, dest.wid, dest.wid); assert(tmp.wid == dest.wid); fprintf(vvp_out, " %%mov %u, %u, %u; Move signal select into place\n", @@ -2471,13 +2475,13 @@ static void draw_select_signal_dest(ivl_expr_t exp, } } -static struct vector_info draw_select_unsized_literal(ivl_expr_t exp, +static struct vector_info draw_select_unsized_literal(ivl_expr_t expr, unsigned wid, int stuff_ok_flag) { struct vector_info subv, shiv, res; - ivl_expr_t sube = ivl_expr_oper1(exp); - ivl_expr_t shift = ivl_expr_oper2(exp); + ivl_expr_t sube = ivl_expr_oper1(expr); + ivl_expr_t shift = ivl_expr_oper2(expr); assert(!ivl_expr_sized(sube)); res.wid = wid; @@ -2651,12 +2655,12 @@ static struct vector_info draw_select_unsized_literal(ivl_expr_t exp, return res; } -static struct vector_info draw_select_expr(ivl_expr_t exp, unsigned wid, +static struct vector_info draw_select_expr(ivl_expr_t expr, unsigned wid, int stuff_ok_flag) { struct vector_info subv, shiv, res; - ivl_expr_t sube = ivl_expr_oper1(exp); - ivl_expr_t shift = ivl_expr_oper2(exp); + ivl_expr_t sube = ivl_expr_oper1(expr); + ivl_expr_t shift = ivl_expr_oper2(expr); int alloc_exclusive = (stuff_ok_flag&STUFF_OK_RO)? 0 : 1; int cmp; @@ -2667,22 +2671,23 @@ static struct vector_info draw_select_expr(ivl_expr_t exp, unsigned wid, /* First look for the self expression in the lookaside, and allocate that if possible. If I find it, then immediately return that. */ - if ( (res.base = allocate_vector_exp(exp, wid, alloc_exclusive)) != 0) { + if ( (res.base = allocate_vector_exp(expr, wid, alloc_exclusive)) != 0) { fprintf(vvp_out, "; Reuse base=%u wid=%u from lookaside.\n", res.base, wid); return res; } if (ivl_expr_type(sube) == IVL_EX_SIGNAL) { - res = draw_select_signal(exp, sube, shift, ivl_expr_width(exp), wid); + res = draw_select_signal(expr, sube, shift, ivl_expr_width(expr), + wid); fprintf(vvp_out, "; Save base=%u wid=%u in lookaside.\n", res.base, wid); - save_expression_lookaside(res.base, exp, wid); + save_expression_lookaside(res.base, expr, wid); return res; } if (! ivl_expr_sized(sube)) { - res = draw_select_unsized_literal(exp, wid, stuff_ok_flag); + res = draw_select_unsized_literal(expr, wid, stuff_ok_flag); return res; } @@ -2760,19 +2765,19 @@ static struct vector_info draw_select_expr(ivl_expr_t exp, unsigned wid, if (res.base >= 8) { fprintf(vvp_out, "; Save expression base=%u wid=%u in lookaside\n", res.base, wid); - save_expression_lookaside(res.base, exp, wid); + save_expression_lookaside(res.base, expr, wid); } return res; } -static void draw_select_expr_dest(ivl_expr_t exp, struct vector_info dest, +static void draw_select_expr_dest(ivl_expr_t expr, struct vector_info dest, int stuff_ok_flag) { struct vector_info tmp; - ivl_expr_t sube = ivl_expr_oper1(exp); - ivl_expr_t shift= ivl_expr_oper2(exp); + ivl_expr_t sube = ivl_expr_oper1(expr); + ivl_expr_t shift= ivl_expr_oper2(expr); /* If the shift expression is not present, then this is really a pad expression, and that can be handled pretty @@ -2787,37 +2792,37 @@ static void draw_select_expr_dest(ivl_expr_t exp, struct vector_info dest, draw_eval_expr_dest(sube, subv, stuff_ok_flag); - pad_in_place(dest, subv.wid, ivl_expr_signed(exp)); + pad_in_place(dest, subv.wid, ivl_expr_signed(expr)); return; } if (ivl_expr_type(sube) == IVL_EX_SIGNAL) { - draw_select_signal_dest(exp, sube, shift, dest, stuff_ok_flag); + draw_select_signal_dest(expr, sube, shift, dest, stuff_ok_flag); return; } /* Fallback, is to draw the expression by width, and mov it to the required dest. */ - tmp = draw_select_expr(exp, dest.wid, stuff_ok_flag); + tmp = draw_select_expr(expr, dest.wid, stuff_ok_flag); assert(tmp.wid == dest.wid); fprintf(vvp_out, " %%mov %u, %u, %u; Move select into place\n", dest.base, tmp.base, dest.wid); if (tmp.base >= 8) { - save_expression_lookaside(tmp.base, exp, tmp.wid); + save_expression_lookaside(tmp.base, expr, tmp.wid); clr_vector(tmp); } } -static struct vector_info draw_ternary_expr(ivl_expr_t exp, unsigned wid) +static struct vector_info draw_ternary_expr(ivl_expr_t expr, unsigned wid) { struct vector_info res, tru, fal, tst; unsigned lab_true, lab_false, lab_out; - ivl_expr_t cond = ivl_expr_oper1(exp); - ivl_expr_t true_ex = ivl_expr_oper2(exp); - ivl_expr_t false_ex = ivl_expr_oper3(exp); + ivl_expr_t cond = ivl_expr_oper1(expr); + ivl_expr_t true_ex = ivl_expr_oper2(expr); + ivl_expr_t false_ex = ivl_expr_oper3(expr); lab_true = local_count++; lab_false = local_count++; @@ -2891,34 +2896,34 @@ static struct vector_info draw_ternary_expr(ivl_expr_t exp, unsigned wid) res = tru; if (res.base >= 8) - save_expression_lookaside(res.base, exp, wid); + save_expression_lookaside(res.base, expr, wid); return res; } -static struct vector_info draw_sfunc_expr(ivl_expr_t exp, unsigned wid) +static struct vector_info draw_sfunc_expr(ivl_expr_t expr, unsigned wid) { - unsigned parm_count = ivl_expr_parms(exp); + unsigned parm_count = ivl_expr_parms(expr); struct vector_info res; /* If the function has no parameters, then use this short-form to draw the statement. */ if (parm_count == 0) { - assert(ivl_expr_value(exp) == IVL_VT_LOGIC - || ivl_expr_value(exp) == IVL_VT_BOOL); + assert(ivl_expr_value(expr) == IVL_VT_LOGIC + || ivl_expr_value(expr) == IVL_VT_BOOL); res.base = allocate_vector(wid); res.wid = wid; assert(res.base); fprintf(vvp_out, " %%vpi_func %u %u \"%s\", %u, %u;\n", - ivl_file_table_index(ivl_expr_file(exp)), - ivl_expr_lineno(exp), ivl_expr_name(exp), + ivl_file_table_index(ivl_expr_file(expr)), + ivl_expr_lineno(expr), ivl_expr_name(expr), res.base, res.wid); return res; } - res = draw_vpi_func_call(exp, wid); + res = draw_vpi_func_call(expr, wid); /* New basic block starts after VPI calls. */ clear_expression_lookaside(); @@ -2926,14 +2931,14 @@ static struct vector_info draw_sfunc_expr(ivl_expr_t exp, unsigned wid) return res; } -static struct vector_info draw_unary_expr(ivl_expr_t exp, unsigned wid) +static struct vector_info draw_unary_expr(ivl_expr_t expr, unsigned wid) { struct vector_info res; - ivl_expr_t sub = ivl_expr_oper1(exp); + ivl_expr_t sub = ivl_expr_oper1(expr); const char *rop = 0; int inv = 0; - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case '&': rop = "and"; break; case '|': rop = "or"; break; case '^': rop = "xor"; break; @@ -2942,7 +2947,7 @@ static struct vector_info draw_unary_expr(ivl_expr_t exp, unsigned wid) case 'X': rop = "xnor"; break; } - switch (ivl_expr_opcode(exp)) { + switch (ivl_expr_opcode(expr)) { case '~': res = draw_eval_expr_wid(sub, wid, STUFF_OK_XZ); switch (res.base) { @@ -3027,7 +3032,8 @@ static struct vector_info draw_unary_expr(ivl_expr_t exp, unsigned wid) fprintf(stderr, "%s:%u: vvp.tgt error: " "Unable to allocate %u thread bits " "to pad unary expression result.\n", - ivl_expr_file(exp), ivl_expr_lineno(exp), wid); + ivl_expr_file(expr), ivl_expr_lineno(expr), + wid); vvp_errors += 1; } @@ -3123,12 +3129,12 @@ static struct vector_info draw_unary_expr(ivl_expr_t exp, unsigned wid) default: fprintf(stderr, "vvp error: unhandled unary: %c\n", - ivl_expr_opcode(exp)); + ivl_expr_opcode(expr)); assert(0); } if (res.base >= 8) - save_expression_lookaside(res.base, exp, wid); + save_expression_lookaside(res.base, expr, wid); return res; } @@ -3139,19 +3145,19 @@ static struct vector_info draw_unary_expr(ivl_expr_t exp, unsigned wid) * the expression can be preplaced, and if so it will evaluate it in * place. */ -static void draw_eval_expr_dest(ivl_expr_t exp, struct vector_info dest, +static void draw_eval_expr_dest(ivl_expr_t expr, struct vector_info dest, int stuff_ok_flag) { struct vector_info tmp; - switch (ivl_expr_type(exp)) { + switch (ivl_expr_type(expr)) { case IVL_EX_SIGNAL: - draw_signal_dest(exp, dest, -1, 0L); + draw_signal_dest(expr, dest, -1, 0L); return; case IVL_EX_SELECT: - draw_select_expr_dest(exp, dest, stuff_ok_flag); + draw_select_expr_dest(expr, dest, stuff_ok_flag); return; default: @@ -3160,7 +3166,7 @@ static void draw_eval_expr_dest(ivl_expr_t exp, struct vector_info dest, /* Fallback, is to draw the expression by width, and move it to the required dest. */ - tmp = draw_eval_expr_wid(exp, dest.wid, stuff_ok_flag); + tmp = draw_eval_expr_wid(expr, dest.wid, stuff_ok_flag); assert(tmp.wid == dest.wid); /* If the replication is 0 we can have a zero width, so skip it. */ @@ -3168,22 +3174,22 @@ static void draw_eval_expr_dest(ivl_expr_t exp, struct vector_info dest, dest.base, tmp.base, dest.wid); if (tmp.base >= 8) - save_expression_lookaside(tmp.base, exp, tmp.wid); + save_expression_lookaside(tmp.base, expr, tmp.wid); clr_vector(tmp); } -struct vector_info draw_eval_expr_wid(ivl_expr_t exp, unsigned wid, +struct vector_info draw_eval_expr_wid(ivl_expr_t expr, unsigned wid, int stuff_ok_flag) { struct vector_info res; - switch (ivl_expr_type(exp)) { + switch (ivl_expr_type(expr)) { default: case IVL_EX_NONE: fprintf(stderr, "%s:%u: vvp-tgt error: unhandled expr. type: " - "%u at %s:%d\n", ivl_expr_file(exp), ivl_expr_lineno(exp), - ivl_expr_type(exp), __FILE__, __LINE__); + "%u at %s:%d\n", ivl_expr_file(expr), ivl_expr_lineno(expr), + ivl_expr_type(expr), __FILE__, __LINE__); exit(1); res.base = 0; res.wid = 0; @@ -3191,62 +3197,62 @@ struct vector_info draw_eval_expr_wid(ivl_expr_t exp, unsigned wid, case IVL_EX_EVENT: fprintf(stderr, "%s:%u: vvp-tgt error: A named event is not " "handled in this context (expression).\n", - ivl_expr_file(exp), ivl_expr_lineno(exp)); + ivl_expr_file(expr), ivl_expr_lineno(expr)); exit(1); break; case IVL_EX_STRING: - res = draw_string_expr(exp, wid); + res = draw_string_expr(expr, wid); break; case IVL_EX_BINARY: - res = draw_binary_expr(exp, wid, stuff_ok_flag); + res = draw_binary_expr(expr, wid, stuff_ok_flag); break; case IVL_EX_CONCAT: - res = draw_concat_expr(exp, wid, stuff_ok_flag); + res = draw_concat_expr(expr, wid, stuff_ok_flag); break; case IVL_EX_NUMBER: - res = draw_number_expr(exp, wid); + res = draw_number_expr(expr, wid); break; case IVL_EX_REALNUM: - res = draw_realnum_expr(exp, wid); + res = draw_realnum_expr(expr, wid); break; case IVL_EX_SELECT: - if (ivl_expr_oper2(exp) == 0) - res = draw_pad_expr(exp, wid); + if (ivl_expr_oper2(expr) == 0) + res = draw_pad_expr(expr, wid); else - res = draw_select_expr(exp, wid, stuff_ok_flag); + res = draw_select_expr(expr, wid, stuff_ok_flag); break; case IVL_EX_SIGNAL: - res = draw_signal_expr(exp, wid, stuff_ok_flag); + res = draw_signal_expr(expr, wid, stuff_ok_flag); break; case IVL_EX_TERNARY: - res = draw_ternary_expr(exp, wid); + res = draw_ternary_expr(expr, wid); break; case IVL_EX_SFUNC: - res = draw_sfunc_expr(exp, wid); + res = draw_sfunc_expr(expr, wid); break; case IVL_EX_UFUNC: - res = draw_ufunc_expr(exp, wid); + res = draw_ufunc_expr(expr, wid); break; case IVL_EX_UNARY: - res = draw_unary_expr(exp, wid); + res = draw_unary_expr(expr, wid); break; } return res; } -struct vector_info draw_eval_expr(ivl_expr_t exp, int stuff_ok_flag) +struct vector_info draw_eval_expr(ivl_expr_t expr, int stuff_ok_flag) { - return draw_eval_expr_wid(exp, ivl_expr_width(exp), stuff_ok_flag); + return draw_eval_expr_wid(expr, ivl_expr_width(expr), stuff_ok_flag); } diff --git a/tgt-vvp/vector.c b/tgt-vvp/vector.c index 48e3e7a4c..7835b997c 100644 --- a/tgt-vvp/vector.c +++ b/tgt-vvp/vector.c @@ -48,15 +48,16 @@ static __inline__ unsigned peek_exp_bit(unsigned addr) return allocation_map[addr].exp_bit; } -static __inline__ void set_exp(unsigned addr, ivl_expr_t exp, unsigned ebit) +static __inline__ void set_exp(unsigned addr, ivl_expr_t expr, unsigned ebit) { - allocation_map[addr].exp = exp; + allocation_map[addr].exp = expr; allocation_map[addr].exp_bit = ebit; } -static __inline__ void set_sig(unsigned addr, ivl_signal_t exp, unsigned sig_word, unsigned ebit) +static __inline__ void set_sig(unsigned addr, ivl_signal_t expr, + unsigned sig_word, unsigned ebit) { - allocation_map[addr].sig = exp; + allocation_map[addr].sig = expr; allocation_map[addr].sig_word = sig_word; allocation_map[addr].sig_bit = ebit; } @@ -151,9 +152,9 @@ void clear_expression_lookaside(void) lookaside_top = 0; } -static int test_expression_savable(ivl_expr_t exp) +static int test_expression_savable(ivl_expr_t expr) { - switch (ivl_expr_type(exp)) { + switch (ivl_expr_type(expr)) { case IVL_EX_NUMBER: case IVL_EX_STRING: @@ -164,7 +165,7 @@ static int test_expression_savable(ivl_expr_t exp) } } -void save_expression_lookaside(unsigned addr, ivl_expr_t exp, unsigned wid) +void save_expression_lookaside(unsigned addr, ivl_expr_t expr, unsigned wid) { unsigned idx; assert(addr >= 8); @@ -178,11 +179,11 @@ void save_expression_lookaside(unsigned addr, ivl_expr_t exp, unsigned wid) set_sig(addr+idx, 0, 0, 0); /* Only certain types of expressions are savable. */ - if ( ! test_expression_savable(exp)) + if ( ! test_expression_savable(expr)) return; for (idx = 0 ; idx < wid ; idx += 1) { - set_exp(addr+idx, exp, idx); + set_exp(addr+idx, expr, idx); } if ((addr+wid) > lookaside_top) @@ -280,7 +281,7 @@ static int compare_exp(ivl_expr_t l, ivl_expr_t r) return 0; } -static unsigned find_expression_lookaside(ivl_expr_t exp, unsigned wid) +static unsigned find_expression_lookaside(ivl_expr_t expr, unsigned wid) { unsigned idx, match; ivl_signal_t sig; @@ -289,10 +290,10 @@ static unsigned find_expression_lookaside(ivl_expr_t exp, unsigned wid) return 0; /* Look in the expression lookaside for this expression. */ - assert(exp); + assert(expr); match = 0; for (idx = 8 ; idx < lookaside_top ; idx += 1) { - if (! compare_exp(allocation_map[idx].exp, exp)) { + if (! compare_exp(allocation_map[idx].exp, expr)) { match = 0; continue; } @@ -310,10 +311,10 @@ static unsigned find_expression_lookaside(ivl_expr_t exp, unsigned wid) /* The general expression lookup failed. If this is an IVL_EX_SIGNAL, then look again in the variable lookaside (which is saved l-values) for the expression. */ - if (ivl_expr_type(exp) != IVL_EX_SIGNAL) + if (ivl_expr_type(expr) != IVL_EX_SIGNAL) return 0; - sig = ivl_expr_signal(exp); + sig = ivl_expr_signal(expr); /* Only reg signals (variables) will be in the signal lookaside, because only blocking assigned values are in the @@ -349,11 +350,11 @@ static unsigned find_expression_lookaside(ivl_expr_t exp, unsigned wid) * caller will not need to evaluate the expression. If this function * returns 0, then the expression is not found and nothing is allocated. */ -unsigned allocate_vector_exp(ivl_expr_t exp, unsigned wid, +unsigned allocate_vector_exp(ivl_expr_t expr, unsigned wid, int exclusive_flag) { unsigned idx; - unsigned la = find_expression_lookaside(exp, wid); + unsigned la = find_expression_lookaside(expr, wid); if (la == 0) return 0; diff --git a/tgt-vvp/vvp_priv.h b/tgt-vvp/vvp_priv.h index 902e5432c..201044298 100644 --- a/tgt-vvp/vvp_priv.h +++ b/tgt-vvp/vvp_priv.h @@ -1,7 +1,7 @@ #ifndef __vvp_priv_H #define __vvp_priv_H /* - * Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -83,10 +83,11 @@ extern int draw_scope(ivl_scope_t scope, ivl_scope_t parent); extern void draw_lpm_mux(ivl_lpm_t net); -extern struct vector_info draw_ufunc_expr(ivl_expr_t exp, unsigned wid); -extern int draw_ufunc_real(ivl_expr_t exp); +extern struct vector_info draw_ufunc_expr(ivl_expr_t expr, unsigned wid); +extern int draw_ufunc_real(ivl_expr_t expr); -extern void pad_expr_in_place(ivl_expr_t exp, struct vector_info res, unsigned swid); +extern void pad_expr_in_place(ivl_expr_t expr, struct vector_info res, + unsigned swid); /* * modpath.c symbols. @@ -110,9 +111,9 @@ extern void cleanup_modpath(void); */ extern void draw_vpi_task_call(ivl_statement_t net); -extern struct vector_info draw_vpi_func_call(ivl_expr_t exp, +extern struct vector_info draw_vpi_func_call(ivl_expr_t expr, unsigned wid); -extern int draw_vpi_rfunc_call(ivl_expr_t exp); +extern int draw_vpi_rfunc_call(ivl_expr_t expr); /* * Switches (tran) @@ -195,8 +196,8 @@ extern const char*draw_input_from_net(ivl_nexus_t nex); * therefore might be multiply allocated if allowed. */ -extern struct vector_info draw_eval_expr(ivl_expr_t exp, int stuff_ok_flag); -extern struct vector_info draw_eval_expr_wid(ivl_expr_t exp, unsigned w, +extern struct vector_info draw_eval_expr(ivl_expr_t expr, int stuff_ok_flag); +extern struct vector_info draw_eval_expr_wid(ivl_expr_t expr, unsigned w, int stuff_ok_flag); #define STUFF_OK_XZ 0x0001 #define STUFF_OK_47 0x0002 @@ -261,13 +262,13 @@ extern void clr_vector(struct vector_info vec); extern void clear_expression_lookaside(void); extern void save_expression_lookaside(unsigned addr, - ivl_expr_t exp, + ivl_expr_t expr, unsigned wid); extern void save_signal_lookaside(unsigned addr, ivl_signal_t sig, unsigned use_word, unsigned wid); -extern unsigned allocate_vector_exp(ivl_expr_t exp, unsigned wid, +extern unsigned allocate_vector_exp(ivl_expr_t expr, unsigned wid, int exclusive_flag); extern int number_is_unknown(ivl_expr_t ex); diff --git a/tgt-vvp/vvp_process.c b/tgt-vvp/vvp_process.c index 6d418e11a..3dca172d6 100644 --- a/tgt-vvp/vvp_process.c +++ b/tgt-vvp/vvp_process.c @@ -917,8 +917,8 @@ static int show_stmt_block_named(ivl_statement_t net, ivl_scope_t scope) static int show_stmt_case(ivl_statement_t net, ivl_scope_t sscope) { int rc = 0; - ivl_expr_t exp = ivl_stmt_cond_expr(net); - struct vector_info cond = draw_eval_expr(exp, 0); + ivl_expr_t expr = ivl_stmt_cond_expr(net); + struct vector_info cond = draw_eval_expr(expr, 0); unsigned count = ivl_stmt_case_count(net); unsigned local_base = local_count; @@ -1034,8 +1034,8 @@ static int show_stmt_case(ivl_statement_t net, ivl_scope_t sscope) static int show_stmt_case_r(ivl_statement_t net, ivl_scope_t sscope) { int rc = 0; - ivl_expr_t exp = ivl_stmt_cond_expr(net); - int cond = draw_eval_real(exp); + ivl_expr_t expr = ivl_stmt_cond_expr(net); + int cond = draw_eval_real(expr); unsigned count = ivl_stmt_case_count(net); unsigned local_base = local_count; @@ -1374,9 +1374,9 @@ static int show_stmt_condit(ivl_statement_t net, ivl_scope_t sscope) { int rc = 0; unsigned lab_false, lab_out; - ivl_expr_t exp = ivl_stmt_cond_expr(net); + ivl_expr_t expr = ivl_stmt_cond_expr(net); struct vector_info cond - = draw_eval_expr(exp, STUFF_OK_XZ|STUFF_OK_47|STUFF_OK_RO); + = draw_eval_expr(expr, STUFF_OK_XZ|STUFF_OK_47|STUFF_OK_RO); assert(cond.wid == 1); @@ -1447,14 +1447,14 @@ static int show_stmt_delay(ivl_statement_t net, ivl_scope_t sscope) static int show_stmt_delayx(ivl_statement_t net, ivl_scope_t sscope) { int rc = 0; - ivl_expr_t exp = ivl_stmt_delay_expr(net); + ivl_expr_t expr = ivl_stmt_delay_expr(net); ivl_statement_t stmt = ivl_stmt_sub_stmt(net); - switch (ivl_expr_value(exp)) { + switch (ivl_expr_value(expr)) { case IVL_VT_BOOL: case IVL_VT_LOGIC: { - struct vector_info del = draw_eval_expr(exp, 0); + struct vector_info del = draw_eval_expr(expr, 0); fprintf(vvp_out, " %%ix/get 0, %u, %u;\n", del.base, del.wid); clr_vector(del); @@ -1462,7 +1462,7 @@ static int show_stmt_delayx(ivl_statement_t net, ivl_scope_t sscope) } case IVL_VT_REAL: { - int word = draw_eval_real(exp); + int word = draw_eval_real(expr); fprintf(vvp_out, " %%cvt/ur 0, %d;\n", word); clr_word(word); break; @@ -1684,9 +1684,9 @@ static int show_stmt_repeat(ivl_statement_t net, ivl_scope_t sscope) { int rc = 0; unsigned lab_top = local_count++, lab_out = local_count++; - ivl_expr_t exp = ivl_stmt_cond_expr(net); - struct vector_info cnt = draw_eval_expr(exp, 0); - char *sign = ivl_expr_signed(exp) ? "s" : "u"; + ivl_expr_t expr = ivl_stmt_cond_expr(net); + struct vector_info cnt = draw_eval_expr(expr, 0); + char *sign = ivl_expr_signed(expr) ? "s" : "u"; /* Test that 0 < expr */ fprintf(vvp_out, "T_%u.%u %%cmp/%s 0, %u, %u;\n", thread_count, diff --git a/vpi/sys_display.c b/vpi/sys_display.c index 06f71d1db..2ce1dfde5 100644 --- a/vpi/sys_display.c +++ b/vpi/sys_display.c @@ -1230,7 +1230,7 @@ static PLI_INT32 sys_strobe_calltf(PLI_BYTE8*name) { vpiHandle callh, argv, scope; struct t_cb_data cb; - struct t_vpi_time time; + struct t_vpi_time timerec; struct strobe_cb_info*info; PLI_UINT32 fd_mcd; @@ -1280,13 +1280,13 @@ static PLI_INT32 sys_strobe_calltf(PLI_BYTE8*name) info->scope= scope; array_from_iterator(info, argv); - time.type = vpiSimTime; - time.low = 0; - time.high = 0; + timerec.type = vpiSimTime; + timerec.low = 0; + timerec.high = 0; cb.reason = cbReadOnlySynch; cb.cb_rtn = strobe_cb; - cb.time = &time; + cb.time = &timerec; cb.obj = 0; cb.value = 0; cb.user_data = (char*)info; @@ -1339,7 +1339,7 @@ static PLI_INT32 monitor_cb_2(p_cb_data cb) static PLI_INT32 monitor_cb_1(p_cb_data cause) { struct t_cb_data cb; - struct t_vpi_time time; + struct t_vpi_time timerec; if (monitor_enabled == 0) return 0; if (monitor_scheduled) return 0; @@ -1348,13 +1348,13 @@ static PLI_INT32 monitor_cb_1(p_cb_data cause) the monitor to happen at the end of the time slice and mark it as scheduled. */ monitor_scheduled += 1; - time.type = vpiSimTime; - time.low = 0; - time.high = 0; + timerec.type = vpiSimTime; + timerec.low = 0; + timerec.high = 0; cb.reason = cbReadOnlySynch; cb.cb_rtn = monitor_cb_2; - cb.time = &time; + cb.time = &timerec; cb.obj = 0; cb.value = 0; vpi_register_cb(&cb); @@ -1376,7 +1376,7 @@ static PLI_INT32 sys_monitor_calltf(PLI_BYTE8*name) vpiHandle callh, argv, scope; unsigned idx; struct t_cb_data cb; - struct t_vpi_time time; + struct t_vpi_time timerec; callh = vpi_handle(vpiSysTfCall, 0); argv = vpi_iterate(vpiArgument, callh); @@ -1412,10 +1412,10 @@ static PLI_INT32 sys_monitor_calltf(PLI_BYTE8*name) /* Attach callbacks to all the parameters that might change. */ monitor_callbacks = calloc(monitor_info.nitems, sizeof(vpiHandle)); - time.type = vpiSuppressTime; + timerec.type = vpiSuppressTime; cb.reason = cbValueChange; cb.cb_rtn = monitor_cb_1; - cb.time = &time; + cb.time = &timerec; cb.value = NULL; for (idx = 0 ; idx < monitor_info.nitems ; idx += 1) { diff --git a/vpi/sys_priv.c b/vpi/sys_priv.c index 5f1e2c634..f6846e45b 100644 --- a/vpi/sys_priv.c +++ b/vpi/sys_priv.c @@ -23,13 +23,13 @@ #include #include -PLI_UINT64 timerec_to_time64(const struct t_vpi_time*time) +PLI_UINT64 timerec_to_time64(const struct t_vpi_time*timerec) { PLI_UINT64 tmp; - tmp = time->high; + tmp = timerec->high; tmp <<= 32; - tmp |= (PLI_UINT64) time->low; + tmp |= (PLI_UINT64) timerec->low; return tmp; } diff --git a/vpi/sys_priv.h b/vpi/sys_priv.h index 07e2c60d6..3a13d1851 100644 --- a/vpi/sys_priv.h +++ b/vpi/sys_priv.h @@ -1,7 +1,7 @@ #ifndef __vpi_sys_priv_H #define __vpi_sys_priv_H /* - * Copyright (c) 2002-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2002-2010 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -33,7 +33,7 @@ struct context_s { extern void sgenrand(struct context_s *context, unsigned long seed); extern unsigned long genrand(struct context_s *context); -extern PLI_UINT64 timerec_to_time64(const struct t_vpi_time*time); +extern PLI_UINT64 timerec_to_time64(const struct t_vpi_time*timerec); extern char *as_escaped(char *arg); extern char *get_filename(vpiHandle callh, char *name, vpiHandle file);