1 /**************************************************************************** 2 Copyright (C) 1987-2015 by Jeffery P. Hansen 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along 15 with this program; if not, write to the Free Software Foundation, Inc., 16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 ****************************************************************************/ 18 #ifndef __net_h 19 #define __net_h 20 21 #define GW_DRIVER 0x1 /* Driver wires only */ 22 #define GW_DRIVEE 0x2 /* Drivee wires only */ 23 #define GW_ALL 0x3 /* All wires */ 24 25 26 #define DLM_GET_VISIBLE 0 /* Get name only when visible */ 27 #define DLM_GET_ALWAYS 1 /* Get name always */ 28 29 30 31 /* 32 A GNet is a collection of wires and wire segments all connected by 33 joints and outsplices. 34 */ 35 struct net { 36 char *n_signame; /* Signal name of this net */ 37 38 int n_labelWidth; /* Width of the label text */ 39 40 int n_nbits; /* Bit width of this net */ 41 short n_dtype; /* Used only in HDL modules to track net type */ 42 short n_vtype; /* Used only in netlist modules to track net type */ 43 int n_refs; /* Reference count */ 44 GModuleDef *n_mod; /* Module this net is in */ 45 GCElement *n_ionet; /* I/O gate if this is a port */ 46 unsigned n_mark : 1; /* Mark for nets */ 47 unsigned n_show_name : 1;/* Is net name visible? */ 48 unsigned n_finalized : 1;/* Is net finalized? */ 49 50 unsigned n_generation; /* Generation number of net (used in net merging) */ 51 52 short n_wnum; /* Counter for counting wires */ 53 short n_gnum; /* Counter for counting joints, etc. */ 54 GWire *n_driver; /* "driver" (for display purposes) wire of net */ 55 GNet *n_next; /* Next net in freelist */ 56 }; 57 58 GNet *new_GNet(const char*,GModuleDef*); 59 GNet *new_GNet_compatable(const char*,GNet*,GModuleDef*); 60 void delete_GNet(GNet*); 61 GNet *net_pickOne(GNet*,GNet*,int); 62 void net_decref(GNet*); 63 void net_incref(GNet*); 64 void net_update(GNet *n); 65 int net_connectOK(GNet *n1,GNet *n2,int isMidWire); 66 void net_setSize(GNet *net,int nbits); 67 void net_setDType(GNet *net,int dtype); 68 void net_rename(GNet *net,const char *s,int showName); 69 void net_select(GNet *n,int drawp); 70 void net_unselect(int drawp); 71 72 const char *GNet_getDTypeStr(GNet *n); 73 void GNet_labelClosest(GNet *net,int x,int y); 74 void GNet_draw(GNet*); 75 void GNet_hideName(GNet*); 76 void GNet_showName(GNet*); 77 void GNet_checkNameVisibility(GNet*,int); 78 void GNet_setVType(GNet *n,const char *vtype); 79 const char *GNet_getVType(GNet *n); 80 int GNet_getDisplayLabel(GNet *net,char label[],int len,int mode); 81 int GNet_getWires(GNet *n,GWire **wlist,unsigned which); 82 int GNet_getLabelWidth(GNet *net); 83 #define GNet_getShowName(n) (n)->n_show_name 84 #define GNet_numWires(n) (n)->n_wnum 85 #define GNet_getNBits(n) (n)->n_nbits 86 87 #endif 88