/*
* $Id: ext_nets.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $
*
* $Log: ext_nets.c,v $
* Revision 1.1.1.1 2003/11/04 23:34:57 mjames
* Imported into local repositrory
*
* Revision 1.13 2002/09/09 10:26:56 mjames
* Removed set generic range and replaced it with a set generic value command
* that takes both integers and ranges.
*
* Revision 1.12 2002/01/16 10:07:42 mjames
* converted to use #ident
*
* Revision 1.11 2001/10/31 22:20:04 mjames
* Tidying up problematical comments caused by CVS
* 'intelligent' comment guessing
*
* Revision 1.10 2001/10/31 16:22:15 mjames
* Added a datastructure to hide regular expression information from programs.
* Changed call to regexec to indicate 0 subexpressions to be matched
* rather than a number dependent on strlen(string) which was wrong.
*
* Revision 1.9 2001/10/10 20:18:23 mjames
* Added a vert_regcomp function to compile regular expressions
* with '^' (match start string) and '$' (match end string) bracketing
* this => wildcard must match entire string not just a part of it.
*
* Revision 1.8 2001/10/07 20:50:53 mjames
* Added wildcard checking (warn user about
* using wildcard '*' on the end of a string in stead of wildcard '.*')
*
* Revision 1.7 2001/09/25 23:15:23 mjames
* Converted wildcards to use proper regexp pattern match library
*
* Revision 1.6 2001/07/09 15:36:17 mjames
* Removed verbose diagnostics from the setting and clearing of flags.
*
* Revision 1.5 2001/06/07 14:46:48 mjames
* Corrected conflict
*
* Revision 1.4 2001/06/07 13:38:15 MJAMES
* Removed internal/external detection from jumpering and
* placed it in ext_nets.c so that the properties of nets affected by set/del ext are
* correctly updated
*
* Revision 1.3 2001/06/06 12:10:23 mjames
* Move from HPUX
*
* Revision 1.2 2001/03/29 22:08:56 mjames
* Modified to define the scope of set generic commands : now can be global
* or defined for a socket or a simple wildcarded list of sockets.
*
* In addition the is_FPGA property has been activated so that FPGA components
* are not listed out when used in a Verilog (.vb) file.
*
* Version raised to 11.02
*
* Revision 1.1.1.1 2000/10/19 21:58:37 mjames
* Mike put it here
*
*
* Revision 1.27 2000/10/04 10:37:04 10:37:04 mjames (Mike James)
* Modified for Vertical2 : support COMPONENTS and SIGNALS
*
* Revision 1.27 2000/10/04 10:37:04 10:37:04 mjames (Mike James)
* Part of Release PSAVAT01
*
* Revision 1.26 2000/10/02 11:04:12 11:04:12 mjames (Mike James)
* new_vhdl
*
* Revision 1.25 2000/09/27 14:42:13 14:42:13 mjames (Mike James)
* Part of Release Sep_27_ST_2000
*
* Revision 1.24 2000/09/21 10:15:42 10:15:42 mjames (Mike James)
* Part of Release Sep21Alpha
*
* Revision 1.23 2000/08/25 09:57:11 09:57:11 mjames (Mike James)
* Part of Release Aug25_alpha
*
* Revision 1.22 2000/08/16 08:57:27 08:57:27 mjames (Mike James)
* Part of Release CD01_Aug2000
*
* Revision 1.21 2000/08/14 14:45:08 14:45:08 mjames (Mike James)
* Part of Release Aug_14_2000
*
* Revision 1.20 2000/08/11 08:30:29 08:30:29 mjames (Mike James)
* Part of Release Aug_11_2000
*
* Revision 1.19 2000/08/09 10:31:43 10:31:43 mjames (Mike James)
* Part of Release Aug__9_2000
*
* Revision 1.18 2000/05/31 11:42:51 11:42:51 mjames (Mike James)
* Part of Release May_31_2000
*
* Revision 1.17 2000/05/08 17:01:34 17:01:34 mjames (Mike James)
* Part of Release May__8_2000
*
* Revision 1.16 2000/05/08 16:59:27 16:59:27 mjames (Mike James)
* Part of Release May__8_2000
*
* Revision 1.15 2000/05/08 16:57:04 16:57:04 mjames (Mike James)
* Part of Release May__8_2000
*
* Revision 1.14 2000/03/08 16:18:58 16:18:58 mjames (Mike James)
* New version including PC
*
* Revision 1.11 2000/01/20 15:58:43 15:58:43 mjames (Mike James)
* Part of Release R22
*
* Revision 1.10 99/12/22 11:15:23 11:15:23 mjames (Mike James)
* Part of Release Dec_22_1999
*
* Revision 1.9 99/06/25 14:35:27 14:35:27 mjames (Mike James)
* Added in reference to expression.h, but no changes made
* to the function of acfread yet.
*
* Revision 1.8 99/06/18 09:23:50 09:23:50 mjames (Mike James)
*
* Revision 1.7 98/04/24 14:11:18 14:11:18 mjames (Mike James)
* added generic.h header
*
* Revision 1.6 97/04/23 08:42:50 08:42:50 mjames (Mike James)
* CHecked in for release rel23041997
*
* Revision 1.5 97/01/03 13:37:41 13:37:41 mjames (Mike James)
* Altered the set/del ext functions to make themn stop after
* they have found a match if a wildcarded net identifier was
* not given.
*
* Revision 1.4 96/07/19 14:38:53 14:38:53 mjames (Mike James)
* Update to give to PRL
*
* Revision 1.3 1996/07/12 15:52:12 mjames
* Sorted out things like Alias and Jumpers
* Work Correctly
* Print COrrectly
*
* Revision 1.3 1996/07/12 15:52:12 mjames
* Sorted out things like Alias and Jumpers
* Work Correctly
* Print COrrectly
*
* Revision 1.2 96/06/17 13:01:53 13:01:53 mjames (Mike James)
* Altered the printing of JUMPERED and ALIASED nets
* ,
*
* Revision 1.1 96/06/04 11:54:57 11:54:57 mjames (Mike James)
* Initial revision
* */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#include <regex.h>
#include "vertcl_main.h"
#include "expression.h"
#include "generic.h"
#include "database.h"
#include "routing.h"
#include "ext_nets.h"
#include "cmdparse.h"
#include "cmdlog.h"
#include "chck_names.h"
#include "sorting.h"
/* streq() and strneq() declaration */
#include "lx_support.h"
#ident "@(#)$Header: c:\\cygwin\\cvsroot/Vert03/vertlib/ext_nets.c,v 1.1.1.1 2003/11/04 23:34:57 mjames Exp $"
/* this function sets the is_external flags on sockets */
typedef enum { SET_EXT,DEL_EXT,SET_FPGA,DEL_FPGA } flag_change_t;
static void set_clear_flags(char * template,
flag_change_t oper)
{
int rc;
long count = 0;
socket_t * skt = socket_head;
int found = 0,pass;
net_t *routed_net = routed_list;
/* compile regular expression */
vert_regex_t * preg;
rc = vert_regcomp(&preg,template);
if (rc != 0 )
{
char errbuff[100];
regerror(rc,preg->preg,errbuff,100);
Log(LOG_ERROR,"-- Problem (rc=%d) %s with '%s' as regular expression\n",rc,errbuff,template);
return /*TCL_ERROR*/;
}
else
{
Log(LOG_GENERAL,"-- Using '%s' as match pattern\n",template);
}
while(skt) {
found = regexec(preg->preg,skt->identifier,0,preg->regpatt,0);
if(!found) {
switch (oper) {
case SET_EXT:
if(level & 4)
Log(LOG_GENERAL,"-- Set '%s' as external\n",skt->identifier);
skt->is_external = 1;
count++;
break;
case DEL_EXT:
if(level & 4)
Log(LOG_GENERAL,"-- Set '%s' as internal\n",skt->identifier);
skt->is_external = 0;
count++;
break;
case SET_FPGA:
if(level & 4)
Log(LOG_GENERAL,"-- Set '%s' as FPGA\n",skt->identifier);
skt->is_FPGA = 1;
count++;
break;
case DEL_FPGA:
if(level & 4)
Log(LOG_GENERAL,"-- Set '%s' as not FPGA\n",skt->identifier);
skt->is_FPGA = 0;
count++;
break;
}
}
skt = skt->next;
}
/* code moved here from jumpering.c as it is needed in several contexts, not just in jumpering */
/* firstly, set up the has_external flags on all of the nets, by checking to see if any
nodes on any nets are connected to external sockets.
If connected to an external socket, the net gets the property has_external*/
pass = 2;
while (pass)
{
if (pass == 2)
{
routed_net = routed_list;
pass = 1;
}
else
{
routed_net = named_list;
pass = 0;
};
while (routed_net)
{
noderef_t *noderefs = routed_net->nodes;
routed_net->has_external = 0;
while (noderefs)
{
if (noderefs->node->socket->is_external && !routed_net->has_external) {
routed_net->has_external = 1;
/* Log(LOG_GENERAL,"-- external socket on net %s\n",routed_net->identifier); */
}
noderefs = noderefs->next;
}
/* if(!routed_net->has_external)
Log(LOG_GENERAL,"-- no external socket on net %s\n",routed_net->identifier); */
routed_net = routed_net->next;
}
}
vert_regfree(&preg);
Log(LOG_GENERAL,"-- Set/cleared flag on %d objects\n",count);
}
void set_external_flags(char * template )
{
Log(LOG_GENERAL,"-- Beginning setting external flags : prefix '%s' --\n",template );
set_clear_flags(template,SET_EXT);
Log(LOG_GENERAL,"-- Finished setting external flags --\n");
}
void clear_external_flags(char * template )
{
Log(LOG_GENERAL,"-- Beginning clearing external flags : prefix '%s' --\n",template );
set_clear_flags(template,DEL_EXT);
Log(LOG_GENERAL,"-- Finished clearing external flags --\n");
}
void set_FPGA_flags(char * template )
{
Log(LOG_GENERAL,"-- Beginning setting FPGA flags : prefix '%s' --\n",template );
set_clear_flags(template,SET_FPGA);
Log(LOG_GENERAL,"-- Finished setting FPGA flags --\n");
}
void clear_FPGA_flags(char * template )
{
Log(LOG_GENERAL,"-- Beginning setting FPGA flags : prefix '%s' --\n",template );
set_clear_flags(template,DEL_FPGA);
Log(LOG_GENERAL,"-- Finished setting FPGA flags --\n");
}