diff options
| author | Clifford Wolf <clifford@clifford.at> | 2014-02-06 19:22:46 +0100 | 
|---|---|---|
| committer | Clifford Wolf <clifford@clifford.at> | 2014-02-06 19:22:46 +0100 | 
| commit | fa295a4528513d6beeff638520d519faafd99324 (patch) | |
| tree | b11afcff018bdb515596ec4b89dac9ff6a514931 | |
| parent | d4b0f28881e361f53b61e67c4cb5cd04c196d204 (diff) | |
| download | yosys-fa295a4528513d6beeff638520d519faafd99324.tar.gz yosys-fa295a4528513d6beeff638520d519faafd99324.tar.bz2 yosys-fa295a4528513d6beeff638520d519faafd99324.zip | |
Added generic RTLIL::SigSpec::parse_sel() with support for selection variables
| -rw-r--r-- | kernel/rtlil.cc | 18 | ||||
| -rw-r--r-- | kernel/rtlil.h | 1 | ||||
| -rw-r--r-- | passes/cmds/connect.cc | 6 | ||||
| -rw-r--r-- | passes/sat/eval.cc | 8 | ||||
| -rw-r--r-- | passes/sat/sat.cc | 43 | 
5 files changed, 39 insertions, 37 deletions
| diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 2ab3320bd..95d62503c 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -1649,6 +1649,24 @@ bool RTLIL::SigSpec::parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::stri  	return true;  } +bool RTLIL::SigSpec::parse_sel(RTLIL::SigSpec &sig, RTLIL::Design *design, RTLIL::Module *module, std::string str) +{ +	if (str.empty() || str[0] != '@') +		return parse(sig, module, str); + +	str = RTLIL::escape_id(str.substr(1)); +	if (design->selection_vars.count(str) == 0) +		return false; + +	sig = RTLIL::SigSpec(); +	RTLIL::Selection &sel = design->selection_vars.at(str); +	for (auto &it : module->wires) +		if (sel.selected_member(module->name, it.first)) +			sig.append(it.second); + +	return true; +} +  bool RTLIL::SigSpec::parse_rhs(const RTLIL::SigSpec &lhs, RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str)  {  	if (str == "0") { diff --git a/kernel/rtlil.h b/kernel/rtlil.h index df0e94dcc..caadf1981 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -411,6 +411,7 @@ struct RTLIL::SigSpec {  	std::vector<RTLIL::SigBit> to_sigbit_vector() const;  	RTLIL::SigBit to_single_sigbit() const;  	static bool parse(RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str); +	static bool parse_sel(RTLIL::SigSpec &sig, RTLIL::Design *design, RTLIL::Module *module, std::string str);  	static bool parse_rhs(const RTLIL::SigSpec &lhs, RTLIL::SigSpec &sig, RTLIL::Module *module, std::string str);  }; diff --git a/passes/cmds/connect.cc b/passes/cmds/connect.cc index 7a54e8dc6..7da2b9517 100644 --- a/passes/cmds/connect.cc +++ b/passes/cmds/connect.cc @@ -137,7 +137,7 @@ struct ConnectPass : public Pass {  				log_cmd_error("Cant use -set together with -unset and/or -port.\n");  			RTLIL::SigSpec sig_lhs, sig_rhs; -			if (!RTLIL::SigSpec::parse(sig_lhs, module, set_lhs)) +			if (!RTLIL::SigSpec::parse_sel(sig_lhs, design, module, set_lhs))  				log_cmd_error("Failed to parse set lhs expression `%s'.\n", set_lhs.c_str());  			if (!RTLIL::SigSpec::parse_rhs(sig_lhs, sig_rhs, module, set_rhs))  				log_cmd_error("Failed to parse set rhs expression `%s'.\n", set_rhs.c_str()); @@ -157,7 +157,7 @@ struct ConnectPass : public Pass {  				log_cmd_error("Cant use -unset together with -port and/or -nounset.\n");  			RTLIL::SigSpec sig; -			if (!RTLIL::SigSpec::parse(sig, module, unset_expr)) +			if (!RTLIL::SigSpec::parse_sel(sig, design, module, unset_expr))  				log_cmd_error("Failed to parse unset expression `%s'.\n", unset_expr.c_str());  			sigmap.apply(sig); @@ -173,7 +173,7 @@ struct ConnectPass : public Pass {  				log_cmd_error("Can't find cell %s.\n", port_cell.c_str());  			RTLIL::SigSpec sig; -			if (!RTLIL::SigSpec::parse(sig, module, port_expr)) +			if (!RTLIL::SigSpec::parse_sel(sig, design, module, port_expr))  				log_cmd_error("Failed to parse port expression `%s'.\n", port_expr.c_str());  			module->cells.at(RTLIL::escape_id(port_cell))->connections[RTLIL::escape_id(port_port)] = sigmap(sig); diff --git a/passes/sat/eval.cc b/passes/sat/eval.cc index 5d36b474c..5c38cc2cf 100644 --- a/passes/sat/eval.cc +++ b/passes/sat/eval.cc @@ -464,7 +464,7 @@ struct EvalPass : public Pass {  		for (auto &it : sets) {  			RTLIL::SigSpec lhs, rhs; -			if (!RTLIL::SigSpec::parse(lhs, module, it.first)) +			if (!RTLIL::SigSpec::parse_sel(lhs, design, module, it.first))  				log_cmd_error("Failed to parse lhs set expression `%s'.\n", it.first.c_str());  			if (!RTLIL::SigSpec::parse_rhs(lhs, rhs, module, it.second))  				log_cmd_error("Failed to parse rhs set expression `%s'.\n", it.second.c_str()); @@ -486,7 +486,7 @@ struct EvalPass : public Pass {  		{  			for (auto &it : shows) {  				RTLIL::SigSpec signal, value, undef; -				if (!RTLIL::SigSpec::parse(signal, module, it)) +				if (!RTLIL::SigSpec::parse_sel(signal, design, module, it))  					log_cmd_error("Failed to parse show expression `%s'.\n", it.c_str());  				signal.optimize();  				value = signal; @@ -513,14 +513,14 @@ struct EvalPass : public Pass {  			for (auto &it : shows) {  				RTLIL::SigSpec sig; -				if (!RTLIL::SigSpec::parse(sig, module, it)) +				if (!RTLIL::SigSpec::parse_sel(sig, design, module, it))  					log_cmd_error("Failed to parse show expression `%s'.\n", it.c_str());  				signal.append(sig);  			}  			for (auto &it : tables) {  				RTLIL::SigSpec sig; -				if (!RTLIL::SigSpec::parse(sig, module, it)) +				if (!RTLIL::SigSpec::parse_sel(sig, design, module, it))  					log_cmd_error("Failed to parse table expression `%s'.\n", it.c_str());  				tabsigs.append(sig);  			} diff --git a/passes/sat/sat.cc b/passes/sat/sat.cc index 378546539..c08271590 100644 --- a/passes/sat/sat.cc +++ b/passes/sat/sat.cc @@ -111,7 +111,7 @@ struct SatHelper  		{  			RTLIL::SigSpec lhs, rhs; -			if (!RTLIL::SigSpec::parse(lhs, module, s.first)) +			if (!RTLIL::SigSpec::parse_sel(lhs, design, module, s.first))  				log_cmd_error("Failed to parse lhs set expression `%s'.\n", s.first.c_str());  			if (!RTLIL::SigSpec::parse_rhs(lhs, rhs, module, s.second))  				log_cmd_error("Failed to parse rhs set expression `%s'.\n", s.second.c_str()); @@ -180,7 +180,7 @@ struct SatHelper  		{  			RTLIL::SigSpec lhs, rhs; -			if (!RTLIL::SigSpec::parse(lhs, module, s.first)) +			if (!RTLIL::SigSpec::parse_sel(lhs, design, module, s.first))  				log_cmd_error("Failed to parse lhs set expression `%s'.\n", s.first.c_str());  			if (!RTLIL::SigSpec::parse_rhs(lhs, rhs, module, s.second))  				log_cmd_error("Failed to parse rhs set expression `%s'.\n", s.second.c_str()); @@ -201,7 +201,7 @@ struct SatHelper  		{  			RTLIL::SigSpec lhs, rhs; -			if (!RTLIL::SigSpec::parse(lhs, module, s.first)) +			if (!RTLIL::SigSpec::parse_sel(lhs, design, module, s.first))  				log_cmd_error("Failed to parse lhs set expression `%s'.\n", s.first.c_str());  			if (!RTLIL::SigSpec::parse_rhs(lhs, rhs, module, s.second))  				log_cmd_error("Failed to parse rhs set expression `%s'.\n", s.second.c_str()); @@ -222,7 +222,7 @@ struct SatHelper  		{  			RTLIL::SigSpec lhs; -			if (!RTLIL::SigSpec::parse(lhs, module, s)) +			if (!RTLIL::SigSpec::parse_sel(lhs, design, module, s))  				log_cmd_error("Failed to parse lhs set expression `%s'.\n", s.c_str());  			show_signal_pool.add(sigmap(lhs)); @@ -241,28 +241,28 @@ struct SatHelper  		for (auto &s : sets_def) {  			RTLIL::SigSpec sig; -			if (!RTLIL::SigSpec::parse(sig, module, s)) +			if (!RTLIL::SigSpec::parse_sel(sig, design, module, s))  				log_cmd_error("Failed to parse set-def expression `%s'.\n", s.c_str());  			sets_def_undef[0].insert(sig);  		}  		for (auto &s : sets_any_undef) {  			RTLIL::SigSpec sig; -			if (!RTLIL::SigSpec::parse(sig, module, s)) +			if (!RTLIL::SigSpec::parse_sel(sig, design, module, s))  				log_cmd_error("Failed to parse set-def expression `%s'.\n", s.c_str());  			sets_def_undef[1].insert(sig);  		}  		for (auto &s : sets_all_undef) {  			RTLIL::SigSpec sig; -			if (!RTLIL::SigSpec::parse(sig, module, s)) +			if (!RTLIL::SigSpec::parse_sel(sig, design, module, s))  				log_cmd_error("Failed to parse set-def expression `%s'.\n", s.c_str());  			sets_def_undef[2].insert(sig);  		}  		for (auto &s : sets_def_at[timestep]) {  			RTLIL::SigSpec sig; -			if (!RTLIL::SigSpec::parse(sig, module, s)) +			if (!RTLIL::SigSpec::parse_sel(sig, design, module, s))  				log_cmd_error("Failed to parse set-def expression `%s'.\n", s.c_str());  			sets_def_undef[0].insert(sig);  			sets_def_undef[1].erase(sig); @@ -271,7 +271,7 @@ struct SatHelper  		for (auto &s : sets_any_undef_at[timestep]) {  			RTLIL::SigSpec sig; -			if (!RTLIL::SigSpec::parse(sig, module, s)) +			if (!RTLIL::SigSpec::parse_sel(sig, design, module, s))  				log_cmd_error("Failed to parse set-def expression `%s'.\n", s.c_str());  			sets_def_undef[0].erase(sig);  			sets_def_undef[1].insert(sig); @@ -280,7 +280,7 @@ struct SatHelper  		for (auto &s : sets_all_undef_at[timestep]) {  			RTLIL::SigSpec sig; -			if (!RTLIL::SigSpec::parse(sig, module, s)) +			if (!RTLIL::SigSpec::parse_sel(sig, design, module, s))  				log_cmd_error("Failed to parse set-def expression `%s'.\n", s.c_str());  			sets_def_undef[0].erase(sig);  			sets_def_undef[1].erase(sig); @@ -329,7 +329,7 @@ struct SatHelper  			{  				RTLIL::SigSpec lhs, rhs; -				if (!RTLIL::SigSpec::parse(lhs, module, s.first)) +				if (!RTLIL::SigSpec::parse_sel(lhs, design, module, s.first))  					log_cmd_error("Failed to parse lhs proof expression `%s'.\n", s.first.c_str());  				if (!RTLIL::SigSpec::parse_rhs(lhs, rhs, module, s.second))  					log_cmd_error("Failed to parse rhs proof expression `%s'.\n", s.second.c_str()); @@ -357,7 +357,7 @@ struct SatHelper  			{  				RTLIL::SigSpec lhs, rhs; -				if (!RTLIL::SigSpec::parse(lhs, module, s.first)) +				if (!RTLIL::SigSpec::parse_sel(lhs, design, module, s.first))  					log_cmd_error("Failed to parse lhs proof-x expression `%s'.\n", s.first.c_str());  				if (!RTLIL::SigSpec::parse_rhs(lhs, rhs, module, s.second))  					log_cmd_error("Failed to parse rhs proof-x expression `%s'.\n", s.second.c_str()); @@ -509,7 +509,7 @@ struct SatHelper  		{  			for (auto &s : shows) {  				RTLIL::SigSpec sig; -				if (!RTLIL::SigSpec::parse(sig, module, s)) +				if (!RTLIL::SigSpec::parse_sel(sig, design, module, s))  					log_cmd_error("Failed to parse show expression `%s'.\n", s.c_str());  				log("Import show expression: %s\n", log_signal(sig));  				modelSig.append(sig); @@ -733,10 +733,6 @@ struct SatPass : public Pass {  		log("        show the model for the specified signal. if no -show option is\n");  		log("        passed then a set of signals to be shown is automatically selected.\n");  		log("\n"); -		log("    -show @<sel_name>\n"); -		log("        add all wires from the specified selection (see help select) to\n"); -		log("        the list of signals to be shown.\n"); -		log("\n");  		log("    -show-inputs, -show-outputs\n");  		log("        add all module input (output) ports to the list of shown signals\n");  		log("\n"); @@ -1026,19 +1022,6 @@ struct SatPass : public Pass {  					sets_def.push_back(it.second->name);  		} -		for (auto &str : shows) { -			if (str.empty() || str[0] != '@') -				continue; -			str = RTLIL::escape_id(str.substr(1)); -			if (design->selection_vars.count(str) == 0) -				log_cmd_error("Selection %s is not defined!\n", RTLIL::id2cstr(str)); -			RTLIL::Selection &sel = design->selection_vars.at(str); -			str.clear(); -			for (auto &it : module->wires) -				if (sel.selected_member(module->name, it.first)) -					str += (str.empty() ? "" : ",") + it.first; -		} -  		if (show_inputs) {  			for (auto &it : module->wires)  				if (it.second->port_input) | 
