static int activate_timer (void) { uint32 t; sim_debug (DBG_DEBUG, & clk_dev, "clk_svc: TR has %d time units left\n", t); sim_debug (DBG_DEBUG, & clk_dev, "activate_timer: TR is %lld %#llo.\n", rTR, rTR); if (bit_is_neg(rTR, 27)) { if ((t = sim_is_active(&TR_clk_unit[0])) != 0) sim_debug (DBG_DEBUG, & clk_dev, "activate_timer: TR cancelled with %d time units left.\n", t); else sim_debug (DBG_DEBUG, & clk_dev, "activate_timer: TR loaded with negative value, but it was alread stopped.\n", t); sim_cancel(&TR_clk_unit[0]); return 0; } if ((t = sim_is_active(&TR_clk_unit[0])) != 0) { sim_debug (DBG_DEBUG, & clk_dev, "activate_timer: TR was still running with %d time units left.\n", t); sim_cancel(&TR_clk_unit[0]); // BUG: do we need to cancel? } #ifdef USE_IDLE if (! sim_is_active (& TR_clk_unit [0])) sim_activate (& TR_clk_unit[ 0], sim_rtcn_init(CLK_TR_HZ, TR_CLK)); #else (void) sim_rtcn_init(CLK_TR_HZ, TR_CLK); sim_activate(&TR_clk_unit[0], rTR); #endif if ((t = sim_is_active(&TR_clk_unit[0])) == 0) sim_debug (DBG_DEBUG, & TR_clk_unit, "activate_timer: TR is not running\n", t); else sim_debug (DBG_DEBUG, & TR_clk_unit, "activate_timer: TR is now running with %d time units left.\n", t); return 0; }
/* * Print the id of bit x (for header of tt) */ static void print_id(bit_t x) { node_t v; if (x == true_bit) { printf(" T "); } else if (x == false_bit) { printf(" F "); } else { v = node_of_bit(x); if (is_variable_node(&dag, v)) { if (bit_is_neg(x)) { printf(" ~%c ", 'a' + (char) (v-1)); } else { printf(" %c ", 'a' + (char) (v-1)); } } else if (v < 10) { if (bit_is_neg(x)) { printf(" ~p%"PRId32" ", v); } else { printf(" p%"PRId32" ", v); } } else if (v < 100) { if (bit_is_neg(x)) { printf(" ~p%"PRId32" ", v); } else { printf(" p%"PRId32" ", v); } } else { if (bit_is_neg(x)) { printf(" ~p%"PRId32" ", v); } else { printf(" p%"PRId32" ", v); } } } }
/* * Compute the truth table for bit x * - if x is known, we take it from tt * - otherwise, we use the dat */ static uint32_t dag_truth_table(bit_t x) { node_t v; uint32_t left, right, aux; if (fresh_bit(x)) { v = node_of_bit(x); switch (node_kind(&dag, v)) { case OR_NODE: left = dag_truth_table(left_child_of_node(&dag, v)); right = dag_truth_table(right_child_of_node(&dag, v)); aux = left | right; break; case XOR_NODE: left = dag_truth_table(left_child_of_node(&dag, v)); right = dag_truth_table(right_child_of_node(&dag, v)); aux = left ^ right; break; case UNUSED_NODE: case CONSTANT_NODE: case VARIABLE_NODE: default: printf("*** BUG: invalid node in DAG ***\n"); fflush(stdout); abort(); } if (bit_is_neg(x)) { aux = ~aux; } return aux; } else { return tt[x]; } }