⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 verilog-y

📁 將Verilog設計轉成VHDL設計的程式
💻
📖 第 1 页 / 共 3 页
字号:
	;task_declaration	: VL_TASK VL_ID ';' 	{		fprintf(debug, "VL_TASK\n");		$$=(PBDeclP)calloc(1,sizeof(PBDecl));		$$->file_name=beginproc();		fprintf(fp,"procedure %s(",$2); 		buggy=$$;		t->inc();	}	io_declaration_opt_list 	{		fprintf(fp,"\b\b);\nbegin\n");	}	statement VL_ENDTASK	{		$$=(PBDeclP)buggy;		fprintf(fp,"end %s;\n",$2); 		endproc();	}	;io_declaration_opt_list	: io_declaration_opt	{		fprintf(debug,"io_declaration_opt_list : io_declaration_opt\n");	}	| io_declaration_opt_list io_declaration_opt	{		fprintf(debug,"io_declaration_opt_list : io_declaration_opt_list io_declaration_opt\n");	}	;io_declaration_opt	: input_declaration	{		$1->toVHDL(fp);		fprintf(fp,"; ");		fprintf(debug,"io_declaration_opt : input_declaration\n");	}	| output_declaration	{		$1->toVHDL(fp);		fprintf(fp,"; ");		fprintf(debug,"io_declaration_opt : output_declaration\n");	}	| inout_declaration	{		$1->toVHDL(fp);		fprintf(fp,"; ");		fprintf(debug,"io_declaration_opt : inout_declaration\n");	}	;	module_declaration	: VL_ID VL_ID list_of_ports_opt ';'          {		$$=(MDeclP)calloc(1,sizeof(MDecl));		fprintf(debug,"module_declaration\n");		///printf("%s\n",$1);		///char *ptr=$1;		///$$->mname=(char*)calloc(strlen($1)+1,sizeof(char));		///strcpy($$->mname,$1);		///printf("%s", $1);		///printf("%s, %s\n",$1,$$->mname);		$$->mname=$1;		$$->iname=$2;		$$->ports=$3;	  }input_declaration	: VL_INPUT range_opt list_of_variables ';'          {		fprintf(debug,"input_declaration: VL_INPUT range_opt variable_list ';'\n");		$$=new IODecl(IN,$3,$2);		/*printf("%s\n",$$->toVHDL());*/	   		  }        ;output_declaration        : VL_OUTPUT range_opt list_of_variables ';'          {		fprintf(debug,"output_declaration: VL_OUTPUT range_opt list_of_variable ';'\n");		$$=new IODecl(OUT,$3,$2);		/*printf("%s\n",$$->toVHDL());*/          }        ;inout_declaration        : VL_INOUT range_opt list_of_variables ';'          {		fprintf(debug,"inout_declaration: VL_INOUT range_opt list_of_variables ';'\n");		$$=new IODecl(INOUT,$3,$2);		/*printf("%s\n",$$->toVHDL());*/          }        ;/*parameter_declaration	: VL_PARAMETER identifier '=' constant_expression ';'	{		$$=(PDeclP)calloc(1,sizeof(PDecl));		$$->name=$2;		$$->expres=$4;	}	;*/parameters_declaration	: VL_PARAMETER list_of_parameter_declaration ';' 	{		$$=$2;	}	;parameter_declaration	: identifier '=' constant_expression	{		//$$=expres3($1,"=",$3);		$$=(PDeclP)calloc(1,sizeof(PDecl));		$$->name=$1;		$$->expres=$3;	}	;list_of_parameter_declaration	: parameter_declaration	{		$$=new List();		$$->add($1);	}	| list_of_parameter_declaration ',' parameter_declaration	{		$1->add($3);		$$=$1;	}net_declaration	: VL_WIRE range_opt list_of_variables ';'	{		fprintf(debug,"net_declaration\n");		$$=new BitVec(BV_NET,$3,$2);	}reg_declaration        : VL_REG range_opt list_of_register_variables ';'          {		fprintf(debug,"reg_declaration: VL_REG range_opt register_variable_list ';'\n");		$$=new BitVec(BV_REG,$3,$2);		/*while(!$3->empty()){			RVarP tmp=(RVarP)$3->remove();			printf("%s , %s",tmp->name,tmp->extra);		}		$$->toVHDL(stdout);*/          }        ;initial_statement	: VL_INITIAL 	{		$$=(PBDeclP)calloc(1,sizeof(PBDecl));		fprintf(debug,"VL_INITIAL\n");		$$->file_name=beginproc();		fprintf(fp,"process begin\n");		t->inc();		buggy=$$;	} statement	{		fprintf(debug,"initial_statement: VL_INITIAL statement\n");		t->dec();		fprintf(fp,"end process;\n");		$$=(PBDeclP)buggy;		endproc();	}	;always_statement	: VL_ALWAYS	{		$$=(PBDeclP)calloc(1,sizeof(PBDecl));		$$->file_name=beginproc();		fprintf(debug,"VL_ALWAYS\n");		fprintf(fp,"process begin\n");		fprintf(fp,"loop\n");		t->inc();		buggy=$$;	} 	statement	{		fprintf(debug,"always_statement: VL_ALWAYS statement\n");		t->dec();		fprintf(fp,"end loop;\n");		fprintf(fp,"end process;\n");		endproc();		$$=(PBDeclP)buggy;	}	;guarded_always_statement	: VL_ALWAYS event_control	{		$$=(PBDeclP)calloc(1,sizeof(PBDecl));		$$->file_name=beginproc();		fprintf(debug,"VL_ALWAYS\n");		t->printTab(fp);		t->inc();		fprintf(fp,"block (\n");		t->printTab(fp);		fprintf(fp,"%s\n",$2);		t->dec();		t->printTab(fp);		fprintf(fp,")\n");		t->printTab(fp);		fprintf(fp,"begin\n");		t->inc();		t->printTab(fp);		fprintf(fp,"process begin\n");		t->printTab(fp);		fprintf(fp,"if GUARD then\n");		t->inc();		buggy=$$;	} 	statement	{		fprintf(debug,"always_statement: VL_ALWAYS statement\n");		t->dec();		t->printTab(fp);		fprintf(fp,"end if;\n");		t->printTab(fp);		fprintf(fp,"wait on GUARD;\n");		t->printTab(fp);		fprintf(fp,"end process;\n");		t->dec();		t->printTab(fp);		fprintf(fp,"end block;\n");		$$=(PBDeclP)buggy;		endproc();	}	;statement_or_null	: ';'	{		fprintf(debug,"statement_or_null: ;\n");			}	| statement	{		fprintf(debug,"statement_or_null: statement\n");			}	;/* if statement gives 1 shift/reduce conflict */statement	: assignment ';'	{		fprintf(debug,"statement: assignment\n");		t->printTab(fp);		fprintf(fp,"%s;\n",$1);	}	| ifLine	{		fprintf(debug,"statement: if (expression) statement_or_null\n");		t->dec();		t->printTab(fp);		fprintf(fp,"end if;\n");	}	| ifLine VL_ELSE 	{		t->dec();		t->printTab(fp);		t->inc();		fprintf(fp,"else\n");	}	statement_or_null	{		fprintf(debug,"statement: if ( expression ) statement_or_null else statement_or_null\n");		t->dec();		t->printTab(fp);		fprintf(fp,"endif;\n");	}	| VL_CASE '(' expression ')'	{		t->printTab(fp);		t->inc();		fprintf(fp,"case %s is\n",$3);	} 	case_items VL_ENDCASE	{		t->dec();		t->printTab(fp);		fprintf(fp,"end case;\n");	}	| VL_FOR '(' assignment ';' expression ';' assignment ')' 	{		t->printTab(fp);		fprintf(fp,"%s;\n",$3);		t->printTab(fp);		fprintf(fp,"while %s loop\n",$5);		t->inc();			}	statement	{		fprintf(debug,"statement: VL_FOR '(' assignment ';' expression ';' assignment ')'\n");		t->printTab(fp);		fprintf(fp,"%s;\n",$7);		t->dec();		t->printTab(fp);		fprintf(fp,"end loop;\n");	}	| VL_FOREVER	{		fprintf(debug,"statament: VL_FOREVER\n");		t->printTab(fp);		t->inc();		fprintf(fp,"loop\n");	}	statement	{		t->dec();		t->printTab(fp);		fprintf(fp,"end loop;\n");	}	| VL_WHILE '(' expression ')'	{		t->printTab(fp);		t->inc();		fprintf(fp,"while %s loop\n",$3);	}	statement	{		t->dec();		t->printTab(fp);		fprintf(fp,"end loop;\n");	}	| delay_control 	{ 	} 	statement_or_null	{			}	| event_control 	{		t->printTab(fp);		t->inc();		fprintf(fp,"block (\n");		t->printTab(fp);		fprintf(fp,"%s\n",$1);		t->dec();		t->printTab(fp);		fprintf(fp,")\n");		t->printTab(fp);		fprintf(fp,"begin\n");		t->inc();		t->printTab(fp);		fprintf(fp,"process begin\n");		t->printTab(fp);		fprintf(fp,"if GUARD then\n");		t->inc();	} 	statement_or_null	{		t->dec();		t->printTab(fp);		fprintf(fp,"end if;\n");		t->printTab(fp);		fprintf(fp,"wait on GUARD;\n");		t->printTab(fp);		fprintf(fp,"end process;\n");		t->dec();		t->printTab(fp);		fprintf(fp,"end block;\n");	}	| seq_block	{		fprintf(debug,"statement: seq_block\n");	}	| VL_ASSIGN assignment ';'	{		fprintf(debug,"statement: VL_ASSIGN assignment\n");	}	| task_call	{		fprintf(debug,"statement: task call\n");	}	;task_call	: VL_ID list_of_parameters_opt ';'	{		t->printTab(fp);		fprintf(fp,"%s %s;\n",$1,$2);	}	;list_of_parameters_opt	: /*empty*/	{		$$="";	}	| '(' list_of_expressions ')'	{		$$=expres3("(",$2,")");	}	;	list_of_expressions	: expression	{		$$=$1;	}	| list_of_expressions ',' expression	{		$$=expres3($$,",",$3);	}	;ifLine: VL_IF '(' expression ')'	{		t->printTab(fp);		t->inc();		fprintf(fp,"if (%s) then\n",$3);	}	statement_or_null	{		fprintf(debug,"statement: if ( expression ) statement_or_null\n");	}	;seq_block	: VL_BEGIN	{		//t->printTab(fp);		//t->inc();		//fprintf(fp,"begin\n");		fprintf(debug,"VL_BEGIN\n");	} statements VL_END	{		fprintf(debug,"statements VL_END\n");		//t->dec();		//t->printTab(fp);		//fprintf(fp,"end\n");	}	;statements:	/* empty */	{		fprintf(debug,"statements: empty\n");	}	| statements statement	{		fprintf(debug,"statements: statements statement\n");	}	;assignment	: lvalue '=' expression	{		fprintf(debug,"assignment: lvalue = expression\n");		$$=expres3($1," <= ",$3);			}	;case_items	: case_item	| case_items case_item	;case_item	: expressions ':' 	{		fprintf(debug,"case_item: expression ':' statement_or_null\n");		t->printTab(fp);		t->inc();		fprintf(fp,"when ");		while(!$1->empty()){			char *tmp=(char*)$1->remove();			fprintf(fp,"%s ",tmp);			if(!$1->empty())				fprintf(fp,"| ");		}		fprintf(fp,"=>\n");	}	statement_or_null 	{		t->dec();	}	| VL_DEFAULT ':'  	{		t->printTab(fp);		t->inc();		fprintf(fp,"when others =>\n");	}	statement_or_null

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -