#ifndef UDEFFLAGS_H
#define UDEFFLAGS_H
+#include <map>
+#include <string>
+#include <assert.h>
+#include <iostream>
namespace BEEV
{
+ using std::string;
/******************************************************************
* Struct UserDefFlags:
enum SATSolvers solver_to_use;
+ std::map<string,string> config_options;
+
+ void set(string n, string v)
+ {
+ assert(n.size() > 0);
+ assert(v.size() > 0);
+ assert(config_options.find(n) == config_options.end());
+ config_options[n] = v;
+ }
+
+ string get(string n)
+ {
+ return get(n,"");
+ }
+
+ string get(string n, string def)
+ {
+ if (config_options.empty())
+ return def;
+
+ string result;
+ std::map<string,string>::iterator it = config_options.find(n);
+ if (it == config_options.end())
+ result = def;
+ else
+ result = it->second;
+
+ if (stats_flag)
+ std::cout << n << ":" << result << std::endl;
+
+ return result;
+ }
+
//CONSTRUCTOR
UserDefinedFlags()
{
- //collect statistics on certain functions
+
+ //collect statistics on certain functions
stats_flag = false;
//print DAG nodes
lookup.insert(make_pair(tolower("--SMTLIB1"),SMT_LIB1_FORMAT));
lookup.insert(make_pair(tolower("--disable-cbitp"),DISABLE_CBITP));
+ if (!strncmp(argv[i],"--config_",strlen("--config_")))
+ {
+ // Must contain an equals.
+ // Must contain a name >=1 character long.
+ // Must contain a value >=1 char.
+ string s(argv[i]);
+ size_t a = s.find("_");
+ size_t b = s.find("=");
+ if (a== string::npos || b == string::npos || b < a || b==a+1 || b==s.length()-1)
+ {
+ fprintf(stderr,usage,prog);
+ cout << helpstring;
+ return -1;
+ break;
+ }
+
+ string name = s.substr(a+1,b-a-1);
+ string value = s.substr(b+1);
+
+ bm->UserFlags.set(name,value);
+ }
+ else
switch(lookup[tolower(argv[i])])
{
}
-// ONLY SELECT ONE OF THESE!
-const bool multiplication_variant1 = false; // multiplication with repeat addition.
-const bool multiplication_variant2 = false; // multiplication with partial products.
-const bool multiplication_variant3 = true; // multiplication with booth recoding.
-const bool multiplication_variant4 = false; // multiplication via sorting networks.
-const bool multiplication_variant5 = false; // Using bounds.
-
-
// Multiply two bitblasted numbers
template <class BBNode, class BBNodeManagerT>
BBNodeVec BitBlaster<BBNode,BBNodeManagerT>::BBMult(const BBNodeVec& _x, const BBNodeVec& _y,
y = _x;
}
+ string mv = uf->get("multiplication_variant","3");
+
const int bitWidth = x.size();
+ stack<BBNode> products[bitWidth];
- if (multiplication_variant1) {
- //cout << "v1";
+ if (mv == "1") {
+ //cerr << "v1";
return mult_normal(x, y, support);
}
-
- stack<BBNode> products[bitWidth];
-
- if (multiplication_variant2) {
+ else if (mv == "2") {
//cout << "v2";
mult_allPairs(x, y, support,products);
return buildAdditionNetworkResult(products,support, bitWidth);
}
- if (multiplication_variant3) {
- //cout << "v3";
+ else if (mv == "3") {
+ //cout << "v3" << endl;
mult_Booth(_x, _y, support,n[0],n[1],products);
return buildAdditionNetworkResult(products,support,bitWidth);
}
-
- if (multiplication_variant4)
+ else if (mv == "4")
{
//cout << "v4";
mult_Booth(_x, _y, support,n[0],n[1],products);
}
return buildAdditionNetworkResult(products,support, bitWidth);
}
-
- if (multiplication_variant5)
+ else if (mv == "5")
{
//cout << "v5";
if (!statsFound(n))
mult_allPairs(x, y, support, products);
return multWithBounds(n, products, support);
}
-
- FatalError("sda44f");
+ else
+ FatalError("sda44f");
}
//======