mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 13:29:12 +00:00 
			
		
		
		
	Add Const methods is_fully_zero(), is_fully_def(), and is_fully_undef()
This commit is contained in:
		
							parent
							
								
									0be738eaac
								
							
						
					
					
						commit
						4ba5bd12c6
					
				
					 2 changed files with 37 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -161,6 +161,39 @@ std::string RTLIL::Const::decode_string() const
 | 
			
		|||
	return string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool RTLIL::Const::is_fully_zero() const
 | 
			
		||||
{
 | 
			
		||||
	cover("kernel.rtlil.const.is_fully_zero");
 | 
			
		||||
 | 
			
		||||
	for (auto bit : bits)
 | 
			
		||||
		if (bit != RTLIL::State::S0)
 | 
			
		||||
			return false;
 | 
			
		||||
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool RTLIL::Const::is_fully_def() const
 | 
			
		||||
{
 | 
			
		||||
	cover("kernel.rtlil.const.is_fully_def");
 | 
			
		||||
 | 
			
		||||
	for (auto bit : bits)
 | 
			
		||||
		if (bit != RTLIL::State::S0 && bit != RTLIL::State::S1)
 | 
			
		||||
			return false;
 | 
			
		||||
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool RTLIL::Const::is_fully_undef() const
 | 
			
		||||
{
 | 
			
		||||
	cover("kernel.rtlil.const.is_fully_undef");
 | 
			
		||||
 | 
			
		||||
	for (auto bit : bits)
 | 
			
		||||
		if (bit != RTLIL::State::Sx && bit != RTLIL::State::Sz)
 | 
			
		||||
			return false;
 | 
			
		||||
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void RTLIL::AttrObject::set_bool_attribute(RTLIL::IdString id)
 | 
			
		||||
{
 | 
			
		||||
	attributes[id] = RTLIL::Const(1);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -479,6 +479,10 @@ struct RTLIL::Const
 | 
			
		|||
	inline RTLIL::State &operator[](int index) { return bits.at(index); }
 | 
			
		||||
	inline const RTLIL::State &operator[](int index) const { return bits.at(index); }
 | 
			
		||||
 | 
			
		||||
	bool is_fully_zero() const;
 | 
			
		||||
	bool is_fully_def() const;
 | 
			
		||||
	bool is_fully_undef() const;
 | 
			
		||||
 | 
			
		||||
	inline RTLIL::Const extract(int offset, int len = 1, RTLIL::State padding = RTLIL::State::S0) const {
 | 
			
		||||
		RTLIL::Const ret;
 | 
			
		||||
		ret.bits.reserve(len);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue