Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-16 Thread Bob Paddock

>you have to be a bit careful here.
>you have R1, R2, R3 on your board which will get renumberd as
>R2 -> R1
>R1 -> R3
>R3 -> R2

> So it seems like maybe what needs to happen is generate an internal 
> was/is list and then for each pin on a net apply the was/is change.

Protel generates a unique hash, which is a long random string, that is used
as an anchor point, while things are being renumbered.   The first
placed part will be assigned a hash, the seconds place part the next hash.
Then no mater how things are renumbered you always know the first place part,
tho I've never find a reason to care about that.  This method keeps things
from getting scrambled during the renumbering.


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-16 Thread Dan McMahill

Dan McMahill wrote:

Mike Hansen wrote:




Is there documentation anywhere on how to get started in developing 
for PCB/gschem?  I am well versed in Windows C++ development but would 
need quite a bit of time to get up to speed on performing code work in 
PCB.




as DJ mentioned, no real docs other than the pcb web site says how to
get sources from CVS and the file README.cvs talks about what you need
to build from CVS sources.

Here is a patch which gets most of the way there.  Basic functionality
is there and works, the big comment at the top of the ActionRenumber()
function lists whats left to do.




I got a bit overly motivated last night and at lunch today.  I have the 
renumbering pretty much all working.


What I did is add an action, Renumber(), which if called with no 
arguments it will prompt for a file name.  If given a file name as an 
argument it will use that file.  The renumbering runs top to bottom, 
left to right.  In other words you'll get


R1 R2 R3
R4 R5 R6
R7 R8 R9

The output file has all the changes.

The loaded netlist is modified

Parts that have no name keep no name.

Elements which are locked or elements with locked names do not get 
renumbered.


Renumbering starts with the first character which is one of [0-9] or ?.

What is not working is when you renumber and then try to undo, the 
netlist modification is not undone.  This will require modification of 
the undo infrastructure to deal with netlist changes.


At this point I'd appreciate some feedback.  Apply the attached patch to 
current CVS sources and then from within PCB, press ":" (without the 
quotes) to get the action entry and then "Renumber()" (again with no 
quotes).


I'm sure there is room for some more efficient algorithms as there are a 
couple of pretty brute force searches and list insertions.  Also, the 
screen redraws after each element is renumbered.  Doh!


-Dan


Index: src/action.c
===
RCS file: /cvsroot/pcb/pcb/src/action.c,v
retrieving revision 1.89
diff -u -2 -r1.89 action.c
--- src/action.c15 Aug 2006 02:50:42 -  1.89
+++ src/action.c16 Aug 2006 22:07:49 -
@@ -3115,4 +3115,317 @@
 /* --- 
*/
 
+static const char renumber_syntax[] =
+"Renumber()\n"
+"Renumber(filename)";
+
+static const char renumber_help[] =
+"Renumber all elements.";
+
+/* %start-doc actions Renumber
+
+%end-doc */
+
+/* FIXME
+  - add option for renumbering direction (top to bottom, left to right
+  is what I coded up).  Numbering happens on a "row by row" basis.
+
+  - What to do about elements with no name?  Right now they are
+ignored.  Maybe they should get names like I1, I2 (for Instance)
+
+  - need to be able to undo the mods to the netlist.  This will take
+adding infrastructure to the undo system
+
+
+*/
+static int
+ActionRenumber (int argc, char **argv, int x, int y)
+{
+  Boolean changed = False;
+  ElementTypePtr *element_list;
+  ElementTypePtr *locked_element_list;
+  unsigned int i, j, k, cnt, lock_cnt;
+  unsigned int tmpi;
+  size_t sz;
+  char *tmps;
+  char *name;
+  FILE *out;
+  size_t cnt_list_sz = 100;
+  struct _cnt_list {char *name; unsigned int cnt;} *cnt_list;
+  char **was, **is, *pin;
+  unsigned int c_cnt = 0;
+  int unique, ok;
+
+  if (argc < 1)
+name = gui->prompt_for ("Renumber annotation file:", 0);
+  else
+name = argv[0];
+
+  if ((out = fopen (name, "r")))
+{
+  fclose (out);
+  if (! gui->
+ confirm_dialog (_("File exists!  Ok to overwrite?"), 0))
+   return 0;
+}
+  if ((out = fopen (name, "w")) == NULL)
+{
+  Message ("Could not open %s\n", name);
+  return 1;
+}
+
+  fprintf (out, "*COMMENT* PCB Annotation File\n");
+  fprintf (out, "*VERSION* 20060814\n");
+
+  /*
+   * Make a first pass through all of the elements and sort them out
+   * by location on the board.  While here we also collect a list of
+   * locked elements.
+   *
+   * We'll actually renumber things in the 2nd pass.
+   */
+  element_list = calloc (PCB->Data->ElementN, sizeof (ElementTypePtr));
+  locked_element_list = calloc (PCB->Data->ElementN, sizeof (ElementTypePtr));
+  was = calloc (PCB->Data->ElementN, sizeof (char *));
+  is = calloc (PCB->Data->ElementN, sizeof (char *));
+  if (element_list == NULL || locked_element_list == NULL || was == NULL || is 
== NULL)
+{
+  fprintf (stderr, "calloc() failed in %s\n", __FUNCTION__);
+  exit (1);
+}
+  
+
+  cnt = 0;
+  lock_cnt = 0;
+  ELEMENT_LOOP (PCB->Data);
+  {
+if (TEST_FLAG (LOCKFLAG, element->Name) || TEST_FLAG (LOCKFLAG, element))
+  {
+   /* 
+* add to the list of locked elements which we won't try to
+* renumber and whose reference designators are now reserved.
+*/
+   fprintf (out, "*WARN* Element \"%s\" at (%d,%d) is locked and will not 
be renumbered.\n", 
+UNKNOW

Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-16 Thread Dan McMahill

DJ Delorie wrote:

You probably need to update the loaded netlist too.



I think the function that changes the element name should be
responsible for that change also.  No point making everyone's life
difficult.



you have to be a bit careful here.

you have R1, R2, R3 on your board which will get renumberd as


R2 -> R1
R1 -> R3
R3 -> R2



if you work this out ahead of time, you can just iterate through the 
elements and change the names.  But if the individual name changes 
update the netlist, you might go from an original netlist of



net0
   R1-1

net1
   R1-2 R2-1

net2
   R2-2 R3-1

net3
   R3-2


and after the R2->R1 change:

net0
   R1-1

net1
   R1-2 R1-1

net2
   R1-2 R3-1

net3
   R3-2

you see the problem already.  R1-1 is now part of 2 nets.

So it seems like maybe what needs to happen is generate an internal 
was/is list and then for each pin on a net apply the was/is change.


I've done a sort of proof of concept patch for this but it is ugly and 
needs to be refactored a bit before it could be added.


-Dan


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-16 Thread Dan McMahill

Bob Paddock wrote:

On Tuesday 15 August 2006 21:58, Dan McMahill wrote:


Just to be clear, DJ was talking about the case where R1## are on page 
1, R2## on page 2, etc and was suggesting that a board level renumbering 
wouldn't mess with the 1st digit.  It is this particular case where 
you're trying to maintain some of the schematic numbering where I 
wondered if renumbering from the layout made sense.  In the case were 
you're globally renumbering from layout I can certainly see that it 
would be a preference for some people.



It is my preference that the designators do retain schematic page reference.
I do projects with lots of parts, but only can print out Letter sized schematic
pages.  Makes the board a lot easier to stuff, and less clutter on the bench,
if you only have to deal with one page at a time.  That option should be
configurable.



R1 R2 R3
R4 R5 R6
R7 R8 R9




but maybe you want left to right then top to bottom like




R1 R4 R7
R2 R5 R8
R3 R6 R9



In my many years at a contract manufacture it has always been one of those
two, I have never seen the others you listed, 
unless it was completely random; those sucked to work on.




then perhaps in the KISS spirit (keep is simple, stupid) these should be 
the only 2 to support.  Someone else suggested sorting by distance from 
the upper left corner but this seems like it could be a bit confusing in 
the end.


-Dan



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-16 Thread Bob Paddock
On Tuesday 15 August 2006 21:58, Dan McMahill wrote:

> Just to be clear, DJ was talking about the case where R1## are on page 
> 1, R2## on page 2, etc and was suggesting that a board level renumbering 
> wouldn't mess with the 1st digit.  It is this particular case where 
> you're trying to maintain some of the schematic numbering where I 
> wondered if renumbering from the layout made sense.  In the case were 
> you're globally renumbering from layout I can certainly see that it 
> would be a preference for some people.

It is my preference that the designators do retain schematic page reference.
I do projects with lots of parts, but only can print out Letter sized schematic
pages.  Makes the board a lot easier to stuff, and less clutter on the bench,
if you only have to deal with one page at a time.  That option should be
configurable.

>R1 R2 R3
>R4 R5 R6
>R7 R8 R9

>but maybe you want left to right then top to bottom like

>R1 R4 R7
>R2 R5 R8
>R3 R6 R9

In my many years at a contract manufacture it has always been one of those
two, I have never seen the others you listed, 
unless it was completely random; those sucked to work on.

-- 
 http://www.softwaresafety.net/ http://www.designer-iii.com/
 http://www.unusualresearch.com/


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Mike Hansen
It should work like the renumber in gschem, the first digit is maintained as 
normally R is for resistor, C for capacitor, and so on.




From: Dan McMahill <[EMAIL PROTECTED]>
Reply-To: gEDA user mailing list 
To: gEDA user mailing list 
Subject: Re: gEDA-user: Renumber in PCB/Was/Is List
Date: Tue, 15 Aug 2006 21:58:57 -0400

Mike Hansen wrote:
I do find this useful(of course it was me that started the thread).   My 
schematic workflow may not be the best. I just plunk down refdes's that 
are unique and then when I get to the PCB I would like to simply renumber 
and then do a was/is on the schematic once I am done.


Just to be clear, DJ was talking about the case where R1## are on page 1, 
R2## on page 2, etc and was suggesting that a board level renumbering 
wouldn't mess with the 1st digit.  It is this particular case where you're 
trying to maintain some of the schematic numbering where I wondered if 
renumbering from the layout made sense.  In the case were you're globally 
renumbering from layout I can certainly see that it would be a preference 
for some people.


In this day of automation the part numbering on the PCB may not be as big 
a deal as it once was...back in the day the board stuffers had people 
sitting on row after row of benches stuffing parts into the PCB and 
sending them off to wave soldering.  It was a good idea to keep part 
numbers in a logical order so that they weren't searching for the next 
part to stuff on the board.


But even when I do protos I find myself lost on the board if there isn't a 
logical order.


I will see if I can squeeze in some time to look at the example code to 
perform this task.


ok.  I actually made a little more progress, but there are some details 
left on what it should do  to be worked out.



From: DJ Delorie <[EMAIL PROTECTED]>
Reply-To: gEDA user mailing list 
To: geda-user@moria.seul.org
Subject: Re: gEDA-user: Renumber in PCB/Was/Is List
Date: Tue, 15 Aug 2006 18:42:09 -0400

> In this case, is there really much value in renumbering at all from 
the

> layout end of the flow?

Good point ;-)


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user





___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user






___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user





___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Dan McMahill

Mike Hansen wrote:
I do find this useful(of course it was me that started the thread).   My 
schematic workflow may not be the best. I just plunk down refdes's that 
are unique and then when I get to the PCB I would like to simply 
renumber and then do a was/is on the schematic once I am done.


Just to be clear, DJ was talking about the case where R1## are on page 
1, R2## on page 2, etc and was suggesting that a board level renumbering 
wouldn't mess with the 1st digit.  It is this particular case where 
you're trying to maintain some of the schematic numbering where I 
wondered if renumbering from the layout made sense.  In the case were 
you're globally renumbering from layout I can certainly see that it 
would be a preference for some people.


In this day of automation the part numbering on the PCB may not be as 
big a deal as it once was...back in the day the board stuffers had 
people sitting on row after row of benches stuffing parts into the PCB 
and sending them off to wave soldering.  It was a good idea to keep part 
numbers in a logical order so that they weren't searching for the next 
part to stuff on the board.


But even when I do protos I find myself lost on the board if there isn't 
a logical order.


I will see if I can squeeze in some time to look at the example code to 
perform this task.


ok.  I actually made a little more progress, but there are some details 
left on what it should do  to be worked out.



From: DJ Delorie <[EMAIL PROTECTED]>
Reply-To: gEDA user mailing list 
To: geda-user@moria.seul.org
Subject: Re: gEDA-user: Renumber in PCB/Was/Is List
Date: Tue, 15 Aug 2006 18:42:09 -0400

> In this case, is there really much value in renumbering at all from the
> layout end of the flow?

Good point ;-)


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user





___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user






___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Mike Hansen
I do find this useful(of course it was me that started the thread).   My 
schematic workflow may not be the best. I just plunk down refdes's that are 
unique and then when I get to the PCB I would like to simply renumber and 
then do a was/is on the schematic once I am done.


In this day of automation the part numbering on the PCB may not be as big a 
deal as it once was...back in the day the board stuffers had people sitting 
on row after row of benches stuffing parts into the PCB and sending them off 
to wave soldering.  It was a good idea to keep part numbers in a logical 
order so that they weren't searching for the next part to stuff on the 
board.


But even when I do protos I find myself lost on the board if there isn't a 
logical order.


I will see if I can squeeze in some time to look at the example code to 
perform this task.




From: DJ Delorie <[EMAIL PROTECTED]>
Reply-To: gEDA user mailing list 
To: geda-user@moria.seul.org
Subject: Re: gEDA-user: Renumber in PCB/Was/Is List
Date: Tue, 15 Aug 2006 18:42:09 -0400

> In this case, is there really much value in renumbering at all from the
> layout end of the flow?

Good point ;-)


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user





___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Mike Hansen

I was thinking something like this:

-find the part that is closest to the upper left(use the hypoteneuse of the 
X,Y coordinates).  This is our anchor part.   Or we could allow users to 
specify which corner to start at.
-iterate over the list of parts finding the next one closest via hypoteneuse 
from X,Y to X,Y.


Basically the part renumbering would spread out from one corner having the 
lowest numbers to the opposite corner having the highest numbers.




From: Dan McMahill <[EMAIL PROTECTED]>
Reply-To: gEDA user mailing list 
To: gEDA user mailing list 
Subject: Re: gEDA-user: Renumber in PCB/Was/Is List
Date: Tue, 15 Aug 2006 18:28:51 -0400

Mike Hansen wrote:
Does PCB have a renumbering command?  This would be a command that would 
renumber the components on the circuit board say starting with the 
smallest value in the upper left and then proceeding to the lower right 
corner of the board.   And this would also generate a was/is list, showing 
the old component refdes and the new one(ideally you would have an app 
that could take the was/is and update the sch file).



Is there any value in having some controls to how the renumbering would 
work?  In particular, you might want to number left to right, top to bottom 
like:



R1 R2 R3
R4 R5 R6
R7 R8 R9

but maybe you want left to right then top to bottom like

R1 R4 R7
R2 R5 R8
R3 R6 R9

I guess one could support "tblr", "tbrl", "btlr", "btrl", "tblr", "tbrl", 
"btlr", "btrl".  Would this just create confusion?  It could be that "tblr" 
is the default if not specified.


Renumber()  <= uses tblr, prompts for filename
Renumber(lrtb) <= uses lrtb, prmopts for filename
Renumber(tblr, filename) <= uses tblr and specified file


-Dan



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user





___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Steve Meier
Sure there is... to make a maximum test of the shorted nets drc.



On Tue, 2006-08-15 at 18:42 -0400, DJ Delorie wrote:
> > In this case, is there really much value in renumbering at all from the 
> > layout end of the flow?
> 
> Good point ;-)
> 
> 
> ___
> geda-user mailing list
> geda-user@moria.seul.org
> http://www.seul.org/cgi-bin/mailman/listinfo/geda-user



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread DJ Delorie

> In this case, is there really much value in renumbering at all from the 
> layout end of the flow?

Good point ;-)


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Dan McMahill

DJ Delorie wrote:

While thats one valid method, please don't enforce it.



Enforce, no, but I was hoping the final code could perhaps support it.
Say, by only modifying the last N digits?



In this case, is there really much value in renumbering at all from the 
layout end of the flow?


-Dan


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread DJ Delorie

> While thats one valid method, please don't enforce it.

Enforce, no, but I was hoping the final code could perhaps support it.
Say, by only modifying the last N digits?


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Dan McMahill

Mike Hansen wrote:
Does PCB have a renumbering command?  This would be a command that would 
renumber the components on the circuit board say starting with the 
smallest value in the upper left and then proceeding to the lower right 
corner of the board.   And this would also generate a was/is list, 
showing the old component refdes and the new one(ideally you would have 
an app that could take the was/is and update the sch file).



Is there any value in having some controls to how the renumbering would 
work?  In particular, you might want to number left to right, top to 
bottom like:



R1 R2 R3
R4 R5 R6
R7 R8 R9

but maybe you want left to right then top to bottom like

R1 R4 R7
R2 R5 R8
R3 R6 R9

I guess one could support "tblr", "tbrl", "btlr", "btrl", "tblr", 
"tbrl", "btlr", "btrl".  Would this just create confusion?  It could be 
that "tblr" is the default if not specified.


Renumber()  <= uses tblr, prompts for filename
Renumber(lrtb) <= uses lrtb, prmopts for filename
Renumber(tblr, filename) <= uses tblr and specified file


-Dan



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread John Sheahan

DJ Delorie wrote:

This is pretty standard functionality in commercial packages.  The
board stuffers like to have the components in a logical
arrangement(R10 is near R9, etc.).


I always numbered mine by pages, like all R100-R199 were on schematic
page 1, etc.  They tended to get grouped together anyway that way.



While thats one valid method, please don't enforce it.

I prefer to be able to find R101 near R102 on the board, and
use text search in xpdf when I have to locate r101 on the
schematic.
john



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Dan McMahill

Mike Hansen wrote:



Is there documentation anywhere on how to get started in developing for 
PCB/gschem?  I am well versed in Windows C++ development but would need 
quite a bit of time to get up to speed on performing code work in PCB.




as DJ mentioned, no real docs other than the pcb web site says how to
get sources from CVS and the file README.cvs talks about what you need
to build from CVS sources.

Here is a patch which gets most of the way there.  Basic functionality
is there and works, the big comment at the top of the ActionRenumber()
function lists whats left to do.

-Dan

Index: action.c
===
RCS file: /cvsroot/pcb/pcb/src/action.c,v
retrieving revision 1.89
diff -u -2 -r1.89 action.c
--- action.c15 Aug 2006 02:50:42 -  1.89
+++ action.c15 Aug 2006 19:19:58 -
@@ -3115,4 +3115,201 @@
 /* --- 
*/
 
+static const char renumber_syntax[] =
+"Renumber()";
+
+static const char renumber_help[] =
+"Renumber all elements.";
+
+/* %start-doc actions Renumber
+
+%end-doc */
+
+/* FIXME
+   - how to specify the file name?  Probably have a option to get one
+   from calling the action directly like Renumber(logfile) and if not
+   specified have the gui prompt for a file name.
+
+  - add option for renumbering direction (top to bottom, left to right
+  is what I coded up).  Numbering happens on a "row by row" basis.
+
+  - add an option to keep or override locked elements.  I have mixed
+  feelings here.  Do we really ever care about keeping the names on
+  some?  But then again, locked is locked right?
+
+  - What to do about elements with no name?  Right now they are
+ignored.  Maybe they should get names like I1, I2 (for Instance)
+
+  - need to redo the loaded netlist so you can renumber and then hit
+'o' on a complete layout and have it still show correct connectivity.
+
+  - finalize the file format.  I'd vote for something like
+
+command data
+
+where to start with you'd have something like command =
+{*COMMENT*, *RENAME*, *WARN*}
+
+and data is whatever the particular command needs.  So for
+renames, 
+
+*RENAME* "old" "new"
+
+Do we need any rules for quoting here?  This file format is
+simple, similar to the PADS ECO file format, and extensible if we
+state early on that unrecognized commands should just be ignored
+(perhaps with a warning) by any tools which use this file.  
+
+*/
+static int
+ActionRenumber (int argc, char **argv, int x, int y)
+{
+  Boolean changed = False;
+  ElementTypePtr *element_list;
+  unsigned int i, j, cnt;
+  unsigned int tmpi;
+  size_t sz;
+  char *tmps;
+  struct _cnt_list {char *name; unsigned int cnt;} *cnt_list;
+
+  /*
+   * Make a first pass through all of the elements and sort them out
+   * by location on the board.
+   *
+   * We'll actually renumber things in the 2nd pass.
+   */
+
+  printf ("Allocate memory for %d elements\n", PCB->Data->ElementN);
+  element_list = calloc( PCB->Data->ElementN, sizeof (ElementTypePtr));
+  if ( element_list == NULL )
+{
+  fprintf (stderr, "calloc() failed in %s\n", __FUNCTION__);
+  exit (1);
+}
+  
+
+  cnt = 0;
+  ELEMENT_LOOP (PCB->Data);
+  {
+cnt++;
+/*
+  printf("Pass#1: Element name \"%s\" is at %d, %d\n", 
+  UNKNOWN (NAMEONPCB_NAME (element)),
+  element->MarkX, element->MarkY);
+*/
+/* search for correct position in the list */
+i = 0;
+while (element_list[i] && element->MarkY > element_list[i]->MarkY ) 
+  i++;
+
+/*
+  printf ("Index (from Y position is %d\n", i);
+*/
+
+/* 
+ * We have found the position where we have the first element that
+ * has the same Y value or a lower Y value.  Now move forward if
+ * needed through the X values
+ */
+while (element_list[i] 
+  && element->MarkY == element_list[i]->MarkY 
+  && element->MarkX > element_list[i]->MarkX) 
+  i++;
+
+/*
+  printf ("Index (from X position is %d\n", i);
+*/
+for (j = cnt-1; j > i ; j--)
+  {
+   element_list[j] = element_list[j - 1];
+  }
+element_list[i] = element;
+  }
+  END_LOOP;
+
+  /* 
+   * Now that the elements are sorted by board position, we go through
+   * and renumber them.
+   */
+  /* FIXME -- need to grow the list dynamically, this line is LAME */
+  cnt_list = calloc (100, sizeof (struct _cnt_list));
+  for (i = 0; i < cnt; i++)
+{
+  printf("Pass#2: Element name \"%s\" is at %d, %d\n", 
+  UNKNOWN (NAMEONPCB_NAME (element_list[i])),
+  element_list[i]->MarkX, element_list[i]->MarkY);
+
+  /* If there is no refdes, maybe just spit out a warning */
+  if (NAMEONPCB_NAME (element_list[i]))
+   {
+ /* figure out the prefix */
+ tmps = strdup (NAMEONPCB_NAME (element_list[i]));
+ j = 0;
+ while (tmps[j] &&

Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Steve Meier
Well I am also very interested in pin swapping at the PCB level and
then having the schematic corrected.

Some of the devices use differential I/O it would be nice if these pin
pairs were tied together. But on FPGA's the use of a pair of pins as
differential or single ended is mostly up to the designer.

I have been giving some thought (I need to be careful here because DJ
might be listening and some of you might remember what DJ did with my
meanderings about porn converted to PCB foot prints) to an expanded
hierarchical netlist which would include information about which pins
can be swapped and which of those pins can also be used as differential
pairs. Retaining the order in which the pins are swapped is critical.
Esentialy this is how I manualy do it today.

1) draw schematic
2) generate netlist
3) import netlist into PCB
4) figure out which pins to swap (write them down)
5) edit schematic and swap pins by hand
6) regenerate netlist
7) re-import netlist into pcb
8) repeat steps 4 through 7 until i am more crazzy then usual and the
board is completed.

9) find and fix all the shorted pollygons ;) now i am much more crazzy
then normal


My general idea has been that for pin level swapping the symbol must be
embedded in the schematic. A netlist which tells PCB which pins and
"slots" are swapable. PCB would do its majic, correcting its version of
the netlist and generating a list of swapped pins.. This list of swapped
pins would then be output as a file and a new program would read in the
file and swap the attribute information for the embedded symbols. This
would mean that none of the nets would need to be moved.

Also, I would suggest a move towards XML for these files (new netlist
and swapped pins) 

Steve Meier




On Tue, 2006-08-15 at 15:51 -0400, Patrick Doyle wrote:
> The feature I'm most looking forward to coming out of this exercise is
> the ability to back annotate pin-swap information.  Right now I'm just
> plugging my busses together between the processor and the memory (or
> interface connector, or whatever), anticipating that when I look at
> the rats nest I'll wish I swapped the order of a few things.  If I can
> do that in PCB and then flow the information back to the schematic,
> that will be great.  Otherwise, I'm anticipating a couple of
> iterations of the schematic until I see something I like.
> 
> Perhaps those with more experience in this area in general, and with
> these tools in particular, would care to comment on a better approach.
>  I've got thick skin -- be brutal :-)
> 
> --wpd
> 
> 
> ___
> geda-user mailing list
> geda-user@moria.seul.org
> http://www.seul.org/cgi-bin/mailman/listinfo/geda-user



___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread ldoolitt
Patrick -

On Tue, Aug 15, 2006 at 03:51:41PM -0400, Patrick Doyle wrote:
> The feature I'm most looking forward to coming out of this exercise is
> the ability to back annotate pin-swap information.  Right now I'm just
> plugging my busses together between the processor and the memory (or
> interface connector, or whatever), anticipating that when I look at
> the rats nest I'll wish I swapped the order of a few things.  If I can
> do that in PCB and then flow the information back to the schematic,
> that will be great.

I've given up using schematics for this sort of thing.
I just lay out the board, export the net list to a table
(or spreadsheet, if you like), and then derive the mapping
between FPGA signal names and pins from that list.
The schematic is reserved for things other than connecting
100 dots on one chip to 100 dots on other chips.

Example: http://recycle.lbl.gov/llrf4/

   - Larry


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread DJ Delorie

> Perhaps those with more experience in this area in general, and with
> these tools in particular, would care to comment on a better
> approach.

Having just went through this...

I added more slots to the dual XOR I was working with; the extra slots
had pins swapped.  I kept gschem and pcb both open, plus an xterm.

When I wanted to swap pins in pcb, I'd change the slot in gschem,
save, Up-Return to rerun gsch2pcb, and File->Load Netlist in pcb.

It goes quickly once you get used to it.


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Patrick Doyle

The feature I'm most looking forward to coming out of this exercise is
the ability to back annotate pin-swap information.  Right now I'm just
plugging my busses together between the processor and the memory (or
interface connector, or whatever), anticipating that when I look at
the rats nest I'll wish I swapped the order of a few things.  If I can
do that in PCB and then flow the information back to the schematic,
that will be great.  Otherwise, I'm anticipating a couple of
iterations of the schematic until I see something I like.

Perhaps those with more experience in this area in general, and with
these tools in particular, would care to comment on a better approach.
I've got thick skin -- be brutal :-)

--wpd


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread DJ Delorie

> This is pretty standard functionality in commercial packages.  The
> board stuffers like to have the components in a logical
> arrangement(R10 is near R9, etc.).

I always numbered mine by pages, like all R100-R199 were on schematic
page 1, etc.  They tended to get grouped together anyway that way.


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Mike Hansen
Well at least with this proposed mod(the renumber) one would definitely want 
to update the netlist.  The normal procedure would be to do the renumber, 
spit out the was/is list, using the was/is list update your schematic(of 
course it would be desirable to have a utility to update the schematic also 
with the was/is list).


This is pretty standard functionality in commercial packages.  The board 
stuffers like to have the components in a logical arrangement(R10 is near 
R9, etc.).




From: DJ Delorie <[EMAIL PROTECTED]>
Reply-To: gEDA user mailing list 
To: geda-user@moria.seul.org
Subject: Re: gEDA-user: Renumber in PCB/Was/Is List
Date: Tue, 15 Aug 2006 15:23:05 -0400

> I think the function that changes the element name should be
> responsible for that change also.  No point making everyone's life
> difficult.

At least, with a flag that says to do it.  I wonder if we'd screw the
user by not letting them rename an element out of the net.  OTOH they
can always reload the netlist, if they can.  No easy answer here, I
suppose.


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user





___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread DJ Delorie

> I think the function that changes the element name should be
> responsible for that change also.  No point making everyone's life
> difficult.

At least, with a flag that says to do it.  I wonder if we'd screw the
user by not letting them rename an element out of the net.  OTOH they
can always reload the netlist, if they can.  No easy answer here, I
suppose.


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread DJ Delorie

> You probably need to update the loaded netlist too.

I think the function that changes the element name should be
responsible for that change also.  No point making everyone's life
difficult.


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Dan McMahill

DJ Delorie wrote:

Is there documentation anywhere on how to get started in developing
for PCB/gschem?



No formal documentation, but it's not hard.  Look at src/puller.c for
an example of tying a custom function in (the action API is in hid.h).
You can also look at src/hid/bom/bom.c for code that looks up the X,Y
location of all elements.  The only remaining part is to look in
undo.h and change.h for the relevent functions to actually rename the
elements.


You probably need to update the loaded netlist too.  Also you may need 
to turn off the 'unique name' and (maybe) the 'locked element' checks. 
If you don't turn off the locked element checks you'll have to deal with 
that too.


If I get overly motivated tonight I'll send at least a partial patch.

-Dan


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread DJ Delorie

> Is there documentation anywhere on how to get started in developing
> for PCB/gschem?

No formal documentation, but it's not hard.  Look at src/puller.c for
an example of tying a custom function in (the action API is in hid.h).
You can also look at src/hid/bom/bom.c for code that looks up the X,Y
location of all elements.  The only remaining part is to look in
undo.h and change.h for the relevent functions to actually rename the
elements.

To add a file to the build, look for "puller" in src/Makefile.am and
add yours in the same way, then run autogen.sh.


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Mike Hansen



Is there documentation anywhere on how to get started in developing for 
PCB/gschem?  I am well versed in Windows C++ development but would need 
quite a bit of time to get up to speed on performing code work in PCB.

From: DJ Delorie <[EMAIL PROTECTED]>
Reply-To: gEDA user mailing list 
To: geda-user@moria.seul.org
Subject: Re: gEDA-user: Renumber in PCB/Was/Is List
Date: Tue, 15 Aug 2006 11:33:12 -0400

It doesn't, but it's the kind of thing that's easily added, say, as a
beginner's project (hint).


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user





___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread DJ Delorie

It doesn't, but it's the kind of thing that's easily added, say, as a
beginner's project (hint).


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user


Re: gEDA-user: Renumber in PCB/Was/Is List

2006-08-15 Thread Dan McMahill

Mike Hansen wrote:
Does PCB have a renumbering command?  This would be a command that would 
renumber the components on the circuit board say starting with the 
smallest value in the upper left and then proceeding to the lower right 
corner of the board.   And this would also generate a was/is list, 
showing the old component refdes and the new one(ideally you would have 
an app that could take the was/is and update the sch file).




Not currently.  Sounds like a good idea though.  I'd recommend that we 
try to make the was/is file be flexible enough to handle slot/pin 
swapping and maybe some other back annotation sorts of data.  I'd also 
make it an easy to parse format that isn't tied to gschem.


If you feel like putting together a patch, I'd be interested.

It is probably not all that hard.  If you're interested I can point you 
in the right direction.


-Dan


___
geda-user mailing list
geda-user@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user