module top;
buff b0 ();
endmodule
module buff (buf_in, buf_out);
input buf_in;
inout out;
`ifdef SYNTHESIS
wire a;
`endif
inv i0 (.in(buf_in), .out(a ));
inv i1 (.in(a ), .out(buf_out));
endmodule
module inv (in, out);
input in;
output out;
assign out = ~in;
endmodule
Sample Perl code
#!/usr/bin/env perl
use Verilog::Netlist;
# Setup options so files can be found
use Verilog::Getopt;
my $opt = new Verilog::Getopt;
$opt->parameter( "+incdir+verilog",
"-y","verilog",
);
# Prepare netlist
my $nl = new Verilog::Netlist (options => $opt,);
foreach my $file ('top.v') {
$nl->read_file (filename=>$file);
}
# Read in any sub-modules
$nl->link();
#$nl->lint(); # Optional, see docs; probably not wanted
$nl->exit_if_error();
foreach my $mod ($nl->top_modules_sorted) {
show_hier ($mod, " ", "", "");
}
sub show_hier {
my $mod = shift;
my $indent = shift;
my $hier = shift;
my $cellname = shift;
if (!$cellname) {$hier = $mod->name;} #top modules get the des
+ign name
else {$hier .= ".$cellname";} #append the cellname
printf ("%-45s %s\n", $indent."Module ".$mod->name,$hier);
foreach my $sig ($mod->ports_sorted) {
printf ($indent." %sput %s\n", $sig->direction, $sig->
+name);
}
foreach my $cell ($mod->cells_sorted) {
printf ($indent. " Cell %s\n", $cell->name);
foreach my $pin ($cell->pins_sorted) {
printf ($indent." .%s(%s)\n", $pin->name, $pin->ne
+tname);
}
show_hier ($cell->submod, $indent." ", $hier, $cell->name
+) if $cell->submod;
}
}
I am unable to get where the `ifdef is defined. |