mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	Update frontends to avoid bits()
This commit is contained in:
		
							parent
							
								
									c89a4da607
								
							
						
					
					
						commit
						24a95bd6cf
					
				
					 6 changed files with 37 additions and 26 deletions
				
			
		|  | @ -1076,8 +1076,10 @@ RTLIL::Const AstNode::realAsConst(int width) | |||
| 		bool is_negative = v < 0; | ||||
| 		if (is_negative) | ||||
| 			v *= -1; | ||||
| 		RTLIL::Const::Builder b(width); | ||||
| 		for (int i = 0; i < width; i++, v /= 2) | ||||
| 			result.bits().push_back((fmod(floor(v), 2) != 0) ? RTLIL::State::S1 : RTLIL::State::S0); | ||||
| 			b.push_back((fmod(floor(v), 2) != 0) ? RTLIL::State::S1 : RTLIL::State::S0); | ||||
| 		result = b.build(); | ||||
| 		if (is_negative) | ||||
| 			result = const_neg(result, result, false, false, result.size()); | ||||
| 	} | ||||
|  |  | |||
|  | @ -732,16 +732,17 @@ struct AST_INTERNAL::ProcessGenerator | |||
| 				current_case->actions.push_back(SigSig(en, true)); | ||||
| 
 | ||||
| 				RTLIL::SigSpec triggers; | ||||
| 				RTLIL::Const polarity; | ||||
| 				RTLIL::Const::Builder polarity_builder; | ||||
| 				for (auto sync : proc->syncs) { | ||||
| 					if (sync->type == RTLIL::STp) { | ||||
| 						triggers.append(sync->signal); | ||||
| 						polarity.bits().push_back(RTLIL::S1); | ||||
| 						polarity_builder.push_back(RTLIL::S1); | ||||
| 					} else if (sync->type == RTLIL::STn) { | ||||
| 						triggers.append(sync->signal); | ||||
| 						polarity.bits().push_back(RTLIL::S0); | ||||
| 						polarity_builder.push_back(RTLIL::S0); | ||||
| 					} | ||||
| 				} | ||||
| 				RTLIL::Const polarity = polarity_builder.build(); | ||||
| 
 | ||||
| 				RTLIL::Cell *cell = current_module->addCell(sstr.str(), ID($print)); | ||||
| 				set_src_attr(cell, ast); | ||||
|  | @ -829,16 +830,17 @@ struct AST_INTERNAL::ProcessGenerator | |||
| 				current_case->actions.push_back(SigSig(en, true)); | ||||
| 
 | ||||
| 				RTLIL::SigSpec triggers; | ||||
| 				RTLIL::Const polarity; | ||||
| 				RTLIL::Const::Builder polarity_builder; | ||||
| 				for (auto sync : proc->syncs) { | ||||
| 					if (sync->type == RTLIL::STp) { | ||||
| 						triggers.append(sync->signal); | ||||
| 						polarity.bits().push_back(RTLIL::S1); | ||||
| 						polarity_builder.push_back(RTLIL::S1); | ||||
| 					} else if (sync->type == RTLIL::STn) { | ||||
| 						triggers.append(sync->signal); | ||||
| 						polarity.bits().push_back(RTLIL::S0); | ||||
| 						polarity_builder.push_back(RTLIL::S0); | ||||
| 					} | ||||
| 				} | ||||
| 				RTLIL::Const polarity = polarity_builder.build(); | ||||
| 
 | ||||
| 				RTLIL::Cell *cell = current_module->addCell(cellname, ID($check)); | ||||
| 				set_src_attr(cell, ast); | ||||
|  | @ -893,7 +895,7 @@ struct AST_INTERNAL::ProcessGenerator | |||
| 				RTLIL::Const priority_mask = RTLIL::Const(0, cur_idx); | ||||
| 				for (int i = 0; i < portid; i++) { | ||||
| 					int new_bit = port_map[std::make_pair(memid, i)]; | ||||
| 					priority_mask.bits()[new_bit] = orig_priority_mask[i]; | ||||
| 					priority_mask.set(new_bit, orig_priority_mask[i]); | ||||
| 				} | ||||
| 				action.priority_mask = priority_mask; | ||||
| 				sync->mem_write_actions.push_back(action); | ||||
|  |  | |||
|  | @ -4366,7 +4366,7 @@ replace_fcall_later:; | |||
| 					log_assert(a.size() == b.size()); | ||||
| 					for (auto i = 0; i < a.size(); i++) | ||||
| 						if (a[i] != b[i]) | ||||
| 							a.bits()[i] = RTLIL::State::Sx; | ||||
| 							a.set(i, RTLIL::State::Sx); | ||||
| 					newNode = mkconst_bits(location, a.to_bits(), sign_hint); | ||||
| 				} else if (children[1]->isConst() && children[2]->isConst()) { | ||||
| 					newNode = std::make_unique<AstNode>(location, AST_REALVALUE); | ||||
|  | @ -5368,8 +5368,11 @@ bool AstNode::replace_variables(std::map<std::string, AstNode::varinfo_t> &varia | |||
| 		offset -= variables.at(str).offset; | ||||
| 		if (variables.at(str).range_swapped) | ||||
| 			offset = -offset; | ||||
| 		std::vector<RTLIL::State> &var_bits = variables.at(str).val.bits(); | ||||
| 		std::vector<RTLIL::State> new_bits(var_bits.begin() + offset, var_bits.begin() + offset + width); | ||||
| 		const RTLIL::Const &val = variables.at(str).val; | ||||
| 		std::vector<RTLIL::State> new_bits; | ||||
| 		new_bits.reserve(width); | ||||
| 		for (int i = 0; i < width; i++) | ||||
| 			new_bits.push_back(val[offset+i]); | ||||
| 		auto newNode = mkconst_bits(location, new_bits, variables.at(str).is_signed); | ||||
| 		newNode->cloneInto(*this); | ||||
| 		return true; | ||||
|  | @ -5513,7 +5516,7 @@ std::unique_ptr<AstNode> AstNode::eval_const_function(AstNode *fcall, bool must_ | |||
| 					int index = i + offset - v.offset; | ||||
| 					if (v.range_swapped) | ||||
| 						index = -index; | ||||
| 					v.val.bits().at(index) = r.at(i); | ||||
| 					v.val.set(index, r.at(i)); | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue