mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-31 03:32:29 +00:00 
			
		
		
		
	Added Verilog support for "`default_nettype none"
This commit is contained in:
		
							parent
							
								
									0851c2b6ea
								
							
						
					
					
						commit
						02e6f2c5be
					
				
					 8 changed files with 31 additions and 8 deletions
				
			
		|  | @ -81,6 +81,18 @@ namespace VERILOG_FRONTEND { | |||
| 
 | ||||
| "`timescale"[ \t]+[^ \t\r\n/]+[ \t]*"/"[ \t]*[^ \t\r\n]* /* ignore timescale directive */ | ||||
| 
 | ||||
| "`default_nettype"[ \t]+[^ \t\r\n/]+ { | ||||
| 	char *p = yytext; | ||||
| 	while (*p != 0 && *p != ' ' && *p != '\t') p++; | ||||
| 	while (*p == ' ' || *p == '\t') p++; | ||||
| 	if (!strcmp(p, "none")) | ||||
| 		VERILOG_FRONTEND::default_nettype_wire = false; | ||||
| 	else if (!strcmp(p, "wire")) | ||||
| 		VERILOG_FRONTEND::default_nettype_wire = true; | ||||
| 	else | ||||
| 		frontend_verilog_yyerror("Unsupported default nettype: %s", p); | ||||
| } | ||||
| 
 | ||||
| "`"[a-zA-Z_$][a-zA-Z0-9_$]* { | ||||
| 	frontend_verilog_yyerror("Unimplemented compiler directive or undefined macro %s.", yytext); | ||||
| } | ||||
|  |  | |||
|  | @ -53,6 +53,7 @@ namespace VERILOG_FRONTEND { | |||
| 	struct AstNode *current_ast, *current_ast_mod; | ||||
| 	int current_function_or_task_port_id; | ||||
| 	std::vector<char> case_type_stack; | ||||
| 	bool default_nettype_wire; | ||||
| } | ||||
| 
 | ||||
| static void append_attr(AstNode *ast, std::map<std::string, AstNode*> *al) | ||||
|  |  | |||
|  | @ -373,7 +373,6 @@ std::string frontend_verilog_preproc(FILE *f, std::string filename, const std::m | |||
| 		} | ||||
| 
 | ||||
| 		if (tok == "`timescale") { | ||||
| 			std::string name; | ||||
| 			skip_spaces(); | ||||
| 			while (!tok.empty() && tok != "\n") | ||||
| 				tok = next_token(true); | ||||
|  |  | |||
|  | @ -256,6 +256,7 @@ struct VerilogFrontend : public Frontend { | |||
| 		AST::get_line_num = &frontend_verilog_yyget_lineno; | ||||
| 
 | ||||
| 		current_ast = new AST::AstNode(AST::AST_DESIGN); | ||||
| 		default_nettype_wire = true; | ||||
| 
 | ||||
| 		FILE *fp = f; | ||||
| 		std::string code_after_preproc; | ||||
|  | @ -279,7 +280,7 @@ struct VerilogFrontend : public Frontend { | |||
| 					child->attributes[attr] = AST::AstNode::mkconst_int(1, false); | ||||
| 		} | ||||
| 
 | ||||
| 		AST::process(design, current_ast, flag_dump_ast1, flag_dump_ast2, flag_dump_vlog, flag_nolatches, flag_nomem2reg, flag_mem2reg, flag_lib, flag_noopt, flag_icells, flag_ignore_redef, flag_defer); | ||||
| 		AST::process(design, current_ast, flag_dump_ast1, flag_dump_ast2, flag_dump_vlog, flag_nolatches, flag_nomem2reg, flag_mem2reg, flag_lib, flag_noopt, flag_icells, flag_ignore_redef, flag_defer, default_nettype_wire); | ||||
| 
 | ||||
| 		if (!flag_nopp) | ||||
| 			fclose(fp); | ||||
|  |  | |||
|  | @ -42,6 +42,9 @@ namespace VERILOG_FRONTEND | |||
| 
 | ||||
| 	// this function converts a Verilog constant to an AST_CONSTANT node
 | ||||
| 	AST::AstNode *const2ast(std::string code, char case_type = 0); | ||||
| 
 | ||||
| 	// state of `default_nettype
 | ||||
| 	extern bool default_nettype_wire; | ||||
| } | ||||
| 
 | ||||
| // the pre-processor
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue