[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-bug: gEDA
This is a multi-part message in MIME format.
--------------040801000804050903090007
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hi, Dan McMahill suggested I submit this as a bug so as it's less likely
to get lost:
Hi all. I'm not sure what the preferred patch file format is for you
guys, this was made with 'cvs diff -Nau' followed by the filenames. I'm
adding a file but -N didn't seem to catch it, so it's attached
seperately. Here's the summary:
net=Vcc:8,15,14 (for example) is now checked against the pinnumber=
attribs for duplicates.
footprint= is checked to get the proper pincount (I included some
support for special cases like TO92, which doesn't quite have 92 pins :)
, and the number of pins defined vs. the number of pins that SHOULD be
defined is compared. Total pins are found by: total = num_net_pins +
(numslots * numpins). Of course if numslots == 0 that multiplier
doesn't happen.
It's a quick hack but I wanted to check that on some new symbols I
created. I ran it against the current symbols and there are quite a few
(especially in 4000 and 74) that this throws warnings on.
Attachments follow.
Jim
--------------040801000804050903090007
Content-Type: text/plain;
name="pincounts.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="pincounts.h"
/* pincounts.h */
typedef struct st_pincount PINCOUNT;
struct st_pincount {
char *footprint;
int pincount;
};
static PINCOUNT p_pincounts[] = {
{ "footprint=TO92", 3 },
{ "footprint=TO-220AB", 3 },
{ NULL, 3 },
};
int s_get_footprint_size(char *footprint)
{
PINCOUNT *pcount = p_pincounts;
char *tmp;
while(pcount->footprint != NULL) {
if (!strcasecmp(footprint, pcount->footprint))
return pcount->pincount;
pcount++;
}
tmp = &footprint[strlen(footprint)-1];
while((*tmp >= '0') && (*tmp <= '9'))
{
if (tmp == footprint)
return -1;
tmp--;
}
tmp++;
if (*tmp == '\0')
return -1;
return atoi(tmp);
}
--------------040801000804050903090007
Content-Type: text/plain;
name="symcheck.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="symcheck.patch"
Index: include/struct.h
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gsymcheck/include/struct.h,v
retrieving revision 1.5
diff -a -u -r1.5 struct.h
--- include/struct.h 26 Jul 2002 03:32:53 -0000 1.5
+++ include/struct.h 27 Aug 2004 07:52:18 -0000
@@ -52,10 +52,15 @@
/* misc attributes */
int found_footprint;
+ int footprint_size;
int found_refdes;
/* number of pins */
int numpins;
+ /* number of net pins */
+ int numnetpins;
+ /* number of slots */
+ int numslots;
/* total error counter */
int error_count;
Index: include/prototype.h
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gsymcheck/include/prototype.h,v
retrieving revision 1.11
diff -a -u -r1.11 prototype.h
--- include/prototype.h 4 Jul 2004 03:29:45 -0000 1.11
+++ include/prototype.h 27 Aug 2004 07:52:19 -0000
@@ -29,6 +29,7 @@
void s_check_obsolete_forbidden_attributes(OBJECT *object_head, SYMCHECK *s_current);
void s_check_missing_attribute(OBJECT *object, char *attribute, SYMCHECK *s_current);
void s_check_missing_attributes(OBJECT *object_head, SYMCHECK *s_current);
+void s_check_totalpins(OBJECT *object_head, SYMCHECK *s_current);
/* s_symstruct.c */
SYMCHECK *s_symstruct_init(void);
void s_symstruct_print(SYMCHECK *s_current);
Index: src/s_check.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gsymcheck/src/s_check.c,v
retrieving revision 1.18
diff -a -u -r1.18 s_check.c
--- src/s_check.c 7 Sep 2002 23:44:58 -0000 1.18
+++ src/s_check.c 27 Aug 2004 07:52:23 -0000
@@ -32,7 +32,7 @@
#include "../include/struct.h"
#include "../include/globals.h"
#include "../include/prototype.h"
-
+#include "../include/pincounts.h"
int
s_check_all(TOPLEVEL *pr_current)
@@ -82,7 +82,13 @@
/* check for device attribute */
s_check_device(object_head, s_symcheck);
-
+
+ /* check for missing attributes */
+ s_check_missing_attributes(object_head, s_symcheck);
+
+ /* check for obsolete attributes */
+ s_check_obsolete_forbidden_attributes(object_head, s_symcheck);
+
/* check for pinseq attribute (and multiples) on all pins */
s_check_pinseq(object_head, s_symcheck);
@@ -104,11 +110,8 @@
/* check for connections with in a symbol (completely disallowed) */
s_check_connections(object_head, s_symcheck);
- /* check for missing attributes */
- s_check_missing_attributes(object_head, s_symcheck);
-
- /* check for obsolete attributes */
- s_check_obsolete_forbidden_attributes(object_head, s_symcheck);
+ /* Check to make sure the total number of pins is correct */
+ s_check_totalpins(object_head, s_symcheck);
/* now report the info/warnings/errors to the user */
@@ -359,13 +362,83 @@
int missing_pinnumber_attrib_sum=0;
int multiple_pinnumber_attrib_sum=0;
int counter=0;
+ int j;
GList *found_numbers = NULL;
GList *ptr1 = NULL;
GList *ptr2 = NULL;
- char *number;
+ char *number = NULL;
char *message;
+ char *net = NULL;
+ char *temp;
+ char *netpins = NULL;
char tempstr[10];
+
+ counter = 0;
+
+ while(net = o_attrib_search_toplevel(object_head, "net", counter))
+ {
+ message = u_basic_strdup_multiple("Found net=", net,
+ " attribute\n", NULL);
+ s_current->info_messages = g_list_append(s_current->info_messages,
+ message);
+
+ netpins = u_basic_breakup_string(net, ':', 1);
+
+ if (!netpins) {
+ message = u_basic_strdup("Bad net= attribute\n");
+ s_current->error_messages = g_list_append(s_current->error_messages,
+ message);
+ s_current->error_count++;
+
+ free(net);
+ counter++;
+ continue;
+ }
+
+ j = 0;
+ do {
+ if (number) {
+ free(number);
+ number = NULL;
+ }
+
+ number = u_basic_breakup_string(netpins, ',', j);
+
+ if (!number)
+ break;
+
+ message = u_basic_strdup_multiple("Found pin number ", number,
+ " in net attribute\n", NULL);
+ s_current->info_messages = g_list_append(s_current->info_messages,
+ message);
+
+
+ if (strcmp(number, "0") == 0) {
+ message = u_basic_strdup("Found pinnumber 0 in net= attribute\n");
+ s_current->error_messages = g_list_append(s_current->error_messages,
+ message);
+ s_current->error_count++;
+ }
+
+ temp = g_strdup(number);
+ found_numbers = g_list_append(found_numbers, temp);
+
+ s_current->numnetpins++;
+
+ j++;
+ } while (number);
+
+ if (number)
+ free(number);
+
+
+ free(net);
+ free(netpins);
+
+ counter++;
+ }
+
o_current = object_head;
while(o_current != NULL)
@@ -394,7 +467,7 @@
while (string)
{
message = u_basic_strdup_multiple("Found pinnumber=", string,
- " attribute\n", NULL);
+ " attribute\n", NULL);
s_current->info_messages = g_list_append(s_current->info_messages,
message);
@@ -435,11 +508,13 @@
s_current->missing_pinnumber_attrib += missing_pinnumber_attrib_sum;
s_current->multiple_pinnumber_attrib += multiple_pinnumber_attrib_sum;
}
-
o_current = o_current->next;
}
+
+
+
ptr1 = found_numbers;
while (ptr1)
{
@@ -480,7 +555,7 @@
g_list_free(found_numbers);
- sprintf(tempstr, "%d", s_current->numpins);
+ sprintf(tempstr, "%d", s_current->numpins + s_current->numnetpins);
message = u_basic_strdup_multiple("Found ", tempstr, " pins inside symbol\n", NULL);
s_current->info_messages = g_list_append(s_current->info_messages,
message);
@@ -496,7 +571,6 @@
char* slotnum = NULL;
char* pins = NULL;
char* temp = NULL;
- int numslots;
char numslots_str[10];
int slot;
int i,j;
@@ -517,8 +591,8 @@
return;
}
- numslots=atoi(value);
- sprintf(numslots_str, "%d", numslots);
+ s_current->numslots=atoi(value);
+ sprintf(numslots_str, "%d", s_current->numslots);
free(value);
message = u_basic_strdup_multiple("Found numslots=", numslots_str,
@@ -526,7 +600,7 @@
s_current->info_messages = g_list_append(s_current->info_messages,
message);
- if (numslots == 0) {
+ if (s_current->numslots == 0) {
message = u_basic_strdup("numslots set to zero, symbol does not have slots\n");
s_current->info_messages = g_list_append(s_current->info_messages,
message);
@@ -539,7 +613,7 @@
while (slotdef != NULL)
{
- if (i > numslots-1) {
+ if (i > s_current->numslots-1) {
sprintf(tempstr1, "%d", i+1); /* i starts at zero */
message =
@@ -585,7 +659,7 @@
free(slotnum);
/* make sure that the slot # is less than the number of slots */
- if (slot > numslots) {
+ if (slot > s_current->numslots) {
sprintf(tempstr1, "%d", slot);
message =
u_basic_strdup_multiple("Slot ", tempstr1,
@@ -690,7 +764,7 @@
}
- if (!slotdef && i < numslots) {
+ if (!slotdef && i < s_current->numslots) {
message =
u_basic_strdup_multiple("Missing slotdef= (there should be ",
numslots_str, " slotdef= attributes)\n",
@@ -1050,7 +1124,10 @@
s_check_missing_attributes(OBJECT *object_head, SYMCHECK *s_current)
{
OBJECT *o_current;
+ PINCOUNT *pcount;
char *message;
+ char tempstr[10];
+ char *tmp;
o_current = object_head;
while(o_current != NULL)
@@ -1068,6 +1145,18 @@
" attribute\n", NULL);
s_current->info_messages = g_list_append(s_current->info_messages,
message);
+
+
+ s_current->footprint_size = s_get_footprint_size(
+ o_current->text->string);
+
+ sprintf(tempstr, "%d", s_current->footprint_size);
+
+ message = u_basic_strdup_multiple("Footprint size is ",
+ tempstr, ".\n", NULL);
+ s_current->info_messages = g_list_append(s_current->info_messages,
+ message);
+
s_current->found_footprint++;
}
@@ -1115,3 +1204,28 @@
}
}
+
+void
+s_check_totalpins(OBJECT *object_head, SYMCHECK *s_current)
+{
+ int totalpins = 0;
+ char *message;
+
+ totalpins = s_current->numnetpins;
+
+ if (s_current->numslots)
+ totalpins += s_current->numpins * s_current->numslots;
+ else
+ totalpins += s_current->numpins;
+
+ if (totalpins != s_current->footprint_size &&
+ s_current->footprint_size != -1) {
+ message = u_basic_strdup_multiple("Number of pins does not match ",
+ "footprint size.\n", NULL);
+ s_current->warning_messages = g_list_append(s_current->warning_messages,
+ message);
+ s_current->warning_count++;
+ }
+
+
+}
Index: src/s_symstruct.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gsymcheck/src/s_symstruct.c,v
retrieving revision 1.10
diff -a -u -r1.10 s_symstruct.c
--- src/s_symstruct.c 26 Jul 2002 03:32:53 -0000 1.10
+++ src/s_symstruct.c 27 Aug 2004 07:52:23 -0000
@@ -70,7 +70,10 @@
s_symcheck->found_footprint=FALSE;
s_symcheck->found_refdes=FALSE;
+ s_symcheck->footprint_size = -1;
s_symcheck->numpins=0;
+ s_symcheck->numnetpins=0;
+ s_symcheck->numslots=0;
s_symcheck->error_count=0;
s_symcheck->warning_count=0;
--------------040801000804050903090007--