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/] [soc_gen.pl] - Diff between revs 24 and 25

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

Rev 24 Rev 25
Line 27... Line 27...
use constant NUM_COLUMNS     => 4;
use constant NUM_COLUMNS     => 4;
 
 
 
 
require "widget.pl";
require "widget.pl";
require "verilog_gen.pl";
require "verilog_gen.pl";
 
require "readme_gen.pl";
require "hdr_file_gen.pl";
require "hdr_file_gen.pl";
 
 
 
 
 
 
 
 
Line 63... Line 63...
 
 
#################
#################
#  add_module_to_soc
#  add_module_to_soc
###############
###############
sub add_module_to_soc{
sub add_module_to_soc{
        my ($soc,$ip,$category,$module,$info,$soc_state)=@_;
        my ($soc,$ip,$category,$module,$info)=@_;
        my ($instance_id,$id)= get_instance_id($soc,$category,$module);
        my ($instance_id,$id)= get_instance_id($soc,$category,$module);
 
 
        #add module instanance
        #add module instanance
        my $result=$soc->soc_add_instance($instance_id,$category,$module,$ip);
        my $result=$soc->soc_add_instance($instance_id,$category,$module,$ip);
 
 
Line 76... Line 76...
                show_info($info,$info_text);
                show_info($info,$info_text);
                return;
                return;
        }
        }
        $soc->soc_add_instance_order($instance_id);
        $soc->soc_add_instance_order($instance_id);
 
 
        # Read deafult parameter from lib and add them to soc
        # Read default parameter from lib and add them to soc
        my %param_default= $ip->get_param_default($category,$module);
        my %param_default= $ip->get_param_default($category,$module);
 
 
        my $rr=$soc->soc_add_instance_param($instance_id,\%param_default);
        my $rr=$soc->soc_add_instance_param($instance_id,\%param_default);
        if($rr == 0){
        if($rr == 0){
                my $info_text= "Failed to add deafualt parameter to \"$instance_id\".  $instance_id does not exist exist.";
                my $info_text= "Failed to add defualt parameter to \"$instance_id\".  $instance_id does not exist exist.";
                show_info($info,$info_text);
                show_info($info,$info_text);
                return;
                return;
        }
        }
        my @r=$ip->ip_get_param_order($category,$module);
        my @r=$ip->ip_get_param_order($category,$module);
        $soc->soc_add_instance_param_order($instance_id,\@r);
        $soc->soc_add_instance_param_order($instance_id,\@r);
 
 
        get_module_parameter($soc,$ip,$instance_id,$soc_state);
        get_module_parameter($soc,$ip,$instance_id);
 
 
 
 
 
 
}
}
################
################
#       remove_instance_from_soc
#       remove_instance_from_soc
################
################
sub remove_instance_from_soc{
sub remove_instance_from_soc{
        my ($soc,$instance_id,$soc_state)=@_;
        my ($soc,$instance_id)=@_;
        $soc->soc_remove_instance($instance_id);
        $soc->soc_remove_instance($instance_id);
        $soc->soc_remove_from_instance_order($instance_id);
        $soc->soc_remove_from_instance_order($instance_id);
        set_state($soc_state,"refresh_soc",0);
        set_gui_status($soc,"refresh_soc",0);
}
}
 
 
 
 
 
 
###############
###############
#   get module_parameter
#   get module_parameter
##############
##############
 
 
sub get_module_parameter{
sub get_module_parameter{
        my ($soc,$ip,$instance_id,$soc_state)=@_;
        my ($soc,$ip,$instance_id)=@_;
 
 
        #read module parameters from lib
        #read module parameters from lib
        my $module=$soc->soc_get_module($instance_id);
        my $module=$soc->soc_get_module($instance_id);
        my $category=$soc->soc_get_category($instance_id);
        my $category=$soc->soc_get_category($instance_id);
        my @parameters=$ip->ip_get_module_parameters($category,$module);
        my @parameters=$ip->ip_get_param_order($category,$module);
        my $param_num = @parameters;
        my $param_num = @parameters;
 
 
        #read soc parameters
        #read soc parameters
        my %param_value= $soc->soc_get_module_param($instance_id);
        my %param_value= $soc->soc_get_module_param($instance_id);
        my %new_param_value=%param_value;
        my %new_param_value=%param_value;
        #gui
        #gui
        my $table_size = ($param_num<10) ? 10 : $param_num;
        my $table_size = ($param_num<10) ? 10 : $param_num;
        my $window = def_popwin_size(600,400,"Parameter setting for $module ");
        my($width,$hight)=max_win_size();
        my $table = def_table($table_size, 7, TRUE);
        my $window =  def_popwin_size(.6*$width,.6*$hight, "Parameter setting for $module ");
 
        my $table = def_table($table_size, 7, FALSE);
 
 
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
        $scrolled_win->set_policy( "automatic", "automatic" );
        $scrolled_win->set_policy( "automatic", "automatic" );
        $scrolled_win->add_with_viewport($table);
        $scrolled_win->add_with_viewport($table);
        my $row=0;
        my $row=0;
 
 
        my $ok = def_image_button('icons/select.png','OK');
        my $ok = def_image_button('icons/select.png','OK');
        my $okbox=def_hbox(TRUE,0);
 
        $okbox->pack_start($ok, FALSE, FALSE,0);
 
 
        $table->attach (gen_label_in_center("Parameter name"),0, 3, $row, $row+1,'expand','shrink',2,2);
 
        $table->attach (gen_label_in_center("Value"),3, 6, $row, $row+1,'expand','shrink',2,2);
 
        $table->attach (gen_label_in_center("Description"),6, 7, $row, $row+1,'expand','shrink',2,2);
 
        $row++;
        foreach my $p (@parameters){
        foreach my $p (@parameters){
                my ($deafult,$type,$content,$info)= $ip->ip_get_parameter($category,$module,$p);
                my ($default,$type,$content,$info)= $ip->ip_get_parameter($category,$module,$p);
 
 
                my $value=$param_value{$p};
                my $value=$param_value{$p};
 
 
                if ($type eq "Entry"){
                if ($type eq "Entry"){
                        my $entry=gen_entry($value);
                        my $entry=gen_entry($value);
                        $table->attach_defaults ($entry, 3, 6, $row, $row+1);
                        $table->attach ($entry, 3, 6, $row, $row+1,'expand','shrink',2,2);
                        $entry-> signal_connect("changed" => sub{$new_param_value{$p}=$entry->get_text();});
                        $entry-> signal_connect("changed" => sub{$new_param_value{$p}=$entry->get_text();});
                }
                }
                elsif ($type eq "Combo-box"){
                elsif ($type eq "Combo-box"){
                        my @combo_list=split(",",$content);
                        my @combo_list=split(",",$content);
                        my $pos=get_item_pos($value, @combo_list);
                        my $pos=get_item_pos($value, @combo_list);
                        my $combo=gen_combo(\@combo_list, $pos);
                        my $combo=gen_combo(\@combo_list, $pos);
                        $table->attach_defaults ($combo, 3, 6, $row, $row+1);
                        $table->attach ($combo, 3, 6, $row, $row+1,'expand','shrink',2,2);
                        $combo-> signal_connect("changed" => sub{$new_param_value{$p}=$combo->get_active_text();});
                        $combo-> signal_connect("changed" => sub{$new_param_value{$p}=$combo->get_active_text();});
 
 
                }
                }
                elsif   ($type eq "Spin-button"){
                elsif   ($type eq "Spin-button"){
                  my ($min,$max,$step)=split(",",$content);
                  my ($min,$max,$step)=split(",",$content);
Line 160... Line 165...
                  $min=~ s/\D//g;
                  $min=~ s/\D//g;
                  $max=~ s/\D//g;
                  $max=~ s/\D//g;
                  $step=~ s/\D//g;
                  $step=~ s/\D//g;
                  my $spin=gen_spin($min,$max,$step);
                  my $spin=gen_spin($min,$max,$step);
                  $spin->set_value($value);
                  $spin->set_value($value);
                  $table->attach_defaults ($spin, 3, 4, $row, $row+1);
                  $table->attach ($spin, 3, 4, $row, $row+1,'expand','shrink',2,2);
                  $spin-> signal_connect("value_changed" => sub{ $new_param_value{$p}=$spin->get_value_as_int(); });
                  $spin-> signal_connect("value_changed" => sub{ $new_param_value{$p}=$spin->get_value_as_int(); });
 
 
                 # $box=def_label_spin_help_box ($param,$info, $value,$min,$max,$step, 2);
                 # $box=def_label_spin_help_box ($param,$info, $value,$min,$max,$step, 2);
                }
                }
                if (defined $info && $type ne "Fixed"){
                if (defined $info && $type ne "Fixed"){
                        my $info_button=def_image_button('icons/help.png');
                        my $info_button=def_image_button('icons/help.png');
                        $table->attach_defaults ($info_button, 6, 7, $row, $row+1);
                        $table->attach ($info_button, 6, 7, $row, $row+1,'expand','shrink',2,2);
                        $info_button->signal_connect('clicked'=>sub{
                        $info_button->signal_connect('clicked'=>sub{
                                message_dialog($info);
                                message_dialog($info);
 
 
                        });
                        });
 
 
                }
                }
                if ($type ne "Fixed"){
                if ($type ne "Fixed"){
                        #print "$p:val:$value\n";
                        #print "$p:val:$value\n";
                        my $label =gen_label_in_center($p);
                        my $label =gen_label_in_center($p);
                        $table->attach_defaults ($label, 0, 3, $row, $row+1);
                        $table->attach ($label, 0, 3, $row, $row+1,'expand','shrink',2,2);
                        $row++;
                        $row++;
                }
                }
 
 
 
 
        }
        }
 
        #if ($row== 0){
 
                        #my $label =gen_label_in_left("The $module IP does not have any adjatable parameter");
 
                #       $table->attach ($label, 0, 7, $row, $row+1,'expand','shrink',2,2);
 
 
        my $mtable = def_table(10, 1, TRUE);
        #}
 
 
 
        my $mtable = def_table(10, 1, FALSE);
 
 
        $mtable->attach_defaults($scrolled_win,0,1,0,9);
        $mtable->attach_defaults($scrolled_win,0,1,0,9);
        $mtable->attach_defaults($okbox,0,1,9,10);
        $mtable->attach($ok,0,1,9,10,'expand','shrink',2,2);
 
 
        $window->add ($mtable);
        $window->add ($mtable);
        $window->show_all();
        $window->show_all();
 
 
        $ok-> signal_connect("clicked" => sub{
        $ok-> signal_connect("clicked" => sub{
Line 225... Line 235...
                                }#plug_num
                                }#plug_num
                        }#if
                        }#if
                }#plugs
                }#plugs
 
 
 
 
                set_state($soc_state,"refresh_soc",0);
                set_gui_status($soc,"refresh_soc",0);
                #$$refresh_soc->clicked;
                #$$refresh_soc->clicked;
 
 
                });
                });
 
 
 
 
Line 311... Line 321...
 
 
##############
##############
#       gen_dev_box
#       gen_dev_box
##############
##############
 
 
sub gen_instance{;
sub gen_instance{
        #my ($soc,$ip,$infc,$instance_id,$soc_state,$info)=@_;
        #my ($soc,$ip,$infc,$instance_id,$info)=@_;
        my ($soc,$ip,$infc,$instance_id,$soc_state,$info,$table,$offset)=@_;
        my ($soc,$ip,$infc,$instance_id,$info,$table,$offset)=@_;
 
 
 
 
 
 
#       my $box= def_vbox (FALSE,0);
#       my $box= def_vbox (FALSE,0);
 
 
Line 337... Line 347...
        my $up=def_image_button("icons/up_sim.png");
        my $up=def_image_button("icons/up_sim.png");
        $box1->pack_start( $up, FALSE, FALSE, 3);
        $box1->pack_start( $up, FALSE, FALSE, 3);
        $box1->pack_start($param_button,   FALSE, FALSE,3);
        $box1->pack_start($param_button,   FALSE, FALSE,3);
        $table->attach_defaults ($box1 ,0,1,$offset+1,$offset+2);
        $table->attach_defaults ($box1 ,0,1,$offset+1,$offset+2);
        $param_button->signal_connect (clicked => sub{
        $param_button->signal_connect (clicked => sub{
                get_module_parameter($soc,$ip,$instance_id,$soc_state);
                get_module_parameter($soc,$ip,$instance_id);
 
 
        });
        });
        $up->signal_connect (clicked => sub{
        $up->signal_connect (clicked => sub{
                $soc->soc_decrease_instance_order($instance_id);
                $soc->soc_decrease_instance_order($instance_id);
                set_state($soc_state,"refresh_soc",0);
                set_gui_status($soc,"refresh_soc",0);
 
 
        });
        });
 
 
        #remove button
        #remove button
        #my ($box2,$cancel_button) = button_box("Remove");
        #my ($box2,$cancel_button) = button_box("Remove");
Line 356... Line 366...
        my $dwn=def_image_button("icons/down_sim.png");
        my $dwn=def_image_button("icons/down_sim.png");
        $box2->pack_start( $dwn, FALSE, FALSE, 3);
        $box2->pack_start( $dwn, FALSE, FALSE, 3);
        $box2->pack_start($cancel_button,   FALSE, FALSE,3);
        $box2->pack_start($cancel_button,   FALSE, FALSE,3);
        $table->attach_defaults ($box2,0,1,$offset+2,$offset+3);
        $table->attach_defaults ($box2,0,1,$offset+2,$offset+3);
        $cancel_button->signal_connect (clicked => sub{
        $cancel_button->signal_connect (clicked => sub{
                remove_instance_from_soc($soc,$instance_id,$soc_state);
                remove_instance_from_soc($soc,$instance_id);
 
 
        });
        });
        $dwn->signal_connect (clicked => sub{
        $dwn->signal_connect (clicked => sub{
                $soc->soc_increase_instance_order($instance_id);
                $soc->soc_increase_instance_order($instance_id);
                set_state($soc_state,"refresh_soc",0);
                set_gui_status($soc,"refresh_soc",0);
 
 
        });
        });
 
 
 
 
        #instance name
        #instance name
Line 388... Line 398...
                }
                }
                else {
                else {
                #add instance name to soc
                #add instance name to soc
                        $soc->soc_set_instance_name($instance_id,$instance_name);
                        $soc->soc_set_instance_name($instance_id,$instance_name);
 
 
                        set_state($soc_state,"refresh_soc",25);
                        set_gui_status($soc,"refresh_soc",25);
 
 
                }
                }
        });
        });
 
 
 
 
Line 545... Line 555...
                                }
                                }
                                # "$name\:$connect\[$i]";
                                # "$name\:$connect\[$i]";
 
 
 
 
 
 
                                set_state($soc_state,"refresh_soc",0);
                                set_gui_status($soc,"refresh_soc",0);
                        },\@ll);
                        },\@ll);
 
 
 
 
        }#for $plug_num
        }#for $plug_num
 
 
Line 589... Line 599...
 
 
###############
###############
#       generate_dev_table
#       generate_dev_table
############
############
sub generate_dev_table{
sub generate_dev_table{
        my($soc,$ip,$infc,$soc_state,$info)=@_;
        my($soc,$ip,$infc,$info)=@_;
        #my $box= def_hbox (TRUE,0);
        #my $box= def_hbox (TRUE,0);
 
 
        my $table=def_table(3,25,FALSE);
        my $table=def_table(3,25,FALSE);
        my $row=0;
        my $row=0;
        my @instance_list=$soc->soc_get_instance_order();
        my @instance_list=$soc->soc_get_instance_order();
Line 601... Line 611...
                @instance_list=$soc->soc_get_all_instances();
                @instance_list=$soc->soc_get_all_instances();
        }
        }
        my $i=0;
        my $i=0;
 
 
        foreach my $instanc(@instance_list){
        foreach my $instanc(@instance_list){
                $row=gen_instance($soc,$ip,$infc,$instanc,$soc_state,$info,$table,$row);
                $row=gen_instance($soc,$ip,$infc,$instanc,$info,$table,$row);
 
 
        }
        }
        if($row<20){for ($i=$row; $i<20; $i++){
        if($row<20){for ($i=$row; $i<20; $i++){
 
 
                my $temp=gen_label_in_center(" ");
                my $temp=gen_label_in_center(" ");
Line 622... Line 632...
#  show_active_dev
#  show_active_dev
#
#
################ 
################ 
 
 
sub show_active_dev{
sub show_active_dev{
        my($soc,$ip,$infc,$soc_state,$refresh_ref,$info)=@_;
        my($soc,$ip,$infc,$refresh_ref,$info)=@_;
        my $box= def_table (1, 1, FALSE);
        my $box= def_table (1, 1, FALSE);
        my $dev_table = generate_dev_table($soc,$ip,$infc,$soc_state,$info);
        my $dev_table = generate_dev_table($soc,$ip,$infc,$info);
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
        $scrolled_win->set_policy( "automatic", "automatic" );
        $scrolled_win->set_policy( "automatic", "automatic" );
        $scrolled_win->add_with_viewport($dev_table);
        $scrolled_win->add_with_viewport($dev_table);
 
 
 
 
 
 
        $$refresh_ref-> signal_connect("clicked" => sub{
        $$refresh_ref-> signal_connect("clicked" => sub{
 
 
                $dev_table->destroy;
                $dev_table->destroy;
                select(undef, undef, undef, 0.1); #wait 10 ms
                select(undef, undef, undef, 0.1); #wait 10 ms
                $dev_table = generate_dev_table($soc,$ip,$infc,$soc_state,$info);
                $dev_table = generate_dev_table($soc,$ip,$infc,$info);
                #$box->attach_defaults ($dev_table, 0, 1, 0, 1);#( $dev_table, FALSE, FALSE, 3);
                #$box->attach_defaults ($dev_table, 0, 1, 0, 1);#( $dev_table, FALSE, FALSE, 3);
                $scrolled_win->add_with_viewport($dev_table);
                $scrolled_win->add_with_viewport($dev_table);
                $dev_table->show;
                $dev_table->show;
                $scrolled_win->show_all;
                $scrolled_win->show_all;
 
 
Line 680... Line 690...
 
 
##############
##############
#       create tree
#       create tree
##############
##############
sub create_tree {
sub create_tree {
   my ($info,$ip,$soc,$soc_state)=@_;
   my ($info,$ip,$soc)=@_;
   my $model = Gtk2::TreeStore->new ('Glib::String', 'Glib::String', 'Glib::Scalar', 'Glib::Boolean');
   my $model = Gtk2::TreeStore->new ('Glib::String', 'Glib::String', 'Glib::Scalar', 'Glib::Boolean');
   my $tree_view = Gtk2::TreeView->new;
   my $tree_view = Gtk2::TreeView->new;
   $tree_view->set_model ($model);
   $tree_view->set_model ($model);
   my $selection = $tree_view->get_selection;
   my $selection = $tree_view->get_selection;
 
 
   $selection->set_mode ('browse');
   $selection->set_mode ('browse');
   $tree_view->set_size_request (200, -1);
   #$tree_view->set_size_request (200, -1);
 
 
   #
   #
   # this code only supports 1 level of children. If we
   # this code only supports 1 level of children. If we
   # want more we probably have to use a recursing function.
   # want more we probably have to use a recursing function.
   #
   #
Line 731... Line 741...
   }
   }
 
 
   my $cell = Gtk2::CellRendererText->new;
   my $cell = Gtk2::CellRendererText->new;
   $cell->set ('style' => 'italic');
   $cell->set ('style' => 'italic');
   my $column = Gtk2::TreeViewColumn->new_with_attributes
   my $column = Gtk2::TreeViewColumn->new_with_attributes
                                        ("Double click to add the device",
                                        ("IP list",
                                        $cell,
                                        $cell,
                                        'text' => DISPLAY_COLUMN,
                                        'text' => DISPLAY_COLUMN,
                                        'style_set' => ITALIC_COLUMN);
                                        'style_set' => ITALIC_COLUMN);
 
 
  $tree_view->append_column ($column);
  $tree_view->append_column ($column);
Line 770... Line 780...
 
 
 
 
 
 
        if($module){
        if($module){
                #print "$module  is selected via row activaton!\n";
                #print "$module  is selected via row activaton!\n";
                add_module_to_soc($soc,$ip,$category,$module,\$info,$soc_state);
                add_module_to_soc($soc,$ip,$category,$module,\$info);
                set_state($soc_state,"refresh_soc",0);
                set_gui_status($soc,"refresh_soc",0);
        }
        }
 
 
 
 
 
 
 
 
Line 790... Line 800...
  my $scrolled_window = Gtk2::ScrolledWindow->new;
  my $scrolled_window = Gtk2::ScrolledWindow->new;
  $scrolled_window->set_policy ('automatic', 'automatic');
  $scrolled_window->set_policy ('automatic', 'automatic');
  $scrolled_window->set_shadow_type ('in');
  $scrolled_window->set_shadow_type ('in');
  $scrolled_window->add($tree_view);
  $scrolled_window->add($tree_view);
 
 
  my $hbox = Gtk2::HBox->new (TRUE, 0);
  my $hbox = Gtk2::HBox->new (FALSE, 0);
  $hbox->pack_start ( $scrolled_window, TRUE, TRUE, 0);
  $hbox->pack_start ( $scrolled_window, TRUE, TRUE, 0);
 
 
 
 
 
 
  return $hbox;
  return $hbox;
Line 842... Line 852...
#       generate_soc
#       generate_soc
#################
#################
 
 
sub generate_soc{
sub generate_soc{
        my ($soc,$info)=@_;
        my ($soc,$info)=@_;
        my $name=$soc->soc_get_soc_name();
        my $name=$soc->object_get_attribute('soc_name');
                if (length($name)>0){
                if (length($name)>0){
                        my @tmp=split('_',$name);
                        my @tmp=split('_',$name);
                        if ( $tmp[-1] =~ /^[0-9]+$/ ){
                        if ( $tmp[-1] =~ /^[0-9]+$/ ){
                                message_dialog("The soc name must not end with '_number'!");
                                message_dialog("The soc name must not end with '_number'!");
                                return 0;
                                return 0;
                        }
                        }
 
 
                        my $file_v=soc_generate_verilog($soc);
                        my ($file_v,$top_v,$readme)=soc_generate_verilog($soc);
 
 
                        # Write object file
                        # Write object file
                        open(FILE,  ">lib/soc/$name.SOC") || die "Can not open: $!";
                        open(FILE,  ">lib/soc/$name.SOC") || die "Can not open: $!";
 
                        print FILE perl_file_header("$name.SOC");
                        print FILE Data::Dumper->Dump([\%$soc],[$name]);
                        print FILE Data::Dumper->Dump([\%$soc],[$name]);
                        close(FILE) || die "Error closing file: $!";
                        close(FILE) || die "Error closing file: $!";
 
 
                        # Write verilog file
                        # Write verilog file
                        open(FILE,  ">lib/verilog/$name.v") || die "Can not open: $!";
                        open(FILE,  ">lib/verilog/$name.v") || die "Can not open: $!";
                        print FILE $file_v;
                        print FILE $file_v;
                        close(FILE) || die "Error closing file: $!";
                        close(FILE) || die "Error closing file: $!";
 
 
 
                        # Write Top module file
 
                        my $l=autogen_warning().get_license_header("${name}_top.v");
 
                        open(FILE,  ">lib/verilog/${name}_top.v") || die "Can not open: $!";
 
                        print FILE "$l\n$top_v";
 
                        close(FILE) || die "Error closing file: $!";
 
 
 
 
 
                        # Write readme file
 
                        open(FILE,  ">lib/verilog/README") || die "Can not open: $!";
 
                        print FILE $readme;
 
                        close(FILE) || die "Error closing file: $!";
 
 
                        # copy all files in project work directory
                        # copy all files in project work directory
                        my $dir = Cwd::getcwd();
                        my $dir = Cwd::getcwd();
                        #make target dir
                        #make target dir
                        my $project_dir   = abs_path("$dir/../../");
                        my $project_dir   = abs_path("$dir/../../");
                        my $target_dir  = "$project_dir/mpsoc_work/SOC/$name";
                        my $target_dir  = "$project_dir/mpsoc_work/SOC/$name";
                        mkpath("$target_dir/src_verilog/lib/",1,0755);
                        mkpath("$target_dir/src_verilog/lib/",1,01777);
                        mkpath("$target_dir/sw",1,0755);
                        mkpath("$target_dir/sw",1,01777);
 
 
                #copy hdl codes in src_verilog
                #copy hdl codes in src_verilog
 
 
                my ($file_ref,$warnings)= get_all_files_list($soc,"hdl_files");
                my ($file_ref,$warnings)= get_all_files_list($soc,"hdl_files");
 
 
                copy_file_and_folders($file_ref,$project_dir,"$target_dir/src_verilog/lib");
                copy_file_and_folders($file_ref,$project_dir,"$target_dir/src_verilog/lib");
 
 
                        show_info(\$info,$warnings)                     if(defined $warnings);
                        show_info(\$info,$warnings)                     if(defined $warnings);
 
 
 
 
 
                #copy jtag control files 
 
                my @jtags=(("/mpsoc/src_peripheral/jtag/jtag_wb"),("jtag"));
 
                copy_file_and_folders(\@jtags,$project_dir,"$target_dir/src_verilog/lib");
 
 
                #my @pathes=("$dir/../src_peripheral","$dir/../src_noc","$dir/../src_processor");
                #my @pathes=("$dir/../src_peripheral","$dir/../src_noc","$dir/../src_processor");
                #foreach my $p(@pathes){
                #foreach my $p(@pathes){
                #       find(
                #       find(
                #               sub {
                #               sub {
                #                       return unless ( -f $_ );
                #                       return unless ( -f $_ );
Line 894... Line 919...
                        #       );
                        #       );
                #}
                #}
 
 
 
 
                move ("$dir/lib/verilog/$name.v","$target_dir/src_verilog/");
                move ("$dir/lib/verilog/$name.v","$target_dir/src_verilog/");
 
                move ("$dir/lib/verilog/${name}_top.v","$target_dir/src_verilog/");
 
                move ("$dir/lib/verilog/README" ,"$target_dir/sw/");
 
                # Copy Software files
                # Write system.h and generated file
 
                        generate_header_file($soc,$project_dir,$target_dir,$dir);
 
 
 
 
 
                # Write Software files
 
                        ($file_ref,$warnings)= get_all_files_list($soc,"sw_files");
                        ($file_ref,$warnings)= get_all_files_list($soc,"sw_files");
                        copy_file_and_folders($file_ref,$project_dir,"$target_dir/sw");
                        copy_file_and_folders($file_ref,$project_dir,"$target_dir/sw");
 
 
                # Write Software gen files
                # Write system.h and Software gen files
                        ($file_ref,$warnings)= get_all_files_list($soc,"gen_sw_files");
                        generate_header_file($soc,$project_dir,$target_dir,$dir);
                        foreach my $f(@{$file_ref}){
 
                                #print "$f\n";
 
 
 
 
 
                        }
 
 
 
 
 
                # Write main.c file if not exist
                # Write main.c file if not exist
                my $n="$target_dir/sw/main.c";
                my $n="$target_dir/sw/main.c";
                if (!(-f "$n")) {
                if (!(-f "$n")) {
Line 950... Line 968...
// a simple delay function
// a simple delay function
void delay ( unsigned int num ){
void delay ( unsigned int num ){
 
 
        while (num>0){
        while (num>0){
                num--;
                num--;
                asm volatile (\"nop\");
                nop(); // asm volatile (\"nop\");
        }
        }
        return;
        return;
 
 
}
}
 
 
Line 1029... Line 1047...
sub wb_address_setting {
sub wb_address_setting {
        my $soc=shift;
        my $soc=shift;
 
 
 
 
        my $window = def_popwin_size(1200,500,"Wishbone slave port address setting");
        my $window = def_popwin_size(1200,500,"Wishbone slave port address setting");
        my $table = def_table(10, 6, TRUE);
        my $table = def_table(10, 6, FALSE);
 
 
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
        $scrolled_win->set_policy( "automatic", "automatic" );
        $scrolled_win->set_policy( "automatic", "automatic" );
        $scrolled_win->add_with_viewport($table);
        $scrolled_win->add_with_viewport($table);
        my $row=0;
        my $row=0;
 
 
        #title
        #title
        $table->attach_defaults(gen_label_in_left  ("Instance name"),0,1,$row,$row+1);
        $table->attach(gen_label_in_left  ("Instance name"),0,1,$row,$row+1,'expand','shrink',2,2);
        $table->attach_defaults(gen_label_in_left  ("Interface name"),1,2,$row,$row+1);
        $table->attach(gen_label_in_left  ("Interface name"),1,2,$row,$row+1,'expand','shrink',2,2);
        $table->attach_defaults(gen_label_in_left  ("Bus name"),2,3,$row,$row+1);
        $table->attach(gen_label_in_left  ("Bus name"),2,3,$row,$row+1,'expand','shrink',2,2);
        $table->attach_defaults(gen_label_in_center("Base address"),3,4,$row,$row+1);
        $table->attach(gen_label_in_center("Base address"),3,4,$row,$row+1,'expand','shrink',2,2);
        $table->attach_defaults(gen_label_in_center("End address"),4,5,$row,$row+1);
        $table->attach(gen_label_in_center("End address"),4,5,$row,$row+1,'expand','shrink',2,2);
        $table->attach_defaults(gen_label_in_center("Size (Bytes)"),5,6,$row,$row+1);
        $table->attach(gen_label_in_center("Size (Bytes)"),5,6,$row,$row+1,'expand','shrink',2,2);
 
 
        my (@newbase,@newend,@connects);
        my (@newbase,@newend,@connects);
 
 
        $row++;
        $row++;
        my @all_instances=$soc->soc_get_all_instances();
        my @all_instances=$soc->soc_get_all_instances();
Line 1092... Line 1110...
 
 
                                        my ($box,$valid) =addr_box_gen(sprintf("0x%08x", $base), sprintf("0x%08x", $end),\@newbase,\@newend,\@connects,$number);
                                        my ($box,$valid) =addr_box_gen(sprintf("0x%08x", $base), sprintf("0x%08x", $end),\@newbase,\@newend,\@connects,$number);
                                        $status_all[$number]=$valid;
                                        $status_all[$number]=$valid;
 
 
 
 
                                        $table->attach_defaults($label1,0,1,$row,$row+1);
                                        $table->attach($label1,0,1,$row,$row+1,'expand','shrink',2,2);
                                        $table->attach_defaults($plug_name,1,2,$row,$row+1);
                                        $table->attach($plug_name,1,2,$row,$row+1,'expand','shrink',2,2);
                                        $table->attach_defaults($label2,2,3,$row,$row+1);
                                        $table->attach($label2,2,3,$row,$row+1,'expand','shrink',2,2);
                                        $table->attach_defaults($entry1,3,4,$row,$row+1);
                                        $table->attach($entry1,3,4,$row,$row+1,'expand','shrink',2,2);
                                        $table->attach_defaults($entry2,4,5,$row,$row+1);
                                        $table->attach($entry2,4,5,$row,$row+1,'expand','shrink',2,2);
 
 
 
 
                                        $table->attach_defaults($box,5,7,$row,$row+1);
                                        $table->attach($box,5,7,$row,$row+1,'expand','shrink',2,2);
 
 
 
 
                                        $entry1->signal_connect('changed'=>sub{
                                        $entry1->signal_connect('changed'=>sub{
                                                my $base_in=$entry1->get_text();
                                                my $base_in=$entry1->get_text();
                                                if (length($base_in)<2){ $entry1->set_text('0x')};
                                                if (length($base_in)<2){ $entry1->set_text('0x')};
                                                my $end_in=$entry2->get_text();
                                                my $end_in=$entry2->get_text();
                                                my $valid;
                                                my $valid;
                                                $box->destroy;
                                                $box->destroy;
                                                ($box,$valid)=addr_box_gen($base_in, $end_in,\@newbase,\@newend,\@connects,$number);
                                                ($box,$valid)=addr_box_gen($base_in, $end_in,\@newbase,\@newend,\@connects,$number);
                                                $status_all[$number]=$valid;
                                                $status_all[$number]=$valid;
                                                $table->attach_defaults($box,5,7,$number+1,$number+2);
                                                $table->attach($box,5,7,$number+1,$number+2,'expand','shrink',2,2);
                                                $table->show_all;
                                                $table->show_all;
 
 
 
 
                                        } );
                                        } );
                                        $entry2->signal_connect('changed'=>sub{
                                        $entry2->signal_connect('changed'=>sub{
Line 1123... Line 1141...
                                                if (length($end_in)<2){ $entry2->set_text('0x')};
                                                if (length($end_in)<2){ $entry2->set_text('0x')};
                                                my $valid;
                                                my $valid;
                                                $box->destroy;
                                                $box->destroy;
                                                ($box,$valid)=addr_box_gen($base_in, $end_in,\@newbase,\@newend,\@connects,$number);
                                                ($box,$valid)=addr_box_gen($base_in, $end_in,\@newbase,\@newend,\@connects,$number);
                                                $status_all[$number]=$valid;
                                                $status_all[$number]=$valid;
                                                $table->attach_defaults($box,5,7,$number+1,$number+2);
                                                $table->attach($box,5,7,$number+1,$number+2,'expand','shrink',2,2);
                                                $table->show_all;
                                                $table->show_all;
                                        } );
                                        } );
 
 
 
 
 
 
Line 1139... Line 1157...
                }#foreach my $plug
                }#foreach my $plug
        }#foreach my $instance_id
        }#foreach my $instance_id
 
 
 
 
        my $ok = def_image_button('icons/select.png','OK');
        my $ok = def_image_button('icons/select.png','OK');
        my $okbox=def_hbox(TRUE,0);
 
        $okbox->pack_start($ok, FALSE, FALSE,0);
 
 
 
        my $refresh = def_image_button('icons/revert.png','Revert');
        my $refresh = def_image_button('icons/revert.png','Revert');
        my $refbox=def_hbox(TRUE,0);
        my $refbox=def_hbox(TRUE,0);
        $refbox->pack_start($refresh, FALSE, FALSE,0);
        $refbox->pack_start($refresh, FALSE, FALSE,0);
 
 
Line 1193... Line 1211...
 
 
                });
                });
 
 
 
 
 
 
        $row= ($row<9)? 9:$row;
 
        $table->attach_defaults($refbox,2,3,$row,$row+1);
        $table->attach ($refbox,2,3,$row,$row+1,'expand','shrink',2,2);
        $table->attach_defaults($okbox,3,4,$row,$row+1);
        $table->attach ($ok,3,4,$row,$row+1,'expand','shrink',2,2);
 
 
        $window->add($scrolled_win);
        $window->add($scrolled_win);
        $window->show_all;
        $window->show_all;
 
 
 
 
Line 1329... Line 1347...
#############
#############
#       load_soc
#       load_soc
#############
#############
 
 
sub load_soc{
sub load_soc{
        my ($soc,$soc_state)=@_;
        my ($soc,$info)=@_;
        my $file;
        my $file;
        my $dialog = Gtk2::FileChooserDialog->new(
        my $dialog = Gtk2::FileChooserDialog->new(
                'Select a File', undef,
                'Select a File', undef,
                'open',
                'open',
                'gtk-cancel' => 'cancel',
                'gtk-cancel' => 'cancel',
Line 1351... Line 1369...
        if ( "ok" eq $dialog->run ) {
        if ( "ok" eq $dialog->run ) {
                $file = $dialog->get_filename;
                $file = $dialog->get_filename;
                my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
                my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
                if($suffix eq '.SOC'){
                if($suffix eq '.SOC'){
                        my $pp= eval { do $file };
                        my $pp= eval { do $file };
 
                        if ($@ || !defined $pp){
 
                                show_info(\$info,"**Error reading  $file file: $@\n");
 
                                 $dialog->destroy;
 
                                return;
 
                        }
                        clone_obj($soc,$pp);
                        clone_obj($soc,$pp);
                        set_state($soc_state,"load_file",0);
                        set_gui_status($soc,"load_file",0);
                }
                }
     }
     }
     $dialog->destroy;
     $dialog->destroy;
 
 
 
 
Line 1392... Line 1415...
sub socgen_main{
sub socgen_main{
 
 
        my $infc = interface->interface_new();
        my $infc = interface->interface_new();
        my $ip = ip->lib_new ();
        my $ip = ip->lib_new ();
        my $soc = soc->soc_new();
        my $soc = soc->soc_new();
 
        set_gui_status($soc,"ideal",0);
        #my $soc= eval { do 'lib/soc/soc.SOC' };
        #my $soc= eval { do 'lib/soc/soc.SOC' };
 
 
        my $soc_state=  def_state("ideal");
 
        # main window
        # main window
        #my $window = def_win_size(1000,800,"Top");
        #my $window = def_win_size(1000,800,"Top");
        #  The main table containg the lib tree, selected modules and info section 
        #  The main table containg the lib tree, selected modules and info section 
        my $main_table = Gtk2::Table->new (20, 12, FALSE);
        my $main_table = Gtk2::Table->new (20, 12, FALSE);
 
 
Line 1407... Line 1431...
 
 
 
 
        my $refresh_dev_win = Gtk2::Button->new_from_stock('ref');
        my $refresh_dev_win = Gtk2::Button->new_from_stock('ref');
 
 
        # A tree view for holding a library
        # A tree view for holding a library
        my $tree_box = create_tree ($info,$ip,$soc,$soc_state);
        my $tree_box = create_tree ($info,$ip,$soc);
 
 
 
 
 
 
        $main_table->set_row_spacings (4);
        $main_table->set_row_spacings (4);
        $main_table->set_col_spacings (1);
        $main_table->set_col_spacings (1);
 
 
        my  $device_win=show_active_dev($soc,$ip,$infc,$soc_state,\$refresh_dev_win,$info);
        my  $device_win=show_active_dev($soc,$ip,$infc,\$refresh_dev_win,$info);
 
 
 
 
        my $generate = def_image_button('icons/gen.png','Generate');
        my $generate = def_image_button('icons/gen.png','Generate');
        my $genbox=def_hbox(TRUE,0);
 
        $genbox->pack_start($generate,   FALSE, FALSE,0);
 
 
 
 
 
 
 
 
 
 
 
        my $wb = def_image_button('icons/setting.png','Wishbone address setting');
        my $wb = def_image_button('icons/setting.png','Wishbone address setting');
        my $wbbox=def_hbox(TRUE,0);
 
        $wbbox->pack_start($wb,   FALSE, FALSE,0);
 
 
 
        my $open = def_image_button('icons/browse.png','Load Tile');
        my $open = def_image_button('icons/browse.png','Load Tile');
        my $openbox=def_hbox(TRUE,0);
 
        $openbox->pack_start($open,   FALSE, FALSE,0);
 
 
 
 
 
 
        my $entry=gen_entry_object($soc,'soc_name',undef,undef,undef,undef);
 
        my $entrybox=labele_widget_info(" Tile name:",$entry);
 
 
        my ($entrybox,$entry) = def_h_labeled_entry('Tile name:');
 
        $entry->signal_connect( 'changed'=> sub{
 
                my $name=$entry->get_text();
 
                $soc->soc_set_soc_name($name);
 
        });
 
 
 
        #$table->attach_defaults ($event_box, $col, $col+1, $row, $row+1);
        #$table->attach_defaults ($event_box, $col, $col+1, $row, $row+1);
        $main_table->attach_defaults ($tree_box , 0, 2, 0, 17);
        $main_table->attach_defaults ($tree_box , 0, 2, 0, 17);
        $main_table->attach_defaults ($device_win , 2, 12, 0, 17);
        $main_table->attach_defaults ($device_win , 2, 12, 0, 17);
        $main_table->attach_defaults ($infobox  , 0, 12, 17,19);
        $main_table->attach_defaults ($infobox  , 0, 12, 17,19);
        $main_table->attach_defaults ($openbox,0, 3, 19,20);
        $main_table->attach ($open,0, 3, 19,20,'expand','shrink',2,2);
        $main_table->attach_defaults ($entrybox,3, 7, 19,20);
        $main_table->attach_defaults ($entrybox,3, 7, 19,20);
        $main_table->attach_defaults ($wbbox, 7, 10, 19,20);
        $main_table->attach ($wb, 7, 10, 19,20,'expand','shrink',2,2);
        $main_table->attach_defaults ($genbox, 10, 12, 19,20);
        $main_table->attach ($generate, 10, 12, 19,20,'expand','shrink',2,2);
 
 
 
 
        #check soc status every 0.5 second. referesh device table if there is any changes 
        #check soc status every 0.5 second. referesh device table if there is any changes 
        Glib::Timeout->add (100, sub{
        Glib::Timeout->add (100, sub{
 
                my ($state,$timeout)= get_gui_status($soc);
                my ($state,$timeout)= get_state($soc_state);
 
 
 
                if ($timeout>0){
                if ($timeout>0){
                        $timeout--;
                        $timeout--;
                        set_state($soc_state,$state,$timeout);
                        set_gui_status($soc,$state,$timeout);
 
 
                }
                }
                elsif( $state ne "ideal" ){
                elsif( $state ne "ideal" ){
                        $refresh_dev_win->clicked;
                        $refresh_dev_win->clicked;
                        my $saved_name=$soc->soc_get_soc_name();
                        my $saved_name=$soc->object_get_attribute('soc_name',undef);
                        if(defined $saved_name) {$entry->set_text($saved_name);}
                        if(defined $saved_name) {$entry->set_text($saved_name);}
                        set_state($soc_state,"ideal",0);
                        set_gui_status($soc,"ideal",0);
 
 
                }
                }
                return TRUE;
                return TRUE;
 
 
        } );
        } );
 
 
Line 1484... Line 1501...
                wb_address_setting($soc);
                wb_address_setting($soc);
 
 
        });
        });
 
 
        $open-> signal_connect("clicked" => sub{
        $open-> signal_connect("clicked" => sub{
                load_soc($soc,$soc_state);
                load_soc($soc,$info);
 
 
        });
        });
 
 
        my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
        my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
                $sc_win->set_policy( "automatic", "automatic" );
                $sc_win->set_policy( "automatic", "automatic" );

powered by: WebSVN 2.1.0

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