/* VHDLOUT (GED) -- VHDL Netlist Data Output */ /* VHDLOUT (GED) -- VHDL Netzlistenausgabe */ /* // Copyright (c) 2007-2012 Oliver Bartels F+E, Muenchen // Author: Roman Ludwig // Changes History: // rl (120427) RELEASED FOR BAE V7.8. // rl (101019) RELEASED FOR BAE V7.6. // rl (091021) RELEASED FOR BAE V7.4. // rl (081014) RELEASED FOR BAE V7.2. // rl (071029) RELEASED FOR BAE V7.0. // rl (070227) ORIGINAL CODING. DERIVED FROM EDIFOUT.ULC. // // DESCRIPTION // // The vhdlout User Language program generates a VHDL // netlist output for use with external PLD layout/fitter programs. // vhdlout reads a (logical *_log) netlist and automatically creates // a layout worksheet to extract the required data. // In hierachic design the VHDL netlist contains module ports // The output is directed to a file with extension ".vhdl". */ // Includes #include "pop.ulh" // User Language popup utilities // Disable undo state request #pragma ULCALLERNOUNDO // Messages string UPRDDBFILE = M("Jobdatei ? ","Job File ? "); string REPSTART = M("VHDL-Netzlisten Ausgabe...", "VHDL netlist output..."); string REPDONE = M("VHDL-Netzliste ausgegeben auf Datei '%s'.", "VHDL netlist written to file '%s'."); string ERRDDBACC = M("Fehler beim Lesen der Design Datenbank!", "Error reading design database!"); // INI file parameter name definitions #define PAR_VHDLFEXT "VHFLFEXT_GED" // VHDL file name extension #define PAR_VHDLEXTL "VHFLEXTL_GED" // External library name #define PAR_EDFOPPATT "EDFOPPATT_GED" // Port net name pattern #define PAR_EDFOPINDIR "EDFOPINDIR_GED" // Pin direction attr. name // Global constants string VHDLEXT = bae_inistrval(PAR_VHDLFEXT,".vhd") /* VHDL file name extension */; string EXTLIBNAME = bae_inistrval(PAR_VHDLEXTL,"") /* External library name */; string PORTPATT = bae_inistrval(PAR_EDFOPPATT,"[??]*") /* Port net name pattern */; string PINDIRATT = bae_inistrval(PAR_EDFOPINDIR,"$dir") /* Pin direction attribute name */; // Global variables int nlfile /* Netlist file handle */; struct logpdef { // Logical part definition string llname /* Logical library part name */; STRINGS inpl /* Input pin list */; int inpn /* Input pin count */; STRINGS outl /* Outut pin list */; int outn /* Outut pin count */; STRINGS iol /* Input/output pin list */; int ion /* Input/output pin count */; index L_CPART cpart /* Sample netlist part */; } lpartl[] /* Logical library part list */; int lpartn = 0 /* Logical library part count */; int inslogidx /* Logical lib. part insert index */; // Main program void main() { string jobfname /* Job file name */; string jobename /* Job element name */; string placefname /* Place file name */; string msgbuf /* Message buffer */; // Perform BAE Demo check with abort option BAE_Demo_check(2); // Abort if invalid interpreter type if (uliptype()!=ULIPGED) error_class(); // Get the plan file and element name if (bae_askddbfname(jobfname,1,UPRDDBFILE) || bae_askddbename(jobename,jobfname,DDBCLPCON,"")) // Abort error_abort(); // Build the VHDL netlist file name placefname=convstring(jobfname,0)+VHDLEXT; // Start output bae_prtdialog(REPSTART); // Open the VHDL netlist file nlfile=fopen(placefname,1); // Create the library worksheet switch (existddbelem(jobfname,DDBCLLAY,jobename)) { // Layout not found case 0 : createlay(jobfname,jobename); break; // Layout does already exist case 1 : bae_loadelem(jobfname,jobename,DDBCLLAY); break; // File access failed default : error(ERRDDBACC); } // Create the cell definition list creacelllist(); // Write the design writedesign(); // Write the output done message sprintf(msgbuf,REPDONE,placefname); bae_prtdialog(msgbuf); } static void createlay(string filename,string elemname) /* // Create the layout sheet for the netlist // Parameters: // string filename : Layout file name // string elemname : Layout element name */ { // Insert the new element parameters bae_clriactqueue(); bae_storemenuiact(1,0,LMB); bae_storetextiact(1,filename); bae_storetextiact(1,elemname); bae_storetextiact(1,"10"); bae_storetextiact(1,"10"); // Call the create new element menu function if (bae_callmenu(MNU_GEDCREELEM)) // Parameter store failed error(ERRDDBACC); } static void creacelllist() /* // Create the logical cell library list */ { index L_CPART cpart /* Connection part index */; index L_CPIN cpin /* Connection pin index */; index L_ATTRIBUTE attr /* Attribute index */; string logname /* Logical library part name */; string pinname /* Pin name */; string dirname /* Direction name */; int inoutfound /* INOUT pin found */; int outfound /* OUTPUT pin found */; int i /* Loop control variable */; forall (cpart) { // Get the logical library part name forall (attr of cpart where attr.NAME=="$llname") { // Store the logical library part name logname=attr.VALUE; strupper(logname); break; } // Update logical library part list fclogp(logname,cpart); } // Loop for all log. library parts for (i=0;i=0) // Log. library part exists return; // Allocate new log. part entry lpartn++; // Copy old data entries to new position for (i=(lpartn-1)-1;i>=inslogidx;i--) lpartl[i+1]=lpartl[i]; // Insert new data lpartl[inslogidx].llname=llname; lpartl[inslogidx].cpart=cpart; lpartl[inslogidx].inpn=0; lpartl[inslogidx].outn=0; lpartl[inslogidx].ion=0; } static int findlog(string llname) /* // Search a log. part entry // Return value : // log. part index or (-1) if not of found // Parameters : // string log. part : Name of log. part searched */ { int slb=0 /* Search lower boundary */; int sub=lpartn-1 /* Search upper boundary */; int sidx /* Search index */; int compres /* Compare result */; // Loop until search area empty while (slb<=sub) { // Get the search index sidx=(slb+sub)>>1; // Compare entries compres=strcmp(llname,lpartl[sidx].llname); // Test if log. part found if (compres==0) // Log. part found return(sidx); // Update the search area if (compres<0) sub=sidx-1; else slb=sidx+1; } // Store the insert log. part index inslogidx=slb; // Log. part not found return(-1); } static void writedesign() /* // Write the design */ { index L_CPART cpart /* Connection part index */; index L_CPIN cpin /* Connection pin index */; index L_CNET cnet /* Connection list index */; index L_ATTRIBUTE attr /* Attribute index */; string jobname /* Job name */; string netname /* Net name */; string partname /* Part name */; string logname /* Logical library part name */; string dirname /* Direction name */; int inoutfound /* INOUT pin found */; int outfound /* OUTPUT pin found */; STRINGS inpl /* Input pin list */; int inpn = 0 /* Input pin count */; STRINGS outl /* Outut pin list */; int outn = 0 /* Outut pin count */; STRINGS iol /* Input/output pin list */; int ion = 0 /* Input/output pin count */; int listflag = 0 /* List output flag */; int i, j /* Loop control variables */; // Get the job name jobname=bae_planename(); strupper(jobname); // Write the library reference fprintf(nlfile,"-- Bartels AutoEngineer %s, VHDL netlist output\n", bae_swversion(0)); fprintf(nlfile,"\n-- Project file :%s\n",bae_planfname()); fprintf(nlfile,"\n-- Output time %s\n\n",getdatetime()); fprintf(nlfile,"LIBRARY IEEE;\n"); fprintf(nlfile,"USE IEEE.STD_LOGIC_1164.ALL;\n"); fprintf(nlfile,"USE IEEE.STD_LOGIC_UNSIGNED.ALL;\n"); fprintf(nlfile,"LIBRARY WORK;\n"); fprintf(nlfile,"USE WORK.MESSAGES.ALL;\n"); if (EXTLIBNAME!="") fprintf(nlfile,"LIBRARY %s;\n",EXTLIBNAME); // Write the design interface fprintf(nlfile,"ENTITY top IS\n"); fprintf(nlfile," PORT (\n"); // Scan the port list forall (cnet where strmatch(cnet.NAME,PORTPATT)!=0) { // Get the port name netname=strextract(cnet.NAME,4,strlen(cnet.NAME)); convnetname(netname); // Scan the port type inoutfound=outfound=0; forall (cpin of cnet) forall (attr of cpin where attr.NAME==PINDIRATT) { // Get the direction dirname=attr.VALUE; strupper(dirname); if (dirname=="INOUT") inoutfound=1; else if (dirname=="OUTPUT") outfound=1; break; } // Output the port type if (inoutfound) { iol[ion]=netname; ion++; } else if (outfound) { outl[outn]=netname; outn++; } else { inpl[inpn]=netname; inpn++; } } // Write inputs if (inpn) { for (i=0;i %s", listflag ? ",\n " : "\n ", cpin.NAME,netname); listflag=1; } fprintf(nlfile,"\n );\n"); } fprintf(nlfile,"END structural;\n\n"); fprintf(nlfile,"CONFIGURATION top_config OF top IS\n"); fprintf(nlfile," FOR structural\n"); for (i=0;i