mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 11:42:30 +00:00 
			
		
		
		
	rtlil: Fix handling of connections on wire deletion
This commit is contained in:
		
							parent
							
								
									4585d60b8a
								
							
						
					
					
						commit
						d6600fb1d5
					
				
					 2 changed files with 35 additions and 11 deletions
				
			
		|  | @ -2157,17 +2157,12 @@ void RTLIL::Module::remove(const pool<RTLIL::Wire*> &wires) | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		void operator()(RTLIL::SigSpec &lhs, RTLIL::SigSpec &rhs) { | 		void operator()(RTLIL::SigSpec &lhs, RTLIL::SigSpec &rhs) { | ||||||
| 			log_assert(GetSize(lhs) == GetSize(rhs)); | 			// When a deleted wire occurs on the lhs we can just remove that part
 | ||||||
| 			lhs.unpack(); | 			// of the assignment
 | ||||||
| 			rhs.unpack(); | 			lhs.remove2(*wires_p, &rhs); | ||||||
| 			for (int i = 0; i < GetSize(lhs); i++) { | 
 | ||||||
| 				RTLIL::SigBit &lhs_bit = lhs.bits_[i]; | 			// Then replace all rhs occurrences with a dummy wire
 | ||||||
| 				RTLIL::SigBit &rhs_bit = rhs.bits_[i]; | 			(*this)(rhs); | ||||||
| 				if ((lhs_bit.wire != nullptr && wires_p->count(lhs_bit.wire)) || (rhs_bit.wire != nullptr && wires_p->count(rhs_bit.wire))) { |  | ||||||
| 					lhs_bit = State::Sx; |  | ||||||
| 					rhs_bit = State::Sx; |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} | 		} | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
|  | @ -4238,6 +4233,34 @@ void RTLIL::SigSpec::remove2(const std::set<RTLIL::SigBit> &pattern, RTLIL::SigS | ||||||
| 	check(); | 	check(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void RTLIL::SigSpec::remove2(const pool<RTLIL::Wire*> &pattern, RTLIL::SigSpec *other) | ||||||
|  | { | ||||||
|  | 	if (other) | ||||||
|  | 		cover("kernel.rtlil.sigspec.remove_other"); | ||||||
|  | 	else | ||||||
|  | 		cover("kernel.rtlil.sigspec.remove"); | ||||||
|  | 
 | ||||||
|  | 	unpack(); | ||||||
|  | 
 | ||||||
|  | 	if (other != NULL) { | ||||||
|  | 		log_assert(width_ == other->width_); | ||||||
|  | 		other->unpack(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	for (int i = GetSize(bits_) - 1; i >= 0; i--) { | ||||||
|  | 		if (bits_[i].wire != NULL && pattern.count(bits_[i].wire)) { | ||||||
|  | 			bits_.erase(bits_.begin() + i); | ||||||
|  | 			width_--; | ||||||
|  | 			if (other != NULL) { | ||||||
|  | 				other->bits_.erase(other->bits_.begin() + i); | ||||||
|  | 				other->width_--; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	check(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| RTLIL::SigSpec RTLIL::SigSpec::extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other) const | RTLIL::SigSpec RTLIL::SigSpec::extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other) const | ||||||
| { | { | ||||||
| 	if (other) | 	if (other) | ||||||
|  |  | ||||||
|  | @ -924,6 +924,7 @@ public: | ||||||
| 	void remove(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other) const; | 	void remove(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other) const; | ||||||
| 	void remove2(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other); | 	void remove2(const pool<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other); | ||||||
| 	void remove2(const std::set<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other); | 	void remove2(const std::set<RTLIL::SigBit> &pattern, RTLIL::SigSpec *other); | ||||||
|  | 	void remove2(const pool<RTLIL::Wire*> &pattern, RTLIL::SigSpec *other); | ||||||
| 
 | 
 | ||||||
| 	void remove(int offset, int length = 1); | 	void remove(int offset, int length = 1); | ||||||
| 	void remove_const(); | 	void remove_const(); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue