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

Re: gEDA-user: Check for same refdes



Hi all,

Thank you Stuart, for committing the changes into CVS.

Something "funny" happened....
When I was working on the DRC patch yesterday, I added a specific check
for duplicated references to the DRC2 backend. This change was not
included in the patch because the file was overwrote with the original
version by accident before I made the diff.

When Peter asked about changing the message, I wonder what was
happening... I realized the DRC2 changes were missing, and I coded them
again. I attach now the diff, and please accept my apologies for all the
inconveniences.

The "funny" thing is that the duplicated reference problem was already
begin catched by the DRC2 backend, just because if there are duplicated
references, there should be duplicated slots used as well...

So now, the question is: should this new test be added to the drc2
backend? 
Personally, I think it won't hurt anyone, while it can give more
information of what's wrong to the user, so my vote is to include it
anyway.

Any thoughts?

Regards,

Carlos

El dom, 23-01-2005 a las 10:03 +0100, Peter Kaiser escribió:
> Hi Carlos,
> 
> new DRC2 runs fine.
> 
> It found my refdes=A? as well as my double transistor M2!!
> 
> May be you can change the message:
> Checking duplicated slots...
> 
> to:
> Checking duplicated slots or same refdes...
> 
> In analog simulation I never use the slot attribute. It always will be the 
> problem that the same refdes is on two components.
> 
> Thank's for your work.
> 
> 
> Peter
> 
> 
> 
> 
> 
> 
> Am Samstag, 22. Januar 2005 22:46 schrieb Carlos Nieves Ónega:
> > 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: ChangeLog
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/ChangeLog,v
retrieving revision 1.210
diff -a -u -r1.210 ChangeLog
--- ChangeLog	8 Jan 2005 02:12:53 -0000	1.210
+++ ChangeLog	23 Jan 2005 12:30:42 -0000
@@ -1,3 +1,19 @@
+2004-01-23 Carlos Nieves Onega <cnieves@xxxxxxxxxx>
+
+	* scheme/gnet-drc2.scm: Added check for duplicated references. 
+	
+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: scheme/gnet-drc2.scm
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/devel/gnetlist/scheme/gnet-drc2.scm,v
retrieving revision 1.2
diff -a -u -r1.2 gnet-drc2.scm
--- scheme/gnet-drc2.scm	27 Oct 2003 02:37:32 -0000	1.2
+++ scheme/gnet-drc2.scm	23 Jan 2005 12:30:47 -0000
@@ -21,6 +21,7 @@
 ;; DRC backend written by Carlos Nieves Onega starts here.
 ;;
 ;;
+;;  2005-01-23: Added check for duplicated references.
 ;;  2003-10-24: Added numslots and slot attributes check.
 ;;  2003-06-17: Added configuration support and slots check.
 ;;  2003-06-05: Now checking for unconnected pins look into the DRC matrix if 
@@ -40,6 +41,7 @@
 ;;       Check                                    Variable                       Value
 ;; -----------------------------------------------------------------------------------------------
 ;; Not numbered parts.                     dont-check-non-numbered-parts         whatever you want
+;; Duplicated part references  (Note 1)    dont-check-duplicated-references      whatever you want
 ;; Nets with only one connection.          dont-check-one-connection-nets        whatever you want
 ;; Type of pins connected to each net.     dont-check-pintypes-of-nets           whatever you want
 ;; Net not driven.                         dont-check-not-driven-nets            whatever you want
@@ -51,8 +53,12 @@
 ;;     Report them as a warning            action-unused-slots                   #\w
 ;;     Report them as an error             action-unused-slots                   #\w
 ;;
+;; Note 1: DRC checks are case sensitive by default. If you want them to be case insensitive, then you
+;; only have to define the variable 'case_insensitive' to whatever value you want.
+;;
 ;; Example:
 ;; (define dont-check-non-numbered-parts 1)
+;; (define dont-check-duplicated-references 1)
 ;; (define dont-check-one-connection-nets 1)
 ;; (define dont-check-pintypes-of-nets 1)
 ;; (define dont-check-not-driven-nets 1)
@@ -60,6 +66,7 @@
 ;; (define dont-check-duplicated-slots 1)
 ;; (define dont-check-unused-slots 1)
 ;; (define action-unused-slots #\w)
+;; (define case_insensitive 1)
 ;;
 ;; The check for not driven nets only is performed when checking the type of the pins connected 
 ;; to each net.
@@ -461,6 +468,40 @@
     (for-each check-slots-of-package packages)
     ))
 
+;; Count the ocurrences of a given reference in the given list.
+(define drc2:count-reference-in-list
+  (lambda (refdes list)
+    (if (null? list)
+	0
+	(let ( (comparison (if (defined? 'case_insensitive)
+			       (string-ci=? refdes (car list))
+			       (string=? refdes (car list)))))
+	  (if comparison
+	      (+ 1 (drc2:count-reference-in-list refdes (cdr list)))
+	      (+ 0 (drc2:count-reference-in-list refdes (cdr list))))
+	  ))
+))
+
+;; Check duplicated references of the given list
+;;   If the number of ocurrences of a reference in the schematic doesn't match the number
+;;   of unique slots used by that part, then that reference is used more than one time in
+;;   the schematic.
+(define drc2:check-duplicated-references 
+  (lambda (port list)
+    (if (null? list)
+	0
+	(let ( (refdes (car list)))
+	       (if (> (drc2:count-reference-in-list refdes (gnetlist:get-non-unique-packages ""))
+		      (length (gnetlist:get-unique-slots refdes)))
+		   (begin
+		     (display (string-append "ERROR: Duplicated reference " refdes ".") port)
+		     (newline port)
+		     (set! errors_number (+ errors_number 1))))
+	       (drc2:check-duplicated-references port (cdr list))
+	       ))
+))
+
+
 ;
 ;  End of symbol checking functions
 ;-----------------------------------------------------------------------
@@ -803,6 +844,14 @@
 		  (drc2:check-non-numbered-items port packages)
 		  (newline port)))
 
+	    ;; Check for duplicated references   
+	    (if (not (defined? 'dont-check-duplicated-references))
+		(begin
+		  (display "Checking duplicated references..." port)
+		  (newline port)
+		  (drc2:check-duplicated-references port packages)
+		  (newline port)))
+
 	    ;; Check nets with only one connection
 	    (if (not (defined? 'dont-check-one-connection-nets))
 		(begin