mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 11:42:30 +00:00 
			
		
		
		
	cxxrtl: Assert well-formedness of input to udivmod
				
					
				
			This commit is contained in:
		
							parent
							
								
									6206a3af30
								
							
						
					
					
						commit
						18d1907fa8
					
				
					 1 changed files with 3 additions and 2 deletions
				
			
		|  | @ -583,8 +583,9 @@ struct value : public expr_base<value<Bits>> { | |||
| 		value<Bits> dividend = *this; | ||||
| 		if (dividend.ucmp(divisor)) | ||||
| 			return {/*quotient=*/value<Bits>{0u}, /*remainder=*/dividend}; | ||||
| 		uint32_t divisor_shift = divisor.ctlz() - dividend.ctlz(); | ||||
| 		divisor = divisor.shl(value<Bits>{divisor_shift}); | ||||
| 		int64_t divisor_shift = divisor.ctlz() - dividend.ctlz(); | ||||
| 		assert(divisor_shift >= 0); | ||||
| 		divisor = divisor.shl(value<Bits>{(chunk::type) divisor_shift}); | ||||
| 		for (size_t step = 0; step <= divisor_shift; step++) { | ||||
| 			quotient = quotient.shl(value<Bits>{1u}); | ||||
| 			if (!dividend.ucmp(divisor)) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue