missing NULL terminator in set_config_x
[geda-gaf.git] / docs / wiki / geda-vams_netlister_readme.html
blob968cc08e6f6edcbd8c28890154d51a6392f3b5bf
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html>
4 <head>
5 <link rel="stylesheet" media="screen" type="text/css" href="./style.css" />
6 <link rel="stylesheet" media="screen" type="text/css" href="./design.css" />
7 <link rel="stylesheet" media="print" type="text/css" href="./print.css" />
9 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10 </head>
11 <body>
13 <h1 class="sectionedit1" id="vams_netlister_readme">VAMS netlister README</h1>
14 <div class="level1">
16 </div>
17 <!-- EDIT1 SECTION "VAMS netlister README" [1-36] -->
18 <h2 class="sectionedit2" id="vams_netlister">VAMS netlister</h2>
19 <div class="level2">
20 <pre class="code">date: 10 october 2000
21 gEDA: gnetlist vams mode
22 first unrevised vams mode documentation
25 Written by: Martin Lehmann
26 -------------------------------------------------------------------------
29 VHDL-AMS support for the gEDA gnetlist tool
30 -------------------------------------------
32 CONTENT:
34 1. functionality
35 1. ARCHITECTURE generation
36 2. ENTITY generation
37 3. automatisate gnetlist calls
39 2. implementation
40 1. the vams mode of gEDA gnetlist
41 1. scheme
42 1. settings and new definition
43 2. gnet-vams.scm
44 1. routines main structure
45 3. helpfully setting in gEDA gschem environment
47 2. new c-code
48 1. routines
49 2. code-adaptation
51 2. automatic generating gnetlist calls in gEDA gschem
52 1. generated gEDA gnetlist calls
53 2. scheme
54 1. generate_netlist.scm
55 2. settings
57 3. new c-code
58 1. routines
59 2. code-adaptation
62 The purpose of our endevour, is that gEDA gnelist completly
63 supportted VHDL-AMS (VHDL Analog and Mixed-Signal) netlist
64 generation.
66 The VHDL-AMS netlist support mode is called vams.
69 1. FUNCTIONALITY
71 gEDA gnetlist in vams mode allow it to generate a VHDL-AMS
72 ARCHITECTURE or an ENTIY declaration. Which of both tasks is
73 performed, dependends on the generate-mode variable. This variable
74 is defined in the gnetlist command or will be set default.
76 If generate-mode=1 (default) gnetlist creates a netlist as an
77 VHDL-AMS ARCHITECTURE of the current schematic. Otherwise
78 (generate-mode=2), it creates an VHDL-AMS ENTITY declaration of the
79 selected component (this task needs information from gEDA gschem,
80 see below).
82 Now follows a stepwise discription of the program run in both
83 submodes.
85 We presuppose that you are familiar with the structure of gEDA
86 gnetlist usage (otherwise try gnetlist -help) and that you have
87 ever seen an VHDL-AMS ARCHITECTURE with its belonging ENTITY. If
88 you does not then the following distription will be seems very
89 strange to you. Maybe the syntax files (syntax_entity.txt,
90 syntax_architeture.txt) can helps you further.
92 ==================================================================
94 1.1. ARCHITECTURE GENERATION
97 We suppose generate-mode is equal to 1, from this it follows that
98 vams creates a netlist as an ARCHITECTURE (saved to
99 &lt;value-of-toplevel-attribute-entity&gt;_arc.&lt;output-fileextension&gt;).
102 ARCHITECTURE &lt;architecture-identifier&gt; OF &lt;entity-identifier&gt; IS
104 The architecture-identifier we are getting from the toplevel
105 attribute architecture, which we have introduced. If it is not
106 defined, we are setting architecture-identifier default
107 (default_architecture). The same have we doing with the
108 entity-identifier (toplevel attribute entity, default_entity).
111 {&lt;subnet-object&gt; &lt;subnet-name&gt; : subnet-kind;}
113 In the signal declaration part all subnets of the schematic will be
114 declarated. A subnet declaration consists of an net-object, a
115 net-name and a net-kind. All subnets are connected to various
116 components pins. If this pins have all the same port-object and the
117 same port-kind it is ok, but if one of them different, the net is
118 faulty, and will be not declarated. Moreover, if the subnet-object
119 a quantity, then it will be checked, whether the subnet consists
120 exactly one output pin (port-mode), else the subnet is faulty too.
121 The three net attributes (object, kind, mode) we are getting from
122 the pin attribs, port_kind, port_object and port_mode (which we
123 have introduced newly) of a component pin.
126 BEGIN
128 Ok. it&#039;s only marks the start of the architecture body.
131 {&lt;label&gt; : ENTITY &lt;entity&gt; [(&lt;architecture&gt;)]
132 [GENERIC MAP (&lt;set generic&gt; =&gt; &lt;generic-value&gt;
133 {; &lt;set-generic=&gt; &lt;generic-value&gt;})]
134 PORT MAP ( &lt;pin-name&gt; =&gt; &lt;subnet-name&gt;{; &lt;.. =&gt; ..&gt;});}
136 We only support component instantiation statements, like this
137 above, because we generate simple VHDL-AMS netlists. The label of
138 an instance is defined from the uref of the instanciated
139 component. Watch out, this label must be unique,it is not checked
140 anywhere. The entity variable is not the same as the
141 entity-identifier, it is the value of the device attribute which on
142 its part identifies the precompiled ENTITY of this special
143 component. Similar is the architecture variable belonging to the
144 instanciated components ARCHITECTURE (note: one ENTITY can have more
145 ARCHITECTURES), hence we are getting it from the component
146 attribute ARCHITECTURE (newly introduced).
148 All generics of the generic-list are component parameters, which
149 are different from its default values (set in its ENTITY
150 declaration). How can we distinguish them? All defined generics
151 are attached to the component and looks like :
153 &lt;attribute-name&gt;=?&lt;default-value&gt; &lt;- default, not in
154 generic-list
156 And if you want to change a parameter, you only must delete the
157 ?-character and replace the default-value with your wanted value,
158 like this :
160 &lt;attribute-name&gt;=&lt;new-value&gt; &lt;- element of generic list
162 If you do it this way, the new assigned value and its attribute-name
163 will be appear in the GENERIC MAP (set-generic=attribute-name and
164 generic-value=new-value).
166 The PORT MAP consists of all pins of a component and which nets
167 them connected to. The pin-name is getting from the pin# attribute
168 of the pin and the subnet-name means the value of the label
169 attribute of a net (mostly default named), which the pin is
170 connected to. If the pin directly wired to a PORT component (=
171 component, which device attribute =PORT), then we assign the uref
172 of this component to subnet-name.
175 END ARCHITECTURE &lt;architecture-identifier&gt;;
177 I think, this line needs no more explanation. The
178 architecture-identifier is the same like in the first line of
179 ARCHITECTURE declaration. Hence, the ARCHITECTURE part ends here.
181 ==================================================================
183 1.2. ENTITY GENERATION
186 Now, we suppose generate-mode is equal to 2, from this it follows
187 that vams creates an ENTITY declaration of a component (save to
188 &lt;component-device&gt;.vhdl). If there no component selected (empty
189 top-attribs list) then it will be created an toplevel ENTITY of the
190 current schematic (save to
191 &lt;value-of-toplevel-attribute-entity&gt;.vhdl).
194 LIBRARY &lt;library-identifier&gt;{,&lt;library-identifier&gt;};
195 USE &lt;package-identidier&gt;{,&lt;package-identifier&gt;};
197 Well, the context clause part is not very ingenious. All libraries
198 and packages you needs for your simulation you must insert staticly
199 (a library contents precompiled ENTITIES, ARCHITECTURES and
200 PACKAGES, which are needed from base components [base of the
201 hierachical netlist] of your schematic. a package contents
202 predefined types, constants, ...). We are searching for a better
203 usability of this part.
206 ENTITY &lt;entity-identifier&gt; IS
207 [genric_clause]
208 [port_clause]
209 END ENTITY;
211 If you want generate a toplevel ENTITY of your current schematic
212 then the entity-identifier is defined from the toplevel attribute
213 entity of the schematic-file. Moreover, there are no generic_clause
214 and no port_clause.
216 In case of an component based ENTITY declaration, the
217 entity-identifier is getting from the device attribute of the
218 selected component (this attribute is included in top-attribs list,
219 which is defined in the automatic generated gnetlist command .. more
220 about this, later).
223 generic_clause :=
224 GENERIC ( &lt;generic-identifier&gt; : REAL := &lt;default-value&gt;
225 {;&lt;generic-identifier&gt; : REAL := &lt;default-value&gt;});
227 All needed generic-identifiers and it default-values are getting
228 from the top-attribs list. Note: all attached attributes of a
229 component appears in the generic_clause, only special attributes,
230 like uref, source and architecture, are taked out. The values of
231 this attributes are taked from the top-attribs list, too, but it
232 does not matter whether the value starts with a ?-character or not
233 (?-character always will be deleted, if it exist in front of a
234 value).
237 port_clause :=
238 PORT (&lt;port-kind&gt; &lt;port-identifier&gt; : [&lt;port-mode&gt;] &lt;port-type&gt;
239 {;&lt;port-kind&gt; &lt;port-identifier&gt; : [&lt;port-mode&gt;] &lt;port-type&gt;});
241 All variables of this clause are grabbed from the symbol of the
242 selected component. Port-kind corresponds with the value of the
243 port_kind attribute of the pin, which pin# attribute value is equal
244 to port-identifier. Just as corresponds port-type with the the
245 value of the pin attribute port_type and port-mode with the value
246 of port_mode.
248 ===================================================================
250 1.3. AUTOMATISATING gnetlist CALLS
252 Because it is very arduous to type the whole gnetlist command,
253 which all its parameters, per hand into the terminal, we are
254 implement an automatisation of this process in gEDA gschem. This
255 makes it possible to create a VHDL-AMS ARCHITECTURE or ENTITY
256 whitout any commandline actions. The only thing you must do, is to
257 use one of the following hotkeys:
259 &lt;g e&gt; for generating an ENTITY
260 &lt;g n&gt; for genarating an ARCHITECTURE.
262 NOTE to &lt;g e&gt; - hotkey : If one component of the schematic
263 selected then the ENTITY generation
264 will be applied to this component !!
266 ===================================================================
268 2. IMPLEMENTATION
270 At this section it will be explained the basic concept of the
271 implementation, which is splited in two sections. The first one
272 aimed to the gnelist implementation and the second to the gschem
273 implementation.
276 2.1. THE VAMS MODE OF gEDA gnetlist
278 To realize gnetlist VHDL-AMS support, it was necessary to create
279 new scheme and c stuff.
282 2.1.1. SCHEME
284 The scheme implementation contents two parts. On one hand the new
285 file gnet-vams.scm, which realize the VHDL-AMS-code generation, and
286 on the other hand some settings in rc-files.
289 2.1.1.1. SETTINGS AND NEW DEFINITIONS
291 The following lines insert in your gschemrc, or wherever you want,
292 but it must be loaded at gnetlist startup.
294 - load two modules, which we needs in our new implementation.
296 (define-module (ice-9 ls) :use-module (ice-9 common-list)
297 :use-module (ice-9 string-fun))
299 - load main file for VHDL-AMS support, which contents the
300 startup procedure vams.
302 (load &quot;&lt;path_of_gnet-vams.scm&gt;/gnet-vams.scm&quot;)
305 2.1.1.2. gnet-vams.scm
307 This file contents all necessary scheme-functions to generate
308 VHDL-AMS-code. Especially, the main procedure vams, which can be
309 execute from the gnetlist command.
311 For example :
313 gnetlist -g vams schematic_filename.sch
318 2.1.2.1. ROUTINES MAIN STRUCTURE
320 the mainly functions structure looks like:
322 - (vams output-filename)
324 ARCHITECTURE generation
326 - (vams:write-secondary-unit architecture entity output-port)
328 - (vams:write-architecture-declarative-part output-port)
329 - (vams:write-signal-declarations output-port)
331 - (vams:write-architecture-statement-part packages output-port)
332 - (vams:write-generic-map output-port package)
333 - (vams:write-port-map package output-port)
335 ENTITY declaraction
337 - (vams:write-primary-unit entity port-list generic-list output-port)
339 - (vams:write-context-clause output-port)
341 - (vams:write-generic-clause generic-list output-port)
342 - (vams:write-generic-list generic-list output-port)
344 - (vams:write-port-clause port-list output-port)
345 - (vams:write-port-list port-list output-port)
348 2.1.1.3 HELPFULLY SETTING IN THE gEDA gschem ENVIRONMENT
350 This settings are not absolutly necessary, but they makes work
351 easier.
353 - set in .gEDA/gschemrc or wherever you want, but place it
354 right.
356 (attribute-promotion &quot;enable&quot;)
357 (promote-invisible &quot;enable&quot;)
358 (enforce-hierarchy &quot;disabled&quot;)
360 (attribute-name &quot;port_object&quot;)
361 (attribute-name &quot;port_type&quot;)
362 (attribute-name &quot;port_mode&quot;)
363 (attribute-name &quot;entity&quot;)
364 (attribute-name &quot;architecture&quot;)
367 2.1.2. NEW C - CODE
369 To got all informations, which we needed for currently netlist
370 generation, we must implemented two new c - functions.
373 2.1.2.1 NEW ROUTINES (saved in vams_misc.c)
376 SCM vams_get_package_attributes(SCM scm_uref)
378 The first function gets all attribute names (not its values) of a
379 component. This routine requires the name a component (package),
380 especially the uref of it, and returns a list of all attribute
381 names which are attached to this package.
383 We needs this functionality to produce a currectly
384 VHDL-AMS GENERIC MAP.
387 char* vams_get_attribs_list
388 (OBJECT *object, SCM *list, OBJECT **return_found)
390 It exists only for the support of the first function.
393 2.1.2.2. CODE ADAPTATION
395 To place this new functions at gnetlist scheme&#039;s disposal, you must
396 perform the following actions.
398 (1) gnetlist/src/g_register.c
400 gh_new_procedure1_0
401 (&quot;gnetlist:vams-get-package-attributes&quot;,
402 vams_get_package_attributes);
405 (2) gnetlist/include/prototype.h
407 SCM vams_get_package_attributes(SCM scm_uref);
410 (3) edit gnetlist/src/Makefile.in or directly in Makefile
412 (if you have edited Makefile.in you must run make config of
413 course)
415 - add &quot;vams_misc.c&quot; to gnetlist_SOURCES - variable
416 - add &quot;vams_misc.o&quot; to gnetlist_OBJECTS - variable
418 (4) copy vams_misc.c to gEDA/gnetlist/src/
420 (5) compile your code newly
422 ===================================================================
424 2.2. AUTOMATIC GENERATING gnetlist CALLS IN gEDA gschem
426 To realize this new feature it was necessary to put more
427 information from the schematic to the scheme world of gEDA gschem.
428 Concretly, we needs the filename of the current schematic, because
429 gEDA gnetlist required it, and the attached attributes of a
430 selected component for creating an VHDL-AMS ENTITY. Hence, the
431 gnetlist command is mutated to an unidirectional interface between
432 the world of gschem scheme and the world of gnetlist scheme.
434 There are three important things, which transfer through this
435 interface:
437 (1) the source-file, which contents the complett filename
438 (with path) of the current schematic.
440 (2) the top-attribs list, which contents all attached
441 attributes of the selected component.
443 (3) the generate-mode, which is defined by the users actions.
446 2.2.1. STRUCTURE OF gEDA gnetlist CALLS FROM COMMANDLINE OR FROM gEDA
447 gschem.
449 typical commandline call :
451 gnetlist [-o &lt;output-filename&gt;]
452 -g vams
453 &lt;schematic-file&gt;
455 There are nothing to explain. The top-attribs list and the
456 generate-mode variable are default defined (&#039;() and 1).
459 calls from gEDA gschem (3 possible variations) :
462 Note: vhdl-path is a predefined variable, which is set in
463 generate_netlist.scm first times. You can it simple redefine
464 in your local gschemrc file, which is loading everytimes you
465 starts gEDA gschem.
468 (1) hot-key-stroke: - g n (generate netlist)
470 --&gt; generates a netlist of the current schematic.
473 gnetlist -o &lt;vhdl-path&gt;/&lt;target-file&gt;
474 -g vams
475 &lt;source-file&gt;
477 The source-file variable is equate to the complett
478 path+filename of the current schematic, which we get with
479 help of a self coded c function. If you cut out the filename
480 of the source-file variable (source-file without path) then
481 you are getting the target-file.generate-mode and
482 top-attribs are default again.
484 (2) hot-key-stroke: - g e (generate-entity)
485 and no component is selected.
487 --&gt; generates an toplevel ENTITY of the current
488 schematic.
491 gnetlist -c &lt;scheme-comm&gt;
492 -o &lt;vhdl-path&gt;/&lt;target-file&gt;
493 -g vams
494 &lt;source-file&gt;
496 scheme-comm=&quot;(define top-attribs &#039;&lt;top-attribs&gt;)
497 (define generate-mode &#039;2)&quot;
500 Source-file needs no comment, because it is the same as in
501 (1). To get all attributes of a selected component, we are
502 must write a new c function again. The values, which we get
503 from this new function are saved in top-attribs. The sense
504 of the scheme-comm command is to put top-attribs and
505 generate-mode from the gschem to the gnetlist environment.
506 At last, the target-file consists of the pure basefilename
507 of the source-file and an .vhdl extention.
509 (3) hot-key-stroke: - g e (generate-entity)
510 and only one component is selected.
512 --&gt; generates an ENTITY of the selected schematic.
515 commandline is the same as in (2).
518 Differences: The target-file is different, but it does not
519 matter, because gnetlist generate an new output-filename in
520 in this case (&lt;device-name-of-selected-component&gt;.vhdl,
521 normally).But one fact is very important: the top-attribs
522 variable includes all attached attributes of the selected
523 component now.
525 2.2.2. SCHEME
527 The gnetlist command is generating from two scheme functions, which
528 are saved in generate_netlist.scm. This functions starts if the
529 gschem user is typing one of the specified hot-keys ([g e] starts
530 generate-entity and [g n] starts generate-netlis). Both routines
531 puts the whole gnetlist command together and execute it. The syntax
532 you see above.
535 2.2.2.1. generate_netlist.scm
538 2.2.2.2. SETTINGS
540 If you want use the new feature then you must do some entries in one
541 of your gEDA gschem rc-files
543 necessary defines:
545 - in system-gschemrc
547 (&quot;g&quot; . gnetlist-keymap)
549 Edit your global-keymap and if &quot;g&quot; always defined then find
550 out an other free hot-key-stroke.
552 Note: the documentation supports the &quot;g&quot; - key only.
555 - in one of the gschem startup files
557 (define gnetlist-keymap
558 &#039;((&quot;n&quot; . generate-netlist)
559 (&quot;e&quot; . generate-entity)))
562 loads :
564 (load &quot;/home/fliser3/.gEDA/generate_netlist.scm&quot;)
567 2.2.3. NEW C-CODE
569 The c-code makes it possible to get directly informations from the
570 gschem tool, which is necessary for the online execution of
571 gnetlist.
574 2.2.3.1. ROUTINES
576 It exists two new c-functions. Both are put down in
577 misc_for_gnetlist.c.
580 SCM get_selected_filename(gpointer data,
581 guint callback_action,
582 GtkWidget *widget)
584 This function returns the whole filename of the current schematic,
585 which is picked from the w_current-&gt;page_current-&gt;page_filename
586 string.
589 SCM get_selected_component_attributes(gpointer data,
590 guint callback_action,
591 GtkWidget *widget)
593 How the name is saying, this functions returns all attributes of
594 the selected component. It is realized with a simple while loop
595 over all objects of the schematic, which picked out all elements
596 where the selected flag is set.
599 2.2.3.2. CODE-ADAPTATION
601 Here are some actions you must conclude to makes the software
602 runable.
604 (1) new lines in /gschem/src/g_register.c
606 gh_new_procedure0_0 (&quot;get-selected-filename&quot;,g_get_selected_filename);
609 (2) new lines in /gschem/include/prototype.h
611 SCM g_get_selected_filename();
614 (3) copy the file misc_for_gnetlist.c to gschem/src
616 (4) add in file /gschem/src/Makefile.in or directly in Makefile.
618 (if you have edited Makefile.in you must run make config of
619 course)
621 - add &quot;misc_for_gnetlist.c&quot; to gschem_SOURCES - variable
622 - add &quot;misc_for_gnetlist.o&quot; to gschem_OBJECTS - variable
624 (5) add new lines in /gschem/src/g_key.c
626 SCM g_get_selected_filename(void)
628 return (get_selected_filename(window_current, 0, NULL));
632 (6) compile your changed c-code newly</pre>
634 </div>
635 <!-- EDIT2 SECTION "VAMS netlister" [37-20220] -->
636 <h2 class="sectionedit3" id="vams_netlister_syntax_architecture">VAMS netlister syntax architecture</h2>
637 <div class="level2">
638 <pre class="code">ARCHITECTURE &lt;architecture-identifier&gt; OF &lt;entity-identifier&gt; IS
640 {&lt;subnet-object&gt; &lt;subnet-name&gt; : subnet-kind;}
642 BEGIN
644 {&lt;label&gt; : ENTITY &lt;entity&gt; [(&lt;architecture&gt;)]
645 [GENERIC MAP (&lt;set-generic&gt; =&gt; &lt;generic-value&gt;
646 {; &lt;set-generic=&gt; &lt;generic-value&gt;})]
647 PORT MAP ( &lt;pin-name&gt; =&gt; &lt;subnet-name&gt;{; &lt;.. =&gt; ..&gt;});}
649 END ARCHITECTURE &lt;architecture-identifier&gt;;</pre>
651 </div>
652 <!-- EDIT3 SECTION "VAMS netlister syntax architecture" [20221-20667] -->
653 <h2 class="sectionedit4" id="vams_netlister_syntax_entity">VAMS netlister syntax entity</h2>
654 <div class="level2">
655 <pre class="code">LIBRARY &lt;library-identifier&gt;{,&lt;library-identifier&gt;};
656 USE &lt;package-identidier&gt;{,&lt;package-identifier&gt;};
658 ENTITY &lt;entity-identifier&gt; IS
659 [GENERIC ( &lt;generic-identifier&gt; : REAL := &lt;default-value&gt;
660 {;&lt;generic-identifier&gt; : REAL := &lt;default-value&gt;}); ]
661 [PORT (&lt;port-kind&gt; &lt;port-identifier&gt; : [&lt;port-mode&gt;] &lt;port-type&gt;
662 {;&lt;port-kind&gt; &lt;port-identifier&gt; : [&lt;port-mode&gt;] &lt;port-type&gt;});]
663 END ENTITY;</pre>
665 </div>
666 <!-- EDIT4 SECTION "VAMS netlister syntax entity" [20668-] --></body>
667 </html>