[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gEDA: Patch to pålay with busses



Don't take this too seriously, but I'm an impatient sort of guy, so here
goes:

Thanks to a couple of hooks already present in the latest CVS libgeda,
just a few lines added to libgeda and one extra component in misc makes it
possible to play with busses and rippers in gschem.

In gschem things actually work pretty well. Normal pins and nets do no
longer connect to busses. To connect to a bus, you have to use the fat end
of the bus ripper component (add misc symbol...). The bus entry number
appears as "?", and can be edited as desired. The netname= for busses can
be set to "DATA(0:15)"

Fine so far, but:

gnetlist will probably choke big time. And I know nothing about
gnetlist, so I do not if it is possible to even do busses in gnetlist this
way. Presumably a non-trivial task.

Greetings from
Egil

Patch enclosed, cut here:
-------------------------------------------------------------------------
*** libgeda/noweb/s_conn.nw.orig	Wed Oct  9 16:25:24 2002
--- libgeda/noweb/s_conn.nw	Wed Oct  9 16:09:05 2002
***************
*** 18,21 ****
--- 18,22 ----
  <<s_conn.c : s_conn_remove_complex()>>
  <<s_conn.c : s_conn_check_midpoint()>>
+ <<s_conn.c : s_is_compatible_objects()>>
  <<s_conn.c : s_conn_update_object()>>
  <<s_conn.c : s_conn_update_complex()>>
***************
*** 321,324 ****
--- 322,380 ----
  
  
+ @section Function @code{s_is_compatible_objects()}
+ 
+ @defun s_is_compatible_objects object other_object
+ @end defun
+ 
+ <<s_conn.c : s_is_compatible_objects()>>=
+ /* Like oil and water: BUS and NET
+  * - Egil Kvaleberg
+  */
+ static int
+ s_is_compatible_objects( OBJECT * object, OBJECT * other_object )
+ {
+   if ((object->type == OBJ_BUS)
+    || (object->type == OBJ_PIN && object->pin_type == PIN_TYPE_BUS)) {
+       /*
+        * BUS category
+        */
+       if (other_object->type == OBJ_NET) {
+ #if DEBUG
+ 	printf("*EK* BUS and NET does not connect\n");
+ #endif
+ 	return FALSE;
+       }
+       if (other_object->type == OBJ_PIN
+        && other_object->pin_type != PIN_TYPE_BUS) {
+ #if DEBUG
+ 	printf("*EK* BUS and net-PIN does not connect\n");
+ #endif
+ 	return FALSE;
+       }
+   } else if ((object->type == OBJ_NET)
+ 	  || (object->type == OBJ_PIN && object->pin_type != PIN_TYPE_BUS)) {
+       /*
+        * NET category
+        */
+       if (other_object->type == OBJ_BUS) {
+ #if DEBUG
+ 	printf("*EK* NET and BUS does not connect\n");
+ #endif
+ 	return FALSE;
+       }
+       if (other_object->type == OBJ_PIN
+        && other_object->pin_type == PIN_TYPE_BUS) {
+ #if DEBUG
+ 	printf("*EK* NET and BUS-PIN does not connect\n");
+ #endif
+ 	return FALSE;
+       }
+   }
+   return TRUE;
+ }
+ 
+ @ %def s_is_compatible_objects
+ 
+ 
  @section Function @code{s_conn_update_object()}
  
***************
*** 364,367 ****
--- 420,424 ----
  
        /* here is where you check the end points */
+       if (s_is_compatible_objects(object,other_object)) { /*EK*/
  	for (k = 0; k < 2; k++) {
  	  /* do first end point */
***************
*** 638,641 ****
--- 695,699 ----
  
  	} /* end of for over endpoints */
+       } /* end of if for compatible objects */
  
        object_list = object_list->next;
*** libgeda/src/Makefile.am.orig	Wed Oct  9 16:25:27 2002
--- libgeda/src/Makefile.am	Wed Oct  9 15:17:04 2002
***************
*** 47,53 ****
  
  .nw.c:
! 	$(NOTANGLE) $(NOTANGLEFLAGS) $(NOTANGLEROOT)'$@ : *' $< > ../src/$@
! 	$(INDENTBIN) $(INDENTFLAG) ../src/$@
  	rm -f ../src/$@~
  
  CPROTO =	cproto
--- 47,60 ----
  
  .nw.c:
! 	@if test $(NOTANGLE) = "no"; then \
! 		echo ; \
! 		echo "NOTANGLE not set"; \
! 		echo "Do rm libgeda.c in src and re-run configure"; \
! 		exit 1;\
! 	fi
! 	$(NOTANGLE) $(NOTANGLEFLAGS) $(NOTANGLEROOT)'$@ : *' $< > ../src/tmp.c
! 	$(INDENTBIN) $(INDENTFLAG) ../src/tmp.c
  	rm -f ../src/$@~
+ 	mv -f ../src/tmp.c ../src/$@
  
  CPROTO =        cproto
*** docs/fileformats/fileformats.html.orig	Wed Oct  9 16:25:30 2002
--- docs/fileformats/fileformats.html	Wed Oct  9 16:17:27 2002
***************
*** 16,20 ****
  The primary file format used in gEDA is the schematic/symbol format.
  Files which end with .sch or .sym are schematics or symbol files. This
! file format is current as of gEDA version 20001006.  
  <p>
  
--- 16,20 ----
  The primary file format used in gEDA is the schematic/symbol format.
  Files which end with .sch or .sym are schematics or symbol files. This
! file format is current as of gEDA version 20020922.
  <p>
  
***************
*** 66,70 ****
  
  Example:<br>
! v 19990327<p>
  
  <UL>
--- 66,70 ----
  
  Example:<br>
! v 20020922<p>
  
  <UL>
***************
*** 138,142 ****
  <strong>
  Net<br>
- Pin<br>
  Bus<p>
  </strong>
--- 138,141 ----
***************
*** 146,154 ****
  Examples:<br>
  N 12700 29400 32900 29400 4<br>
- P 17800 33100 22300 33100 1<br>
  U 27300 37400 37200 35300 3<p>
  
  <UL>
!         type = N P U (net pin bus respectively)<br>
          x1 y1 = first point<br>
          x2 y2 = second point<br>
--- 145,152 ----
  Examples:<br>
  N 12700 29400 32900 29400 4<br>
  U 27300 37400 37200 35300 3<p>
  
  <UL>
! 	type   = N U (net bus respectively)<br>
  	x1 y1 = first point<br>
  	x2 y2 = second point<br>
***************
*** 158,161 ****
--- 156,179 ----
  
  <hr>
+ <strong>
+ Pin<p>
+ </strong>
+ 
+ type x1 y1 x2 y2 color type whichend<p>
+ 
+ Examples:<br>
+ P 0 200 200 200 1 0 0<p>
+ 
+ <UL>
+ 	type = P <br>
+ 	x1 y1 = first point<br>
+ 	x2 y2 = second point<br>
+ 	color = see include/colors.h<br>
+ 	type  = 0 normally, 1 for special purpose bus pins<br>
+ 	whichend = 0 normally, 1 if second point is the sweet spot<br>
+ </UL>
+ <p>
+ 
+ <hr>
  <strong> Line </strong><p>
  
***************
*** 166,170 ****
  
  <UL>
!         type = N P U (net pin bus respectively)<br>
          x1 y1 = first point<br>
          x2 y2 = second point<br>
--- 184,188 ----
  
  <UL>
! 	type = L<br>
  	x1 y1 = first point<br>
  	x2 y2 = second point<br>
*** /dev/null	Thu Apr 11 14:25:15 2002
--- symbols/misc/ripper-1.sym	Wed Oct  9 16:23:17 2002
***************
*** 0 ****
--- 1,23 ----
+ v 20020922
+ #
+ # the bus ripper consists of two pins
+ # the first one is a bus type pin that connects to busses
+ # to make it visuably different from the other pin, it is overlayed
+ # by a wide line
+ # the second one is a normal type that connects to nets
+ # the component has a pinnumber=? attribute that should be set
+ # to the bus bit number
+ # the component also has a device=ripper attrbute
+ # presumably, the bus itself has a netname attribute like this:
+ #
+ #       netname=DATA(0:15)
+ #
+ # and no, this component was not made with gschem
+ #
+ T 0 300 5 8 0 0 0 0
+ device=ripper
+ P 0 200 100 100 1 1 0
+ P 200 0 100 100 1 0 0
+ T 100 150 5 8 1 1 0 0
+ pinnumber=?
+ L 0 200 100 100 1 30 0 0 -1 -1

-------------------------------------------------------------------------