Ejemplo n.º 1
0
void pop_transformation ()
  {
  subs_top_x =
    exp_array_index_1d (transformation_stack, TRANSFORMATION, transformation_stack->icUsed - 1).subs_top_x ;
  subs_top_y =
    exp_array_index_1d (transformation_stack, TRANSFORMATION, transformation_stack->icUsed - 1).subs_top_y ;
  cxClientArea =
    exp_array_index_1d (transformation_stack, TRANSFORMATION, transformation_stack->icUsed - 1).cxClientArea ;
  cyClientArea =
    exp_array_index_1d (transformation_stack, TRANSFORMATION, transformation_stack->icUsed - 1).cyClientArea ;
  scale =
    exp_array_index_1d (transformation_stack, TRANSFORMATION, transformation_stack->icUsed - 1).scale ;
  }
Ejemplo n.º 2
0
static void move (QCADDesignObject *obj, double dxWorld, double dyWorld)
  {
  int Nix ;
  QCADRuler *ruler = QCAD_RULER (obj) ;

  QCAD_DESIGN_OBJECT_CLASS (g_type_class_peek (g_type_parent (QCAD_TYPE_RULER)))->move (obj, dxWorld, dyWorld) ;

  for (Nix = 0 ; Nix < ruler->icLabelsVisible ; Nix++)
    qcad_design_object_move (QCAD_DESIGN_OBJECT (exp_array_index_1d (ruler->labels, GRADUATION, Nix).lbl), dxWorld, dyWorld) ;
  }
Ejemplo n.º 3
0
static void qcad_ruler_instance_finalize (GObject *object)
  {
  int Nix ;
  QCADRuler *ruler = QCAD_RULER (object) ;

  DBG_OO (fprintf (stderr, "QCADRuler::instance_finalize:Entering\n")) ;
  for (Nix = 0 ; Nix < ruler->labels->icUsed ; Nix++)
    g_object_unref (G_OBJECT (exp_array_index_1d (ruler->labels, GRADUATION, Nix).lbl)) ;
  exp_array_free (ruler->labels) ;
  G_OBJECT_CLASS (g_type_class_peek (g_type_parent (QCAD_TYPE_RULER)))->finalize (object) ;
  DBG_OO (fprintf (stderr, "QCADRuler::instance_finalize:Leaving\n")) ;
  }
Ejemplo n.º 4
0
static QCADLabel *get_label_from_array (EXP_ARRAY *ar, int idx, double dCurrentGrad, GdkColor *clr)
  {
  GRADUATION grad = {NULL, 0.0} ;
  GRADUATION *ar_grad = NULL ;

  if (idx == ar->icUsed)
    {
    grad.lbl = qcad_label_new ("%.2lf", dCurrentGrad) ;
    grad.dVal = dCurrentGrad ;
    exp_array_insert_vals (ar, &grad, 1, 1, -1) ;
    ar_grad = &grad ;
    }
  else
  if ((ar_grad = &exp_array_index_1d (ar, GRADUATION, idx))->dVal != dCurrentGrad)
    {
    qcad_label_set_text (QCAD_LABEL (ar_grad->lbl), "%.2lf", dCurrentGrad) ;
    ar_grad->dVal = dCurrentGrad ;
    }

  memcpy (&(QCAD_DESIGN_OBJECT (ar_grad->lbl)->clr), clr, sizeof (GdkColor)) ;

  return ar_grad->lbl ;
  }
Ejemplo n.º 5
0
// start helpers
static void swap_buses (GtkTreeModel *tm, GtkTreeSelection *sel, bus_layout_D *dialog, GtkTreePath *tpSrc, GtkTreePath *tpDst)
  {
  int Nix ;
  GtkTreeIter itr ;
  SWAP_BUSES_STRUCT src, dst ;
  SWAP_BUSES_STRUCT *min = NULL, *max = NULL ;
  EXP_ARRAY *ar_bSelSrc = NULL, *ar_bSelDst = NULL ;
  gboolean bDstExpanded = TRUE ;

  if (!gtk_tree_model_get_iter (tm, &(src.itr), tpSrc)) return ;
  src.tp = gtk_tree_path_copy (tpSrc) ;
  src.icChildren = gtk_tree_model_iter_n_children (tm, &(src.itr)) ;

  if (!gtk_tree_model_get_iter (tm, &(dst.itr), tpDst))
    {
    gtk_tree_path_free (src.tp) ;
    return ;
    }
  dst.tp = gtk_tree_path_copy (tpDst) ;
  dst.icChildren = gtk_tree_model_iter_n_children (tm, &(dst.itr)) ;

  if (dst.icChildren < src.icChildren)
    {
    min = &dst ;
    max = &src ;
    }
  else
    {
    min = &src ;
    max = &dst ;
    }

  bDstExpanded = gtk_tree_view_row_expanded (gtk_tree_selection_get_tree_view (sel), dst.tp) ;

  g_signal_handlers_block_matched (G_OBJECT (sel), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer)tree_view_selection_changed, NULL) ;

  for (Nix = 0 ; Nix < max->icChildren - min->icChildren ; Nix++)
    gtk_tree_store_append (GTK_TREE_STORE (tm), &itr, &(min->itr)) ;

  gtk_tree_path_down (src.tp) ;
  gtk_tree_path_down (dst.tp) ;

  ar_bSelSrc = exp_array_new (sizeof (gboolean), 1) ;
  ar_bSelDst = exp_array_new (sizeof (gboolean), 1) ;
  exp_array_1d_insert_vals (ar_bSelSrc, NULL, max->icChildren, 0) ;
  exp_array_1d_insert_vals (ar_bSelDst, NULL, max->icChildren, 0) ;

  for (Nix = 0 ; Nix < max->icChildren ; Nix++)
    {
    exp_array_index_1d (ar_bSelSrc, gboolean, Nix) =
      gtk_tree_selection_path_is_selected (sel, src.tp) ;
    exp_array_index_1d (ar_bSelDst, gboolean, Nix) =
      gtk_tree_selection_path_is_selected (sel, dst.tp) ;

    gtk_tree_path_next (src.tp) ;
    gtk_tree_path_next (dst.tp) ;
    }

  if (!gtk_tree_path_up (src.tp)) goto swap_buses_quit ;
  if (!gtk_tree_path_up (dst.tp)) goto swap_buses_quit ;
  gtk_tree_path_down (src.tp) ;
  gtk_tree_path_down (dst.tp) ;

  for (Nix = 0 ; Nix < max->icChildren ; Nix++)
    {
    if (exp_array_index_1d (ar_bSelDst, gboolean, Nix))
      gtk_tree_view_expand_to_path (gtk_tree_selection_get_tree_view (sel), src.tp) ;

    if (exp_array_index_1d (ar_bSelSrc, gboolean, Nix))
      gtk_tree_view_expand_to_path (gtk_tree_selection_get_tree_view (sel), dst.tp) ;

    gtk_tree_path_next (src.tp) ;
    gtk_tree_path_next (dst.tp) ;
    }

  if (!gtk_tree_path_up (src.tp)) goto swap_buses_quit ;
  if (!gtk_tree_path_up (dst.tp)) goto swap_buses_quit ;
  gtk_tree_path_down (src.tp) ;
  gtk_tree_path_down (dst.tp) ;

  for (Nix = 0 ; Nix < max->icChildren ; Nix++)
    {
    swap_model_paths_contents (tm, src.tp, dst.tp) ;
    gtk_tree_path_next (src.tp) ;
    gtk_tree_path_next (dst.tp) ;
    }

  if (!gtk_tree_path_up (src.tp)) goto swap_buses_quit ;
  if (!gtk_tree_path_up (dst.tp)) goto swap_buses_quit ;
  gtk_tree_path_down (src.tp) ;
  gtk_tree_path_down (dst.tp) ;

  for (Nix = 0 ; Nix < max->icChildren ; Nix++)
    {
    GTK_TREE_SELECTION_SET_PATH_SELECTED (sel, src.tp, exp_array_index_1d (ar_bSelDst, gboolean, Nix)) ;
    GTK_TREE_SELECTION_SET_PATH_SELECTED (sel, dst.tp, exp_array_index_1d (ar_bSelSrc, gboolean, Nix)) ;
    gtk_tree_path_next (src.tp) ;
    gtk_tree_path_next (dst.tp) ;
    }

  if (!gtk_tree_path_up (src.tp)) goto swap_buses_quit ;
  if (!gtk_tree_path_up (dst.tp)) goto swap_buses_quit ;

  swap_model_paths_contents (tm, src.tp, dst.tp) ;

  gtk_tree_path_down (src.tp) ;
  gtk_tree_path_down (dst.tp) ;

  for (Nix = 0 ; Nix < min->icChildren ; Nix++)
    gtk_tree_path_next (max->tp) ;
  if (gtk_tree_model_get_iter (tm, &itr, max->tp))
    while (gtk_tree_store_remove (GTK_TREE_STORE (tm), &itr)) ;

  if (!bDstExpanded)
    {
    for (Nix = 0 ; Nix < ar_bSelDst->icUsed ; Nix++)
      if (exp_array_index_1d (ar_bSelDst, gboolean, Nix))
        break ;

    if (Nix == ar_bSelDst->icUsed)
      if (gtk_tree_path_up (src.tp))
        gtk_tree_view_collapse_row (gtk_tree_selection_get_tree_view (sel), src.tp) ;
    }

swap_buses_quit:

  exp_array_free (ar_bSelSrc) ;
  exp_array_free (ar_bSelDst) ;
  gtk_tree_path_free (src.tp) ;
  gtk_tree_path_free (dst.tp) ;
  g_signal_handlers_unblock_matched (G_OBJECT (sel), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer)tree_view_selection_changed, NULL) ;
  tree_view_selection_changed (sel, dialog) ;
  }
Ejemplo n.º 6
0
static void DialogToBusLayout (bus_layout_D *dialog, BUS_LAYOUT *bus_layout)
  {
  GtkTreeModel *tm = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tview)) ;
  int Nix ;
  int icTopLevel = gtk_tree_model_iter_n_children (tm, NULL), icCells = -1 ;
  GtkTreePath *tp = NULL, *tpCells = NULL ;
  GtkTreeIter itr ;
  int Nix1, idxCell = -1 ;
  int row_type ;
  EXP_ARRAY *cell_list = NULL ;
  BUS *bus ;

  // destroy all buses before adding the new ones
  for (Nix = bus_layout->buses->icUsed - 1 ; Nix > -1 ; Nix--)
    {
    exp_array_free (exp_array_index_1d (bus_layout->buses, BUS, Nix).cell_indices) ;
    g_free (exp_array_index_1d (bus_layout->buses, BUS, Nix).pszName) ;
    }
  exp_array_remove_vals (bus_layout->buses, 1, 0, bus_layout->buses->icUsed) ;

  // Since we've destroyed all buses, no cells are members of any bus any longer
  for (Nix = 0 ; Nix < bus_layout->inputs->icUsed ; Nix++)
    exp_array_index_1d (bus_layout->inputs, BUS_LAYOUT_CELL, Nix).bIsInBus = FALSE ;
  for (Nix = 0 ; Nix < bus_layout->outputs->icUsed ; Nix++)
    exp_array_index_1d (bus_layout->outputs, BUS_LAYOUT_CELL, Nix).bIsInBus = FALSE ;

  if (icTopLevel > 0)
    {
    tp = gtk_tree_path_new_first () ;
    for (Nix = 0 ; Nix < icTopLevel ; Nix++, gtk_tree_path_next (tp))
      {
      if (gtk_tree_model_get_iter (tm, &itr, tp))
        {
        gtk_tree_model_get (tm, &itr, BUS_LAYOUT_MODEL_COLUMN_TYPE, &row_type, -1) ;
        if (ROW_TYPE_BUS & row_type)
          {
          exp_array_1d_insert_vals (bus_layout->buses, NULL, 1, -1) ;
          bus = &(exp_array_index_1d (bus_layout->buses, BUS, bus_layout->buses->icUsed - 1)) ;
          gtk_tree_model_get (tm, &itr, BUS_LAYOUT_MODEL_COLUMN_NAME, &(bus->pszName), -1) ;
          if (ROW_TYPE_INPUT & row_type)
            {
            bus->bus_function = QCAD_CELL_INPUT ;
            cell_list = bus_layout->inputs ;
            }
          else
            {
            bus->bus_function = QCAD_CELL_OUTPUT ;
            cell_list = bus_layout->outputs ;
            }
          bus->cell_indices = exp_array_new (sizeof (int), 1) ;
          if ((icCells = gtk_tree_model_iter_n_children (tm, &itr)) > 0)
            {
            gtk_tree_path_down (tpCells = gtk_tree_path_copy (tp)) ;

            for (Nix1 = 0 ; Nix1 < icCells ; Nix1++, gtk_tree_path_next (tpCells))
              if (gtk_tree_model_get_iter (tm, &itr, tpCells))
                {
                gtk_tree_model_get (tm, &itr, BUS_LAYOUT_MODEL_COLUMN_INDEX, &idxCell, -1) ;
                exp_array_1d_insert_vals (bus->cell_indices, &idxCell, 1, -1) ;
                // Flag this cell in the master cell list as a member of some bus
                exp_array_index_1d (cell_list, BUS_LAYOUT_CELL, idxCell).bIsInBus = TRUE ;
                }
            gtk_tree_path_free (tpCells) ;
            }
          }
        }
      }
    gtk_tree_path_free (tp) ;
    }
  }
Ejemplo n.º 7
0
int main (int argc, char **argv)
  {
  VectorTable *pvt = NULL ;
  VTL_RESULT vt_load_result = VTL_OK ;
  int Nix, Nix1, Nix2 ;
  DESIGN *design = NULL, *working_design = NULL ;
  simulation_data *sim_data = NULL ;
  GRand *rnd = NULL ;
  EXP_ARRAY *ref_hcs = NULL, *out_hcs = NULL ;
  HONEYCOMB_DATA *hcdRef = NULL, *hcdOut = NULL ;
  EXP_ARRAY *icSuccesses = NULL ;
  int icOutputBuses = 0 ;
  SIMULATION_OUTPUT *sim_output = NULL ;
  int single_success = 0 ;
  gboolean bDie = FALSE ;
  CMDLINE_ARGS cmdline_args = 
    {
    .bExitOnFailure             = FALSE,
    .bDisplaceInputs            = FALSE,
    .bDisplaceOutputs           = FALSE,
    .number_of_sims             =  1,
    .sim_engine                 = COHERENCE_VECTOR,
    .dTolerance                 =  0.0,
    .dThreshLower               = -0.5,
    .dThreshUpper               =  0.5,
    .icAverageSamples           =  1,
    .pszFailureFNamePrefix      = NULL,
    .pszSimOptsFName            = NULL,
    .pszReferenceSimOutputFName = NULL,
    .pszFName                   = NULL,
    .pszVTFName                 = NULL,
    .circuit_delay              =  0,
    .ignore_from_end            =  0,
    .n_to_displace              = -1,
    .bNormalDisp		= FALSE,
    .dVariance			=  1.0,
    };

  preamble (&argc, &argv) ;

  parse_cmdline (argc, argv, &cmdline_args) ;

  flush_fprintf (stderr,
  _("Simulation engine               : %s\n"
    "Simulation options file         : %s\n"
    "Circuit file                    : %s\n"
    "Reference simulation output file: %s\n"
    "number of simulations           : %d\n"
    "uniform distribution ?	     : %s\n"
    "tolerance                       : %lf\n"
    "variance			     : %lf\n"
    "lower polarization threshold    : %lf\n"
    "upper polarization threshold    : %lf\n"
    "samples for running average     : %d\n"
    "exit on failure ?               : %s\n"
    "failure output file name prefix : %s\n"
    "initial honeycombs to ignore    : %d\n"
    "trailing honeycombs to ignore   : %d\n"
    "displace input cells also?      : %d\n"
    "displace output cells also?     : %d\n"
    "number of cells to displace     : %d\n"
    ),
    SIM_ENGINE_TO_STRING(cmdline_args.sim_engine),
    cmdline_args.pszSimOptsFName,         cmdline_args.pszFName,         cmdline_args.pszReferenceSimOutputFName, 
    cmdline_args.number_of_sims,          cmdline_args.bNormalDisp ? "TRUE" : "FALSE",  cmdline_args.dTolerance,  cmdline_args.dVariance,     
    cmdline_args.dThreshLower,            cmdline_args.dThreshUpper,     cmdline_args.icAverageSamples, cmdline_args.bExitOnFailure ? "TRUE" : "FALSE",
    cmdline_args.pszFailureFNamePrefix,   cmdline_args.circuit_delay, cmdline_args.ignore_from_end, cmdline_args.bDisplaceInputs ? "TRUE" : "FALSE", 
    cmdline_args.bDisplaceOutputs ? "TRUE" : "FALSE", cmdline_args.n_to_displace) ;

#ifdef GTK_GUI
  gtk_init (&argc, &argv) ;
#else
  g_type_init () ;
#endif /* def GTK_GUI */

  if (!open_project_file (cmdline_args.pszFName, &design))
    {
    flush_fprintf (stderr, _("Failed to open file \"%s\"!"), cmdline_args.pszFName) ;
    return 1 ;
    }
  else
  if (NULL == design)
    {
    flush_fprintf (stderr, _("Failed to open file \"%s\"!"), cmdline_args.pszFName) ;
    return 1 ;
    }

  if (NULL == (sim_output = open_simulation_output_file (cmdline_args.pszReferenceSimOutputFName)))
    {
    flush_fprintf (stderr, _("Failed to open the reference simulation output file !\n")) ;
    return 3 ;
    }

  if (NULL != cmdline_args.pszVTFName)
    {
    pvt = VectorTable_new () ;
    if (NULL != pvt->pszFName)
      g_free (pvt->pszFName) ;
    pvt->pszFName = g_strdup (cmdline_args.pszVTFName) ;
    VectorTable_add_inputs (pvt, design) ;
    vt_load_result = VectorTable_load (pvt) ;
    if (VTL_FILE_FAILED == vt_load_result || VTL_MAGIC_FAILED == vt_load_result)
      {
      VectorTable_free (pvt) ;
      pvt = NULL ;
      }
    }

  if (NULL != pvt)
    {
    flush_fprintf (stderr, _("Using the following vector table:\n")) ;
    VectorTable_dump (pvt, stderr, 0) ;
    }

  if (BISTABLE == cmdline_args.sim_engine)
    {
    bistable_OP *bo = NULL ;

    if (NULL == (bo = open_bistable_options_file (cmdline_args.pszSimOptsFName)))
      {
      flush_fprintf (stderr, _("Failed to open simulation options file !\n")) ;
      return 4 ;
      }
    bistable_options_dump (bo, stderr) ;
    memcpy (&bistable_options, bo, sizeof (bistable_OP)) ;
    }

  else
  if (COHERENCE_VECTOR == cmdline_args.sim_engine)
    {
    coherence_OP *co = NULL ;

    if (NULL == (co = open_coherence_options_file (cmdline_args.pszSimOptsFName)))
      {
      flush_fprintf (stderr, _("Failed to open simulation options file !\n")) ;
      return 5 ;
      }
    coherence_options_dump (co, stderr) ;
    memcpy (&coherence_options, co, sizeof (coherence_OP)) ;
    }

#ifdef HAVE_FORTRAN
  else
  if (SEMI_COHERENT == cmdline_args.sim_engine)
    {
    semi_coherent_OP *sco = NULL ;

    if (NULL == (sco = open_semi_coherent_options_file (cmdline_args.pszSimOptsFName)))
      {
      flush_fprintf (stderr, _("Failed to open simulation options file !\n")) ;
      return 5 ;
      }
    semi_coherent_options_dump (sco, stderr) ;
    memcpy (&semi_coherent_options, sco, sizeof (semi_coherent_OP)) ;
    }
	  
  else
  if (TS_FIELD_CLOCK == cmdline_args.sim_engine)
    {
    ts_fc_OP *sco = NULL ;

    if (NULL == (sco = open_ts_fc_options_file (cmdline_args.pszSimOptsFName)))
      {
      flush_fprintf (stderr, _("Failed to open simulation options file !\n")) ;
      return 5 ;
      }
    ts_fc_options_dump (sco, stderr) ;
    memcpy (&ts_fc_options, sco, sizeof (ts_fc_OP)) ;
    }  
#endif /* HAVE_FORTRAN */

  printf (_("Running %d %s with a radial tolerance of %lf\n"), cmdline_args.number_of_sims, 
    1 == cmdline_args.number_of_sims ? _("simulation") : _("simulations"), cmdline_args.dTolerance) ;

  ref_hcs = create_honeycombs_from_buses (sim_output->sim_data, sim_output->bus_layout, QCAD_CELL_OUTPUT, cmdline_args.dThreshLower, cmdline_args.dThreshUpper, cmdline_args.icAverageSamples) ;

  rnd = g_rand_new () ;

  icSuccesses = exp_array_new (sizeof (int), 1) ;
  for (Nix = 0 ; Nix < design->bus_layout->buses->icUsed ; Nix++)
    if (QCAD_CELL_OUTPUT == exp_array_index_1d (design->bus_layout->buses, BUS, Nix).bus_function)
      icOutputBuses++ ;
  exp_array_1d_insert_vals (icSuccesses, NULL, icOutputBuses, 0) ;
  for (Nix = 0 ; Nix < icSuccesses->icUsed ; Nix++)
    exp_array_index_1d (icSuccesses, int, Nix) = 0 ;

  for (Nix = 0 ; Nix < cmdline_args.number_of_sims && !bDie ; Nix++)
    {
    flush_fprintf (stderr, _("Running %s simulation %d of %d\n"), NULL == pvt ? _("exhaustive") : _("vector table"), Nix + 1, cmdline_args.number_of_sims) ;
    if (NULL != (working_design = design_copy (design)))
      {
      VectorTable_fill (pvt, working_design) ;
      // Gotta re-load VT from the file, because VectorTable_fill destroys the vectors
      vt_load_result = VectorTable_load (pvt) ;
      if (VTL_FILE_FAILED == vt_load_result || VTL_MAGIC_FAILED == vt_load_result)
        {
        VectorTable_free (pvt) ;
        pvt = NULL ;
        }
		  if (cmdline_args.n_to_displace != 0) {  
			  if (cmdline_args.bNormalDisp)
			  {
				  randomize_design_cells (rnd, working_design, 0.0, cmdline_args.dTolerance, cmdline_args.bDisplaceInputs, cmdline_args.bDisplaceOutputs, cmdline_args.n_to_displace, cmdline_args.dVariance, TRUE) ;
			  }	
			  else
			  {
				  randomize_design_cells (rnd, working_design, 0.0, cmdline_args.dTolerance, cmdline_args.bDisplaceInputs, cmdline_args.bDisplaceOutputs, cmdline_args.n_to_displace, cmdline_args.dVariance, FALSE) ;
			  }
		  }
        if (NULL != (sim_data = run_simulation (cmdline_args.sim_engine, (NULL == pvt ? EXHAUSTIVE_VERIFICATION : VECTOR_TABLE), working_design, pvt)))
        {
        out_hcs = create_honeycombs_from_buses (sim_data, working_design->bus_layout, QCAD_CELL_OUTPUT, cmdline_args.dThreshLower, cmdline_args.dThreshUpper, cmdline_args.icAverageSamples) ;
        // Print out the results for comparison
        for (Nix1 = 0 ; Nix1 < out_hcs->icUsed && !bDie ; Nix1++)
          {
          if (Nix1 < ref_hcs->icUsed)
            {
            hcdRef = exp_array_index_1d (ref_hcs, HONEYCOMB_DATA *, Nix1) ;
            hcdOut = exp_array_index_1d (out_hcs, HONEYCOMB_DATA *, Nix1) ;

            flush_fprintf (stderr, _("Reference output bus is: (0x%08x)\"%s\"\n"), (int)hcdRef, hcdRef->bus->pszName) ;
            for (Nix2 = 0 ; Nix2 < hcdRef->arHCs->icUsed ; Nix2++)
              flush_fprintf (stderr, "%llu ", exp_array_index_1d (hcdRef->arHCs, HONEYCOMB, Nix2).value) ;
            flush_fprintf (stderr, "\n") ;

            flush_fprintf (stderr, _("Output bus is: (0x%08x)\"%s\"\n"), (int)hcdOut, hcdOut->bus->pszName) ;
            for (Nix2 = 0 ; Nix2 < hcdOut->arHCs->icUsed ; Nix2++)
              flush_fprintf (stderr, "%llu ", exp_array_index_1d (hcdOut->arHCs, HONEYCOMB, Nix2).value) ;
            flush_fprintf (stderr, "\n") ;
            }
          }

        // Compare the output honeycombs to the reference honeycombs
        for (Nix1 = 0 ; Nix1 < out_hcs->icUsed && !bDie ; Nix1++)
          {
          if (Nix1 < ref_hcs->icUsed)
            {
            hcdRef = exp_array_index_1d (ref_hcs, HONEYCOMB_DATA *, Nix1) ;
            hcdOut = exp_array_index_1d (out_hcs, HONEYCOMB_DATA *, Nix1) ;

            single_success =
              determine_success (hcdRef, hcdOut, cmdline_args.circuit_delay, cmdline_args.ignore_from_end) ;

            flush_fprintf (stderr, _("This run[%d] bus[%d] was %s\n"), Nix, Nix1, 0 == single_success ? _("unsuccessful") : _("successful")) ;
			flush_fprintf (stderr, _("hcdOut->arHCs->icUsed equals %d\n"),hcdOut->arHCs->icUsed);
			}
          else
            {
            flush_fprintf (stderr, _("Output has more buses than reference !\n")) ;
            single_success = 0 ;
            }

          if (0 == single_success && cmdline_args.bExitOnFailure)
            {
            if (NULL != cmdline_args.pszFailureFNamePrefix)
              {
              char *psz = NULL ;
              SIMULATION_OUTPUT failed_sim_output = {sim_data, design->bus_layout, FALSE} ;

              psz = g_strdup_printf ("%s.sim_output", cmdline_args.pszFailureFNamePrefix) ;
              fprintf (stderr, _("Creating %s to record the failure.\n"), psz) ;
              create_simulation_output_file (psz, &failed_sim_output) ;
              g_free (psz) ;

              psz = g_strdup_printf ("%s.qca", cmdline_args.pszFailureFNamePrefix) ;
              fprintf (stderr, _("Creating %s to record the failure.\n"), psz) ;
              create_file (psz, working_design) ;
              g_free (psz) ;
              }
            bDie = TRUE ;
            }
          else
            exp_array_index_1d (icSuccesses, int, Nix1) += single_success ;
          }
void VectorTableToDialog (vector_table_options_D *dialog, BUS_LAYOUT *bus_layout, int *sim_type, VectorTable *pvt)
  {
  GList *llCols = NULL, *llItr = NULL ;
  int Nix ;
  GtkTreeModel *model = NULL ;
  GtkWidget *tbtn = NULL ;
  GtkTreeViewColumn *col = NULL ;

  if (NULL == dialog || NULL == sim_type || NULL == pvt) return ;

  g_object_set_data (G_OBJECT (dialog->dialog), "user_sim_type", sim_type) ;
  g_object_set_data (G_OBJECT (dialog->dialog), "user_pvt", pvt) ;
  g_object_set_data (G_OBJECT (dialog->dialog), "user_bus_layout", bus_layout) ;
  g_object_set_data (G_OBJECT (dialog->dialog), "idxVector", (gpointer)-1) ;

  if (0 == bus_layout->inputs->icUsed)
    (*sim_type) = EXHAUSTIVE_VERIFICATION ;

  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tbtn = (VECTOR_TABLE == (*sim_type) ? dialog->tbtnVT : dialog->tbtnExhaustive)), TRUE) ;

  g_object_set_data (G_OBJECT (dialog->crActive), "pvt", pvt) ;

  if (NULL != (model = GTK_TREE_MODEL (design_bus_layout_tree_store_new (bus_layout, ROW_TYPE_INPUT, 1, G_TYPE_BOOLEAN))))
    {
    gboolean bActive = FALSE ;
    GtkTreeIter itr, itrChild ;
    int row_type = -1, idx = -1 ;
    QCADCell *cell = NULL ;
    gboolean bBusActive = FALSE ;

    // First reflect the active_flag of current cell inputs
    if (gtk_tree_model_get_iter_first (model, &itr))
      while (TRUE)
        {
        gtk_tree_model_get (model, &itr, 
          BUS_LAYOUT_MODEL_COLUMN_TYPE, &row_type,
          BUS_LAYOUT_MODEL_COLUMN_CELL, &cell, -1) ;
        if (ROW_TYPE_CELL_INPUT == row_type && NULL != cell)
          if (-1 != (idx = VectorTable_find_input_idx (pvt, cell)))
            gtk_tree_store_set (GTK_TREE_STORE (model), &itr, 
              VECTOR_TABLE_MODEL_COLUMN_ACTIVE, exp_array_index_1d (pvt->inputs, VT_INPUT, idx).active_flag, -1) ;
        if (!gtk_tree_model_iter_next_dfs (model, &itr)) break ;
        }

    // For any given bus, if any of its cells are active, then the bus is active. Reflect this.
    if (gtk_tree_model_get_iter_first (model, &itr))
      while (TRUE)
        {
        bBusActive = FALSE ;
        if (gtk_tree_model_iter_children (model, &itrChild, &itr))
          {
          while (TRUE)
            {
            gtk_tree_model_get (model, &itrChild, VECTOR_TABLE_MODEL_COLUMN_ACTIVE, &bActive, -1) ;
            if ((bBusActive = bActive)) break ;
            if (!gtk_tree_model_iter_next (model, &itrChild)) break ;
            }
          gtk_tree_store_set (GTK_TREE_STORE (model), &itr, VECTOR_TABLE_MODEL_COLUMN_ACTIVE, bBusActive, -1) ;
          }
        if (!gtk_tree_model_iter_next (model, &itr)) break ;
        }

    llCols = gtk_tree_view_get_columns (GTK_TREE_VIEW (dialog->tv)) ;
    for (Nix = 0, llItr = llCols ; Nix < 2 && NULL != llItr ; Nix++, llItr = llItr->next) ;
    for (; llItr != NULL ; llItr = llItr->next)
      gtk_tree_view_remove_column (GTK_TREE_VIEW (dialog->tv), GTK_TREE_VIEW_COLUMN (llItr->data)) ;
    g_list_free (llCols) ;

    gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->tv), model) ;
    }

  gtk_tree_view_expand_all (GTK_TREE_VIEW (dialog->tv)) ;

  for (Nix = 0 ; Nix < pvt->vectors->icUsed ; Nix++)
    {
    if (NULL == col)
      col = add_vector_to_dialog (dialog, pvt, Nix) ;
    else
      add_vector_to_dialog (dialog, pvt, Nix) ;
    // Give the dialog a chance to update itself
    if (0 == Nix % 10)
      while (gtk_events_pending ())
        gtk_main_iteration () ;
    }

  if (NULL != col)
    gtk_tree_view_column_clicked (col) ;

  if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (tbtn)))
    vector_table_options_dialog_btnSimType_clicked (tbtn, dialog) ;

  vector_table_options_dialog_reflect_state (dialog) ;
  }
Ejemplo n.º 9
0
void sorted_cells_to_CUDA_Structures_array(
    QCADCell ***sorted_cells,
    double **h_polarization,
    int **h_cell_clock,
    double **h_Ek,
    int **h_neighbours,
    int number_of_cell_layers,
    int *number_of_cells_in_layer,
    int* neighbours_number,
    int** input_indexes,
    int* input_number,
    int** output_indexes,
    int* output_number,
    DESIGN *design
)
{

// Allocate memory for all needed structures
    int i,iLayer, iCell, iNeighbour;
    *neighbours_number = 0;
    int counter = 0;
    int input_counter = 0;
    int output_counter = 0;
    int cells_number = 0;
    int j, ambros;
    BUS_LAYOUT_ITER bli;
    int idxMasterBitOrder;

    /*h_clock_data = (double *) malloc(number_of_samples * 4 * sizeof(double));

    for(j = 0; j < number_of_samples; j++)
      {
        for(ambros=0; ambros<4;ambros++){
          (*h_clock_data)[j * 4 + ambros] = (double)clock_source[ambros].data[j];
        }
      } */



    for(i = 0; i < number_of_cell_layers; i++)
        cells_number+= number_of_cells_in_layer[i];


    tmp = (int*)malloc(cells_number*sizeof(int));

//init neighbours_number
    for( iLayer = 0; iLayer < number_of_cell_layers; iLayer++) {
        for (iCell = 0; iCell < number_of_cells_in_layer[iLayer]; iCell++) {
            if(*neighbours_number < ((bistable_model *)sorted_cells[iLayer][iCell]->cell_model)->number_of_neighbours) {
                *neighbours_number = ((bistable_model *)sorted_cells[iLayer][iCell]->cell_model)->number_of_neighbours;
            }
        }
    }


    *h_polarization = (double*) malloc(cells_number*sizeof(double));
    *h_cell_clock = (int*) malloc(cells_number*sizeof(double));
    *h_Ek = (double*) malloc(*neighbours_number*cells_number*sizeof(double));
    *h_neighbours = (int*) malloc(*neighbours_number*cells_number*sizeof(int));


//fill tmp and count number of inputs
    for( iLayer = 0, counter =0; iLayer < number_of_cell_layers; iLayer++) {
        for (iCell = 0; iCell < number_of_cells_in_layer[iLayer]; iCell++,counter++)
        {
            tmp[counter] = sorted_cells[iLayer][iCell]->id;
            if (sorted_cells[iLayer][iCell]->cell_function == QCAD_CELL_INPUT)
            {
                input_counter++;
            }
            else if (sorted_cells[iLayer][iCell]->cell_function == QCAD_CELL_OUTPUT)
            {
                output_counter++;
            }
        }
    }


    *input_number = input_counter;
    *output_number = output_counter;

    *input_indexes = (int *)malloc(*input_number * sizeof(int));
    *output_indexes = (int *)malloc(*output_number * sizeof(int));

    for (design_bus_layout_iter_first (design_bus_layout, &bli, QCAD_CELL_OUTPUT, &i) ; i > -1 ; design_bus_layout_iter_next (&bli, &i))
    {
        for( iLayer = 0,counter =0; iLayer < number_of_cell_layers; iLayer++) {
            for (iCell = 0; iCell < number_of_cells_in_layer[iLayer]; iCell++,counter++)
            {
                if(sorted_cells[iLayer][iCell]==exp_array_index_1d (design_bus_layout_outputs, BUS_LAYOUT_CELL, i).cell)
                {
                    (*output_indexes)[i] = counter;
                }
            }
        }

    }

    for (idxMasterBitOrder = 0, design_bus_layout_iter_first (design_bus_layout, &bli, QCAD_CELL_INPUT, &i) ; i > -1 ; design_bus_layout_iter_next (&bli, &i), idxMasterBitOrder++)
    {
        for( iLayer = 0,counter =0; iLayer < number_of_cell_layers; iLayer++) {
            for (iCell = 0; iCell < number_of_cells_in_layer[iLayer]; iCell++,counter++)
            {
                if(sorted_cells[iLayer][iCell]==exp_array_index_1d (design_bus_layout_inputs, BUS_LAYOUT_CELL, i).cell)
                {
                    (*input_indexes)[idxMasterBitOrder] = counter;
                    //printf("IdxM:%d,inputidx:%d\n",idxMasterBitOrder,counter);
                }
            }
        }
    }


//input_counter = 0;
//output_counter = 0;
//init neighbours values to -1 and fill input_indexes
    for( iLayer = 0,counter =0; iLayer < number_of_cell_layers; iLayer++) {
        for (iCell = 0; iCell < number_of_cells_in_layer[iLayer]; iCell++,counter++)
        {
            /*if(sorted_cells[iLayer][iCell]->cell_function == QCAD_CELL_INPUT)
            {
            	(*input_indexes)[input_counter] = counter;
            	input_counter++;
            }
            else if(sorted_cells[iLayer][iCell]->cell_function == QCAD_CELL_OUTPUT)
            {
            	(*output_indexes)[output_counter] = counter;
            	output_counter++;
            }*/
            for(i=0; i<*neighbours_number; i++)
            {
                (*h_neighbours)[counter + i*cells_number] = -1;
                (*h_Ek)[counter + i*cells_number] = 0.0;
            }
        }
    }


    counter =0;

//fill structures
    for( iLayer = 0; iLayer < number_of_cell_layers; iLayer++)
    {
        for (iCell = 0; iCell < number_of_cells_in_layer[iLayer]; iCell++)
        {
            (*h_polarization)[counter] = (double)((bistable_model*)(sorted_cells[iLayer][iCell]->cell_model))->polarization;
            (*h_cell_clock)[counter] = sorted_cells[iLayer][iCell]->cell_options.clock;
            for ( iNeighbour = 0; iNeighbour < ((bistable_model *)(sorted_cells[iLayer][iCell]->cell_model))->number_of_neighbours; iNeighbour++)
            {
                (*h_Ek)[counter + iNeighbour*cells_number]=(double)((bistable_model *)(sorted_cells[iLayer][iCell]->cell_model))->Ek[iNeighbour];
                if(sorted_cells[iLayer][iCell]->cell_function != QCAD_CELL_INPUT && sorted_cells[iLayer][iCell]->cell_function != QCAD_CELL_FIXED)
                    (*h_neighbours)[counter + iNeighbour*cells_number]= position_in_CUDA_array(((QCADCell*)((bistable_model *)(sorted_cells[iLayer][iCell]->cell_model))->neighbours[iNeighbour])->id,cells_number);

            }
            counter++;
        }
    }
    free(tmp);




}
Ejemplo n.º 10
0
static void stretch_draw_state_change (QCADStretchyObject *obj, int x, int y, int xRef, int yRef)
  {
  int Nix ;
  QCADRuler *ruler = QCAD_RULER (obj) ;
  int xMIN = MIN (x, xRef), xMAX = MAX (x, xRef), yMIN = MIN (y, yRef), yMAX = MAX (y, yRef) ;
  QCADStretchyObjectClass *klass = QCAD_STRETCHY_OBJECT_CLASS (g_type_class_peek (g_type_parent (QCAD_TYPE_RULER))) ;

  if (NULL != klass->stretch_draw_state_change)
    klass->stretch_draw_state_change (obj, x, y, xRef, yRef) ;

  ruler->ruler_bounding_box.xWorld = real_to_world_x (xMIN) ;
  ruler->ruler_bounding_box.yWorld = real_to_world_y (yMIN) ;
  ruler->ruler_bounding_box.cxWorld = real_to_world_cx (xMAX - xMIN) ;
  ruler->ruler_bounding_box.cyWorld = real_to_world_cy (yMAX - yMIN) ;

  memcpy (&(QCAD_DESIGN_OBJECT (obj)->bounding_box), &(ruler->ruler_bounding_box), sizeof (WorldRectangle)) ;

  for (Nix = 0 ; Nix < ruler->icLabelsVisible ; Nix++)
    world_rect_union (&(QCAD_DESIGN_OBJECT (obj)->bounding_box), &(QCAD_DESIGN_OBJECT (exp_array_index_1d (ruler->labels, GRADUATION, Nix).lbl)->bounding_box), &(QCAD_DESIGN_OBJECT (obj)->bounding_box)) ;

  QCAD_RULER (obj)->orientation =
    QCAD_RULER_CALCULATE_ORIENTATION (
      ruler->ruler_bounding_box.cxWorld,
      ruler->ruler_bounding_box.cyWorld, x, y, xRef, yRef) ;
  }