[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: Check for same refdes



Hi Peter,
attached is a patch implementing duplicate refdes checking. (diff using
CVS version 20050117).
It does the following:
	- Add a new function to libgeda and gnetlist to get a non-unique list
of refdes.
	- Add the new check to drc2 backend.
	- When running gnetlist, remind the user to check the schematics using
the drc2 backend.
	- Slightly modify the behaviour of gnetlist. When there's a component
which has no slot attribute, gnetlist threw a warning (component without
slot attribute), and all backends get the slot 0 for that component. Now
the warning is removed, and the backends get the slot 1 for that
component. I think this is correct, since when there's no slot
attribute, it's assumed that the component is using slot 1.

Hope it's useful. Like all new features, test it and be careful !!. ;-)
(it may contain bugs).

Regards,

Carlos

Note to any developer with CVS access: I have no access to CVS, so feel
free to include this patch.

El dom, 16-01-2005 a las 23:22 +0100, Peter Kaiser escribió:
> Hello,
> 
> is there any possibility to check whether the same refdes attribute is twice 
> on the page?
> 
> I always run into problems when netlisting and I either forgot to replace the 
> R? with R4 or when I copy a block.
> 
> The netlister gives no message when R4 appears twice on a page. The netlist is 
> wrong.
> 
> Peter
> 
> 
> ---Publicidad--------------------------------------------------------
> Melodas y Juegos flipantes para tu mvil  Descrgalas !
> http://www.mobileparty.net/?login=778336
-- 
Carlos Nieves Ónega <cnieves@xxxxxxxxxx>
Index: geda/devel/gnetlist/ChangeLog
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/ChangeLog,v
retrieving revision 1.210
diff -a -u -r1.210 ChangeLog
--- geda/devel/gnetlist/ChangeLog	8 Jan 2005 02:12:53 -0000	1.210
+++ geda/devel/gnetlist/ChangeLog	22 Jan 2005 21:28:45 -0000
@@ -1,3 +1,15 @@
+2004-01-22 Carlos Nieves Onega <cnieves@xxxxxxxxxx>
+
+	* src/g_register.c, src/g_netlist.c, include/prototype.h: 
+	Added function g_get_non_unique_packages so backends 
+	can get a non-unique list of packages. Useful for DRC checking.
+
+	* src/g_netlist.c: g_get_slots and g_get_unique_slots functions: 
+	If a package has no slots attribute, then assume it's using slot 1.
+
+	* src/gnetlist.c: Remind the user to check the schematic
+	has no errors using drc2 backend. 
+	
 2004-12-28 Stuart Brorson   <sdb@xxxxxxxxxx>
 
 	* lib/system-gnetlistrc: Changed to refer to system-gafrc instead
Index: geda/devel/gnetlist/include/prototype.h
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/include/prototype.h,v
retrieving revision 1.38
diff -a -u -r1.38 prototype.h
--- geda/devel/gnetlist/include/prototype.h	17 Jan 2005 03:24:40 -0000	1.38
+++ geda/devel/gnetlist/include/prototype.h	22 Jan 2005 21:28:46 -0000
@@ -3,6 +3,7 @@
 SCM g_get_command_line();   /* SDB -- 8.22.2004 */
 SCM g_get_calling_flags();  /* SDB -- 9.1.2003  */
 SCM g_get_packages(SCM level);
+SCM g_get_non_unique_packages(SCM level);
 SCM g_get_pins(SCM uref);
 SCM g_get_all_nets(SCM scm_level);
 SCM g_get_all_unique_nets(SCM scm_level);
Index: geda/devel/gnetlist/src/g_netlist.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/src/g_netlist.c,v
retrieving revision 1.32
diff -a -u -r1.32 g_netlist.c
--- geda/devel/gnetlist/src/g_netlist.c	3 Sep 2004 23:33:04 -0000	1.32
+++ geda/devel/gnetlist/src/g_netlist.c	22 Jan 2005 21:28:50 -0000
@@ -70,6 +70,36 @@
     return (list);
 }
 
+/* this function will only return a non unique list of packages */
+SCM g_get_non_unique_packages(SCM level)
+{
+    SCM list = SCM_EOL;
+
+    NETLIST *nl_current = NULL;
+
+    SCM_ASSERT( (SCM_NIMP (level) && SCM_STRINGP (level) ),
+		level, SCM_ARG1, "gnetlist:get-pins");
+
+    nl_current = netlist_head;
+    s_scratch_string_init();
+
+    while (nl_current != NULL) {
+
+	if (nl_current->component_uref) {
+	    if (s_scratch_non_unique_string_fill(nl_current->component_uref)) {
+		list = gh_cons(gh_str2scm(nl_current->component_uref,
+					  strlen
+					  (nl_current->component_uref)),
+			       list);
+	    }
+	}
+	nl_current = nl_current->next;
+    }
+
+    s_scratch_string_free();
+    return (list);
+}
+
 
 SCM g_get_pins(SCM uref)
 {
@@ -799,8 +829,11 @@
 					 complex->prim_objs, "slot",
 					 0);
 		}
-		if (slot_tmp) {
-		  slot = g_strconcat ("#d", slot_tmp, NULL);
+		/* When a package has no slot attribute, then assume it's slot number 1 */
+		if (!slot_tmp) {
+		  slot_tmp=g_strdup("1");
+		}
+		slot = g_strconcat ("#d", slot_tmp, NULL);
 		  free (slot_tmp);
 		  slot_number = scm_string_to_number(gh_str2scm(slot, strlen(slot)),
 						     SCM_MAKINUM(10));
@@ -810,10 +843,6 @@
 		  }
 		  else 
 		    fprintf(stderr, "Uref %s: Bad slot number: %s.\n", uref, slot_tmp);
-		} 
-		else {
-		  fprintf(stderr, "Found uref %s without slot attribute\n", uref);
-		}
 	    }
 	}
 	nl_current = nl_current->next;
@@ -864,23 +893,22 @@
 					 complex->prim_objs, "slot",
 					 0);
 		}
-		if (slot_tmp) {
-		  slot = g_strconcat ("#d", slot_tmp, NULL);
-		  free (slot_tmp);
-		  slot_number = scm_string_to_number(gh_str2scm(slot, strlen(slot)),
-						     SCM_MAKINUM(10));
-		  free (slot);
-		  if (slot_number != SCM_BOOL_F) {
-		    if (scm_member(slot_number, slots_list) ==  SCM_BOOL_F) {
-		      slots_list = gh_cons(slot_number, slots_list);
-		    }
+		/* When a package has no slot attribute, then assume it's slot number 1 */
+		if (!slot_tmp) {
+		  slot_tmp=g_strdup("1");
+		}
+		slot = g_strconcat ("#d", slot_tmp, NULL);
+		free (slot_tmp);
+		slot_number = scm_string_to_number(gh_str2scm(slot, strlen(slot)),
+						   SCM_MAKINUM(10));
+		free (slot);
+		if (slot_number != SCM_BOOL_F) {
+		  if (scm_member(slot_number, slots_list) ==  SCM_BOOL_F) {
+		    slots_list = gh_cons(slot_number, slots_list);
 		  }
-		  else 
-		    fprintf(stderr, "Uref %s: Bad slot number: %s.\n", uref, slot_tmp);
-		} 
-		else {
-		  fprintf(stderr, "Found uref %s without slot attribute\n", uref);
 		}
+		else 
+		  fprintf(stderr, "Uref %s: Bad slot number: %s.\n", uref, slot_tmp);
 	    }
 	}
 	nl_current = nl_current->next;
Index: geda/devel/gnetlist/src/g_register.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/src/g_register.c,v
retrieving revision 1.27
diff -a -u -r1.27 g_register.c
--- geda/devel/gnetlist/src/g_register.c	3 Sep 2004 23:33:04 -0000	1.27
+++ geda/devel/gnetlist/src/g_register.c	22 Jan 2005 21:28:51 -0000
@@ -68,6 +68,7 @@
 
   /* netlist functions */
   gh_new_procedure1_0("gnetlist:get-packages", g_get_packages);
+  gh_new_procedure1_0("gnetlist:get-non-unique-packages", g_get_non_unique_packages);
   gh_new_procedure1_0("gnetlist:get-pins", g_get_pins);
   gh_new_procedure1_0("gnetlist:get-all-nets", g_get_all_nets);
   gh_new_procedure1_0("gnetlist:get-all-unique-nets",
Index: geda/devel/gnetlist/src/gnetlist.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/src/gnetlist.c,v
retrieving revision 1.34
diff -a -u -r1.34 gnetlist.c
--- geda/devel/gnetlist/src/gnetlist.c	3 Sep 2004 23:33:04 -0000	1.34
+++ geda/devel/gnetlist/src/gnetlist.c	22 Jan 2005 21:28:52 -0000
@@ -106,9 +106,19 @@
     }
 
 #ifdef __MINGW32__
-    fprintf(stderr, "This is the MINGW32 port.\n");
+    fprintf(stderr, "This is the MINGW32 port.\n\n");
 #endif
 
+    s_log_message ("Remember to check that your schematic has no errors using the drc2 backend.\n");
+    s_log_message ("You can do it running 'gnetlist -g drc2 your_schematic.sch -o drc_output.txt'\n");
+    s_log_message ("and seeing the contents of the file drc_output.txt.\n\n");
+
+    if (!quiet_mode) {
+      fprintf (stderr, "Remember to check that your schematic has no errors using the drc2 backend.\n");
+      fprintf (stderr, "You can do it running 'gnetlist -g drc2 your_schematic.sch -o drc_output.txt'\n");
+      fprintf (stderr, "and seeing the contents of the file drc_output.txt.\n\n");
+
+    }
     /* register guile (scheme) functions */
     g_register_funcs();
 
Index: geda/devel/libgeda/ChangeLog
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/libgeda/ChangeLog,v
retrieving revision 1.221
diff -a -u -r1.221 ChangeLog
--- geda/devel/libgeda/ChangeLog	7 Jan 2005 17:44:07 -0000	1.221
+++ geda/devel/libgeda/ChangeLog	22 Jan 2005 21:29:13 -0000
@@ -1,3 +1,12 @@
+2005-01-22  Carlos Nieves Onega <cnieves@xxxxxxxxxx>
+
+	* noweb/prototype.h, noweb/s_scratch.nw: Added function
+	s_scratch_non_unique_string_fill. This can enable gnetlist
+	to return a non-unique list of packages.
+	In order to don't duplicate code, s_scratch_string_fill
+	function now checks if the string is unique and calls 
+	s_scratch_non_unique_string_fill.
+	
 2005-01-07  Patrick Bernaud  <b-patrick@xxxxxxxxxx>
 
 	* noweb/s_project.nw (s_project_setup_rest): Made it handle
Index: geda/devel/libgeda/include/prototype.h
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/libgeda/include/prototype.h,v
retrieving revision 1.81
diff -a -u -r1.81 prototype.h
--- geda/devel/libgeda/include/prototype.h	15 Jan 2005 21:31:40 -0000	1.81
+++ geda/devel/libgeda/include/prototype.h	22 Jan 2005 21:29:18 -0000
@@ -517,6 +517,7 @@
 void s_scratch_string_init(void);
 void s_scratch_string_free(void);
 int s_scratch_string_fill(char *string);
+int s_scratch_non_unique_string_fill(char *string);
 /* s_slib.c */
 int s_slib_add_entry(char *new_path);
 int s_slib_search_for_dirname(char *dir_name);
Index: geda/devel/libgeda/noweb/s_scratch.nw
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/libgeda/noweb/s_scratch.nw,v
retrieving revision 1.2
diff -a -u -r1.2 s_scratch.nw
--- geda/devel/libgeda/noweb/s_scratch.nw	2 Apr 2002 04:07:47 -0000	1.2
+++ geda/devel/libgeda/noweb/s_scratch.nw	22 Jan 2005 21:29:19 -0000
@@ -15,6 +15,7 @@
 <<s_scratch.c : s_scratch_string_init()>>
 <<s_scratch.c : s_scratch_string_free()>>
 <<s_scratch.c : s_scratch_string_fill()>>
+<<s_scratch.c : s_scratch_non_unique_string_fill()>>
 
 @
 
@@ -144,6 +145,27 @@
     }	
   }	
 	
+  return(s_scratch_non_unique_string_fill(string));
+}
+
+
+@ %def s_scratch_string_fill
+
+@section Function @code{s_scratch_non_unique_string_fill()}
+
+@defun s_scratch_non_unique_string_fill string
+@end defun
+
+<<s_scratch.c : s_scratch_non_unique_string_fill()>>=
+/* returns 0 if no string passed, else 1 if added to list */
+int 
+s_scratch_non_unique_string_fill(char *string)
+{
+  int i;
+	
+  if (!string) 
+  return(0);
+
   string_scratch[scratch_index] = (char *) malloc ( sizeof(char) *
                                                     strlen(string) + 1);
 	
@@ -154,5 +176,4 @@
 }
 
 
-@ %def s_scratch_string_fill
-
+@ %def s_scratch_non_unique_string_fill