Line 71... |
Line 71... |
"prefix=s" => \$prefix,
|
"prefix=s" => \$prefix,
|
"vendor=s" => \$vendor,
|
"vendor=s" => \$vendor,
|
"library=s" => \$library,
|
"library=s" => \$library,
|
"version=s" => \$version,
|
"version=s" => \$version,
|
"component=s" => \$component,
|
"component=s" => \$component,
|
"dest_dir=s" => \$dest_dir,
|
|
"destination=s" => \$destination,
|
"destination=s" => \$destination,
|
"configuration=s" => \$configuration,
|
"local_parameters"
|
"fragment","no_port","local_parameters","tb","debug","verbose","interface_only","top"
|
|
) || die "(use '$program_name -h' for help)";
|
) || die "(use '$program_name -h' for help)";
|
|
|
|
|
##############################################################################
|
##############################################################################
|
## Help option
|
## Help option
|
##############################################################################
|
##############################################################################
|
if ( $opt_h or $opt_help )
|
if ( $opt_h or $opt_help )
|
{ print "\n gen_verilog -envidentifier {sim/syn} -prefix /work -vendor vendor_name -library library_name -component component_name -version version_name -fragment -no_port -local_parameters -destination destination -configuration configuration -dest_dir ../verilog \n";
|
{ print "\n gen_verilog -envidentifier :*Simulation:* -prefix /work/children -vendor vendor_name -library library_name -component component_name -version version_name -destination destination -configuration configuration -local_parameters \n";
|
exit 1;
|
exit 1;
|
}
|
}
|
|
|
|
|
|
|
Line 95... |
Line 93... |
##
|
##
|
#############################################################################
|
#############################################################################
|
|
|
$home = cwd();
|
$home = cwd();
|
|
|
|
unless( $destination) {$destination = "${component}_${version}";}
|
|
|
my $variant;
|
print "\n ---GEN_verilog -envidentifier $envidentifier -prefix $prefix -vendor $vendor -library $library -component $component -version $version -destination $destination ";
|
my $view;
|
|
|
|
if($version) {$variant = "${component}_${version}";}
|
|
else {$variant = "${component}";}
|
|
|
|
unless($destination) { $destination = $variant;}
|
|
unless($configuration) { $configuration = "default";}
|
|
|
|
|
my $cmd = "./tools/verilog/gen_elab_verilog -envidentifier $envidentifier -prefix $prefix -vendor $vendor -library $library -component $component -version $version -destination $destination ";
|
|
|
|
my $cmd;
|
|
|
print "\n GEN_verilog -envidentifier $envidentifier -prefix $prefix -vendor $vendor -library $library -component $component -version $version -configuration $configuration -dest_dir $dest_dir -destination $destination \n";
|
if($opt_local_parameters)
|
|
|
my $main_module_name = yp::lib::get_module_name($vendor,$library,$component,$version) ;
|
|
my $lib_comp_sep = yp::lib::find_lib_comp_sep($vendor,$library,$component);
|
|
my $comp_xml_sep = yp::lib::find_comp_xml_sep($vendor,$library,$component,$version);
|
|
|
|
my $parser = XML::LibXML->new();
|
|
|
|
my $socgen_file = $parser->parse_file(yp::lib::find_componentConfiguration($vendor,$library,$component));
|
|
my $spirit_component_file = $parser->parse_file(yp::lib::find_ipxact_component($vendor,$library,$component,$version));
|
|
|
|
my $sim_library_path ;
|
|
|
|
my $sim_comp_path = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:comp_path/text()")->to_literal;
|
|
|
|
if ($sim_comp_path) {$sim_library_path ="${lib_comp_sep}${sim_comp_path}";}
|
|
else {$sim_library_path = $socgen_file->findnodes("//socgen:componentConfiguration/socgen:sim/socgen:library_path/text()")->to_literal;}
|
|
|
|
|
|
foreach my $X_view ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:envIdentifier[text() = '$envidentifier']"))
|
|
{
|
|
$view = $X_view->findnodes('../spirit:name/text()')->to_literal ;
|
|
}
|
|
|
|
my $path = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}";
|
|
mkdir $path,0755 unless( -e $path );
|
|
|
|
my $path = "${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}";
|
|
mkdir $path,0755 unless( -e $path );
|
|
|
|
|
|
my @instantiations = ();
|
|
my @parameters = ();
|
|
my %parameter_values = ();
|
|
my %parameter_descriptions = ();
|
|
|
|
unless ($socgen_file) { print "No socgen ip file \n";};
|
|
|
|
#/******************************************************************************************/
|
|
#/* */
|
|
#/* get parameters */
|
|
#/* */
|
|
#/******************************************************************************************/
|
|
|
|
|
|
my @Pams = yp::lib::get_parameters($vendor,$library,$component,$version,$configuration);
|
|
|
|
foreach my $Pam (@Pams)
|
|
{
|
|
my $param_name;
|
|
my $param_value;
|
|
|
|
( $param_name,$param_value) = split( /\::/ , $Pam);
|
|
unless(defined $parameter_values{$param_name}) {push ( @parameters, "$param_name");};
|
|
$parameter_values{$param_name} = $param_value;
|
|
}
|
|
|
|
|
|
|
|
|
|
my @signals = yp::lib::get_signals($vendor,$library,$component,$version);
|
|
|
|
|
|
|
|
#/**********************************************************************/
|
|
#/* */
|
|
#/* Every hier cell is constructed from the ipxact file with seperate */
|
|
#/* version for each view */
|
|
#/* */
|
|
#/* Start by opening the output file */
|
|
#/* get fileset name */
|
|
#/* check that requested view exists */
|
|
#/* */
|
|
#/**********************************************************************/
|
|
|
|
foreach my $comp_view ($spirit_component_file->findnodes("//spirit:component/spirit:model/spirit:views/spirit:view/spirit:name[text() = '$view']" ))
|
|
{
|
|
my($view_fileset_name) = $comp_view->findnodes('../spirit:fileSetRef/spirit:localName/text()')->to_literal ;
|
|
$outfile ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${dest_dir}/${view}/${destination}";
|
|
open DEST_FILE,">$outfile" or die "unable to open $outfile";
|
|
|
|
unless ($opt_fragment){ print DEST_FILE "\n module \n\n $main_module_name \n ";}
|
|
|
|
my @I_names = yp::lib::get_instance_names($vendor,$library,$component,$version,$configuration);
|
|
|
|
foreach my $I_name (@I_names)
|
|
{
|
|
my $module_name = yp::lib::get_instance_module_name($vendor,$library,$component,$version,$I_name,$configuration);
|
|
push @instantiations , "${module_name}\n";
|
|
$first = 1;
|
|
my @Pams = yp::lib::get_Parameters($vendor,$library,$component,$version,"root.${I_name}",$configuration);
|
|
foreach my $pam (@Pams)
|
|
{
|
|
( $foo_name,$foo_value) = split( /\::/ , $pam);
|
|
if($first)
|
|
{
|
|
push @instantiations , "#( .${foo_name} (${foo_value})";
|
|
$first = 0;
|
|
}
|
|
else {push @instantiations , ",\n .${foo_name} (${foo_value})";}
|
|
}
|
|
|
|
if($first == 0) { push @instantiations , ")\n";}
|
|
push @instantiations , "$I_name \n (\n ";
|
|
$first = 1;
|
|
|
|
my @Inst_conns = yp::lib::get_instance_adhoc_conns($vendor,$library,$component,$version,$I_name);
|
|
my @Buss_conns = yp::lib::get_instance_conns($vendor,$library,$component,$version,$I_name);
|
|
foreach my $Buss_conn (@Buss_conns)
|
|
{
|
|
if($first)
|
|
{
|
|
push @instantiations , " $Buss_conn";
|
|
$first =0;
|
|
}
|
|
else
|
|
{
|
|
push @instantiations , ",\n $Buss_conn";
|
|
}
|
|
}
|
|
foreach my $Inst_conn (@Inst_conns)
|
|
{
|
|
if($first)
|
|
{
|
|
push @instantiations , " $Inst_conn";
|
|
$first =0;
|
|
}
|
|
else
|
|
{
|
|
push @instantiations , ",\n $Inst_conn";
|
|
}
|
|
}
|
|
push @instantiations , ");\n\n";
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#/**********************************************************************/
|
|
#/* */
|
|
#/* Add any and all global parameters with their default values */
|
|
#/* */
|
|
#/**********************************************************************/
|
|
|
|
unless ($opt_local_parameters)
|
|
{
|
|
my $first = 1;
|
|
foreach my $parameter_name (@parameters)
|
|
{
|
|
my $parameter_value = $parameter_values{$parameter_name};
|
|
if($first)
|
|
{
|
|
print DEST_FILE " #( parameter \n ${parameter_name}=${parameter_value}";
|
|
$first=0;
|
|
}
|
|
else { print DEST_FILE ",\n ${parameter_name}=${parameter_value}";}
|
|
}
|
|
|
|
if ($first == 0) { print DEST_FILE ")\n"; }
|
|
}
|
|
|
|
if($opt_verbose)
|
|
{
|
|
foreach my $Pam (@Pams)
|
|
{
|
|
print DEST_FILE "//*** $Pam ***/ \n";
|
|
}
|
|
}
|
|
|
|
|
|
#/**********************************************************************/
|
|
#/* */
|
|
#/* sort all ports with their type, size and direction */
|
|
#/* */
|
|
#/**********************************************************************/
|
|
|
|
my @port_list = ();
|
|
my @wire_nodes = ();
|
|
my $key;
|
|
my $value;
|
|
|
|
foreach my $signal (@signals)
|
|
{
|
|
( ${port_name},${direction},${type},${vector},${left},${right}) = split ':', $signal;
|
|
|
|
if( $direction ne "node" )
|
|
{
|
{
|
my $q_width = " ";
|
$cmd = "./tools/verilog/gen_elab_verilog -envidentifier $envidentifier -prefix $prefix -vendor $vendor -library $library -component $component -version $version -destination $destination -local_parameters \n";
|
if( ${vector} eq "vector" ) { $q_width = "[ ${left} : ${right}]"; }
|
|
push (@port_list, "${direction} ${type} $q_width ${port_name}");
|
|
}
|
}
|
else
|
else
|
{
|
{
|
my $q_width = " ";
|
$cmd = "./tools/verilog/gen_elab_verilog -envidentifier $envidentifier -prefix $prefix -vendor $vendor -library $library -component $component -version $version -destination $destination \n";
|
if( ${vector} eq "vector" ) { $q_width = "[ $left : $right]";}
|
|
if( $direction eq "node" ) { push @wire_nodes, "$type $q_width ${port_name};";}
|
|
}
|
|
}
|
}
|
|
|
@port_list = sys::lib::trim_sort(@port_list);
|
|
|
|
#/**********************************************************************/
|
|
#/* */
|
|
#/* Now add all ports with their type, size and direction */
|
|
#/* */
|
|
#/**********************************************************************/
|
|
|
|
print DEST_FILE "\n ";
|
if(system($cmd)){}
|
$first = 1;
|
|
|
|
foreach $port_line (@port_list)
|
|
{
|
|
if($first)
|
|
{
|
|
print DEST_FILE " (\n ${port_line}";
|
|
$first=0;
|
|
}
|
|
else
|
|
{
|
|
print DEST_FILE ",\n ${port_line}";
|
|
}
|
|
|
|
}
|
|
|
|
if ($first == 0) { print DEST_FILE ");\n\n\n\n"; }
|
print "Getting get_component_configs($vendor,$library,$component,$version \n";
|
elsif ($opt_no_port) { print DEST_FILE "\n\n\n\n"; }
|
|
else { print DEST_FILE "();\n\n\n\n";}
|
|
|
|
|
my @configs = yp::lib::get_component_configs($vendor,$library,$component,$version);
|
|
|
#/**********************************************************************/
|
foreach my $config (@configs)
|
#/* */
|
|
#/* Add any and all local parameters with their default values */
|
|
#/* */
|
|
#/**********************************************************************/
|
|
|
|
if ($opt_local_parameters)
|
|
{
|
|
foreach my $parameter_name (@parameters)
|
|
{
|
{
|
my $parameter_value = $parameter_values{${parameter_name}};
|
print "GEN_verilog $vendor $library $component $version $config\n";
|
print DEST_FILE "parameter ${parameter_name} = ${parameter_value};\n";
|
|
}
|
|
}
|
|
|
|
@wire_nodes = sys::lib::trim_sort(@wire_nodes);
|
$cmd = "./tools/verilog/gen_elab_verilog -envidentifier $envidentifier -prefix $prefix -vendor $vendor -library $library -component $component -version $version -destination $destination -configuration $config -local_parameters \n";
|
|
if(system($cmd)){}
|
unless ($opt_interface_only)
|
|
{
|
|
foreach my $wire_node (@wire_nodes)
|
|
{
|
|
print DEST_FILE "${wire_node}\n";
|
|
}
|
}
|
|
|
|
|
#/**********************************************************************/
|
|
#/* */
|
|
#/* Dump everything from the ip-xact files into component */
|
|
#/* */
|
|
#/**********************************************************************/
|
|
|
|
print DEST_FILE "\n\n\n";
|
|
while( my $line_out = shift(@instantiations)) { print DEST_FILE "$line_out";}
|
|
|
|
|
|
#/**********************************************************************/
|
|
#/* */
|
|
#/* After all the data from the ip-xact file has been entered we now */
|
|
#/* insert any and all verilog fragments at the end before closing */
|
|
#/* the module */
|
|
#/* */
|
|
#/**********************************************************************/
|
|
|
|
|
|
foreach my $i_name ($spirit_component_file->findnodes("//spirit:fileSets/spirit:fileSet/spirit:file/spirit:name"))
|
|
{
|
|
my($rtl_file) = $i_name ->findnodes('./text()')->to_literal;
|
|
my($file_type) = $i_name ->findnodes('../spirit:userFileType/text()')->to_literal;
|
|
my($view_file) = $i_name ->findnodes('../../spirit:name/text()')->to_literal ;
|
|
|
|
if(($file_type eq "fragment")&& (($view_file eq $view_fileset_name)))
|
|
{
|
|
$SRCFILE ="${home}${prefix}/${vendor}__${library}${lib_comp_sep}${component}${comp_xml_sep}/${rtl_file}";
|
|
open(SRCFILE) or die("Could not open src file. $SRCFILE ");
|
|
foreach $line ()
|
|
{
|
|
chomp($line);
|
|
print DEST_FILE "${line}\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
unless ($opt_fragment ) {print DEST_FILE "\n\n\n endmodule\n\n";}
|
|
}
|
|
|
|
1
|
1
|
|
|