mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 05:19:11 +00:00 
			
		
		
		
	Merge pull request #1976 from YosysHQ/dave/fix-sim-const
sim: Fix handling of constant-connected cell inputs at startup
This commit is contained in:
		
						commit
						c32b4bded5
					
				
					 2 changed files with 18 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -128,8 +128,12 @@ struct SimInstance
 | 
			
		|||
 | 
			
		||||
			for (auto &port : cell->connections()) {
 | 
			
		||||
				if (cell->input(port.first))
 | 
			
		||||
					for (auto bit : sigmap(port.second))
 | 
			
		||||
					for (auto bit : sigmap(port.second)) {
 | 
			
		||||
						upd_cells[bit].insert(cell);
 | 
			
		||||
						// Make sure cell inputs connected to constants are updated in the first cycle
 | 
			
		||||
						if (bit.wire == nullptr)
 | 
			
		||||
							dirty_bits.insert(bit);
 | 
			
		||||
					}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (cell->type.in(ID($dff))) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										13
									
								
								tests/various/sim_const.ys
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								tests/various/sim_const.ys
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
read_verilog <<EOT
 | 
			
		||||
 | 
			
		||||
module top(input clk, output reg [1:0] q);
 | 
			
		||||
	wire [1:0] x = 2'b10;
 | 
			
		||||
	always @(posedge clk)
 | 
			
		||||
		q <= x & 2'b11;
 | 
			
		||||
endmodule
 | 
			
		||||
EOT
 | 
			
		||||
 | 
			
		||||
proc
 | 
			
		||||
sim -clock clk -n 1 -w top
 | 
			
		||||
select -assert-count 1 a:init=2'b10 top/q %i
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue