diff --git a/tgt-vvp/eval_real.c b/tgt-vvp/eval_real.c index b75c189d5..4a33b217c 100644 --- a/tgt-vvp/eval_real.c +++ b/tgt-vvp/eval_real.c @@ -91,6 +91,9 @@ static int draw_binary_real(ivl_expr_t exp) } break; #endif + case 'p': + fprintf(vvp_out, " %%pow/wr %d, %d;\n", l, r); + break; default: fprintf(stderr, "XXXX draw_binary_real(%c)\n", ivl_expr_opcode(exp)); @@ -438,4 +441,3 @@ int draw_eval_real(ivl_expr_t exp) return res; } - diff --git a/vvp/codes.h b/vvp/codes.h index b227cedf8..855b55d9d 100644 --- a/vvp/codes.h +++ b/vvp/codes.h @@ -114,6 +114,7 @@ extern bool of_NOR(vthread_t thr, vvp_code_t code); extern bool of_NORR(vthread_t thr, vvp_code_t code); extern bool of_OR(vthread_t thr, vvp_code_t code); extern bool of_ORR(vthread_t thr, vvp_code_t code); +extern bool of_POW_WR(vthread_t thr, vvp_code_t code); extern bool of_RELEASE_NET(vthread_t thr, vvp_code_t code); extern bool of_RELEASE_REG(vthread_t thr, vvp_code_t code); extern bool of_SET_AV(vthread_t thr, vvp_code_t code); diff --git a/vvp/compile.cc b/vvp/compile.cc index 33cc27641..811f178f5 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -161,6 +161,7 @@ const static struct opcode_table_s opcode_table[] = { { "%nor/r", of_NORR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%or", of_OR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%or/r", of_ORR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, + { "%pow/wr", of_POW_WR, 2, {OA_BIT1, OA_BIT2, OA_NONE} }, { "%release/net",of_RELEASE_NET,1,{OA_FUNC_PTR,OA_NONE,OA_NONE} }, { "%release/reg",of_RELEASE_REG,1,{OA_FUNC_PTR,OA_NONE,OA_NONE} }, { "%set/av", of_SET_AV, 3, {OA_ARR_PTR, OA_BIT1, OA_BIT2} }, diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index d88a1852c..ec7791fd9 100644 --- a/vvp/opcodes.txt +++ b/vvp/opcodes.txt @@ -570,6 +570,12 @@ and the is a writable scalar. The gets the value of the or of all the bits of the src vector. +* %pow/wr , + +This opcode raises (real) to the power of (real). The +result replaces the left operand. + + * %release/net * %release/reg diff --git a/vvp/vthread.cc b/vvp/vthread.cc index bb5b34977..82df48850 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -3172,6 +3172,15 @@ bool of_NOR(vthread_t thr, vvp_code_t cp) return true; } +bool of_POW_WR(vthread_t thr, vvp_code_t cp) +{ + double l = thr->words[cp->bit_idx[0]].w_real; + double r = thr->words[cp->bit_idx[1]].w_real; + thr->words[cp->bit_idx[0]].w_real = pow(l, r); + + return true; +} + /* * These implement the %release/net and %release/reg instructions. The * %release/net instruction applies to a net kind of functor by @@ -3686,4 +3695,3 @@ bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t cp) return true; } -