/*
* $id: c:\\cygwin\\cvsroot/vertical/bundle.c,v 1.9 2001/10/31 16:23:44 mjames Exp $
*
* $Log: bundle.c,v $
* Revision 1.2 2004/06/22 21:44:14 mjames
* Firrst build most files
*
* Revision 1.13 2002/09/09 10:18:04 mjames
* Moved pin remapping function to pin ident editing function from
* sorting pin name routine.
*
* Revision 1.12 2002/08/23 14:21:21 mjames
* Cleared the bundle_index of a pin that does not have bundle membership
*
* Revision 1.11 2001/12/20 13:52:15 mjames
* Removed lost variables
*
* Revision 1.10 2001/10/31 22:19:57 mjames
* Tidying up problematical comments caused by CVS
* 'intelligent' comment guessing
*
* Revision 1.9 2001/10/31 16:23:44 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.8 2001/10/23 21:16:46 mjames
* Removed highest_bundle attribute if someone is removing the bundle
*
* Revision 1.7 2001/10/10 20:18:45 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.6 2001/10/07 20:50:55 mjames
* Added wildcard checking (warn user about
* using wildcard '*' on the end of a string in stead of wildcard '.*')
*
* Revision 1.5 2001/09/25 23:15:24 mjames
* Converted wildcards to use proper regexp pattern match library
*
* Revision 1.4 2001/09/16 20:36:04 mjames
* Second attempt to modify wire bundles to be connector rather than net
* centric. Allows more than one connector to carry the same net,
*
* Revision 1.3 2001/09/16 19:50:07 mjames
* Second attempt at bundling the pins on sockets
*
* Revision 1.2 2001/09/13 21:09:51 mjames
* Using correct pointer references
*
* Revision 1.1 2001/09/12 21:27:21 mjames
* Bundling for Certify .vb files. Bundle up all wires on a connector into a bus
* with the same name as the connector and a width the same as the pins
* on the connector
*
*/
#include "cmdlog.h"
#include "cmdparse.h"
#include "database.h"
#include "expression.h"
#include "generic.h"
#include "printout.h"
#include "sorting.h"
#include "vertcl_main.h"
#include <ctype.h>
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ident "@(#)$Header: C:/cvsroot/Vert03/vertlib/bundle.c,v 1.2 2004/06/22 21:44:14 mjames Exp $"
/* this function sets or clears all of the bundle group related to a socket */
/* it allocates a unique integer to each net on the port list of the socket */
/* faults : Does not check pin directions yet */
/* assumes a net is only on one socket. not true for rings ! */
static void set_bundle (socket_t *socket, int set_or_clear)
{
node_t *node;
int rows, columns;
int bundle;
int bundle_base;
/* Use generics to set up the bundle base */
generic_info_t gen[1];
if (!socket)
return;
/* is the array going from 130:1 or 129:0 ... */
bundle_base = 1;
if (get_generic_value (&socket->generics, "bundle_base", gen) == IS_INTEGER)
{
bundle_base = eval_expression (gen->expr, &global_generics);
}
/* Removed Nov 2008 MDJ
if (get_generic_value(&global_generics, "bundle_base",gen) == IS_INTEGER)
{
bundle_base = eval_expression(gen->expr, &global_generics);
}
*/
/*
printf("bundle base \n",bundle_base);
*/
sort_nodes (socket, EXTRACT_XY);
/* the sort routine tells me pin row and column limits */
/* rows are defined as numbers, columns defined as letters */
rows = socket->max_pin_row - socket->min_pin_row + 1;
columns = socket->max_pin_col - socket->min_pin_col + 1;
node = socket->nodes;
bundle = 0;
while (node)
{
net_t *net = node->net;
/*
printf("node %s\n",node->identifier);
*/
if (net)
{
if (set_or_clear && net->how_routed != Not_Routable)
{
node->bundle_index =
node->pin_row - socket->min_pin_row +
(node->pin_col - socket->min_pin_col) * rows + bundle_base;
net->bundle_member = 1;
bundle++;
/*
printf("net %s ->
%s[%d]\n",net->identifier,net->bundle_parent->identifier,net->bundle_index);
*/
}
else /* clear */
{
node->bundle_index = -1;
net->bundle_member = 0;
}
}
else
{
node->bundle_index = -1;
}
node = node->sktnext;
}
if (set_or_clear)
{
socket->highest_bundle =
rows * columns + bundle_base - 1; /* one more than bundle pins */
socket->lowest_bundle = bundle_base;
socket->bundle_width = bundle;
}
else
{
socket->highest_bundle = 0;
socket->lowest_bundle = 0;
socket->bundle_width = 0;
}
/* for further declarations */
}
void wildcard_bundle (char *chip_id_template, int create_or_delete)
{
int rc;
socket_t *skt = socket_head;
int count = 0;
int found = 0;
/* create_unrouted_list(); */
/* compile regular expression */
vert_regex_t *preg;
if (!chip_id_template)
{
chip_id_template = ".*";
}
rc = vert_regcomp (&preg, chip_id_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,
chip_id_template);
/* return TCL_ERROR;
*/
return;
}
else
{
Log (LOG_GENERAL, "-- Using '%s' as match pattern\n", chip_id_template);
}
while (skt)
{
found = regexec (preg->preg, skt->identifier, 0, preg->regpatt, 0);
if (!found)
{
/*
Log(LOG_GENERAL,"found %s\n",skt->identifier);
*/
count++;
set_bundle (skt, create_or_delete);
}
skt = skt->next;
}
Log (LOG_GENERAL, "-- matched %d sockets\n", count);
vert_regfree (&preg);
}