e_graph.h
来自「对于研究FPGA结构的人来说」· C头文件 代码 · 共 164 行
H
164 行
/*------------------------------------------------------------------------** Copyright 1998 by Paul Leventis, Jonathan Rose and the University of ** Toronto. Use is permitted, provided that this attribution is retained ** and no part of the code is re-distributed or included in any commercial ** product except by written agreement with the above parties. ** ** For more information, contact us directly: ** Paul Leventis (leventi@eecg.utoronto.ca) ** Jonathan Rose (jayar@eecg.toronto.edu) ** Department of Electrical and Computer Engineering ** University of Toronto, 10 King's College Rd., ** Toronto, Ontario, CANADA M5S 1A4 ** Phone: (416) 978-6992 Fax: (416) 971-2286 **------------------------------------------------------------------------*//* * e_graph.h * * EDIF graph definition and function prototypes * This graph format is bulky and very difficult to use. However, it maintains * all information available in an EDIF file, so EDIF parsing is very generic * and if it weren't for my terrible documentation :), it would be possible * to use this module for analyzing hierarchy, or something like that :) * * A LIBRARY contains a hash table of CELLs. * * Each CELL contains a list of VIEWs. * * In EDIF, there are many different types of VIEWs, but this parser only * understands netlist views; any other views are ignored. I don't know * why anyone would ever have multiple netlist views, but if they do, this * parser will parse each of them. However, the analysis stage later on * ignores all but the first netlist view. * * Each NETLISTVIEW containes a tag; An EDIF netlist is of type netlist. A * definition (from the translation table parser, or some other future source) * is either of type logic or latch. I didn't use unions because I was annoyed * at the number of levels of . and -> I needed already, and to add another 5 * would really suck. * * All NETLISTVIEWs have nPorts, nOutPorts (number of input ports is implicit) * A "netlist" view uses the ports array (of size nPorts) to store conections * to the instances that make up the netlist. pFirstInstance and pFirstNet are * used to form linked lists to ease graph destruction later on. * A "logic" view uses ports array, but only to store port names. Right now * logic view can't have more than 1 output, but there is no reason why more * outputs can't be supported. Most code hasn't been hard-coded with a 1-oout * assumption. TT is used to store the truth table. It is packed into bytes * such that the LSB of the 1st byte corresponds to the first entry (i.e. 000) * the truth table, etc. So the size of the TT array will be * 2^(nPorts - nOutPorts - 3) or 1, whichever is greater. * A "latch" view uses the ports array again only for port names. The * first output port is the data output, the first input port is the data * input, and the last input is the clock. All other inputs are ignored. * If no clock is present, then any ignored input ports should be marked with * ignore. * * A PORT element has a name, direction (input, output), an ignore flag, and * a pointer to the connected NET. * * A NET has a name, a link to the next NET in the list, nPorts (the number of * ports on the network), and the ports array of PORTREF. The first element * in the ports array is the source, the rest are sinks. * * A PORTREF contains two things: pInstance is a pointer to the INSTANCE that * is connect to the NET, and portNum is a reference to which port of that * INSTANCE the net connects to. If pInstance is NULL, then portNum refers * to one of ports of current CELL i.e. the net connects to an input or output * pin. In hindsight, I should have made input and output stubs in the netlist * Oh well. * * An INSTANCE is an instantiated CELL element. It has a name, a pointer to * the CELL and NETLISTVIEW it is an instance of, link to the next INSTANCE in * the list, and the ports array, an array of ports corresponding to the ports * listed in the referenced NETLISTVIEW. Each of these ports is a NET pointer. * * Future work: * - Remove some indirection? * - Use freelists! * * P. Leventis, July 97*/#ifndef E_GRAPH_H#define E_GRAPH_H#include "e_hash.h"#define DEFAULT_CELLS 61 #define DEFAULT_INSTANCES 8093#define DEFAULT_LIBRARIES 13 struct CELL_type { char *name; struct NETLISTVIEW_type *pViewLL;}; typedef enum { noview, netlist, logic, latch } ViewType;struct NETLISTVIEW_type { char *name; ViewType tag; int nOutPorts, nPorts, nIn; int input_pin, output_pin, clock_pin; struct PORT_type *ports; char *TT; struct INSTANCE_type *pFirstInstance; struct NET_type *pFirstNet; struct NETLISTVIEW_type *pNextView;};typedef enum { noport, in, out, inout } PortDir;struct PORT_type { char *name; PortDir direction; unsigned char ignore; struct NET_type *pNet;};struct INSTANCE_type { char *name; struct NET_type **ports; struct CELL_type *pCellRef; struct NETLISTVIEW_type *pViewRef; struct INSTANCE_type *pNextInstance;};struct PORTREF_type { struct INSTANCE_type *pInstance; int portNum;}; struct NET_type { char *name; struct PORTREF_type *ports; struct NET_type *pNextNet; int nPorts;};struct LIBRARY_type { char *name; HASH_TABLE *pCellHT;};typedef struct CELL_type CELL;typedef struct PORT_type PORT;typedef struct PORTREF_type PORTREF;typedef struct INSTANCE_type INSTANCE;typedef struct NET_type NET;typedef struct LIBRARY_type LIBRARY;typedef struct NETLISTVIEW_type NETLISTVIEW;void free_CELL(void *);void free_PORT(void *);void free_PORTREF(void *);void free_INSTANCE(void *);void free_LIBRARY(void *);void free_NET(void *);void free_NETLISTVIEW(void *);#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?