OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [perl_gui/] [lib/] [perl/] [verilog_gen.pl] - Diff between revs 21 and 25

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 21 Rev 25
Line 18... Line 18...
#   soc_generate_verilog
#   soc_generate_verilog
#####################
#####################
 
 
sub soc_generate_verilog{
sub soc_generate_verilog{
        my ($soc)= @_;
        my ($soc)= @_;
        my $soc_name=$soc->soc_get_soc_name();
        my $soc_name=$soc->object_get_attribute('soc_name');
        #my $top_ip=ip_gen->ip_gen_new();
        #my $top_ip=ip_gen->ip_gen_new();
        my $top_ip=ip_gen->top_gen_new();
        my $top_ip=ip_gen->top_gen_new();
        if(!defined $soc_name){$soc_name='soc'};
        if(!defined $soc_name){$soc_name='soc'};
 
 
        my @instances=$soc->soc_get_all_instances();
        my @instances=$soc->soc_get_all_instances();
        my $io_sim_v;
        my $io_sim_v;
        my $param_as_in_v="\tparameter\tCORE_ID=0";
        my $param_as_in_v="\tparameter\tCORE_ID=0";
 
        my $param_pass_v="\t.CORE_ID(CORE_ID)";
        my $body_v;
        my $body_v;
 
 
        my ($param_v_all, $local_param_v_all, $wire_def_v_all, $inst_v_all, $plugs_assign_v_all, $sockets_assign_v_all,$io_full_v_all);
        my ($param_v_all, $local_param_v_all, $wire_def_v_all, $inst_v_all, $plugs_assign_v_all, $sockets_assign_v_all,$io_full_v_all);
        my $wires=soc->new_wires();
        my $wires=soc->new_wires();
        my $intfc=interface->interface_new();
        my $intfc=interface->interface_new();
 
 
        foreach my $id (@instances){
        foreach my $id (@instances){
                my ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v)=gen_module_inst($id,$soc,\$io_sim_v,\$param_as_in_v,$top_ip,$intfc,$wires);
                my ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v)=gen_module_inst($id,$soc,\$io_sim_v,\$param_as_in_v,$top_ip,$intfc,$wires,\$param_pass_v);
                my $inst        = $soc->soc_get_instance_name($id);
                my $inst        = $soc->soc_get_instance_name($id);
                add_text_to_string(\$body_v,"/*******************\n*\n*\t$inst\n*\n*\n*********************/\n");
                add_text_to_string(\$body_v,"/*******************\n*\n*\t$inst\n*\n*\n*********************/\n");
 
 
                add_text_to_string(\$local_param_v_all,"$local_param_v\n")      if(defined($local_param_v));
                add_text_to_string(\$local_param_v_all,"$local_param_v\n")      if(defined($local_param_v));
                add_text_to_string(\$wire_def_v_all,"$wire_def_v\n")                    if(defined($wire_def_v));
                add_text_to_string(\$wire_def_v_all,"$wire_def_v\n")                    if(defined($wire_def_v));
Line 76... Line 78...
        add_text_to_string(\$soc_v,"endmodule\n\n");
        add_text_to_string(\$soc_v,"endmodule\n\n");
 
 
 
 
        $soc->soc_add_top($top_ip);
        $soc->soc_add_top($top_ip);
        #print @assigned_wires;
        #print @assigned_wires;
        return "$soc_v";
 
 
        #generate topmodule
 
 
 
        my $top_v = (defined $param_as_in_v )? "module ${soc_name}_top #(\n $param_as_in_v\n)(\n$io_sim_v\n);\n": "module ${soc_name}_top (\n $io_sim_v\n);\n";
 
        my $ins= gen_soc_instance_v($soc,$soc_name,$param_pass_v);
 
 
 
        add_text_to_string(\$top_v,$local_param_v_all."\n".$io_full_v_all);
 
        add_text_to_string(\$top_v,$ins);
 
        my $readme=gen_system_info($soc,$param_as_in_v);
 
        return ("$soc_v",$top_v,$readme);
 
 
 
 
}
}
 
 
#################
#################
#       gen_module_inst
#       gen_module_inst
###############
###############
 
 
sub gen_module_inst {
sub gen_module_inst {
        my ($id,$soc,$io_sim_v,$param_as_in_v,$top_ip, $intfc,$wires)=@_;
        my ($id,$soc,$io_sim_v,$param_as_in_v,$top_ip, $intfc,$wires,$param_pass_v)=@_;
        my $module      =$soc->soc_get_module($id);
        my $module      =$soc->soc_get_module($id);
        my $module_name =$soc->soc_get_module_name($id);
        my $module_name =$soc->soc_get_module_name($id);
        my $category    =$soc->soc_get_category($id);
        my $category    =$soc->soc_get_category($id);
 
 
        my $inst        = $soc->soc_get_instance_name($id);
        my $inst        = $soc->soc_get_instance_name($id);
        my %params      = $soc->soc_get_module_param($id);
        my %params      = $soc->soc_get_module_param($id);
 
 
        my $ip = ip->lib_new ();
        my $ip = ip->lib_new ();
 
 
        my @ports=$ip->ip_list_ports($category,$module);
        my @ports=$ip->ip_list_ports($category,$module);
        my ($inst_v,$intfc_v,$wire_def_v,$plugs_assign_v,$sockets_assign_v,$io_full_v);
        my ($inst_v,$intfc_v,$plugs_assign_v,$sockets_assign_v,$io_full_v);
 
        my $wire_def_v="";
        $plugs_assign_v="\n";
        $plugs_assign_v="\n";
 
 
        my $counter=0;
        my $counter=0;
        my @param_order=$soc->soc_get_instance_param_order($id);
        my @param_order=$soc->soc_get_instance_param_order($id);
 
 
        my ($param_v,$local_param_v,$instance_param_v)= gen_parameter_v(\%params,$id,$inst,$category,$module,$ip,$param_as_in_v,\@param_order,$top_ip);
        my ($param_v,$local_param_v,$instance_param_v)= gen_parameter_v(\%params,$id,$inst,$category,$module,$ip,$param_as_in_v,\@param_order,$top_ip,$param_pass_v);
        my $param_size = keys %params;
 
 
 
 
 
        $top_ip->top_add_def_to_instance($id,'module',$module);
        $top_ip->top_add_def_to_instance($id,'module',$module);
        $top_ip->top_add_def_to_instance($id,'module_name',$module_name);
        $top_ip->top_add_def_to_instance($id,'module_name',$module_name);
        $top_ip->top_add_def_to_instance($id,'category',$category);
        $top_ip->top_add_def_to_instance($id,'category',$category);
Line 118... Line 130...
 
 
 
 
 
 
 
 
        #module name    
        #module name    
        $inst_v=($param_size>0)? "$module_name #(\n": $module_name ;
        $inst_v=( defined $instance_param_v )? "$module_name #(\n": $module_name ;
 
 
 
 
 
 
        #module parameters
        #module parameters
        $inst_v=($param_size>0)? "$inst_v $instance_param_v\n\t)": $inst_v;
        $inst_v=( defined $instance_param_v)? "$inst_v $instance_param_v\n\t)": $inst_v;
        #module instance name 
        #module instance name 
        $inst_v="$inst_v  $inst \t(\n";
        $inst_v="$inst_v  $inst \t(\n";
 
 
        #module ports
        #module ports
        $counter=0;
        $counter=0;
Line 156... Line 168...
                if($NC eq 'yes'){
                if($NC eq 'yes'){
 
 
 
 
                }
                }
                elsif($IO eq 'yes' || !defined $i_type || !defined $i_name || !defined $i_num){ #its an IO port
                elsif($IO eq 'yes' || !defined $i_type || !defined $i_name || !defined $i_num){ #its an IO port
 
                        if($i_port eq 'NC'){
 
                                $NC='yes';
 
                        }else {
                         $assigned_port="$inst\_$port";
                         $assigned_port="$inst\_$port";
                         $$io_sim_v= (!defined $$io_sim_v)? "\t$assigned_port" : "$$io_sim_v, \n\t$assigned_port";
                         $$io_sim_v= (!defined $$io_sim_v)? "\t$assigned_port" : "$$io_sim_v, \n\t$assigned_port";
                         my $new_range = add_instantc_name_to_parameters(\%params,$inst,$range);
                         my $new_range = add_instantc_name_to_parameters(\%params,$inst,$range);
                         my $port_def=(length ($range)>1 )?     "\t$type\t [ $new_range    ] $assigned_port;\n": "\t$type\t\t\t$assigned_port;\n";
                         my $port_def=(length ($range)>1 )?     "\t$type\t [ $new_range    ] $assigned_port;\n": "\t$type\t\t\t$assigned_port;\n";
                         add_text_to_string(\$io_full_v,$port_def);
                         add_text_to_string(\$io_full_v,$port_def);
                        # $top_ip->ipgen_add_port($assigned_port, $new_range, $type ,$intfc_name,$i_port);
                        # $top_ip->ipgen_add_port($assigned_port, $new_range, $type ,$intfc_name,$i_port);
                        $top_ip->top_add_port($id,$assigned_port, $new_range, $type ,$intfc_name,$i_port);
                        $top_ip->top_add_port($id,$assigned_port, $new_range, $type ,$intfc_name,$i_port);
 
                        }
 
 
 
 
                }
                }
                else{ # port connected internally using interface 
                else{ # port connected internally using interface 
                         $assigned_port="$inst\_$i_type\_$i_name\_$i_num\_$i_port";
                         $assigned_port="$inst\_$i_type\_$i_name\_$i_num\_$i_port";
 
 
                         #create plug wires
                         #create plug wires
                         my $wire_string=generate_wire ($range,$assigned_port,$inst,\%params,$i_type,$i_name,$i_num,$i_port, $wires);
                         my ($wire_string,$port_name)=generate_wire ($range,$assigned_port,$inst,\%params,$i_type,$i_name,$i_num,$i_port, $wires);
                         add_text_to_string(\$wire_def_v,$wire_string);
                         #add wire def if it is not defined before
 
 
 
                         add_text_to_string(\$wire_def_v,$wire_string)  if ($wire_def_v !~ /[\s\]]$port_name;/);
 
 
 
 
 
 
                        if($i_type eq 'plug'){
                        if($i_type eq 'plug'){
                                #read socket port name
                                #read socket port name
Line 208... Line 226...
                                if ( length( $v || '' )) {
                                if ( length( $v || '' )) {
                                                $v--;
                                                $v--;
                                                my $name= $soc->soc_get_instance_name($id);
                                                my $name= $soc->soc_get_instance_name($id);
                                                my $joint= "$name\_$i_type\_$i_name\_$v\_$i_port";
                                                my $joint= "$name\_$i_type\_$i_name\_$v\_$i_port";
 
 
                                                my $wire_string=generate_wire ($i_range,"$name\_$i_type\_$i_name\_$v\_$i_port",$inst,\%params,$i_type,$i_name,$i_num,$i_port, $wires);
                                                my ($wire_string,$port_name)=generate_wire ($i_range,"$name\_$i_type\_$i_name\_$v\_$i_port",$inst,\%params,$i_type,$i_name,$i_num,$i_port, $wires);
                                                add_text_to_string(\$wire_def_v,$wire_string);
                                                add_text_to_string(\$wire_def_v,$wire_string) if ($wire_def_v !~ /[\s\]]$port_name;/);
 
 
                                                for(my $i=$v-1; $i>=0; $i--) {
                                                for(my $i=$v-1; $i>=0; $i--) {
                                                        $joint= "$joint ,$name\_$i_type\_$i_name\_$i\_$i_port";
                                                        $joint= "$joint ,$name\_$i_type\_$i_name\_$i\_$i_port";
                                                        #create socket wires
                                                        #create socket wires
                                                         #create plug wires
                                                         #create plug wires
                                                        my $wire_string=generate_wire ($i_range,"$name\_$i_type\_$i_name\_$i\_$i_port",$inst,\%params,$i_type,$i_name,$i_num,$i_port, $wires);
                                                        my ($wire_string,$port_name)=generate_wire ($i_range,"$name\_$i_type\_$i_name\_$i\_$i_port",$inst,\%params,$i_type,$i_name,$i_num,$i_port, $wires);
                                                        add_text_to_string(\$wire_def_v,$wire_string);
                                                        add_text_to_string(\$wire_def_v,$wire_string) if ($wire_def_v !~ /[\s\]]$port_name;/);
 
 
 
 
 
 
 
 
 
 
Line 269... Line 287...
        $inst_v="$inst_v\t);\n";
        $inst_v="$inst_v\t);\n";
 
 
 
 
 
 
 
 
        return ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v);
        return ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v,$param_pass_v);
 
 
 
 
}
}
 
 
 
 
Line 291... Line 309...
                return $new_range;
                return $new_range;
}
}
 
 
 
 
sub gen_parameter_v{
sub gen_parameter_v{
        my ($param_ref,$id,$inst,$category,$module,$ip,$param_as_in_v,$ref_ordered,$top_ip)=@_;
        my ($param_ref,$id,$inst,$category,$module,$ip,$param_as_in_v,$ref_ordered,$top_ip,$param_pass_v)=@_;
        my %params=%$param_ref;
        my %params=%$param_ref;
        my @param_order;
        my @param_order;
        @param_order=@{$ref_ordered} if(defined $ref_ordered);
        @param_order=@{$ref_ordered} if(defined $ref_ordered);
 
 
        my ($param_v,$local_param_v,$instance_param_v);
        my ($param_v,$local_param_v,$instance_param_v);
        my @list;
        my @list;
        @list= (@param_order)? @param_order :
        @list= (@param_order)? @param_order :
sort keys%params;
sort keys%params;
        my $first_param=1;
        my $first_param=1;
        $instance_param_v="";
 
        $local_param_v="";
        $local_param_v="";
        $param_v="";
        $param_v="";
 
 
        #add instance name to parameter value
        #add instance name to parameter value
        foreach my $param (@list){
        foreach my $param (@list){
                $params{$param}=add_instantc_name_to_parameters(\%params,$inst,$params{$param});
                $params{$param}=add_instantc_name_to_parameters(\%params,$inst,$params{$param});
 
 
        }
        }
 
 
 
 
        #print parameters
        #print parameters
        foreach my $param (@list){
        foreach my $param (@list){
                my $inst_param= "$inst\_$param";
                my $inst_param= "$inst\_$param";
                my ($deafult,$type,$content,$info,$glob_param,$redefine_param)= $ip->ip_get_parameter($category,$module,$param);
                my ($deafult,$type,$content,$info,$vfile_param_type,$redefine_param)= $ip->ip_get_parameter($category,$module,$param);
                if (! defined $redefine_param){$redefine_param=1;}
                $vfile_param_type= "Don't include" if (!defined $vfile_param_type );
 
                $vfile_param_type= "Parameter"  if ($vfile_param_type eq 1);
 
                $vfile_param_type= "Localparam" if ($vfile_param_type eq 0);
 
                $redefine_param=1 if (! defined $redefine_param);
 
                $redefine_param=0 if ($vfile_param_type eq "Don't include");
                if($redefine_param eq 1){
                if($redefine_param eq 1){
 
                        $instance_param_v=($first_param eq 1)? "\t\t.$param($inst_param)" : "$instance_param_v,\n\t\t.$param($inst_param)";
                        $instance_param_v=($first_param eq 1)? "$instance_param_v\t\t.$param($inst_param)" : "$instance_param_v,\n\t\t.$param($inst_param)";
 
                        $first_param=0;
                        $first_param=0;
 
 
 
 
                }
                }
 
 
 
 
                if (! defined $glob_param){$glob_param=0;}
 
                if($glob_param eq 0){
                if($vfile_param_type eq "Localparam"){
                        $local_param_v="$local_param_v\tlocalparam\t$inst_param=$params{$param};\n";
                        $local_param_v="$local_param_v\tlocalparam\t$inst_param=$params{$param};\n";
                }else{
                }
 
                elsif($vfile_param_type eq "Parameter"){
                        $param_v="$param_v\tparameter\t$inst_param=$params{$param};\n";
                        $param_v="$param_v\tparameter\t$inst_param=$params{$param};\n";
 
                        $$param_pass_v =(defined ($$param_pass_v ))? "$$param_pass_v,\n\t.$inst_param($inst_param)": "\t.$inst_param($inst_param)";
                        $$param_as_in_v=(defined ($$param_as_in_v))? "$$param_as_in_v ,\n\tparameter\t$inst_param=$params{$param}":
                        $$param_as_in_v=(defined ($$param_as_in_v))? "$$param_as_in_v ,\n\tparameter\t$inst_param=$params{$param}":
                                                                                                                 "   \tparameter\t$inst_param=$params{$param}";
                                                                                                                 "   \tparameter\t$inst_param=$params{$param}";
                        #add parameter to top 
                        #add parameter to top 
                        #$top_ip  $inst_param                   
                        #$top_ip  $inst_param                   
                        $top_ip->top_add_parameter($id,$inst_param,$params{$param},$type,$content,$info,$glob_param,$redefine_param);
                        $top_ip->top_add_parameter($id,$inst_param,$params{$param},$type,$content,$info,$vfile_param_type,$redefine_param);
 
 
                }
                }
 
 
 
 
 
 
Line 364... Line 387...
        foreach my $instance_id (@all_instances){
        foreach my $instance_id (@all_instances){
                my $instance_name=$soc->soc_get_instance_name($instance_id);
                my $instance_name=$soc->soc_get_instance_name($instance_id);
                        my @plugs= $soc->soc_get_all_plugs_of_an_instance($instance_id);
                        my @plugs= $soc->soc_get_all_plugs_of_an_instance($instance_id);
                        foreach my $plug (@plugs){
                        foreach my $plug (@plugs){
                                my @nums=$soc->soc_list_plug_nums($instance_id,$plug);
                                my @nums=$soc->soc_list_plug_nums($instance_id,$plug);
 
 
                                foreach my $num (@nums){
                                foreach my $num (@nums){
                                        my ($addr,$base,$end,$name,$connect_id,$connect_socket,$connect_socket_num)=$soc->soc_get_plug($instance_id,$plug,$num);
                                        my ($addr,$base,$end,$name,$connect_id,$connect_socket,$connect_socket_num)=$soc->soc_get_plug($instance_id,$plug,$num);
                                        if((defined $connect_socket) && ($connect_socket eq 'wb_slave')){
                                        if((defined $connect_socket) && ($connect_socket eq 'wb_slave')){
 
                                                #read wishbone bus address and data width size                                          
 
                                                my $Aw=$soc->soc_get_module_param_value ($connect_id,'Aw');
 
                                                my $Dw=$soc->soc_get_module_param_value ($connect_id,'Dw');
 
                                                $Aw=32 if (!defined $Aw);
 
                                                $Dw=32 if (!defined $Dw);
                                                add_text_to_string(\$addr_mp_v,"/* $instance_name wb_slave $num */\n");
                                                add_text_to_string(\$addr_mp_v,"/* $instance_name wb_slave $num */\n");
                                                my $base_hex=sprintf("32'h%08x", ($base>>2));
                                                #count how many nibbles we have in address size 
                                                my $end_hex=sprintf("32'h%08x", ($end>>2));
                                                my $hh= ($Aw % 4)? ($Aw >> 2)+1 : ($Aw >> 2);
                                                add_text_to_string(\$instance_addr_localparam,"\tlocalparam \t$instance_name\_BASE_ADDR\t=\t$base_hex;\n");
                                                $hh= "'h%0${hh}x";#hex address nibble num
                                                add_text_to_string(\$instance_addr_localparam,"\tlocalparam \t$instance_name\_END_ADDR\t=\t$end_hex;\n");
                                                #change addresses to word as the assign addresses by ProNoC GUI are in bytes  
 
                                                my $bytenum=($Dw/8);
 
                                                my $base_hex=$Aw.sprintf($hh, ($base/$bytenum));
 
                                                my $end_hex=$Aw.sprintf($hh, ($end/$bytenum));
 
                                                #my $base_hex=sprintf("32'h%08x", ($base>>2));
 
                                                #my $end_hex=sprintf("32'h%08x", ($end>>2));
 
                                                add_text_to_string(\$instance_addr_localparam,"\tlocalparam \t$instance_name\_WB$num\_BASE_ADDR\t=\t$base_hex;\n");
 
                                                add_text_to_string(\$instance_addr_localparam,"\tlocalparam \t$instance_name\_WB$num\_END_ADDR\t=\t$end_hex;\n");
                                                if($instance_name ne $instance_id){
                                                if($instance_name ne $instance_id){
                                                        add_text_to_string(\$module_addr_localparam,"\tlocalparam \t$instance_id\_BASE_ADDR\t=\t$base_hex;\n");
                                                        add_text_to_string(\$module_addr_localparam,"\tlocalparam \t$instance_id\_WB$num\_BASE_ADDR\t=\t$base_hex;\n");
                                                        add_text_to_string(\$module_addr_localparam,"\tlocalparam \t$instance_id\_END_ADDR\t=\t$end_hex;\n");
                                                        add_text_to_string(\$module_addr_localparam,"\tlocalparam \t$instance_id\_WB$num\_END_ADDR\t=\t$end_hex;\n");
                                                }
                                                }
 
 
                                                my $connect_name=$soc->soc_get_instance_name($connect_id);
                                                my $connect_name=$soc->soc_get_instance_name($connect_id);
                                                $wires->wire_add("$connect_name\_socket_wb_addr_map_0_sel_one_hot","connected",1);
                                                $wires->wire_add("$connect_name\_socket_wb_addr_map_0_sel_one_hot","connected",1);
                                                $addr_mp_v="$addr_mp_v \tassign $connect_name\_socket_wb_addr_map_0_sel_one_hot[$connect_socket_num\] = (($connect_name\_socket_wb_addr_map_0_grant_addr >= $instance_name\_BASE_ADDR)   & ($connect_name\_socket_wb_addr_map_0_grant_addr <= $instance_name\_END_ADDR));\n";
                                                $addr_mp_v="$addr_mp_v \tassign $connect_name\_socket_wb_addr_map_0_sel_one_hot[$connect_socket_num\] = (($connect_name\_socket_wb_addr_map_0_grant_addr >= $instance_name\_WB$num\_BASE_ADDR)   & ($connect_name\_socket_wb_addr_map_0_grant_addr <= $instance_name\_WB$num\_END_ADDR));\n";
 
 
                                                $number++;
                                                $number++;
                                        }#if
                                        }#if
                                }#foreach my $num
                                }#foreach my $num
                        }#foreach my $plug
                        }#foreach my $plug
Line 429... Line 463...
        $wires->wire_add("$port_name","i_type",$i_type);
        $wires->wire_add("$port_name","i_type",$i_type);
        $wires->wire_add("$port_name","i_name",$i_name);
        $wires->wire_add("$port_name","i_name",$i_name);
        $wires->wire_add("$port_name","i_num",$i_num);
        $wires->wire_add("$port_name","i_num",$i_num);
        $wires->wire_add("$port_name","i_port",$i_port);
        $wires->wire_add("$port_name","i_port",$i_port);
 
 
        return $wire_string;
        return ($wire_string,$port_name);
}
}
 
 
sub port_width_repeat{
sub port_width_repeat{
        my ($range,$value)=@_;
        my ($range,$value)=@_;
        return "$value" if (!defined $range);
        return "$value" if (!defined $range);
Line 487... Line 521...
}
}
 
 
 
 
 
 
 
 
 
sub gen_soc_instance_v{
 
        my ($soc,$soc_name,$param_pass_v)=@_;
 
        my $soc_v;
 
        my $processor_en=0;
 
 
 
        add_text_to_string(\$soc_v,"
 
 
 
// Allow software to remote reset/enable the cpu via jtag
 
 
 
        wire jtag_cpu_en, jtag_system_reset;
 
 
 
        jtag_system_en jtag_en (
 
                .cpu_en(jtag_cpu_en),
 
                .system_reset(jtag_system_reset)
 
 
 
        );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
");
 
 
 
 
 
        my $mm="$soc_name #(\n $param_pass_v \n\t)the_${soc_name}(\n";
 
 
 
        my $top=$soc->soc_get_top();
 
        my @intfcs=$top->top_get_intfc_list();
 
 
 
        my $i=0;
 
 
 
 
 
 
 
 
 
        my $ss="";
 
        my $ww="";
 
 
 
foreach my $intfc (@intfcs){
 
 
 
 
 
 
 
                #reset
 
                if( $intfc eq 'plug:reset[0]'){
 
                        my @ports=$top->top_get_intfc_ports_list($intfc);
 
                        foreach my $p (@ports){
 
                                my($inst,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
 
                                $mm="$mm," if ($i);
 
                                $mm="$mm\n\t\t.$p(${p}_ored_jtag)";
 
                                $ss="$ss\tassign ${p}_ored_jtag = (jtag_system_reset | $p);\n";
 
                                $ww="$ww\twire ${p}_ored_jtag;\n";
 
                                $i=1;
 
 
 
                        }
 
 
 
 
 
 
 
                }
 
                #enable
 
                elsif( $intfc eq 'plug:enable[0]'){
 
                        my @ports=$top->top_get_intfc_ports_list($intfc);
 
                        foreach my $p (@ports){
 
                                my($inst,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
 
                                $mm="$mm," if ($i);
 
                                $mm="$mm\n\t\t.$p(${p}_anded_jtag)";
 
                                $ss="$ss\tassign ${p}_anded_jtag= (jtag_cpu_en & $p);\n";
 
                                $ww="$ww\twire ${p}_anded_jtag;\n";
 
                                $processor_en=1;
 
                                $i=1;
 
 
 
                        }
 
 
 
 
 
                }
 
                else {
 
                #other interface
 
                        my @ports=$top->top_get_intfc_ports_list($intfc);
 
                        foreach my $p (@ports){
 
                        my($inst,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
 
                        $mm="$mm," if ($i);
 
                        $mm="$mm\n\t\t.$p($p)";
 
                        $i=1;
 
 
 
                        }
 
 
 
 
 
                }
 
 
 
 
 
        }
 
        $mm="$mm\n\t);";
 
        add_text_to_string(\$soc_v,"$ww\n");
 
        add_text_to_string(\$soc_v,"$mm\n");
 
        add_text_to_string(\$soc_v,"$ss\n");
 
        add_text_to_string(\$soc_v,"\n endmodule\n");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
        return $soc_v;
 
 
 
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
sub gen_system_info {
 
        my ($soc,$param)=@_;
 
        my ($wb_slaves,$wb_masters,$other,$jtag);
 
        #my (@newbase,@newend,@connects);
 
 
 
 
 
 
 
 
 
        my @all_instances=$soc->soc_get_all_instances();
 
        foreach my $instance_id (@all_instances){
 
                my @plugs= $soc->soc_get_all_plugs_of_an_instance($instance_id);
 
                foreach my $plug (@plugs){
 
                        my @nums=$soc->soc_list_plug_nums($instance_id,$plug);
 
                        foreach my $num (@nums){
 
                                my ($addr,$base,$end,$name,$connect_id,$connect_socket,$connect_socket_num)=$soc->soc_get_plug($instance_id,$plug,$num);
 
                                my $instance_name=$soc->soc_get_instance_name($instance_id);
 
                                my $connect_name=$soc->soc_get_instance_name($connect_id);
 
                                #get interfaces
 
                                if((defined $connect_socket) && ($connect_socket eq 'wb_slave')){
 
 
 
                                        $base=sprintf("0x%08x", $base);
 
                                        $end=sprintf("0x%08x", $end);
 
                                        add_text_to_string(\$wb_slaves, "\t$instance_name, $name, $connect_name, $base, $end\n");
 
 
 
                                }#if
 
                                elsif((defined $connect_socket) && ($connect_socket eq 'wb_master')){
 
                                        add_text_to_string(\$wb_masters,"\t$instance_name, $name, $connect_name\n");
 
                                }
 
                                elsif(defined $connect_socket) {
 
                                        add_text_to_string(\$other,"\t$instance_name, $name, $connect_name\n");
 
 
 
                                }
 
                                # get jtag_wbs
 
                                if((defined $connect_socket) && ($connect_socket eq 'wb_master') && ($instance_id =~ /jtag_wb/)){
 
                                        my $index=$soc->soc_get_module_param_value($instance_id,'VJTAG_INDEX');
 
                                        add_text_to_string(\$jtag, "\t$instance_name,  $connect_name, $index\n");
 
 
 
 
 
                                }
 
 
 
 
 
                        }#foreach my $num
 
                }#foreach my $plug
 
        }#foreach my $instance_id
 
 
 
 
 
my $lisence= get_license_header("readme");
 
my $warning=autogen_warning();
 
 
 
 
 
 
 
 
 
my $readme="
 
$warning
 
$lisence
 
 
 
***********************
 
**      Program the memories
 
***********************
 
 
 
If the memory core and jtag_wb are connected to the same wishbone bus, you can program the memory using
 
 
 
        sh program.sh
 
 
 
but first, you need to update these variables inside the program.sh file
 
 
 
        OFSSET= [offset_in_hex]
 
                The RAM wishbone bus offset address e.g : 0x0000000.
 
        BOUNDRY=[boundry_in_hex ]
 
                The RAM boundary address in hex e.g: 0x00003fff.
 
        VJTAG_INDEX=[Virtual jtag index number]
 
        BINFILE=[file_name]
 
        memory file in binary format. eg ram00.bin
 
 
 
 
 
        you can get OFSSET, BOUNDRY and VJTAG_INDEX values from following
 
        wishbone buse(s)  info & Jtag to wishbone interface (jtag_wb) info sections.
 
        Also check the memory and jtag_wb are connected to the same bus (have same \"connected to\" filed).
 
 
 
***************************
 
**      soc parameters
 
***************************
 
 
 
$param
 
 
 
****************************
 
**      wishbone bus(es)  info
 
****************************
 
        #slave interfaces:
 
        #instance name,  interface name, connected to, base address, boundray address
 
$wb_slaves
 
 
 
        #master interfaces:
 
        #instance name,  interface name, connected to
 
$wb_masters
 
 
 
****************************
 
**      Jtag to wishbone interface (jtag_wb) info:
 
****************************
 
 
 
        #instance name, instance name,  VJTAG_INDEX
 
$jtag
 
 
 
 
 
";
 
 
 
        return $readme;
 
 
 
 
 
 
 
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1;
1;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.