mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 13:29:12 +00:00 
			
		
		
		
	Add option -expose to setundef pass
Option -expose converts undriven wires to inputs. Example usage: setundef -undriven -expose [selection]
This commit is contained in:
		
							parent
							
								
									0fad1570b5
								
							
						
					
					
						commit
						9286acb687
					
				
					 1 changed files with 26 additions and 6 deletions
				
			
		| 
						 | 
					@ -81,6 +81,9 @@ struct SetundefPass : public Pass {
 | 
				
			||||||
		log("    -undriven\n");
 | 
							log("    -undriven\n");
 | 
				
			||||||
		log("        also set undriven nets to constant values\n");
 | 
							log("        also set undriven nets to constant values\n");
 | 
				
			||||||
		log("\n");
 | 
							log("\n");
 | 
				
			||||||
 | 
							log("    -expose\n");
 | 
				
			||||||
 | 
							log("        also expose undriven nets as inputs\n");
 | 
				
			||||||
 | 
							log("\n");
 | 
				
			||||||
		log("    -zero\n");
 | 
							log("    -zero\n");
 | 
				
			||||||
		log("        replace with bits cleared (0)\n");
 | 
							log("        replace with bits cleared (0)\n");
 | 
				
			||||||
		log("\n");
 | 
							log("\n");
 | 
				
			||||||
| 
						 | 
					@ -105,6 +108,7 @@ struct SetundefPass : public Pass {
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		bool got_value = false;
 | 
							bool got_value = false;
 | 
				
			||||||
		bool undriven_mode = false;
 | 
							bool undriven_mode = false;
 | 
				
			||||||
 | 
							bool expose_mode = false;
 | 
				
			||||||
		bool init_mode = false;
 | 
							bool init_mode = false;
 | 
				
			||||||
		SetundefWorker worker;
 | 
							SetundefWorker worker;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -117,6 +121,11 @@ struct SetundefPass : public Pass {
 | 
				
			||||||
				undriven_mode = true;
 | 
									undriven_mode = true;
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								if (args[argidx] == "-expose") {
 | 
				
			||||||
 | 
									got_value = true;
 | 
				
			||||||
 | 
									expose_mode = true;
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			if (args[argidx] == "-zero") {
 | 
								if (args[argidx] == "-zero") {
 | 
				
			||||||
				got_value = true;
 | 
									got_value = true;
 | 
				
			||||||
				worker.next_bit_mode = 0;
 | 
									worker.next_bit_mode = 0;
 | 
				
			||||||
| 
						 | 
					@ -157,6 +166,8 @@ struct SetundefPass : public Pass {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		extra_args(args, argidx, design);
 | 
							extra_args(args, argidx, design);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (expose_mode && !undriven_mode)
 | 
				
			||||||
 | 
								log_cmd_error("Option -expose must be used with option -undriven.\n");
 | 
				
			||||||
		if (!got_value)
 | 
							if (!got_value)
 | 
				
			||||||
			log_cmd_error("One of the options -zero, -one, -anyseq, or -random <seed> must be specified.\n");
 | 
								log_cmd_error("One of the options -zero, -one, -anyseq, or -random <seed> must be specified.\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -184,12 +195,21 @@ struct SetundefPass : public Pass {
 | 
				
			||||||
						undriven_signals.del(sigmap(conn.second));
 | 
											undriven_signals.del(sigmap(conn.second));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				RTLIL::SigSpec sig = undriven_signals.export_all();
 | 
									RTLIL::SigSpec sig = undriven_signals.export_all();
 | 
				
			||||||
				for (auto &c : sig.chunks()) {
 | 
					        if (expose_mode) {
 | 
				
			||||||
					RTLIL::SigSpec bits;
 | 
					          for (auto &c : sig.chunks()) {
 | 
				
			||||||
					for (int i = 0; i < c.width; i++)
 | 
					            c.wire->port_input = true;
 | 
				
			||||||
						bits.append(worker.next_bit());
 | 
					            log("New module port: %s/%s\n", RTLIL::id2cstr(module->name), RTLIL::id2cstr(c.wire->name));
 | 
				
			||||||
					module->connect(RTLIL::SigSig(c, bits));
 | 
					          }
 | 
				
			||||||
				}
 | 
					          module->fixup_ports();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					          for (auto &c : sig.chunks()) {
 | 
				
			||||||
 | 
					            RTLIL::SigSpec bits;
 | 
				
			||||||
 | 
					            for (int i = 0; i < c.width; i++)
 | 
				
			||||||
 | 
					              bits.append(worker.next_bit());
 | 
				
			||||||
 | 
					            module->connect(RTLIL::SigSig(c, bits));
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (init_mode)
 | 
								if (init_mode)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue