diff --git a/tgt-vvp/eval_real.c b/tgt-vvp/eval_real.c index 2bc5be96e..a3c4d69c6 100644 --- a/tgt-vvp/eval_real.c +++ b/tgt-vvp/eval_real.c @@ -297,6 +297,16 @@ static void draw_signal_real_real(ivl_expr_t expr) { ivl_signal_t sig = ivl_expr_signal(expr); + /* Special Case: If the signal is the return value of the function, + then use a different opcode to get the value. */ + if (signal_is_return_value(sig)) { + assert(ivl_signal_dimensions(sig) == 0); + fprintf(vvp_out, " %%retload/real 0; Load %s (draw_signal_real_real)\n", + ivl_signal_basename(sig)); + return; + } + + if (ivl_signal_dimensions(sig) == 0) { fprintf(vvp_out, " %%load/real v%p_0;\n", sig); return; diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index e7c1d50ae..a69e4f359 100644 --- a/vvp/opcodes.txt +++ b/vvp/opcodes.txt @@ -1025,6 +1025,7 @@ that contains the actual offset. In this case, flag-4 is tested, and if not 1, the assign is suppressed. * %retload/vec4 +* %retload/real Read a value from the indexed function argument. The value is read from the argument and pushed to the appropriate stack. diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 0bc396471..aa5d87a9d 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -5049,8 +5049,13 @@ bool of_RET_VEC4(vthread_t thr, vvp_code_t cp) */ bool of_RETLOAD_REAL(vthread_t thr, vvp_code_t cp) { - // NOT IMPLEMENTED - assert(0); + size_t index = cp->number; + + assert(index >= 0 && index < thr->args_real.size()); + unsigned depth = thr->args_real[index]; + // Use the depth to extract the values from the stack + // of the parent thread. + thr->push_real(thr->parent->peek_real(depth)); return true; }