diff options
| author | Miodrag Milanovic <mmicko@gmail.com> | 2019-08-09 09:46:37 +0200 | 
|---|---|---|
| committer | Miodrag Milanovic <mmicko@gmail.com> | 2019-08-09 09:46:37 +0200 | 
| commit | 7a860c562323b8279cdbb8626a47ac8466c78b4c (patch) | |
| tree | d713b5c04ab34aadcbd310237a8cc46951f83e37 /frontends | |
| parent | 8a3329871ba7bab98982a101327b8375cd73344d (diff) | |
| parent | ac2fc3a144fe1094bedcc6b3fda8a498ad43ae76 (diff) | |
| download | yosys-7a860c562323b8279cdbb8626a47ac8466c78b4c.tar.gz yosys-7a860c562323b8279cdbb8626a47ac8466c78b4c.tar.bz2 yosys-7a860c562323b8279cdbb8626a47ac8466c78b4c.zip | |
Merge remote-tracking branch 'upstream/master' into efinix
Diffstat (limited to 'frontends')
| -rw-r--r-- | frontends/aiger/aigerparse.cc | 32 | ||||
| -rw-r--r-- | frontends/aiger/aigerparse.h | 2 | ||||
| -rw-r--r-- | frontends/ast/ast.cc | 2 | ||||
| -rw-r--r-- | frontends/ast/simplify.cc | 17 | ||||
| -rw-r--r-- | frontends/json/jsonparse.cc | 57 | 
5 files changed, 47 insertions, 63 deletions
| diff --git a/frontends/aiger/aigerparse.cc b/frontends/aiger/aigerparse.cc index bb97c5703..85ee34e2d 100644 --- a/frontends/aiger/aigerparse.cc +++ b/frontends/aiger/aigerparse.cc @@ -337,7 +337,7 @@ static RTLIL::Wire* createWireIfNotExists(RTLIL::Module *module, unsigned litera  	return wire;  } -void AigerReader::parse_xaiger() +void AigerReader::parse_xaiger(const dict<int,IdString> &box_lookup)  {  	std::string header;  	f >> header; @@ -373,21 +373,6 @@ void AigerReader::parse_xaiger()  	if (n0)  		module->connect(n0, RTLIL::S0); -	dict<int,IdString> box_lookup; -	for (auto m : design->modules()) { -		auto it = m->attributes.find("\\abc_box_id"); -		if (it == m->attributes.end()) -			continue; -		if (m->name.begins_with("$paramod")) -			continue; -		auto id = it->second.as_int(); -		auto r = box_lookup.insert(std::make_pair(id, m->name)); -		if (!r.second) -			log_error("Module '%s' has the same abc_box_id = %d value as '%s'.\n", -					log_id(m), id, log_id(r.first->second)); -		log_assert(r.second); -	} -  	// Parse footer (symbol table, comments, etc.)  	std::string s;  	bool comment_seen = false; @@ -986,15 +971,16 @@ void AigerReader::post_process()  	}  	module->fixup_ports(); -	design->add(module); -	design->selection_stack.emplace_back(false); -	RTLIL::Selection& sel = design->selection_stack.back(); -	sel.select(module); +	// Insert into a new (temporary) design so that "clean" will only +	// operate (and run checks on) this one module +	RTLIL::Design *mapped_design = new RTLIL::Design; +	mapped_design->add(module); +	Pass::call(mapped_design, "clean"); +	mapped_design->modules_.erase(module->name); +	delete mapped_design; -	Pass::call(design, "clean"); - -	design->selection_stack.pop_back(); +	design->add(module);  	for (auto cell : module->cells().to_vector()) {  		if (cell->type != "$lut") continue; diff --git a/frontends/aiger/aigerparse.h b/frontends/aiger/aigerparse.h index de3c3efbc..583c9d0f9 100644 --- a/frontends/aiger/aigerparse.h +++ b/frontends/aiger/aigerparse.h @@ -47,7 +47,7 @@ struct AigerReader      AigerReader(RTLIL::Design *design, std::istream &f, RTLIL::IdString module_name, RTLIL::IdString clk_name, std::string map_filename, bool wideports);      void parse_aiger(); -    void parse_xaiger(); +    void parse_xaiger(const dict<int,IdString> &box_lookup);      void parse_aiger_ascii();      void parse_aiger_binary();      void post_process(); diff --git a/frontends/ast/ast.cc b/frontends/ast/ast.cc index 943466ee3..c8ca6d164 100644 --- a/frontends/ast/ast.cc +++ b/frontends/ast/ast.cc @@ -1172,7 +1172,7 @@ void AST::process(RTLIL::Design *design, AstNode *ast, bool dump_ast1, bool dump  			if (design->has((*it)->str)) {  				RTLIL::Module *existing_mod = design->module((*it)->str); -				if (!nooverwrite && !overwrite && !existing_mod->get_bool_attribute("\\blackbox")) { +				if (!nooverwrite && !overwrite && !existing_mod->get_blackbox_attribute()) {  					log_file_error((*it)->filename, (*it)->linenum, "Re-definition of module `%s'!\n", (*it)->str.c_str());  				} else if (nooverwrite) {  					log("Ignoring re-definition of module `%s' at %s:%d.\n", diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index e947125bf..6fb94d80b 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -3439,19 +3439,11 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)  {  	std::map<std::string, AstNode*> backup_scope;  	std::map<std::string, AstNode::varinfo_t> variables; -	bool delete_temp_block = false; -	AstNode *block = NULL; +	AstNode *block = new AstNode(AST_BLOCK);  	size_t argidx = 0;  	for (auto child : children)  	{ -		if (child->type == AST_BLOCK) -		{ -			log_assert(block == NULL); -			block = child; -			continue; -		} -  		if (child->type == AST_WIRE)  		{  			while (child->simplify(true, false, false, 1, -1, false, true)) { } @@ -3468,13 +3460,9 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)  			continue;  		} -		log_assert(block == NULL); -		delete_temp_block = true; -		block = new AstNode(AST_BLOCK);  		block->children.push_back(child->clone());  	} -	log_assert(block != NULL);  	log_assert(variables.count(str) != 0);  	while (!block->children.empty()) @@ -3642,8 +3630,7 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)  		log_abort();  	} -	if (delete_temp_block) -		delete block; +	delete block;  	for (auto &it : backup_scope)  		if (it.second == NULL) diff --git a/frontends/json/jsonparse.cc b/frontends/json/jsonparse.cc index f5ae8eb72..7aceffbfc 100644 --- a/frontends/json/jsonparse.cc +++ b/frontends/json/jsonparse.cc @@ -25,7 +25,7 @@ struct JsonNode  {  	char type; // S=String, N=Number, A=Array, D=Dict  	string data_string; -	int data_number; +	int64_t data_number;  	vector<JsonNode*> data_array;  	dict<string, JsonNode*> data_dict;  	vector<string> data_dict_keys; @@ -206,6 +206,38 @@ struct JsonNode  	}  }; +Const json_parse_attr_param_value(JsonNode *node) +{ +	Const value; + +	if (node->type == 'S') { +		string &s = node->data_string; +		size_t cursor = s.find_first_not_of("01xz"); +		if (cursor == string::npos) { +			value = Const::from_string(s); +		} else if (s.find_first_not_of(' ', cursor) == string::npos) { +			value = Const(s.substr(0, GetSize(s)-1)); +		} else { +			value = Const(s); +		} +	} else +	if (node->type == 'N') { +		value = Const(node->data_number, 32); +		if (node->data_number < 0) +			value.flags |= RTLIL::CONST_FLAG_SIGNED; +	} else +	if (node->type == 'A') { +		log_error("JSON attribute or parameter value is an array.\n"); +	} else +	if (node->type == 'D') { +		log_error("JSON attribute or parameter value is a dict.\n"); +	} else { +		log_abort(); +	} + +	return value; +} +  void json_parse_attr_param(dict<IdString, Const> &results, JsonNode *node)  {  	if (node->type != 'D') @@ -214,28 +246,7 @@ void json_parse_attr_param(dict<IdString, Const> &results, JsonNode *node)  	for (auto it : node->data_dict)  	{  		IdString key = RTLIL::escape_id(it.first.c_str()); -		JsonNode *value_node = it.second; -		Const value; - -		if (value_node->type == 'S') { -			string &s = value_node->data_string; -			if (s.find_first_not_of("01xz") == string::npos) -				value = Const::from_string(s); -			else -				value = Const(s); -		} else -		if (value_node->type == 'N') { -			value = Const(value_node->data_number, 32); -		} else -		if (value_node->type == 'A') { -			log_error("JSON attribute or parameter value is an array.\n"); -		} else -		if (value_node->type == 'D') { -			log_error("JSON attribute or parameter value is a dict.\n"); -		} else { -			log_abort(); -		} - +		Const value = json_parse_attr_param_value(it.second);  		results[key] = value;  	}  } | 
