Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / man / man3 / Verilog::CodeGen.3
CommitLineData
86530b38
AT
1.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "CodeGen 3"
132.TH CodeGen 3 "2003-05-09" "perl v5.8.0" "User Contributed Perl Documentation"
133.SH "SYNOPSIS"
134.IX Header "SYNOPSIS"
135.Vb 1
136\& use Verilog::CodeGen;
137.Ve
138.PP
139.Vb 2
140\& mkdir 'DeviceLibs/Objects/YourDesign', 0755;
141\& chdir 'DeviceLibs/Objects/YourDesign';
142.Ve
143.PP
144.Vb 3
145\& # if the directory YourDesign exists, the second argument can be omitted
146\& # create YourModule.pl in YourDesign
147\& &create_template_file('YourModule','YourDesign');
148.Ve
149.PP
150.Vb 2
151\& # create a device library for testing in DeviceLibs/Objects/DeviceLibs
152\& &make_module('YourModule','YourDesign');
153.Ve
154.PP
155.Vb 2
156\& # create the final device library in DeviceLibs (once YourModule code is clean)
157\& &make_module('','YourDesign');
158.Ve
159.SH "USAGE"
160.IX Header "USAGE"
161The most efficient way to use the code generator is using the \s-1GUI\s0 (\*(L"gui.pl\*(R" in scripts in the distribution). Read the documentation in Verilog::CodeGen::Gui.pm). Alternatively, you can use the scripts that the \s-1GUI\s0 uses to do the work (in the scripts/GUI folder). If you want to make your own, follow the \s-1SYNOPSIS\s0.
162.PP
163Then edit the file YourModule.pl in the folder DeviceLibs/Objects/YourDesign.
164.PP
165For example:
166.PP
167.Vb 3
168\& sub gen_YourModule {
169\& my $objref=shift;
170\& my $par=$objref->{parname}||1;
171.Ve
172.PP
173.Vb 1
174\& # Create Objects
175.Ve
176.PP
177.Vb 1
178\& my $submodule=new('SubModule',parname1=>$par);
179.Ve
180.PP
181.Vb 1
182\& # Instantiate
183.Ve
184.PP
185.Vb 14
186\& my $pins="(A,Z)";
187\& my $modname=$objref->{modulename};
188\& my $code = "
189\& module $modname $pins;
190\& input A;
191\& output Z;
192\& ";
193\& $code.=$submodule->inst('suffix',P1=>'A');
194\& $code .="
195\& endmodule // $modname
196\& ";
197\& $objref->{pins}=$pins;
198\& return $code;
199\& } # END of gen_YourModule
200.Ve
201.PP
202Then run \f(CW\*(C`perl YourModule.pl\*(C'\fR to check if the code produces valid a Verilog module.
203.PP
204If this is the case, add YourModule to the device library with \f(CW\*(C`&make_module()\*(C'\fR
205.PP
206Next, create a testbench test_YourModule.pl in a directory on the same level as DeviceLibs (TestObj if you use the \s-1GUI\s0):
207.PP
208.Vb 2
209\& use lib '..';
210\& use DeviceLibs::YourDesign;
211.Ve
212.PP
213.Vb 1
214\& my $device=new("S_buffer_demux",depth=>7,);
215.Ve
216.PP
217.Vb 1
218\& open (VER,">test_S_buffer_demux.v");
219.Ve
220.PP
221.Vb 1
222\& output(*VER);
223.Ve
224.PP
225.Vb 1
226\& modules();
227.Ve
228.PP
229.Vb 6
230\& print VER "
231\& module test_S_buffer_demux;
232\& wire A;
233\& wire [7:0] S;
234\& wire [6:0] Z;
235\& wire D;
236.Ve
237.PP
238.Vb 2
239\& reg a;
240\& reg [7:0] s;
241.Ve
242.PP
243.Vb 2
244\& assign A= a;
245\& assign S= s;
246.Ve
247.PP
248.Vb 4
249\& reg _ck;
250\& ";
251\& $device->instance();
252\& my $x=$device->{""};
253.Ve
254.PP
255.Vb 5
256\& print VER "
257\& // clock generator
258\& always begin: clock_wave
259\& #10 _ck = 0;
260\& #10 _ck = 1;
261.Ve
262.PP
263.Vb 1
264\& end
265.Ve
266.PP
267.Vb 4
268\& always @(posedge _ck)
269\& begin
270\& \e$display(\e" \e%0d \e%b \e%b \e",\e$time,$x. Z,$x. D);
271\& end
272.Ve
273.PP
274.Vb 14
275\& initial
276\& begin
277\& \e$display(\e"Time Z D\e");
278\& a<=1;
279\& #25;
280\& a<=0;
281\& #25;
282\& \e$finish;
283\& end
284\& endmodule
285\& ";
286\& close VER;
287\& run("test_S_buffer_demux.v");
288\& #plot("test_S_buffer_demux.v");
289.Ve
290.PP
291Execute the testbench script with \f(CW\*(C`perl test_YourModule.pl\*(C'\fR.
292.SH "DESCRIPTION"
293.IX Header "DESCRIPTION"
294Provides an object-oriented environment to generate Verilog code for modules and testbenches. The Verilog::CodeGen module provides two functions, one to create a code template and another to create a Perl module which contains the device library. This module , DeviceLibs::YourDesign, provides the class methods and contains the objects for every Verilog module; the objects are created based on a fixed template.
295The purpose of this module is to allow the generation of customized Verilog modules. A Verilog module can have a large number of parameters like input and output bus width, buffer depth, signal delay etc. The code generator allows to create an object that will generate the Verilog module code for arbitraty values of the parameters.
296.SH "UTILITY SCRIPTS"
297.IX Header "UTILITY SCRIPTS"
298With the Perl module distribution come a number of utility scripts. The most important one is gui.pl, a \s-1GUI\s0 frontend for Verilog development using the code generator.
299.SH "MAIN METHODS"
300.IX Header "MAIN METHODS"
301.Sh "\fBnew\fP(\fI$object_name\fP[,%attributes]);"
302.IX Subsection "new($object_name[,%attributes]);"
303Create a new Verilog module object. The object attributes are optional, the object should provide reasonable defaults.
304.Sh "\fBoutput([*filehandle_ref||$filename])\fP"
305.IX Subsection "output([*filehandle_ref||$filename])"
306\&\fIoutput()\fR takes a reference to a filehandle or a filename as argument. These are stored in the global \f(CW%printcfg\fR. Without arguments, this defaults to \s-1STDOUT\s0.
307If \fIoutput()\fR is called with as argument a string containing \en and/or \es, this string is printed on the current filehandle.
308.Sh "\fBmodules\fP"
309.IX Subsection "modules"
310The code generator stores all submodules of a given module in the global \f(CW%modules\fR. Calling \fImodules()\fR prints the code for these modules on the current filehandle.
311.Sh "\fBinstance([$instance_suffix,%connectivity])\fP"
312.IX Subsection "instance([$instance_suffix,%connectivity])"
313The \fIinstance()\fR method will print the code for the instantiation of the object on the current filehandle. An optional instance suffix can be specified (to distinguish between different instances of the same module), as well as the pin connectivity. If the connectivity for a pin is not specified, it defaults to the pin name.
314.Sh "\fBinst([$instance_suffix,%connectivity])\fP"
315.IX Subsection "inst([$instance_suffix,%connectivity])"
316The \fIinst()\fR method will return the code for the instantiation of the object as a string. An optional instance suffix can be specified (to distinguish between different instances of the same module), as well as the pin connectivity. If the connectivity for a pin is not specified, it defaults to the pin name.
317.Sh "\fBrun([$filename])\fP"
318.IX Subsection "run([$filename])"
319Run the netlist through the Icarus Verilog (http://www.icarus.com) open source verilog simulator. The filename is optional if it was specified with the \fIoutput()\fR method.
320.Sh "\fBplot([$filename])\fP"
321.IX Subsection "plot([$filename])"
322Plot the result of the simulation with gtkwave. For this purpose, the \e$dumpvar and \e$dumpfile compiler directives must be present in the testbench code. The filename is optional if it was specified with the \fIoutput()\fR method.
323.Sh "\fBmodule('modulename')\fP"
324.IX Subsection "module('modulename')"
325This method can be used to print the code for a specified module on the current filehandle.
326.Sh "\fBsearch(/pattern/)\fP"
327.IX Subsection "search(/pattern/)"
328Search the verilog code for a given pattern.
329.Sh "\fBfind_inst(/pattern/)\fP"
330.IX Subsection "find_inst(/pattern/)"
331Find all instances matching /pattern/ in the netlist.
332.SH "MAIN ATTRIBUTES"
333.IX Header "MAIN ATTRIBUTES"
334.Sh "\fB{$instance_suffix}\fP"
335.IX Subsection "{$instance_suffix}"
336Returns the full instance name of the object.
337\&\f(CW$x\fR=$object\->{$instance_suffix};
338.SH "TODO"
339.IX Header "TODO"
340.IP "\(bu" 4
341Convert the utility scripts to functions to be called from Verilog::CodeGen.
342.IP "\(bu" 4
343Put the \s-1GUI\s0 scripts in a module Gui.pm.
344.IP "\(bu" 4
345Separate the code for testing purposes from the module object code.
346.SH "SEE ALSO"
347.IX Header "SEE ALSO"
348Icarus Verilog <http://icarus.com/eda/verilog/index.html>
349.SH "AUTHOR"
350.IX Header "AUTHOR"
351W. Vanderbauwhede \fBwim@motherearth.org\fR.
352.PP
353<http://www.comms.eee.strath.ac.uk/~wim>
354.SH "COPYRIGHT"
355.IX Header "COPYRIGHT"
356Copyright (c) 2002 Wim Vanderbauwhede. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.