File: vsplitmodule

package info (click to toggle)
libverilog-perl 3.460-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,188 kB
  • sloc: perl: 8,640; yacc: 3,362; cpp: 2,262; lex: 1,487; makefile: 8; fortran: 3
file content (92 lines) | stat: -rwxr-xr-x 3,337 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/perl -w
# See copyright, etc in below POD section.
######################################################################

use lib 'blib/lib';
use Verilog::EditFiles;
use FindBin qw($RealBin $RealScript $Script);
use strict;

#======================================================================
# When editing, delete this section up to the next #====
die <<EOF
%Error: vsplitmodule is an example program.
Copy $RealBin/$RealScript
to a new name and edit that new file.  Then see the comments.
You should then save the script you create, so that you can easily
recreate the generated files should the input Verilog files change.
EOF
 if !$ENV{HARNESS_ACTIVE};
#======================================================================

# Create a split object
my $split = Verilog::EditFiles->new
    (# Verilog::EditFiles will use the below program name in its comments
     program => $Script,

     # Name of the directory to write the output modules to.
     # I like to put all generated files under a dir named "gen"
     # so it is obvious the files are generated.
     # (But for the Verilog-Perl internal tests, this needs to be test_dir)
     outdir => "test_dir",   #"gen",

     # If true, add "`celldefine" before every module statement.
     #celldefine => 1,

     # For the write_lint method, the name of the linter to use.
     #lint_command => 'vlint --brief',

     # If defined, add the provided text before every module statement.
     # Generally used to insert lint off pragmas.
     #lint_header => "// lint_checking MY_RULES OFF\n",

     # If defined, add the provided text before every module statement.
     # Generally used to insert lint off pragmas.
     #include_header => "`include \"my_defines.v\"\n",

     # If defined, add the provided text before every module statement.
     # Generally used to insert lint off pragmas.
     #timescale_header => "`include \"my_timescale.v\"\n",

     # If set, remove any `timescales.
     #timescale_removal => 1,

     # If 1, replace any synopsys translate on/offs with "`ifdef SYNTHESIS" and
     # "`endif"s.  If set to a string, use that string instead of "SYNTHESIS".
     translate_synthesis => 'SYNTHESIS',

     # The suffix to add to convert a module name into a filename.  Defaults to
     #v_suffix => '.v',

     # If set, show what files are being read and written
     verbose => 1,
     );

# Remove all existing files under the output.  You might not want to do
# this if there are files you want to keep from there
unlink(glob("$split->{outdir}/*.v"));

# Read specified libraries and split them
$split->read_and_split(glob("t/*.v"));

# And write them out
$split->write_files();

# And create a lint file
$split->write_lint();

# If a file needs 'manual' search and replaces, we can do that too.
$split->edit_file
    (# The filename to be edited
     filename=>"$split->{outdir}/a.v",
     # Callback subroutine that takes file contents as a string
     # and returns the new file contents
     cb=>sub {
	 my $wholefile = shift;
	 # Globally search and comment out any lines with "pulldown PULLDOWN"
	 # See "man perlre" for examples.
	 # The %mg here means to match multiple lines (you can put
	 # \n in the regexp), and to do it globally
	 $wholefile =~ s%(pulldown PULLDOWN;)%//vsplitmodule: $1%mg;
	 return $wholefile;
     });