From d2106a3d3ac49d6aa914a7f6afa78c3ac5ecc009 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Fri, 23 May 2008 10:29:44 -0700 Subject: [PATCH] Fix botched processing of MUX with constant select. If the select input was constant, the code then tried to look at the constant data input. Just plain wrong. --- compiler.h | 1 + cprop.cc | 8 +++++++- main.cc | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/compiler.h b/compiler.h index 6b654e6e2..2b38802be 100644 --- a/compiler.h +++ b/compiler.h @@ -86,6 +86,7 @@ extern bool debug_scopes; extern bool debug_eval_tree; extern bool debug_elaborate; extern bool debug_synth2; +extern bool debug_optimizer; /* Path to a directory useful for finding subcomponents. */ extern const char*basedir; diff --git a/cprop.cc b/cprop.cc index d216d5d25..9345b9ea8 100644 --- a/cprop.cc +++ b/cprop.cc @@ -23,6 +23,7 @@ # include "netlist.h" # include "netmisc.h" # include "functor.h" +# include "compiler.h" # include "ivl_assert.h" @@ -831,11 +832,16 @@ void cprop_functor::lpm_mux(Design*des, NetMux*obj) /* If the select input is constant, then replace with a BUFZ */ flag = obj->pin_Sel().nexus()->drivers_constant(); - verinum::V sel_val = flag? obj->pin_Data(1).nexus()->driven_value() : verinum::Vx; + verinum::V sel_val = flag? obj->pin_Sel().nexus()->driven_value() : verinum::Vx; if ((sel_val != verinum::Vz) && (sel_val != verinum::Vx)) { NetBUFZ*tmp = new NetBUFZ(obj->scope(), obj->name(), obj->width()); tmp->set_line(*obj); + if (debug_optimizer) + cerr << obj->get_fileline() << ": debug: " + << "Replace binary MUX with constant select=" << sel_val + << " with a BUFZ to the selected input." << endl; + tmp->rise_time(obj->rise_time()); tmp->fall_time(obj->fall_time()); tmp->decay_time(obj->decay_time()); diff --git a/main.cc b/main.cc index 679e321dc..640fcf4d3 100644 --- a/main.cc +++ b/main.cc @@ -124,6 +124,8 @@ bool debug_scopes = false; bool debug_eval_tree = false; bool debug_elaborate = false; bool debug_synth2 = false; +bool debug_optimizer = false; + /* * Verbose messages enabled. */ @@ -391,6 +393,9 @@ static void read_iconfig_file(const char*ipath) } else if (strcmp(cp,"synth2") == 0) { debug_synth2 = true; cerr << "debug: Enable synth2 debug" << endl; + } else if (strcmp(cp,"optimizer") == 0) { + debug_optimizer = true; + cerr << "debug: Enable optimizer debug" << endl; } else { }