Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rework of automatic task/function support.

This patch splits any VVP net functor that needs to access both
statically and automatically allocated state into two sub-classes,
one for handling operations on statically allocated state, the
other for handling operations on automatically allocated state.
This undoes the increase in run-time memory use introduced when
automatic task/function support was first introduced.

This patch also fixes various issues with event handling in automatic
scopes. Event expressions in automatic scopes may now reference either
statically or automatically allocated variables or arrays, or part
selects or word selects thereof. More complex expressions (e.g.
containing arithmetic or logical operators, function calls, etc.) are
not currently supported.

This patch introduces some error checking for language constructs
that may not reference automatically allocated variables. Further
error checking will follow in a subsequent patch.
  • Loading branch information...
commit 18edf2f15f7279686453ca15a136ae2618c65200 1 parent ea057a7
Martin Whitaker authored committed
Showing with 2,145 additions and 819 deletions.
  1. +1 −0  compiler.h
  2. +1 −2  elab_anet.cc
  3. +2 −2 elab_expr.cc
  4. +1 −1  elab_lval.cc
  5. +1 −2  elab_net.cc
  6. +1 −1  elab_sig.cc
  7. +3 −2 elaborate.cc
  8. +1 −1  eval.cc
  9. +3 −0  main.cc
  10. +6 −1 net_event.cc
  11. +9 −5 netmisc.h
  12. +27 −4 pform.cc
  13. +9 −1 symbol_search.cc
  14. +2 −2 vpi/sys_lxt.c
  15. +2 −2 vpi/sys_lxt2.c
  16. +2 −2 vpi/sys_vcd.c
  17. +1 −0  vpi_user.h
  18. +104 −76 vvp/arith.cc
  19. +56 −28 vvp/arith.h
  20. +153 −14 vvp/array.cc
  21. +2 −2 vvp/bufif.cc
  22. +2 −1  vvp/bufif.h
  23. +3 −29 vvp/compile.cc
  24. +1 −5 vvp/compile.h
  25. +6 −5 vvp/concat.cc
  26. +13 −9 vvp/delay.cc
  27. +8 −4 vvp/delay.h
  28. +4 −3 vvp/dff.cc
  29. +2 −1  vvp/dff.h
  30. +384 −122 vvp/event.cc
  31. +170 −19 vvp/event.h
  32. +4 −3 vvp/extend.cc
  33. +0 −2  vvp/lexor.lex
  34. +32 −23 vvp/logic.cc
  35. +18 −9 vvp/logic.h
  36. +8 −7 vvp/npmos.cc
  37. +4 −2 vvp/npmos.h
  38. +4 −10 vvp/parse.y
  39. +237 −27 vvp/part.cc
  40. +96 −10 vvp/part.h
  41. +12 −7 vvp/reduce.cc
  42. +8 −5 vvp/resolv.cc
  43. +6 −3 vvp/resolv.h
  44. +3 −3 vvp/schedule.cc
  45. +4 −3 vvp/ufunc.cc
  46. +1 −1  vvp/ufunc.h
  47. +1 −1  vvp/vpi_callback.cc
  48. +16 −2 vvp/vpi_event.cc
  49. +7 −2 vvp/vpi_priv.h
  50. +7 −2 vvp/vpi_real.cc
  51. +39 −23 vvp/vpi_scope.cc
  52. +10 −3 vvp/vpi_signal.cc
  53. +2 −2 vvp/vpi_tasks.cc
  54. +61 −38 vvp/vthread.cc
  55. +24 −14 vvp/vthread.h
  56. +8 −4 vvp/vvp_island.cc
  57. +336 −208 vvp/vvp_net.cc
  58. +201 −52 vvp/vvp_net.h
  59. +16 −7 vvp/words.cc
View
1  compiler.h
@@ -87,6 +87,7 @@ extern bool debug_eval_tree;
extern bool debug_elaborate;
extern bool debug_synth2;
extern bool debug_optimizer;
+extern bool debug_automatic;
/* Path to a directory useful for finding subcomponents. */
extern const char*basedir;
View
3  elab_anet.cc
@@ -115,7 +115,7 @@ NetNet* PEIdent::elaborate_anet(Design*des, NetScope*scope) const
const NetExpr*par = 0;
NetEvent* eve = 0;
- symbol_search(des, scope, path_, sig, mem, par, eve);
+ symbol_search(this, des, scope, path_, sig, mem, par, eve);
if (mem != 0) {
@@ -211,4 +211,3 @@ NetNet* PEIdent::elaborate_anet(Design*des, NetScope*scope) const
* Check lvalue of procedural continuous assign (PR#29)
*
*/
-
View
4 elab_expr.cc
@@ -1641,7 +1641,7 @@ unsigned PEIdent::test_width(Design*des, NetScope*scope,
const NetExpr*ex1, *ex2;
- symbol_search(des, scope, path_, net, par, eve, ex1, ex2);
+ symbol_search(0, des, scope, path_, net, par, eve, ex1, ex2);
// If there is a part/bit select expression, then process it
// here. This constrains the results no matter what kind the
@@ -1754,7 +1754,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
const NetExpr*ex1, *ex2;
- NetScope*found_in = symbol_search(des, scope, path_,
+ NetScope*found_in = symbol_search(this, des, scope, path_,
net, par, eve,
ex1, ex2);
View
2  elab_lval.cc
@@ -152,7 +152,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des,
const NetExpr*par = 0;
NetEvent* eve = 0;
- symbol_search(des, scope, path_, reg, par, eve);
+ symbol_search(this, des, scope, path_, reg, par, eve);
if (reg == 0) {
cerr << get_fileline() << ": error: Could not find variable ``"
<< path_ << "'' in ``" << scope_path(scope) <<
View
3  elab_net.cc
@@ -374,7 +374,7 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
const NetExpr*par = 0;
NetEvent* eve = 0;
- symbol_search(des, scope, path_, sig, par, eve);
+ symbol_search(this, des, scope, path_, sig, par, eve);
if (eve != 0) {
cerr << get_fileline() << ": error: named events (" << path_
@@ -631,4 +631,3 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
return sig;
}
-
View
2  elab_sig.cc
@@ -266,7 +266,7 @@ bool PEIdent::elaborate_sig(Design*des, NetScope*scope) const
if (error_implicit)
return true;
- symbol_search(des, scope, path_, sig, par, eve);
+ symbol_search(this, des, scope, path_, sig, par, eve);
if (eve != 0)
return false;
View
5 elaborate.cc
@@ -2861,7 +2861,8 @@ NetProc* PEventStatement::elaborate_st(Design*des, NetScope*scope,
const NetExpr*par = 0;
NetEvent* eve = 0;
- NetScope*found_in = symbol_search(des, scope, id->path(),
+ NetScope*found_in = symbol_search(this, des, scope,
+ id->path(),
sig, par, eve);
if (found_in && eve) {
@@ -3463,7 +3464,7 @@ NetProc* PTrigger::elaborate(Design*des, NetScope*scope) const
const NetExpr*par = 0;
NetEvent* eve = 0;
- NetScope*found_in = symbol_search(des, scope, event_,
+ NetScope*found_in = symbol_search(this, des, scope, event_,
sig, par, eve);
if (found_in == 0) {
View
2  eval.cc
@@ -185,7 +185,7 @@ verinum* PEIdent::eval_const(Design*des, NetScope*scope) const
return new verinum(scope->genvar_tmp_val);
}
- symbol_search(des, scope, path_, net, expr, eve);
+ symbol_search(this, des, scope, path_, net, expr, eve);
if (expr == 0)
return 0;
View
3  main.cc
@@ -124,6 +124,7 @@ bool debug_eval_tree = false;
bool debug_elaborate = false;
bool debug_synth2 = false;
bool debug_optimizer = false;
+bool debug_automatic = false;
/*
* Verbose messages enabled.
@@ -392,6 +393,8 @@ static void read_iconfig_file(const char*ipath)
} else if (strcmp(cp,"optimizer") == 0) {
debug_optimizer = true;
cerr << "debug: Enable optimizer debug" << endl;
+ } else if (strcmp(cp,"automatic") == 0) {
+ debug_automatic = true;
} else {
}
View
7 net_event.cc
@@ -173,6 +173,12 @@ void NetEvent::find_similar_event(list<NetEvent*>&event_list)
if (tmp == this)
continue;
+ /* For automatic tasks, the VVP runtime holds state for events
+ in the automatically allocated context. This means we can't
+ merge similar events in different automatic tasks. */
+ if (scope()->is_auto() && (tmp->scope() != scope()))
+ continue;
+
if ((*idx).second != probe_count)
continue;
@@ -553,4 +559,3 @@ NetProc* NetEvWait::statement()
* Simulate named event trigger and waits.
*
*/
-
View
14 netmisc.h
@@ -36,21 +36,25 @@
* ex2 is the lsb expression for the range. If there is no range, then
* these values are set to 0.
*/
-extern NetScope* symbol_search(Design*des,
- NetScope*start, pform_name_t path,
+extern NetScope* symbol_search(const LineInfo*li,
+ Design*des,
+ NetScope*start,
+ pform_name_t path,
NetNet*&net, /* net/reg */
const NetExpr*&par,/* parameter */
NetEvent*&eve, /* named event */
const NetExpr*&ex1, const NetExpr*&ex2);
-inline NetScope* symbol_search(Design*des,
- NetScope*start, const pform_name_t&path,
+inline NetScope* symbol_search(const LineInfo*li,
+ Design*des,
+ NetScope*start,
+ const pform_name_t&path,
NetNet*&net, /* net/reg */
const NetExpr*&par,/* parameter */
NetEvent*&eve /* named event */)
{
const NetExpr*ex1, *ex2;
- return symbol_search(des, start, path, net, par, eve, ex1, ex2);
+ return symbol_search(li, des, start, path, net, par, eve, ex1, ex2);
}
/*
View
31 pform.cc
@@ -110,11 +110,12 @@ PTask* pform_push_task_scope(char*name, bool is_auto)
PTask*task;
if (pform_cur_generate) {
task = new PTask(task_name, pform_cur_generate->lexical_scope,
- is_auto);
+ is_auto || debug_automatic);
pform_cur_generate->tasks[task->pscope_name()] = task;
pform_cur_generate->lexical_scope = task;
} else {
- task = new PTask(task_name, lexical_scope, is_auto);
+ task = new PTask(task_name, lexical_scope,
+ is_auto || debug_automatic);
pform_cur_module->tasks[task->pscope_name()] = task;
lexical_scope = task;
}
@@ -129,11 +130,12 @@ PFunction* pform_push_function_scope(char*name, bool is_auto)
PFunction*func;
if (pform_cur_generate) {
func = new PFunction(func_name, pform_cur_generate->lexical_scope,
- is_auto);
+ is_auto || debug_automatic);
pform_cur_generate->funcs[func->pscope_name()] = func;
pform_cur_generate->lexical_scope = func;
} else {
- func = new PFunction(func_name, lexical_scope, is_auto);
+ func = new PFunction(func_name, lexical_scope,
+ is_auto || debug_automatic);
pform_cur_module->funcs[func->pscope_name()] = func;
lexical_scope = func;
}
@@ -181,6 +183,20 @@ static LexicalScope*pform_get_cur_scope()
return lexical_scope;
}
+static bool pform_at_module_level()
+{
+ if (pform_cur_generate)
+ if (pform_cur_generate->lexical_scope)
+ return false;
+ else
+ return true;
+ else
+ if (lexical_scope->pscope_parent())
+ return false;
+ else
+ return true;
+}
+
PWire*pform_get_wire_in_scope(perm_string name)
{
/* Note that if we are processing a generate, then the
@@ -1293,6 +1309,13 @@ void pform_make_pgassign_list(svector<PExpr*>*alist,
void pform_make_reginit(const struct vlltype&li,
perm_string name, PExpr*expr)
{
+ if (! pform_at_module_level()) {
+ VLerror(li, "variable declaration assignments are only "
+ "allowed at the module level.");
+ delete expr;
+ return;
+ }
+
PWire*cur = pform_get_wire_in_scope(name);
if (cur == 0) {
VLerror(li, "internal error: reginit to non-register?");
View
10 symbol_search.cc
@@ -28,7 +28,8 @@
/*
* Search for the hierarchical name.
*/
-NetScope*symbol_search(Design*des, NetScope*scope, pform_name_t path,
+NetScope*symbol_search(const LineInfo*li, Design*des, NetScope*scope,
+ pform_name_t path,
NetNet*&net,
const NetExpr*&par,
NetEvent*&eve,
@@ -57,6 +58,13 @@ NetScope*symbol_search(Design*des, NetScope*scope, pform_name_t path,
return 0;
scope = des->find_scope(scope, path_list);
+
+ if (scope->is_auto() && li) {
+ cerr << li->get_fileline() << ": error: Hierarchical "
+ "reference to automatically allocated item "
+ "`" << key << "' in path `" << path << "'" << endl;
+ des->errors += 1;
+ }
}
while (scope) {
View
4 vpi/sys_lxt.c
@@ -546,7 +546,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
case vpiTimeVar:
case vpiReg: type = "reg"; }
- if (skip) break;
+ if (skip || vpi_get(vpiAutomatic, item)) break;
name = vpi_get_str(vpiName, item);
nexus_id = vpi_get(_vpiNexusId, item);
@@ -593,7 +593,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
case vpiRealVar:
- if (skip) break;
+ if (skip || vpi_get(vpiAutomatic, item)) break;
name = vpi_get_str(vpiName, item);
{ char*tmp = create_full_name(name);
View
4 vpi/sys_lxt2.c
@@ -552,7 +552,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
case vpiTimeVar:
case vpiReg: type = "reg"; }
- if (skip) break;
+ if (skip || vpi_get(vpiAutomatic, item)) break;
name = vpi_get_str(vpiName, item);
nexus_id = vpi_get(_vpiNexusId, item);
@@ -603,7 +603,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
case vpiRealVar:
- if (skip) break;
+ if (skip || vpi_get(vpiAutomatic, item)) break;
name = vpi_get_str(vpiName, item);
{ char*tmp = create_full_name(name);
View
4 vpi/sys_vcd.c
@@ -513,7 +513,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break;
}
- if (skip) break;
+ if (skip || vpi_get(vpiAutomatic, item)) break;
name = vpi_get_str(vpiName, item);
prefix = is_escaped_id(name) ? "\\" : "";
@@ -578,7 +578,7 @@ static void scan_item(unsigned depth, vpiHandle item, int skip)
break;
}
- if (skip) break;
+ if (skip || vpi_get(vpiAutomatic, item)) break;
/* Declare the variable in the VCD file. */
name = vpi_get_str(vpiName, item);
View
1  vpi_user.h
@@ -348,6 +348,7 @@ typedef struct t_vpi_delay {
# define vpiSysFuncReal vpiRealFunc
# define vpiSysFuncTime vpiTimeFunc
# define vpiSysFuncSized vpiSizedFunc
+#define vpiAutomatic 50
#define vpiConstantSelect 53
#define vpiSigned 65
/* IVL private properties */
View
180 vvp/arith.cc
@@ -63,7 +63,8 @@ vvp_arith_abs::~vvp_arith_abs()
{
}
-void vvp_arith_abs::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_arith_abs::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
vvp_vector4_t out (bit.size(), BIT4_0);;
@@ -81,13 +82,14 @@ void vvp_arith_abs::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
break;
}
- vvp_send_vec4(ptr.ptr()->out, out);
+ vvp_send_vec4(ptr.ptr()->out, out, 0);
}
-void vvp_arith_abs::recv_real(vvp_net_ptr_t ptr, double bit)
+void vvp_arith_abs::recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t)
{
double out = fabs(bit);
- vvp_send_real(ptr.ptr()->out, out);
+ vvp_send_real(ptr.ptr()->out, out, 0);
}
vvp_arith_cast_int::vvp_arith_cast_int(unsigned wid)
@@ -99,9 +101,10 @@ vvp_arith_cast_int::~vvp_arith_cast_int()
{
}
-void vvp_arith_cast_int::recv_real(vvp_net_ptr_t ptr, double bit)
+void vvp_arith_cast_int::recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t)
{
- vvp_send_vec4(ptr.ptr()->out, vvp_vector4_t(wid_, bit));
+ vvp_send_vec4(ptr.ptr()->out, vvp_vector4_t(wid_, bit), 0);
}
vvp_arith_cast_real::vvp_arith_cast_real(bool signed_flag)
@@ -113,11 +116,12 @@ vvp_arith_cast_real::~vvp_arith_cast_real()
{
}
-void vvp_arith_cast_real::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_arith_cast_real::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
double val;
vector4_to_value(bit, val, signed_);
- vvp_send_real(ptr.ptr()->out, val);
+ vvp_send_real(ptr.ptr()->out, val, 0);
}
// Division
@@ -135,21 +139,22 @@ void vvp_arith_div::wide4_(vvp_net_ptr_t ptr)
{
vvp_vector2_t a2 (op_a_);
if (a2.is_NaN()) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
vvp_vector2_t b2 (op_b_);
if (b2.is_NaN()) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
vvp_vector2_t res2 = a2 / b2;
- vvp_send_vec4(ptr.ptr()->out, vector2_to_vector4(res2, wid_));
+ vvp_send_vec4(ptr.ptr()->out, vector2_to_vector4(res2, wid_), 0);
}
-void vvp_arith_div::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_arith_div::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -160,13 +165,13 @@ void vvp_arith_div::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
unsigned long a;
if (! vector4_to_value(op_a_, a)) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
unsigned long b;
if (! vector4_to_value(op_b_, b)) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
@@ -202,7 +207,7 @@ void vvp_arith_div::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
val >>= 1;
}
- vvp_send_vec4(ptr.ptr()->out, vval);
+ vvp_send_vec4(ptr.ptr()->out, vval, 0);
}
@@ -219,21 +224,22 @@ void vvp_arith_mod::wide_(vvp_net_ptr_t ptr)
{
vvp_vector2_t a2 (op_a_);
if (a2.is_NaN()) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
vvp_vector2_t b2 (op_b_);
if (b2.is_NaN()) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
vvp_vector2_t res = a2 % b2;
- vvp_send_vec4(ptr.ptr()->out, vector2_to_vector4(res, res.size()));
+ vvp_send_vec4(ptr.ptr()->out, vector2_to_vector4(res, res.size()), 0);
}
-void vvp_arith_mod::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_arith_mod::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -244,13 +250,13 @@ void vvp_arith_mod::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
unsigned long a;
if (! vector4_to_value(op_a_, a)) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
unsigned long b;
if (! vector4_to_value(op_b_, b)) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
@@ -275,7 +281,7 @@ void vvp_arith_mod::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
for (unsigned idx = 0 ; idx < wid_ ; idx += 1)
xval.set_bit(idx, BIT4_X);
- vvp_send_vec4(ptr.ptr()->out, xval);
+ vvp_send_vec4(ptr.ptr()->out, xval, 0);
return;
}
@@ -295,7 +301,7 @@ void vvp_arith_mod::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
val >>= 1;
}
- vvp_send_vec4(ptr.ptr()->out, vval);
+ vvp_send_vec4(ptr.ptr()->out, vval, 0);
}
@@ -316,17 +322,18 @@ void vvp_arith_mult::wide_(vvp_net_ptr_t ptr)
vvp_vector2_t b2 (op_b_);
if (a2.is_NaN() || b2.is_NaN()) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
vvp_vector2_t result = a2 * b2;
vvp_vector4_t res4 = vector2_to_vector4(result, wid_);
- vvp_send_vec4(ptr.ptr()->out, res4);
+ vvp_send_vec4(ptr.ptr()->out, res4, 0);
}
-void vvp_arith_mult::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_arith_mult::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -337,13 +344,13 @@ void vvp_arith_mult::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
long a;
if (! vector4_to_value(op_a_, a, false, true)) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
long b;
if (! vector4_to_value(op_b_, b, false, true)) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
@@ -360,7 +367,7 @@ void vvp_arith_mult::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
val >>= 1;
}
- vvp_send_vec4(ptr.ptr()->out, vval);
+ vvp_send_vec4(ptr.ptr()->out, vval, 0);
}
@@ -375,14 +382,15 @@ vvp_arith_pow::~vvp_arith_pow()
{
}
-void vvp_arith_pow::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_arith_pow::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
vvp_vector4_t res4;
if (signed_flag_) {
if (op_a_.has_xz() || op_b_.has_xz()) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
@@ -396,7 +404,7 @@ void vvp_arith_pow::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
vvp_vector2_t b2 (op_b_);
if (a2.is_NaN() || b2.is_NaN()) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
@@ -404,7 +412,7 @@ void vvp_arith_pow::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
res4 = vector2_to_vector4(result, wid_);
}
- vvp_send_vec4(ptr.ptr()->out, res4);
+ vvp_send_vec4(ptr.ptr()->out, res4, 0);
}
@@ -419,7 +427,8 @@ vvp_arith_sum::~vvp_arith_sum()
{
}
-void vvp_arith_sum::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_arith_sum::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -438,14 +447,14 @@ void vvp_arith_sum::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
vvp_bit4_t cur = add_with_carry(a, b, carry);
if (cur == BIT4_X) {
- vvp_send_vec4(net->out, x_val_);
+ vvp_send_vec4(net->out, x_val_, 0);
return;
}
value.set_bit(idx, cur);
}
- vvp_send_vec4(net->out, value);
+ vvp_send_vec4(net->out, value, 0);
}
vvp_arith_sub::vvp_arith_sub(unsigned wid)
@@ -463,7 +472,8 @@ vvp_arith_sub::~vvp_arith_sub()
* further reduce the operation to adding in the inverted value and
* adding a correction.
*/
-void vvp_arith_sub::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_arith_sub::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -482,14 +492,14 @@ void vvp_arith_sub::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
vvp_bit4_t cur = add_with_carry(a, b, carry);
if (cur == BIT4_X) {
- vvp_send_vec4(net->out, x_val_);
+ vvp_send_vec4(net->out, x_val_, 0);
return;
}
value.set_bit(idx, cur);
}
- vvp_send_vec4(net->out, value);
+ vvp_send_vec4(net->out, value, 0);
}
vvp_cmp_eeq::vvp_cmp_eeq(unsigned wid)
@@ -497,7 +507,8 @@ vvp_cmp_eeq::vvp_cmp_eeq(unsigned wid)
{
}
-void vvp_cmp_eeq::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_cmp_eeq::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -513,7 +524,7 @@ void vvp_cmp_eeq::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
vvp_net_t*net = ptr.ptr();
- vvp_send_vec4(net->out, eeq);
+ vvp_send_vec4(net->out, eeq, 0);
}
vvp_cmp_nee::vvp_cmp_nee(unsigned wid)
@@ -521,7 +532,8 @@ vvp_cmp_nee::vvp_cmp_nee(unsigned wid)
{
}
-void vvp_cmp_nee::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_cmp_nee::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -537,7 +549,7 @@ void vvp_cmp_nee::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
vvp_net_t*net = ptr.ptr();
- vvp_send_vec4(net->out, eeq);
+ vvp_send_vec4(net->out, eeq, 0);
}
vvp_cmp_eq::vvp_cmp_eq(unsigned wid)
@@ -551,7 +563,8 @@ vvp_cmp_eq::vvp_cmp_eq(unsigned wid)
* there are X/Z bits anywhere in A or B, the result is X. Finally,
* the result is 1.
*/
-void vvp_cmp_eq::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_cmp_eq::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -583,7 +596,7 @@ void vvp_cmp_eq::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
}
vvp_net_t*net = ptr.ptr();
- vvp_send_vec4(net->out, res);
+ vvp_send_vec4(net->out, res, 0);
}
@@ -598,7 +611,8 @@ vvp_cmp_ne::vvp_cmp_ne(unsigned wid)
* there are X/Z bits anywhere in A or B, the result is X. Finally,
* the result is 0.
*/
-void vvp_cmp_ne::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_cmp_ne::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -630,7 +644,7 @@ void vvp_cmp_ne::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
}
vvp_net_t*net = ptr.ptr();
- vvp_send_vec4(net->out, res);
+ vvp_send_vec4(net->out, res, 0);
}
@@ -651,7 +665,7 @@ void vvp_cmp_gtge_base_::recv_vec4_base_(vvp_net_ptr_t ptr,
: compare_gtge(op_a_, op_b_, out_if_equal);
vvp_vector4_t val (1);
val.set_bit(0, out);
- vvp_send_vec4(ptr.ptr()->out, val);
+ vvp_send_vec4(ptr.ptr()->out, val, 0);
return;
}
@@ -662,7 +676,8 @@ vvp_cmp_ge::vvp_cmp_ge(unsigned wid, bool flag)
{
}
-void vvp_cmp_ge::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_cmp_ge::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
recv_vec4_base_(ptr, bit, BIT4_1);
}
@@ -672,7 +687,8 @@ vvp_cmp_gt::vvp_cmp_gt(unsigned wid, bool flag)
{
}
-void vvp_cmp_gt::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_cmp_gt::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
recv_vec4_base_(ptr, bit, BIT4_0);
}
@@ -687,7 +703,8 @@ vvp_shiftl::~vvp_shiftl()
{
}
-void vvp_shiftl::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_shiftl::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -695,7 +712,7 @@ void vvp_shiftl::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
unsigned long shift;
if (! vector4_to_value(op_b_, shift)) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
@@ -708,7 +725,7 @@ void vvp_shiftl::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
for (unsigned idx = shift ; idx < out.size() ; idx += 1)
out.set_bit(idx, op_a_.value(idx-shift));
- vvp_send_vec4(ptr.ptr()->out, out);
+ vvp_send_vec4(ptr.ptr()->out, out, 0);
}
vvp_shiftr::vvp_shiftr(unsigned wid, bool signed_flag)
@@ -720,7 +737,8 @@ vvp_shiftr::~vvp_shiftr()
{
}
-void vvp_shiftr::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_shiftr::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -728,7 +746,7 @@ void vvp_shiftr::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
unsigned long shift;
if (! vector4_to_value(op_b_, shift)) {
- vvp_send_vec4(ptr.ptr()->out, x_val_);
+ vvp_send_vec4(ptr.ptr()->out, x_val_, 0);
return;
}
@@ -745,7 +763,7 @@ void vvp_shiftr::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
for (unsigned idx = 0 ; idx < shift ; idx += 1)
out.set_bit(idx+out.size()-shift, pad);
- vvp_send_vec4(ptr.ptr()->out, out);
+ vvp_send_vec4(ptr.ptr()->out, out, 0);
}
@@ -780,12 +798,13 @@ vvp_arith_mult_real::~vvp_arith_mult_real()
{
}
-void vvp_arith_mult_real::recv_real(vvp_net_ptr_t ptr, double bit)
+void vvp_arith_mult_real::recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
double val = op_a_ * op_b_;
- vvp_send_real(ptr.ptr()->out, val);
+ vvp_send_real(ptr.ptr()->out, val, 0);
}
/* Real power. */
@@ -797,12 +816,13 @@ vvp_arith_pow_real::~vvp_arith_pow_real()
{
}
-void vvp_arith_pow_real::recv_real(vvp_net_ptr_t ptr, double bit)
+void vvp_arith_pow_real::recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
double val = pow(op_a_, op_b_);
- vvp_send_real(ptr.ptr()->out, val);
+ vvp_send_real(ptr.ptr()->out, val, 0);
}
/* Real division. */
@@ -814,12 +834,13 @@ vvp_arith_div_real::~vvp_arith_div_real()
{
}
-void vvp_arith_div_real::recv_real(vvp_net_ptr_t ptr, double bit)
+void vvp_arith_div_real::recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
double val = op_a_ / op_b_;
- vvp_send_real(ptr.ptr()->out, val);
+ vvp_send_real(ptr.ptr()->out, val, 0);
}
/* Real modulus. */
@@ -831,12 +852,13 @@ vvp_arith_mod_real::~vvp_arith_mod_real()
{
}
-void vvp_arith_mod_real::recv_real(vvp_net_ptr_t ptr, double bit)
+void vvp_arith_mod_real::recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
double val = fmod(op_a_, op_b_);
- vvp_send_real(ptr.ptr()->out, val);
+ vvp_send_real(ptr.ptr()->out, val, 0);
}
/* Real summation. */
@@ -848,12 +870,13 @@ vvp_arith_sum_real::~vvp_arith_sum_real()
{
}
-void vvp_arith_sum_real::recv_real(vvp_net_ptr_t ptr, double bit)
+void vvp_arith_sum_real::recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
double val = op_a_ + op_b_;
- vvp_send_real(ptr.ptr()->out, val);
+ vvp_send_real(ptr.ptr()->out, val, 0);
}
/* Real subtraction. */
@@ -865,12 +888,13 @@ vvp_arith_sub_real::~vvp_arith_sub_real()
{
}
-void vvp_arith_sub_real::recv_real(vvp_net_ptr_t ptr, double bit)
+void vvp_arith_sub_real::recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
double val = op_a_ - op_b_;
- vvp_send_real(ptr.ptr()->out, val);
+ vvp_send_real(ptr.ptr()->out, val, 0);
}
/* Real compare equal. */
@@ -878,7 +902,8 @@ vvp_cmp_eq_real::vvp_cmp_eq_real()
{
}
-void vvp_cmp_eq_real::recv_real(vvp_net_ptr_t ptr, const double bit)
+void vvp_cmp_eq_real::recv_real(vvp_net_ptr_t ptr, const double bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -886,7 +911,7 @@ void vvp_cmp_eq_real::recv_real(vvp_net_ptr_t ptr, const double bit)
if (op_a_ == op_b_) res.set_bit(0, BIT4_1);
else res.set_bit(0, BIT4_0);
- vvp_send_vec4(ptr.ptr()->out, res);
+ vvp_send_vec4(ptr.ptr()->out, res, 0);
}
/* Real compare not equal. */
@@ -894,7 +919,8 @@ vvp_cmp_ne_real::vvp_cmp_ne_real()
{
}
-void vvp_cmp_ne_real::recv_real(vvp_net_ptr_t ptr, const double bit)
+void vvp_cmp_ne_real::recv_real(vvp_net_ptr_t ptr, const double bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -902,7 +928,7 @@ void vvp_cmp_ne_real::recv_real(vvp_net_ptr_t ptr, const double bit)
if (op_a_ != op_b_) res.set_bit(0, BIT4_1);
else res.set_bit(0, BIT4_0);
- vvp_send_vec4(ptr.ptr()->out, res);
+ vvp_send_vec4(ptr.ptr()->out, res, 0);
}
/* Real compare greater than or equal. */
@@ -910,7 +936,8 @@ vvp_cmp_ge_real::vvp_cmp_ge_real()
{
}
-void vvp_cmp_ge_real::recv_real(vvp_net_ptr_t ptr, const double bit)
+void vvp_cmp_ge_real::recv_real(vvp_net_ptr_t ptr, const double bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -918,7 +945,7 @@ void vvp_cmp_ge_real::recv_real(vvp_net_ptr_t ptr, const double bit)
if (op_a_ >= op_b_) res.set_bit(0, BIT4_1);
else res.set_bit(0, BIT4_0);
- vvp_send_vec4(ptr.ptr()->out, res);
+ vvp_send_vec4(ptr.ptr()->out, res, 0);
}
/* Real compare greater than. */
@@ -926,7 +953,8 @@ vvp_cmp_gt_real::vvp_cmp_gt_real()
{
}
-void vvp_cmp_gt_real::recv_real(vvp_net_ptr_t ptr, const double bit)
+void vvp_cmp_gt_real::recv_real(vvp_net_ptr_t ptr, const double bit,
+ vvp_context_t)
{
dispatch_operand_(ptr, bit);
@@ -934,5 +962,5 @@ void vvp_cmp_gt_real::recv_real(vvp_net_ptr_t ptr, const double bit)
if (op_a_ > op_b_) res.set_bit(0, BIT4_1);
else res.set_bit(0, BIT4_0);
- vvp_send_vec4(ptr.ptr()->out, res);
+ vvp_send_vec4(ptr.ptr()->out, res, 0);
}
View
84 vvp/arith.h
@@ -54,8 +54,10 @@ class vvp_arith_abs : public vvp_net_fun_t {
explicit vvp_arith_abs();
~vvp_arith_abs();
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
- void recv_real(vvp_net_ptr_t ptr, double bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
+ void recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t);
private:
};
@@ -65,7 +67,8 @@ class vvp_arith_cast_int : public vvp_net_fun_t {
explicit vvp_arith_cast_int(unsigned wid);
~vvp_arith_cast_int();
- void recv_real(vvp_net_ptr_t ptr, double bit);
+ void recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t);
private:
unsigned wid_;
@@ -76,7 +79,8 @@ class vvp_arith_cast_real : public vvp_net_fun_t {
explicit vvp_arith_cast_real(bool signed_flag);
~vvp_arith_cast_real();
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
private:
bool signed_;
@@ -87,7 +91,8 @@ class vvp_arith_div : public vvp_arith_ {
public:
explicit vvp_arith_div(unsigned wid, bool signed_flag);
~vvp_arith_div();
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
private:
void wide4_(vvp_net_ptr_t ptr);
bool signed_flag_;
@@ -98,7 +103,8 @@ class vvp_arith_mod : public vvp_arith_ {
public:
explicit vvp_arith_mod(unsigned wid, bool signed_flag);
~vvp_arith_mod();
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
private:
void wide_(vvp_net_ptr_t ptr);
bool signed_flag_;
@@ -114,7 +120,8 @@ class vvp_cmp_eeq : public vvp_arith_ {
public:
explicit vvp_cmp_eeq(unsigned wid);
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
};
@@ -122,7 +129,8 @@ class vvp_cmp_nee : public vvp_arith_ {
public:
explicit vvp_cmp_nee(unsigned wid);
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
};
@@ -130,7 +138,8 @@ class vvp_cmp_eq : public vvp_arith_ {
public:
explicit vvp_cmp_eq(unsigned wid);
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
};
@@ -138,7 +147,8 @@ class vvp_cmp_ne : public vvp_arith_ {
public:
explicit vvp_cmp_ne(unsigned wid);
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
};
@@ -165,7 +175,8 @@ class vvp_cmp_ge : public vvp_cmp_gtge_base_ {
public:
explicit vvp_cmp_ge(unsigned wid, bool signed_flag);
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
};
@@ -174,7 +185,8 @@ class vvp_cmp_gt : public vvp_cmp_gtge_base_ {
public:
explicit vvp_cmp_gt(unsigned wid, bool signed_flag);
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
};
/*
@@ -187,7 +199,8 @@ class vvp_arith_mult : public vvp_arith_ {
public:
explicit vvp_arith_mult(unsigned wid);
~vvp_arith_mult();
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
private:
void wide_(vvp_net_ptr_t ptr);
};
@@ -197,7 +210,8 @@ class vvp_arith_pow : public vvp_arith_ {
public:
explicit vvp_arith_pow(unsigned wid, bool signed_flag);
~vvp_arith_pow();
- void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t);
private:
bool signed_flag_;
};
@@ -207,7 +221,8 @@ class vvp_arith_sub : public vvp_arith_ {
public:
explicit vvp_arith_sub(unsigned wid);
~vvp_arith_sub();
- virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
+ virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t);
};
@@ -216,7 +231,8 @@ class vvp_arith_sum : public vvp_arith_ {
public:
explicit vvp_arith_sum(unsigned wid);
~vvp_arith_sum();
- virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
+ virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t);
};
@@ -225,7 +241,8 @@ class vvp_shiftl : public vvp_arith_ {
public:
explicit vvp_shiftl(unsigned wid);
~vvp_shiftl();
- virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
+ virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t);
};
class vvp_shiftr : public vvp_arith_ {
@@ -233,7 +250,8 @@ class vvp_shiftr : public vvp_arith_ {
public:
explicit vvp_shiftr(unsigned wid, bool signed_flag);
~vvp_shiftr();
- virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
+ virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t);
private:
bool signed_flag_;
@@ -263,7 +281,8 @@ class vvp_arith_sum_real : public vvp_arith_real_ {
public:
explicit vvp_arith_sum_real();
~vvp_arith_sum_real();
- void recv_real(vvp_net_ptr_t ptr, double bit);
+ void recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t);
};
class vvp_arith_div_real : public vvp_arith_real_ {
@@ -271,7 +290,8 @@ class vvp_arith_div_real : public vvp_arith_real_ {
public:
explicit vvp_arith_div_real();
~vvp_arith_div_real();
- void recv_real(vvp_net_ptr_t ptr, double bit);
+ void recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t);
};
class vvp_arith_mod_real : public vvp_arith_real_ {
@@ -279,7 +299,8 @@ class vvp_arith_mod_real : public vvp_arith_real_ {
public:
explicit vvp_arith_mod_real();
~vvp_arith_mod_real();
- void recv_real(vvp_net_ptr_t ptr, double bit);
+ void recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t);
};
class vvp_arith_mult_real : public vvp_arith_real_ {
@@ -287,7 +308,8 @@ class vvp_arith_mult_real : public vvp_arith_real_ {
public:
explicit vvp_arith_mult_real();
~vvp_arith_mult_real();
- void recv_real(vvp_net_ptr_t ptr, double bit);
+ void recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t);
};
class vvp_arith_pow_real : public vvp_arith_real_ {
@@ -295,7 +317,8 @@ class vvp_arith_pow_real : public vvp_arith_real_ {
public:
explicit vvp_arith_pow_real();
~vvp_arith_pow_real();
- void recv_real(vvp_net_ptr_t ptr, double bit);
+ void recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t);
};
class vvp_arith_sub_real : public vvp_arith_real_ {
@@ -303,35 +326,40 @@ class vvp_arith_sub_real : public vvp_arith_real_ {
public:
explicit vvp_arith_sub_real();
~vvp_arith_sub_real();
- void recv_real(vvp_net_ptr_t ptr, double bit);
+ void recv_real(vvp_net_ptr_t ptr, double bit,
+ vvp_context_t);
};
class vvp_cmp_eq_real : public vvp_arith_real_ {
public:
explicit vvp_cmp_eq_real();
- void recv_real(vvp_net_ptr_t ptr, const double bit);
+ void recv_real(vvp_net_ptr_t ptr, const double bit,
+ vvp_context_t);
};
class vvp_cmp_ne_real : public vvp_arith_real_ {
public:
explicit vvp_cmp_ne_real();
- void recv_real(vvp_net_ptr_t ptr, const double bit);
+ void recv_real(vvp_net_ptr_t ptr, const double bit,
+ vvp_context_t);
};
class vvp_cmp_ge_real : public vvp_arith_real_ {
public:
explicit vvp_cmp_ge_real();
- void recv_real(vvp_net_ptr_t ptr, const double bit);
+ void recv_real(vvp_net_ptr_t ptr, const double bit,
+ vvp_context_t);
};
class vvp_cmp_gt_real : public vvp_arith_real_ {
public:
explicit vvp_cmp_gt_real();
- void recv_real(vvp_net_ptr_t ptr, const double bit);
+ void recv_real(vvp_net_ptr_t ptr, const double bit,
+ vvp_context_t);
};
#endif
View
167 vvp/array.cc
@@ -332,6 +332,9 @@ static int vpi_array_get(int code, vpiHandle ref)
case vpiSize:
return (int) obj->array_count;
+ case vpiAutomatic:
+ return (int) obj->scope->is_automatic;
+
default:
return 0;
}
@@ -727,7 +730,7 @@ void array_set_word(vvp_array_t arr,
assert(vsig);
vvp_net_ptr_t ptr (vsig->node, 0);
- vvp_send_vec4_pv(ptr, val, part_off, val.size(), vpip_size(vsig));
+ vvp_send_vec4_pv(ptr, val, part_off, val.size(), vpip_size(vsig), 0);
array_word_change(arr, address);
}
@@ -852,9 +855,13 @@ void compile_var_array(char*label, char*name, int last, int first,
/* Make the words. */
arr->vals_width = labs(msb-lsb) + 1;
- arr->vals = new vvp_vector4array_t(arr->vals_width, arr->array_count,
- vpip_peek_current_scope()->is_automatic);
- vpip_add_item_to_current_scope(arr->vals);
+ if (vpip_peek_current_scope()->is_automatic) {
+ arr->vals = new vvp_vector4array_aa(arr->vals_width,
+ arr->array_count);
+ } else {
+ arr->vals = new vvp_vector4array_sa(arr->vals_width,
+ arr->array_count);
+ }
vpip_make_dec_const(&arr->msb, msb);
vpip_make_dec_const(&arr->lsb, lsb);
@@ -908,11 +915,9 @@ class vvp_fun_arrayport : public vvp_net_fun_t {
explicit vvp_fun_arrayport(vvp_array_t mem, vvp_net_t*net, long addr);
~vvp_fun_arrayport();
- void check_word_change(unsigned long addr);
-
- void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
+ virtual void check_word_change(unsigned long addr) = 0;
- private:
+ protected:
vvp_array_t arr_;
vvp_net_t *net_;
unsigned long addr_;
@@ -938,7 +943,37 @@ vvp_fun_arrayport::~vvp_fun_arrayport()
{
}
-void vvp_fun_arrayport::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
+class vvp_fun_arrayport_sa : public vvp_fun_arrayport {
+
+ public:
+ explicit vvp_fun_arrayport_sa(vvp_array_t mem, vvp_net_t*net);
+ explicit vvp_fun_arrayport_sa(vvp_array_t mem, vvp_net_t*net, long addr);
+ ~vvp_fun_arrayport_sa();
+
+ void check_word_change(unsigned long addr);
+
+ void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t);
+
+ private:
+};
+
+vvp_fun_arrayport_sa::vvp_fun_arrayport_sa(vvp_array_t mem, vvp_net_t*net)
+: vvp_fun_arrayport(mem, net)
+{
+}
+
+vvp_fun_arrayport_sa::vvp_fun_arrayport_sa(vvp_array_t mem, vvp_net_t*net, long addr)
+: vvp_fun_arrayport(mem, net, addr)
+{
+}
+
+vvp_fun_arrayport_sa::~vvp_fun_arrayport_sa()
+{
+}
+
+void vvp_fun_arrayport_sa::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t)
{
bool addr_valid_flag;
@@ -948,7 +983,7 @@ void vvp_fun_arrayport::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
addr_valid_flag = vector4_to_value(bit, addr_);
if (! addr_valid_flag)
addr_ = arr_->array_count;
- vvp_send_vec4(port.ptr()->out, array_get_word(arr_,addr_));
+ vvp_send_vec4(port.ptr()->out, array_get_word(arr_,addr_), 0);
break;
default:
@@ -957,13 +992,111 @@ void vvp_fun_arrayport::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
}
}
-void vvp_fun_arrayport::check_word_change(unsigned long addr)
+void vvp_fun_arrayport_sa::check_word_change(unsigned long addr)
{
if (addr != addr_)
return;
vvp_vector4_t bit = array_get_word(arr_, addr_);
- vvp_send_vec4(net_->out, bit);
+ vvp_send_vec4(net_->out, bit, 0);
+}
+
+class vvp_fun_arrayport_aa : public vvp_fun_arrayport, public automatic_hooks_s {
+
+ public:
+ explicit vvp_fun_arrayport_aa(vvp_array_t mem, vvp_net_t*net);
+ explicit vvp_fun_arrayport_aa(vvp_array_t mem, vvp_net_t*net, long addr);
+ ~vvp_fun_arrayport_aa();
+
+ void alloc_instance(vvp_context_t context);
+ void reset_instance(vvp_context_t context);
+
+ void check_word_change(unsigned long addr);
+
+ void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t);
+
+ private:
+ struct __vpiScope*context_scope_;
+ unsigned context_idx_;
+};
+
+vvp_fun_arrayport_aa::vvp_fun_arrayport_aa(vvp_array_t mem, vvp_net_t*net)
+: vvp_fun_arrayport(mem, net)
+{
+ context_scope_ = vpip_peek_context_scope();
+ context_idx_ = vpip_add_item_to_context(this, context_scope_);
+}
+
+vvp_fun_arrayport_aa::vvp_fun_arrayport_aa(vvp_array_t mem, vvp_net_t*net, long addr)
+: vvp_fun_arrayport(mem, net, addr)
+{
+ context_scope_ = vpip_peek_context_scope();
+ context_idx_ = vpip_add_item_to_context(this, context_scope_);
+}
+
+vvp_fun_arrayport_aa::~vvp_fun_arrayport_aa()
+{
+}
+
+void vvp_fun_arrayport_aa::alloc_instance(vvp_context_t context)
+{
+ unsigned long*addr = new unsigned long;
+ vvp_set_context_item(context, context_idx_, addr);
+
+ *addr = addr_;
+}
+
+void vvp_fun_arrayport_aa::reset_instance(vvp_context_t context)
+{
+ unsigned long*addr = static_cast<unsigned long*>
+ (vvp_get_context_item(context, context_idx_));
+
+ *addr = addr_;
+}
+
+void vvp_fun_arrayport_aa::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t context)
+{
+ if (context) {
+ unsigned long*addr = static_cast<unsigned long*>
+ (vvp_get_context_item(context, context_idx_));
+
+ bool addr_valid_flag;
+
+ switch (port.port()) {
+
+ case 0: // Address input
+ addr_valid_flag = vector4_to_value(bit, *addr);
+ if (! addr_valid_flag)
+ *addr = arr_->array_count;
+ vvp_send_vec4(port.ptr()->out, array_get_word(arr_,*addr),
+ context);
+ break;
+
+ default:
+ fprintf(stdout, "XXXX write ports not implemented.\n");
+ assert(0);
+ }
+ } else {
+ context = context_scope_->live_contexts;
+ while (context) {
+ recv_vec4(port, bit, context);
+ context = vvp_get_next_context(context);
+ }
+ }
+}
+
+void vvp_fun_arrayport_aa::check_word_change(unsigned long addr)
+{
+ unsigned long*port_addr = static_cast<unsigned long*>
+ (vthread_get_wt_context_item(context_idx_));
+
+ if (addr != *port_addr)
+ return;
+
+ vvp_vector4_t bit = array_get_word(arr_, addr);
+ vvp_send_vec4(net_->out, bit, vthread_get_wt_context());
}
static void array_attach_port(vvp_array_t array, vvp_fun_arrayport*fun)
@@ -1046,9 +1179,15 @@ bool array_port_resolv_list_t::resolve(bool mes)
vvp_fun_arrayport*fun;
if (use_addr)
- fun = new vvp_fun_arrayport(mem, ptr, addr);
+ if (vpip_peek_current_scope()->is_automatic)
+ fun = new vvp_fun_arrayport_aa(mem, ptr, addr);
+ else
+ fun = new vvp_fun_arrayport_sa(mem, ptr, addr);
else
- fun = new vvp_fun_arrayport(mem, ptr);
+ if (vpip_peek_current_scope()->is_automatic)
+ fun = new vvp_fun_arrayport_aa(mem, ptr);
+ else
+ fun = new vvp_fun_arrayport_sa(mem, ptr);
ptr->fun = fun;
array_attach_port(mem, fun);
View
4 vvp/bufif.cc
@@ -35,7 +35,8 @@ vvp_fun_bufif::vvp_fun_bufif(bool en_invert, bool out_invert,
count_functors_bufif += 1;
}
-void vvp_fun_bufif::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
+void vvp_fun_bufif::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
+ vvp_context_t)
{
switch (ptr.port()) {
case 0:
@@ -115,4 +116,3 @@ void vvp_fun_bufif::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
* Revision 1.8 2002/08/12 01:35:07 steve
* conditional ident string using autoconfig.
*/
-
View
3  vvp/bufif.h
@@ -40,7 +40,8 @@ class vvp_fun_bufif : public vvp_net_fun_t {
vvp_fun_bufif(bool en_invert, bool out_invert,
unsigned str0, unsigned str1);
- void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t);
private:
vvp_vector4_t bit_;
View
32 vvp/compile.cc
@@ -83,6 +83,7 @@ const static struct opcode_table_s opcode_table[] = {
{ "%add", of_ADD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%add/wr", of_ADD_WR, 2, {OA_BIT1, OA_BIT2, OA_NONE} },
{ "%addi", of_ADDI, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
+ { "%alloc", of_ALLOC, 1, {OA_VPI_PTR, OA_NONE, OA_NONE} },
{ "%and", of_AND, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%and/r", of_ANDR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%andi", of_ANDI, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
@@ -134,6 +135,7 @@ const static struct opcode_table_s opcode_table[] = {
{ "%force/v",of_FORCE_V,3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
{ "%force/wr",of_FORCE_WR,2, {OA_FUNC_PTR, OA_BIT1, OA_NONE} },
{ "%force/x0",of_FORCE_X0,3,{OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
+ { "%free", of_FREE, 1, {OA_VPI_PTR, OA_NONE, OA_NONE} },
{ "%inv", of_INV, 2, {OA_BIT1, OA_BIT2, OA_NONE} },
{ "%ix/add", of_IX_ADD, 2, {OA_BIT1, OA_NUMBER, OA_NONE} },
{ "%ix/get", of_IX_GET, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
@@ -181,7 +183,7 @@ const static struct opcode_table_s opcode_table[] = {
{ "%release/wr",of_RELEASE_WR,2,{OA_FUNC_PTR,OA_BIT1,OA_NONE} },
{ "%set/av", of_SET_AV, 3, {OA_ARR_PTR, OA_BIT1, OA_BIT2} },
{ "%set/v", of_SET_VEC,3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
- { "%set/wr", of_SET_WORDR,2,{OA_VPI_PTR, OA_BIT1, OA_NONE} },
+ { "%set/wr", of_SET_WORDR,2,{OA_FUNC_PTR, OA_BIT1, OA_NONE} },
{ "%set/x0", of_SET_X0, 3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
// { "%set/x0/x",of_SET_X0_X,3,{OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
{ "%shiftl/i0", of_SHIFTL_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} },
@@ -1687,34 +1689,6 @@ void compile_fork(char*label, struct symb_s dest, struct symb_s scope)
compile_vpi_lookup(&code->handle, scope.text);
}
-void compile_alloc(char*label, struct symb_s scope)
-{
- if (label)
- compile_codelabel(label);
-
-
- /* Fill in the basics of the %alloc in the instruction. */
- vvp_code_t code = codespace_allocate();
- code->opcode = of_ALLOC;
-
- /* Figure out the target SCOPE. */
- compile_vpi_lookup(&code->handle, scope.text);
-}
-
-void compile_free(char*label, struct symb_s scope)
-{
- if (label)
- compile_codelabel(label);
-
-
- /* Fill in the basics of the %free in the instruction. */
- vvp_code_t code = codespace_allocate();
- code->opcode = of_FREE;
-
- /* Figure out the target SCOPE. */
- compile_vpi_lookup(&code->handle, scope.text);
-}
-
void compile_vpi_call(char*label, char*name,
long file_idx, long lineno,
unsigned argc, vpiHandle*argv)
View
6 vvp/compile.h
@@ -356,8 +356,7 @@ extern void compile_ufunc(char*label, char*code, unsigned wid,
* the threads.
*/
extern void compile_event(char*label, char*type,
- unsigned argc, struct symb_s*argv,
- bool debug_flag);
+ unsigned argc, struct symb_s*argv);
extern void compile_named_event(char*label, char*type);
@@ -406,9 +405,6 @@ extern void compile_fork(char*label, struct symb_s targ_s,
struct symb_s scope_s);
extern void compile_codelabel(char*label);
-extern void compile_alloc(char*label, struct symb_s scope_s);
-extern void compile_free(char*label, struct symb_s scope_s);
-
/*
* The parser uses these functions to compile .scope statements.
* The implementations of these live in the vpi_scope.cc file.
View
11 vvp/concat.cc
@@ -45,7 +45,8 @@ vvp_fun_concat::~vvp_fun_concat()
{
}
-void vvp_fun_concat::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
+void vvp_fun_concat::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t)
{
unsigned pdx = port.port();
@@ -64,7 +65,7 @@ void vvp_fun_concat::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
val_.set_bit(off+idx, bit.value(idx));
}
- vvp_send_vec4(port.ptr()->out, val_);
+ vvp_send_vec4(port.ptr()->out, val_, 0);
}
void compile_concat(char*label, unsigned w0, unsigned w1,
@@ -91,7 +92,8 @@ vvp_fun_repeat::~vvp_fun_repeat()
{
}
-void vvp_fun_repeat::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
+void vvp_fun_repeat::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t)
{
assert(bit.size() == wid_/rep_);
@@ -105,7 +107,7 @@ void vvp_fun_repeat::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
}
- vvp_send_vec4(port.ptr()->out, val);
+ vvp_send_vec4(port.ptr()->out, val, 0);
}
void compile_repeat(char*label, long width, long repeat, struct symb_s arg)
@@ -140,4 +142,3 @@ void compile_repeat(char*label, long width, long repeat, struct symb_s arg)
* Add missing concat.cc to cvs
*
*/
-
View
22 vvp/delay.cc
@@ -183,7 +183,8 @@ void vvp_fun_delay::clean_pulse_events_(vvp_time64_t use_delay)
* wrong. What should happen is that if there are multiple changes,
* multiple vectors approaching the result should be scheduled.
*/
-void vvp_fun_delay::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
+void vvp_fun_delay::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t)
{
if (port.port() > 0) {
// Get the integer value of the bit vector, or 0 if
@@ -248,7 +249,7 @@ void vvp_fun_delay::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
if (use_delay == 0) {
cur_vec4_ = bit;
initial_ = false;
- vvp_send_vec4(net_->out, cur_vec4_);
+ vvp_send_vec4(net_->out, cur_vec4_, 0);
} else {
struct event_*cur = new struct event_(use_simtime);
cur->run_run_ptr = &vvp_fun_delay::run_run_vec4_;
@@ -283,7 +284,8 @@ void vvp_fun_delay::recv_vec8(vvp_net_ptr_t port, const vvp_vector8_t&bit)
}
}
-void vvp_fun_delay::recv_real(vvp_net_ptr_t port, double bit)
+void vvp_fun_delay::recv_real(vvp_net_ptr_t port, double bit,
+ vvp_context_t)
{
if (port.port() > 0) {
/* If the port is not 0, then this is a delay value that
@@ -328,7 +330,7 @@ void vvp_fun_delay::recv_real(vvp_net_ptr_t port, double bit)
if (use_delay == 0) {
cur_real_ = bit;
initial_ = false;
- vvp_send_real(net_->out, cur_real_);
+ vvp_send_real(net_->out, cur_real_, 0);
} else {
struct event_*cur = new struct event_(use_simtime);
cur->run_run_ptr = &vvp_fun_delay::run_run_real_;
@@ -357,7 +359,7 @@ void vvp_fun_delay::run_run()
void vvp_fun_delay::run_run_vec4_(struct event_*cur)
{
cur_vec4_ = cur->ptr_vec4;
- vvp_send_vec4(net_->out, cur_vec4_);
+ vvp_send_vec4(net_->out, cur_vec4_, 0);
}
void vvp_fun_delay::run_run_vec8_(struct vvp_fun_delay::event_*cur)
@@ -369,7 +371,7 @@ void vvp_fun_delay::run_run_vec8_(struct vvp_fun_delay::event_*cur)
void vvp_fun_delay::run_run_real_(struct vvp_fun_delay::event_*cur)
{
cur_real_ = cur->ptr_real;
- vvp_send_real(net_->out, cur_real_);
+ vvp_send_real(net_->out, cur_real_, 0);
}
vvp_fun_modpath::vvp_fun_modpath(vvp_net_t*net)
@@ -418,7 +420,8 @@ static vvp_time64_t delay_from_edge(vvp_bit4_t a, vvp_bit4_t b,
return array[ edge_table[a][b] ];
}
-void vvp_fun_modpath::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
+void vvp_fun_modpath::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t)
{
/* Only the first port is used. */
if (port.port() > 0)
@@ -532,7 +535,7 @@ void vvp_fun_modpath::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
void vvp_fun_modpath::run_run()
{
- vvp_send_vec4(net_->out, cur_vec4_);
+ vvp_send_vec4(net_->out, cur_vec4_, 0);
}
vvp_fun_modpath_src::vvp_fun_modpath_src(vvp_time64_t del[12])
@@ -561,7 +564,8 @@ void vvp_fun_modpath_src::put_delay12(const vvp_time64_t val[12])
delay_[idx] = val[idx];
}
-void vvp_fun_modpath_src::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
+void vvp_fun_modpath_src::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t)
{
if (port.port() == 0) {
// The modpath input...
View
12 vvp/delay.h
@@ -85,9 +85,11 @@ class vvp_fun_delay : public vvp_net_fun_t, private vvp_gen_event_s {
vvp_fun_delay(vvp_net_t*net, vvp_bit4_t init, const vvp_delay_t&d);
~vvp_fun_delay();
- void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t);
void recv_vec8(vvp_net_ptr_t port, const vvp_vector8_t&bit);
- void recv_real(vvp_net_ptr_t port, double bit);
+ void recv_real(vvp_net_ptr_t port, double bit,
+ vvp_context_t);
//void recv_long(vvp_net_ptr_t port, long bit);
private:
@@ -153,7 +155,8 @@ class vvp_fun_modpath : public vvp_net_fun_t, private vvp_gen_event_s {
void add_modpath_src(vvp_fun_modpath_src*that, bool ifnone);
- void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t);
private:
virtual void run_run();
@@ -181,7 +184,8 @@ class vvp_fun_modpath_src : public vvp_net_fun_t {
~vvp_fun_modpath_src();
public:
- void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t);
virtual bool test_vec4(const vvp_vector4_t&bit);
void get_delay12(vvp_time64_t out[12]) const;
View
7 vvp/dff.cc
@@ -39,7 +39,8 @@ vvp_dff::~vvp_dff()
{
}
-void vvp_dff::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
+void vvp_dff::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t)
{
vvp_bit4_t tmp;
@@ -57,7 +58,7 @@ void vvp_dff::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
tmp = clk_cur_;
clk_cur_ = bit.value(0);
if (clk_cur_ == BIT4_1 && tmp != BIT4_1)
- vvp_send_vec4(port.ptr()->out, d_);
+ vvp_send_vec4(port.ptr()->out, d_, 0);
break;
case 2: // CE
@@ -67,7 +68,7 @@ void vvp_dff::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
case 3: // Asynch-D
d_ = bit;
- vvp_send_vec4(port.ptr()->out, d_);
+ vvp_send_vec4(port.ptr()->out, d_, 0);
break;
}
}
View
3  vvp/dff.h
@@ -40,7 +40,8 @@ class vvp_dff : public vvp_net_fun_t {
explicit vvp_dff(bool invert_clk =false, bool invert_ce =false);
~vvp_dff();
- void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
+ void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t);
private:
bool iclk_, ice_;
View
506 vvp/event.cc
@@ -32,7 +32,7 @@
# include <iostream>
-void waitable_hooks_s::run_waiting_threads_(unsigned context_idx)
+void waitable_hooks_s::run_waiting_threads_(vthread_t&threads)
{
// Run the non-blocking event controls.
last = &event_ctls;
@@ -48,17 +48,11 @@ void waitable_hooks_s::run_waiting_threads_(unsigned context_idx)
}
}
- vthread_t tmp;
- if (context_idx) {
- waitable_state_s*state = static_cast<waitable_state_s*>
- (vthread_get_wt_context_item(context_idx));
- tmp = state->threads;
- state->threads = 0;
- } else {
- tmp = threads;
- threads = 0;
- }
- if (tmp) vthread_schedule_list(tmp);
+ vthread_t tmp = threads;
+ if (tmp == 0) return;
+ threads = 0;
+
+ vthread_schedule_list(tmp);
}
evctl::evctl(unsigned long ecount)
@@ -117,9 +111,9 @@ evctl_vector::evctl_vector(vvp_net_ptr_t ptr, const vvp_vector4_t&value,
void evctl_vector::run_run()
{
if (wid_ != 0) {
- vvp_send_vec4_pv(ptr_, value_, off_, value_.size(), wid_);
+ vvp_send_vec4_pv(ptr_, value_, off_, value_.size(), wid_, 0);
} else {
- vvp_send_vec4(ptr_, value_);
+ vvp_send_vec4(ptr_, value_, 0);
}
}
@@ -186,114 +180,156 @@ const vvp_fun_edge::edge_t vvp_edge_negedge
const vvp_fun_edge::edge_t vvp_edge_none = 0;
struct vvp_fun_edge_state_s : public waitable_state_s {
- vvp_fun_edge_state_s() : bit(BIT4_X) {}
+ vvp_fun_edge_state_s()
+ {
+ for (unsigned idx = 0 ; idx < 4 ; idx += 1)
+ bits[idx] = BIT4_X;
+ }
- vvp_bit4_t bit;
+ vvp_bit4_t bits[4];
};
-vvp_fun_edge::vvp_fun_edge(edge_t e, bool debug_flag)
-: edge_(e), debug_(debug_flag)
+vvp_fun_edge::vvp_fun_edge(edge_t e)
+: edge_(e)
{
- bits_[0] = BIT4_X;
- bits_[1] = BIT4_X;
- bits_[2] = BIT4_X;
- bits_[3] = BIT4_X;
}
vvp_fun_edge::~vvp_fun_edge()
{
}
-void vvp_fun_edge::alloc_instance(vvp_context_t context)
+bool vvp_fun_edge::recv_vec4_(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_bit4_t&old_bit, vthread_t&threads)
{
- vvp_set_context_item(context, context_idx, new vvp_fun_edge_state_s);
+ /* See what kind of edge this represents. */
+ edge_t mask = VVP_EDGE(old_bit, bit.value(0));
+
+ /* Save the current input for the next time around. */
+ old_bit = bit.value(0);
+
+ if ((edge_ == vvp_edge_none) || (edge_ & mask)) {
+ run_waiting_threads_(threads);
+ return true;
+ }
+ return false;
}
-void vvp_fun_edge::reset_instance(vvp_context_t context)
+vvp_fun_edge_sa::vvp_fun_edge_sa(edge_t e)
+: vvp_fun_edge(e), threads_(0)
{
- vvp_fun_edge_state_s*state = static_cast<vvp_fun_edge_state_s*>
- (vvp_get_context_item(context, context_idx));
- state->threads = 0;
- state->bit = BIT4_X;
+ for (unsigned idx = 0 ; idx < 4 ; idx += 1)
+ bits_[idx] = BIT4_X;
}
-void vvp_fun_edge::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
+vvp_fun_edge_sa::~vvp_fun_edge_sa()
{
- vvp_bit4_t*old_bit;
- if (context_idx) {
- vvp_fun_edge_state_s*state = static_cast<vvp_fun_edge_state_s*>
- (vthread_get_wt_context_item(context_idx));
- old_bit = &state->bit;
- } else {
- old_bit = &bits_[port.port()];
- }
-
- /* See what kind of edge this represents. */
- edge_t mask = VVP_EDGE(*old_bit, bit.value(0));
+}
- /* Save the current input for the next time around. */
- *old_bit = bit.value(0);
+vthread_t vvp_fun_edge_sa::add_waiting_thread(vthread_t thread)
+{
+ vthread_t tmp = threads_;
+ threads_ = thread;
- if ((edge_ == vvp_edge_none) || (edge_ & mask)) {
- run_waiting_threads_(context_idx);
+ return tmp;
+}
+void vvp_fun_edge_sa::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
+ vvp_context_t)
+{
+ if (recv_vec4_(port, bit, bits_[port.port()], threads_)) {
vvp_net_t*net = port.ptr();
- vvp_send_vec4(net->out, bit);
+ vvp_send_vec4(net->out, bit, 0);
}
}
+vvp_fun_edge_aa::vvp_fun_edge_aa(edge_t e)
+: vvp_fun_edge(e)
+{
+ context_scope_ = vpip_peek_context_scope();
+ context_idx_ = vpip_add_item_to_context(this, context_scope_);
+}
-struct vvp_fun_anyedge_state_s : public waitable_state_s {
- vvp_fun_anyedge_state_s() : bitsr(0.0) {}
+vvp_fun_edge_aa::~vvp_fun_edge_aa()
+{
+}
- vvp_vector4_t bits;
- double bitsr;
-};
+void vvp_fun_edge_aa::alloc_instance(vvp_context_t context)
+{
+ vvp_set_context_item(context, context_idx_, new vvp_fun_edge_state_s);
+}
-vvp_fun_anyedge::vvp_fun_anyedge(bool de