Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
dsd1-10 / dsd-07=Verilog / backan.pdf
Скачиваний:
74
Добавлен:
05.06.2015
Размер:
697.19 Кб
Скачать

Back Annotation and Delay Calculation

Example Listings

Delay Calculators

Creating and Extracting Data From a Hash Table

Figure 5-6 on page 105 shows a set of routines that are called by the example delay calculators shown in Section “Random Cell Scan and Cell Output Nets” on page 109 and “Random Cell Scan and Cell Interconnect Nets” on page 118 . The delay calculators use these routines to build a hash table that contains net identifiers (net handles) and their associated capacitance values, and to extract this stored capacitance data during delay calculation. These routines read the net/capacitance data from a capacitance back annotation file and use standard hashing techniques to store and retrieve the information. You can find a discussion of hash tables in many programming applications manuals.

The capacitance back annotation file corresponding to these routines can contain an arbitrary number of capacitance entries, where an entry must consist of a hierarchical Verilog-XL net name and a single corresponding capacitance value. Figure 4-5 on page 47 and Figure 4-6 on page 47 show two example capacitance back annotation files that follow this syntax.

Although these hashing routines do not use the PLI access routines, they are usually vital to the creation of an efficient delay calculation facility. Note that the routines presented here are not meant to define a standard hash table implementation that you must use within your delay calculation process. They are provided to illustrate one typical solution to the problem of efficiently storing and retrieving back annotated capacitance data.

Figure 5-6 Creating and manipulating a hash table

#include <stdio.h> #include "veriuser.h" #include "acc_user.h"

/* Back annotation routines */

/* Back annotation hash table control */ global bool dl_make_backan_table(); static void dl_init_backan_table(); global void dl_free_backan_table();

/* Back annotation hash table insertion and search */ static void dl_backan_insert();

global double dl_backan_fetch();

/* Auxiliary routines */ static int dl_hash(); global int dl_next_prime();

static int dl_get_numlines();

/****************************************************************/ /* header items*/

October 2000

105

Product Version 3.2

Back Annotation and Delay Calculation

Example Listings

#define no_backan_val -1.0

/* Table of prime values, 0 must be last entry */ int primes[] = {

20011, 25013, 30011, 35023, 40009, 45007, 50021, 80021, 100003, 150001, 200003, 1000003, 5000011, 0 };

int backan_table_size;

struct table

{

handle addr; double val; } *backan_table;

/**************************************************************/

/*R DL_MAKE_BACKAN_TABLE

The backan table is set up and the contents of the file referenced by "filename" are read into the backan table.

*/

exfunc bool dl_make_backan_table(filename) char *filename;

{

FILE *net_file; double val; int num_lines; handle addr;

handle net_handle; char name[100]; int net_count; int i;

if ((net_file = fopen(filename,"r")) == 0)

{

io_printf("Warning: Back-annotate file \"%s\" not found.\n",filename); return(FALSE);

}

net_count = dl_get_numlines(filename); dl_init_backan_table(net_count);

for (i=0; i<net_count; i++)

{

if (fscanf(net_file,"%s%lf\n",name,&val) == EOF)

{

io_printf("Warning: \"%s\", unexpected end of file.\n", filename); break;

}

net_handle = acc_handle_object(name); if (net_handle == null)

io_printf("%s%s%s","Warning from file back annotation : net name \"",name,"\" not found\n");

else dl_backan_insert(net_handle,val);

}

fflush(stdout); fclose(net_file); return(TRUE);

}

October 2000

106

Product Version 3.2

Back Annotation and Delay Calculation

Example Listings

/*R DL_INIT_BACKAN_TABLE

Memory is allocated for the backan table, given the number of nets that have to be stored in it. The values are

all initialized to the defined constant "no_backan_val".

*/

static void dl_init_backan_table(net_count) int net_count;

{

int i;

backan_table_size = dl_next_prime(net_count * 10); if (backan_table_size == 0)

{

io_printf("%s%s\n","Back-annotation error : ",

"required backan table too large; must enhance primes array");

return;

}

else

{

backan_table = (struct table *) malloc(backan_table_size * sizeof(struct table));

}

for (i=0; i<backan_table_size; i++) backan_table[i].val = no_backan_val;

}

/* R DL_FREE_BACKAN_TABLE

Free the memory used by the backan table.

*/

exfunc void dl_free_backan_table()

{

free(backan_table);

}

/*R DL_BACKAN_INSERT

This adds an address and associated value into the backan table, using the hashing function on the address.

*/

static void dl_backan_insert(addr,val) handle addr;

double val;

{

int h = dl_hash(addr);

/* find empty backan table slot */

while (backan_table[h].val != no_backan_val)

{

if (backan_table[h].addr == addr)

{

io_printf("Warning: value for net \"%s\" reassigned.\n", acc_fetch_fullname(addr));

break;

}

h = (h+1) % backan_table_size;

}

/* assign entry to backan table slot */ backan_table[h].val = val; backan_table[h].addr = addr;

}

October 2000

107

Product Version 3.2

Back Annotation and Delay Calculation

Example Listings

/*R DL_BACKAN_FETCH

Finds the backan table entry that coincides with the handle argument. The value of the entry is returned.

*/

exfunc double dl_backan_fetch(handle_val) handle handle_val;

{

int h = dl_hash(handle_val); int dup = 0;

while (backan_table[h].addr != handle_val && dup <= backan_table_size && backan_table[h].val != no_backan_val)

{

dup++;

h = (h + 1) % backan_table_size;

}

/* if every slot in the backan table was checked and the correct */ /* handle_val was not found, notify user of error */

if (dup > backan_table_size)

{

io_printf("Error: net %s not in back annotation file\n", acc_fetch_fullname(handle_val));

return(no_backan_val);

}

return(backan_table[h].val);

}

/*R DL_HASH

Returns the mod (remainder) of the address and the backan table size. This gives us a number in the range 0..(backan_table_size - 1), which will be used as an index into the backan table array.

*/

static int dl_hash(addr) handle addr;

{

return(((int)addr) % backan_table_size);

}

/*R DL_NEXT_PRIME

Returns first prime number higher than number passed in. (uses prime numbers found in the previously defined array of prime numbers).

*/

exfunc int dl_next_prime(num) int num;

{

int i;

for (i=0; primes[i]!=0; i++) if (primes[i] > num)

return(primes[i]);

return(0); /* Exception value */

}

/*R DL_GET_NUMLINES

Returns the number of lines in a file (which should be nearly the same as the number of nets contained in the file).

*/

October 2000

108

Product Version 3.2

Соседние файлы в папке dsd-07=Verilog