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

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk/mpsoc/perl_gui/lib/perl
    from Rev 42 to Rev 43
    Reverse comparison

Rev 42 → Rev 43

/ColorButton.pm
0,0 → 1,103
#!/usr/bin/perl -w
 
use strict;
 
package ColorButton;
 
use Gtk2;
use Glib::Object::Subclass
Gtk2::Button::,
signals => {
color_changed => {},
show => \&on_show,
},
properties => [
Glib::ParamSpec->int (
'red',
'Red',
'The Red component of the RGB color',
0,
0xffff,
0xffff,
[qw/readable writable/]
),
Glib::ParamSpec->int (
'green',
'Green',
'The Green component of the RGB color',
0,
0xffff,
0xffff,
[qw/readable writable/]
),
Glib::ParamSpec->int (
'blue',
'Blue',
'The Blue component of the RGB color',
0,
0xffff,
0xffff,
[qw/readable writable/]
),
Glib::ParamSpec->string (
'label',
'Label',
'The lable of button',
"BBB",
[qw/readable writable/]
),
 
]
;
 
sub INIT_INSTANCE {
my $self = shift;
$self->{red} = 0xffff;
$self->{green} = 0xffff;
$self->{blue} = 0xffff;
$self->{label} = "Colored_button";
 
my $frame = Gtk2::Frame->new;
$frame->set_border_width (3);
$frame->set_shadow_type ('etched-in');
$self->add ($frame);
$frame->show;
my $event_box = Gtk2::EventBox->new;
$event_box->set_size_request (14, 14);
my $lable = Gtk2::Label->new($self->{label});
$event_box->add($lable);
$frame->add ($event_box);
$event_box->show;
$self->{colorbox} = $event_box;
$self->{labelbox} = $lable;
}
 
sub on_show {
my $self = shift;
$self->set_color (red => $self->{red},
green => $self->{green},
blue => $self->{blue});
$self->{labelbox}->set_label ($self->{label});
 
$self->signal_chain_from_overridden;
}
 
sub set_color {
my $self = shift;
my %params = @_;
my $color = Gtk2::Gdk::Color->new ($params{red},
$params{green},
$params{blue});
$self->{colorbox}->get_colormap->alloc_color ($color, 0, 1);
$self->{colorbox}->modify_bg ('normal', $color);
# $self->{colorbox}->modify_bg ('active', $color);
# $self->{colorbox}->modify_bg ('prelight', $color);
$self->{red} = $params{red};
$self->{green} = $params{green};
$self->{blue} = $params{blue};
$self->signal_emit ('color-changed');
}
1
ColorButton.pm Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: common.pl =================================================================== --- common.pl (nonexistent) +++ common.pl (revision 43) @@ -0,0 +1,624 @@ +use strict; +use warnings; + +use String::Similarity; + + +sub find_the_most_similar_position{ + my ($item ,@list)=@_; + my $most_similar_pos=0; + my $lastsim=0; + my $i=0; + # convert item to lowercase + $item = lc $item; + foreach my $p(@list){ + my $similarity= similarity $item, $p; + if ($similarity > $lastsim){ + $lastsim=$similarity; + $most_similar_pos=$i; + } + $i++; + } + return $most_similar_pos; +} + + + +#################### +# file +################## + + +sub read_verilog_file{ + my @files = @_; + my %cmd_line_defines = (); + my $quiet = 1; + my @inc_dirs = (); + my @lib_dirs = (); + my @lib_exts = (); + my $vdb = rvp->read_verilog(\@files,[],\%cmd_line_defines, + $quiet,\@inc_dirs,\@lib_dirs,\@lib_exts); + + my @problems = $vdb->get_problems(); + if (@problems) { + foreach my $problem ($vdb->get_problems()) { + print STDERR "$problem.\n"; + } + # die "Warnings parsing files!"; + } + + return $vdb; +} + + + + +sub append_text_to_file { + my ($file_path,$text)=@_; + open(my $fd, ">>$file_path") or die "could not open $file_path: $!"; + print $fd $text; + close $fd; +} + + + + +sub save_file { + my ($file_path,$text)=@_; + open my $fd, ">$file_path" or die "could not open $file_path: $!"; + print $fd $text; + close $fd; +} + +sub load_file { + my $file_path=shift; + my $str; + if (-f "$file_path") { + + $str = do { + local $/ = undef; + open my $fh, "<", $file_path + or die "could not open $file_path: $!"; + <$fh>; + }; + + } + return $str; +} + +sub merg_files { + my ($source_file_path,$dest_file_path)=@_; + local $/=undef; + open FILE, $source_file_path or die "Couldn't open file: $!"; + my $string = ; + close FILE; + append_text_to_file ($dest_file_path,$string); +} + + + +sub copy_file_and_folders{ + my ($file_ref,$project_dir,$target_dir)=@_; + + foreach my $f(@{$file_ref}){ + my $name= basename($f); + + my $n="$project_dir$f"; + if (-f "$n") { #copy file + copy ("$n","$target_dir/$name"); + }elsif(-f "$f" ){ + copy ("$f","$target_dir/$name"); + }elsif (-d "$n") {#copy folder + dircopy ("$n","$target_dir/$name"); + }elsif(-d "$f" ){ + dircopy ("$f","$target_dir/$name"); + + } + } + +} + + +sub remove_file_and_folders{ + my ($file_ref,$project_dir)=@_; + + foreach my $f(@{$file_ref}){ + my $name= basename($f); + my $n="$project_dir$f"; + if (-f "$n") { #copy file + unlink ("$n"); + }elsif(-f "$f" ){ + unlink ("$f"); + }elsif (-d "$n") {#copy folder + rmtree ("$n"); + }elsif(-d "$f" ){ + rmtree ("$f"); + } + } + +} + +sub read_file_cntent { + my ($f,$project_dir)=@_; + my $n="$project_dir$f"; + my $str; + if (-f "$n") { + + $str = do { + local $/ = undef; + open my $fh, "<", $n + or die "could not open $n: $!"; + <$fh>; + }; + + }elsif(-f "$f" ){ + $str = do { + local $/ = undef; + open my $fh, "<", $f + or die "could not open $f: $!"; + <$fh>; + }; + + + } + return $str; + +} + + +sub check_file_has_string { + my ($file,$string)=@_; + my $r; + open(FILE,$file); + if (grep{/$string/} ){ + $r= 1; #print "word found\n"; + }else{ + $r= 0; #print "word not found\n"; + } + close FILE; + return $r; +} + +############## +# clone_obj +############# + +sub clone_obj{ + my ($self,$clone)=@_; + + foreach my $p (keys %$self){ + delete ($self->{$p}); + } + foreach my $p (keys %$clone){ + $self->{$p}= $clone->{$p}; + my $ref= ref ($clone->{$p}); + if( $ref eq 'HASH' ){ + + foreach my $q (keys %{$clone->{$p}}){ + $self->{$p}{$q}= $clone->{$p}{$q}; + my $ref= ref ($self->{$p}{$q}); + if( $ref eq 'HASH' ){ + + foreach my $z (keys %{$clone->{$p}{$q}}){ + $self->{$p}{$q}{$z}= $clone->{$p}{$q}{$z}; + my $ref= ref ($self->{$p}{$q}{$z}); + if( $ref eq 'HASH' ){ + + foreach my $w (keys %{$clone->{$p}{$q}{$z}}){ + $self->{$p}{$q}{$z}{$w}= $clone->{$p}{$q}{$z}{$w}; + my $ref= ref ($self->{$p}{$q}{$z}{$w}); + if( $ref eq 'HASH' ){ + + + foreach my $m (keys %{$clone->{$p}{$q}{$z}{$w}}){ + $self->{$p}{$q}{$z}{$w}{$m}= $clone->{$p}{$q}{$z}{$w}{$m}; + my $ref= ref ($self->{$p}{$q}{$z}{$w}{$m}); + if( $ref eq 'HASH' ){ + + foreach my $n (keys %{$clone->{$p}{$q}{$z}{$w}{$m}}){ + $self->{$p}{$q}{$z}{$w}{$m}{$n}= $clone->{$p}{$q}{$z}{$w}{$m}{$n}; + my $ref= ref ($self->{$p}{$q}{$z}{$w}{$m}{$n}); + if( $ref eq 'HASH' ){ + + foreach my $l (keys %{$clone->{$p}{$q}{$z}{$w}{$m}{$n}}){ + $self->{$p}{$q}{$z}{$w}{$m}{$n}{$l}= $clone->{$p}{$q}{$z}{$w}{$m}{$n}{$l}; + my $ref= ref ($self->{$p}{$q}{$z}{$w}{$m}{$n}{$l}); + if( $ref eq 'HASH' ){ + } + } + + }#if + }#n + }#if + }#m + }#if + }#w + }#if + }#z + }#if + }#q + }#if + }#p +}#sub + + +sub get_project_dir{ #mpsoc directory address + my $dir = Cwd::getcwd(); + my $project_dir = abs_path("$dir/../../"); + return $project_dir; +} + + +sub remove_project_dir_from_addr{ + my $file=shift; + my $project_dir = get_project_dir(); + $file =~ s/$project_dir//; + return $file; +} + +sub add_project_dir_to_addr{ + my $file=shift; + my $project_dir = get_project_dir(); + return $file if(-f $file ); + return "$project_dir/$file"; + +} + +sub get_full_path_addr{ + my $file=shift; + my $dir = Cwd::getcwd(); + my $full_path = "$dir/$file"; + return $full_path if -f ($full_path ); + return $file; +} + +sub regen_object { + my $path=shift; + $path = get_full_path_addr($path); + my $pp= eval { do $path }; + my $r= ($@ || !defined $pp); + return ($pp,$r,$@); +} + + +################ +# general +################# + + + + +sub trim { my $s = shift; $s=~s/[\n]//gs; return $s }; + +sub remove_all_white_spaces($) +{ + my $string = shift; + $string =~ s/\s+//g; + return $string; +} + + + + +sub get_scolar_pos{ + my ($item,@list)=@_; + my $pos; + my $i=0; + foreach my $c (@list) + { + if( $c eq $item) {$pos=$i} + $i++; + } + return $pos; +} + +sub remove_scolar_from_array{ + my ($array_ref,$item)=@_; + my @array=@{$array_ref}; + my @new; + foreach my $p (@array){ + if($p ne $item ){ + push(@new,$p); + } + } + return @new; +} + +sub replace_in_array{ + my ($array_ref,$item1,$item2)=@_; + my @array=@{$array_ref}; + my @new; + foreach my $p (@array){ + if($p eq $item1 ){ + push(@new,$item2); + }else{ + push(@new,$p); + } + } + return @new; +} + + + +# return an array of common elemnts between two input arays +sub get_common_array{ + my ($a_ref,$b_ref)=@_; + my @A=@{$a_ref}; + my @B=@{$b_ref}; + my @C; + foreach my $p (@A){ + if( grep (/^\Q$p\E$/,@B)){push(@C,$p)}; + } + return @C; +} + +#a-b +sub get_diff_array{ + my ($a_ref,$b_ref)=@_; + my @A=@{$a_ref}; + my @B=@{$b_ref}; + my @C; + foreach my $p (@A){ + if( !grep (/^\Q$p\E$/,@B)){push(@C,$p)}; + } + return @C; + +} + + + +sub compress_nums{ + my @nums=@_; + my @f=sort { $a <=> $b } @nums; + my $s; + my $ls; + my $range=0; + my $x; + + + foreach my $p (@f){ + if(!defined $x) { + $s="$p"; + $ls=$p; + + } + else{ + if($p-$x>1){ #gap exist + if( $range){ + $s=($x-$ls>1 )? "$s:$x,$p": "$s,$x,$p"; + $ls=$p; + $range=0; + }else{ + $s= "$s,$p"; + $ls=$p; + + } + + }else {$range=1;} + + + + } + + $x=$p + } + if($range==1){ $s= ($x-$ls>1 )? "$s:$x": "$s,$x";} + #update $s($ls,$hs); + + return $s; + +} + + + +sub metric_conversion{ + my $size=shift; + my $size_text= $size==0 ? 'Error': + $size<(1 << 10)? $size: + $size<(1 << 20)? join (' ', ($size>>10,"K")) : + $size<(1 << 30)? join (' ', ($size>>20,"M")) : + join (' ', ($size>>30,"G")) ; +return $size_text; +} + + + + + +###### +# state +##### +sub set_gui_status{ + my ($object,$status,$timeout)=@_; + $object->object_add_attribute('gui_status','status',$status); + $object->object_add_attribute('gui_status','timeout',$timeout); +} + + +sub get_gui_status{ + my ($object)=@_; + my $status= $object->object_get_attribute('gui_status','status'); + my $timeout=$object->object_get_attribute('gui_status','timeout'); + return ($status,$timeout); +} + + + + +########### +# color +######### + + + +sub get_color { + my $num=shift; + + my @colors=( + 0x6495ED,#Cornflower Blue + 0xFAEBD7,#Antiquewhite + 0xC71585,#Violet Red + 0xC0C0C0,#silver + 0xADD8E6,#Lightblue + 0x6A5ACD,#Slate Blue + 0x00CED1,#Dark Turquoise + 0x008080,#Teal + 0x2E8B57,#SeaGreen + 0xFFB6C1,#Light Pink + 0x008000,#Green + 0xFF0000,#red + 0x808080,#Gray + 0x808000,#Olive + 0xFF69B4,#Hot Pink + 0xFFD700,#Gold + 0xDAA520,#Goldenrod + 0xFFA500,#Orange + 0x32CD32,#LimeGreen + 0x0000FF,#Blue + 0xFF8C00,#DarkOrange + 0xA0522D,#Sienna + 0xFF6347,#Tomato + 0x0000CD,#Medium Blue + 0xFF4500,#OrangeRed + 0xDC143C,#Crimson + 0x9932CC,#Dark Orchid + 0x800000,#marron + 0x800080,#Purple + 0x4B0082,#Indigo + 0xFFFFFF,#white + 0x000000 #Black + ); + + my $color= ($num< scalar (@colors))? $colors[$num]: 0xFFFFFF; + my $red= ($color & 0xFF0000) >> 8; + my $green= ($color & 0x00FF00); + my $blue= ($color & 0x0000FF) << 8; + + return ($red,$green,$blue); + +} + + +sub get_color_hex_string { + my $num=shift; + + my @colors=( + "6495ED",#Cornflower Blue + "FAEBD7",#Antiquewhite + "C71585",#Violet Red + "C0C0C0",#silver + "ADD8E6",#Lightblue + "6A5ACD",#Slate Blue + "00CED1",#Dark Turquoise + "008080",#Teal + "2E8B57",#SeaGreen + "FFB6C1",#Light Pink + "008000",#Green + "FF0000",#red + "808080",#Gray + "808000",#Olive + "FF69B4",#Hot Pink + "FFD700",#Gold + "DAA520",#Goldenrod + "FFA500",#Orange + "32CD32",#LimeGreen + "0000FF",#Blue + "FF8C00",#DarkOrange + "A0522D",#Sienna + "FF6347",#Tomato + "0000CD",#Medium Blue + "FF4500",#OrangeRed + "DC143C",#Crimson + "9932CC",#Dark Orchid + "800000",#marron + "800080",#Purple + "4B0082",#Indigo + "FFFFFF",#white + "000000" #Black + ); + + my $color= ($num< scalar (@colors))? $colors[$num]: "FFFFFF"; + return $color; + +} + + + + + +sub check_verilog_identifier_syntax { + my $in=shift; + my $error=0; + my $message=''; +# an Identifiers must begin with an alphabetic character or the underscore character + if ($in =~ /^[0-9\$]/){ + return 'an Identifier must begin with an alphabetic character or the underscore character'; + } + + +# Identifiers may contain alphabetic characters, numeric characters, the underscore, and the dollar sign (a-z A-Z 0-9 _ $ ) + if ($in =~ /[^a-zA-Z0-9_\$]+/){ + print "use of illegal character after\n" ; + my @w= split /([^a-zA-Z0-9_\$]+)/, $in; + return "Contain illegal character of \"$w[1]\". Identifiers may contain alphabetic characters, numeric characters, the underscore, and the dollar sign (a-z A-Z 0-9 _ \$ )\n"; + + } + + +# check Verilog reserved words + my @keys = ("always","and","assign","automatic","begin","buf","bufif0","bufif1","case","casex","casez","cell","cmos","config","deassign","default","defparam","design","disable","edge","else","end","endcase","endconfig","endfunction","endgenerate","endmodule","endprimitive","endspecify","endtable","endtask","event","for","force","forever","fork","function","generate","genvar","highz0","highz1","if","ifnone","incdir","include","initial","inout","input","instance","integer","join","large","liblist","library","localparam","macromodule","medium","module","nand","negedge","nmos","nor","noshowcancelled","not","notif0","notif1","or","output","parameter","pmos","posedge","primitive","pull0","pull1","pulldown","pullup","pulsestyle_onevent","pulsestyle_ondetect","remos","real","realtime","reg","release","repeat","rnmos","rpmos","rtran","rtranif0","rtranif1","scalared","showcancelled","signed","small","specify","specparam","strong0","strong1","supply0","supply1","table","task","time","tran","tranif0","tranif1","tri","tri0","tri1","triand","trior","trireg","unsigned","use","vectored","wait","wand","weak0","weak1","while","wire","wor","xnor","xor"); + if( grep (/^$in$/,@keys)){ + return "$in is a Verlig reserved word."; + } + return undef; + +} + + +sub capture_number_after { + my ($after,$text)=@_; + my @q =split (/$after/,$text); + #my $d=$q[1]; + my @d = split (/[^0-9. ]/,$q[1]); + return $d[0]; + +} + +sub capture_string_between { + my ($start,$text,$end)=@_; + my @q =split (/$start/,$text); + my @d = split (/$end/,$q[1]); + return $d[0]; +} + + +sub make_undef_as_string { + foreach my $p (@_){ + $$p= 'undef' if (! defined $$p); + + } +} + +sub powi{ # x^y + my ($x,$y)=@_; # compute x to the y + my $r=1; + for (my $i = 0; $i < $y; ++$i ) { + $r *= $x; + } + return $r; +} + +sub sum_powi{ # x^(y-1) + x^(y-2) + ...+ 1; + my ($x,$y)=@_; # compute x to the y + my $r = 0; + for (my $i = 0; $i < $y; $i++){ + $r += powi( $x, $i ); + } + return $r; +} + + + + +1 +
common.pl Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: compile.pl =================================================================== --- compile.pl (revision 42) +++ compile.pl (revision 43) @@ -2,11 +2,13 @@ use Glib qw/TRUE FALSE/; use strict; use warnings; + +use FindBin; +use lib $FindBin::Bin; + use soc; -#use ip; -#use interface; -#use POSIX 'strtol'; + use File::Path; use File::Find::Rule; use File::Copy; @@ -15,7 +17,6 @@ use Verilog::EditFiles; use Gtk2; -#use Gtk2::Pango; use List::MoreUtils qw( minmax ); @@ -201,12 +202,6 @@ - - - - - - sub select_compiler { my ($self,$name,$top,$target_dir,$end_func)=@_; my $window = def_popwin_size(40,40,"Step 1: Select Compiler",'percent'); @@ -401,7 +396,7 @@ my $widgets= add_new_fpga_board_widgets($self,$name,$top,$target_dir,$end_func); my ($Twin,$tview)=create_text(); - add_colors_to_textview($tview); + my $v1=gen_vpaned($widgets,0.3,$Twin); @@ -541,8 +536,6 @@ }); - - $window->add ($mtable); $window->show_all(); @@ -551,12 +544,6 @@ - - - - - - sub add_new_fpga_board_widgets{ my ($self,$name,$top,$target_dir,$end_func)=@_; my $table = def_table(2, 2, FALSE); @@ -758,27 +745,21 @@ $mtable->attach_defaults($scrolled_win,0,10,0,9); $mtable->attach($back,2,3,9,10,'shrink','shrink',2,2); $mtable->attach($next,8,9,9,10,'shrink','shrink',2,2); - - - - my $board_name=$self->object_get_attribute('compile','board'); #copy board jtag_intfc.sh file my ($fname,$fpath,$fsuffix) = fileparse("$top",qr"\..[^.]*$"); copy("../boards/$board_name/jtag_intfc.sh","${fpath}../sw/jtag_intfc.sh"); - my $n= $self->object_get_attribute('soc_name',undef); - if(!defined $n){ # we are compiling a complete NoC-based mpsoc - my $nx= $self->object_get_attribute('noc_param',"NX"); - my $ny= $self->object_get_attribute('noc_param',"NY"); - for (my $y=0;$y<$ny;$y++){for (my $x=0; $x<$nx;$x++){ - my $tile_num= $y*$nx+$x; - #print "$tile_num\n"; + my $m= $self->object_get_attribute('mpsoc_name',undef); + if(defined $m){ # we are compiling a complete NoC-based mpsoc + my ($nr,$ne,$router_p,$ref_tops)= get_noc_verilator_top_modules_info($self); + for (my $tile_num=0;$tile_num<$ne;$tile_num++){ + #print "$tile_num\n"; my ($soc_name,$num)= $self->mpsoc_get_tile_soc_name($tile_num); next if(!defined $soc_name); copy("../boards/$board_name/jtag_intfc.sh","${fpath}../sw/tile$tile_num/jtag_intfc.sh"); - }} + } } @@ -878,10 +859,8 @@ $box=get_range ($board,$self,$type,$text,$portrange,$p); $table->attach($box, 5,6, $loc, $loc+1,'fill','shrink',2,2); } + - - - $combo->signal_connect("changed" => sub{ #get and saved new value @@ -902,12 +881,6 @@ $table->attach($combo, 4,5, $row, $row+1,'fill','shrink',2,2); - - - - - - $row++; } @@ -951,7 +924,7 @@ my ($app,$table,$tview,$window) = software_main($fpath,'Top.v'); $table->attach($back,1,2,1,2,'shrink','shrink',2,2); $table->attach($regen,4,5,1,2,'shrink','shrink',2,2); - $table->attach ($run,7, 8, 1,2,'shrink','shrink',2,2); + $table->attach ($run,6, 7, 1,2,'shrink','shrink',2,2); $table->attach($prog,9,10,1,2,'shrink','shrink',2,2); @@ -982,7 +955,11 @@ #compile - $run-> signal_connect("clicked" => sub{ + $run-> signal_connect("clicked" => sub{ + my $load= show_gif("icons/load.gif"); + $table->attach ($load,8, 9, 1,2,'shrink','shrink',2,2); + $load->show_all; + set_gui_status($self,'save_project',1); $app->do_save(); my $error = 0; @@ -1065,6 +1042,7 @@ message_dialog("Error in Quartus compilation!",'error'); } } + $load->destroy; }); @@ -1105,8 +1083,7 @@ } } - }); - + }); } @@ -1124,7 +1101,7 @@ my $back=def_image_button('icons/left.png','Previous'); my $regen=def_image_button('icons/refresh.png','Regenerate testbench.v'); #create testbench.v - gen_modelsim_soc_testbench ($self,$name,$top,$target_dir) if ((-f "$target_dir/src_verilog/testbench.v")==0); + gen_modelsim_soc_testbench ($self,$name,$top,$target_dir) unless (-f "$target_dir/src_verilog/testbench.v"); @@ -1150,11 +1127,6 @@ }); - - - - - $back-> signal_connect("clicked" => sub{ $window->destroy; @@ -1242,13 +1214,17 @@ rmtree("$verilator/processed_rtl"); mkpath("$verilator/rtl_work/",1,01777); mkpath("$verilator/processed_rtl/",1,01777); - + my @ff = ("$target_dir/src_verilog"); + push (@ff,"$target_dir/src_verilator") if (-d "$target_dir/src_verilator"); + + + #copy all verilog files in rtl_work folder add_info(\$outtext,"Copy all verilog files in rtl_work folder\n"); my @files = File::Find::Rule->file() ->name( '*.v','*.V','*.sv','*.vh') - ->in( "$target_dir/src_verilog","$target_dir/src_verilator" ); + ->in( @ff ); foreach my $file (@files) { copy($file,"$verilator/rtl_work/"); } @@ -1255,7 +1231,7 @@ @files = File::Find::Rule->file() ->name( '*.sv','*.vh' ) - ->in( "$target_dir/src_verilog","$target_dir/src_verilator" ); + ->in( @ff ); foreach my $file (@files) { copy($file,"$verilator/processed_rtl"); } @@ -1359,13 +1335,8 @@ rm *.o *.a testbench "; - - save_file ($target_dir,$make); - - - } @@ -1375,14 +1346,16 @@ my $window = def_popwin_size(80,80,"Step 2: Compile",'percent'); my $mtable = def_table(10, 10, FALSE); my ($outbox,$outtext)= create_text(); - add_colors_to_textview($outtext); + + my $next=def_image_button('icons/run.png','Next'); my $back=def_image_button('icons/left.png','Previous'); + my $load= show_gif("icons/load.gif"); + $mtable->attach($load,8,9,9,10,'shrink','shrink',2,2); - $mtable->attach_defaults ($outbox ,0, 10, 4,9); $mtable->attach($back,2,3,9,10,'shrink','shrink',2,2); - $mtable->attach($next,8,9,9,10,'shrink','shrink',2,2); + @@ -1422,18 +1395,13 @@ #check if verilator model has been generated if ($result){ add_colored_info(\$outtext,"Veriator model has been generated successfully!",'blue'); + $load->destroy(); + $mtable->attach($next,8,9,9,10,'shrink','shrink',2,2); }else { add_colored_info(\$outtext,"Verilator compilation failed!\n","red"); + $load->destroy(); $next->destroy(); } - - - - - - - - } @@ -1445,26 +1413,36 @@ my $dir = Cwd::getcwd(); my $project_dir = abs_path("$dir/.."); my $src_verilator_dir="$project_dir/src_verilator"; + my $target_verilog_dr ="$target_dir/src_verilog"; + my $target_verilator_dr ="$target_dir/src_verilator"; + my $sw_dir = "$target_dir/sw"; - - + my $src_noc_dir="$project_dir/src_noc"; + mkpath("$target_verilator_dr",1,01777); + #copy src_verilator files - add_info(\$outtext,"Copy verilator files\n"); - my @files=( - "$src_verilator_dir/noc_connection.sv", - "$src_verilator_dir/router_verilator.v" - ); - if (-d "$target_dir/src_verilator/"==0){ - mkpath("$target_dir/src_verilator/",1,01777); + my @files_list = File::Find::Rule->file() + ->name( '*.v','*.V','*.sv' ) + ->in( "$src_verilator_dir" ); + + #make sure source files have key word 'module' + my @files; + foreach my $p (@files_list){ + push (@files,$p) if(check_file_has_string($p,'module')); } - copy_file_and_folders (\@files,$project_dir,"$target_dir/src_verilator"); + copy_file_and_folders (\@files,$project_dir,$target_verilator_dr); - #create each tile top module - my $nx= $self->object_get_attribute('noc_param',"NX"); - my $ny= $self->object_get_attribute('noc_param',"NY"); + + + #copy src_noc files + #my @files2; + #push (@files2,$src_noc_dir); + #copy_file_and_folders (\@files2,$project_dir,$target_verilog_dr); + + + #create each tile top module my $processors_en=0; - my $mpsoc=$self; - + my $mpsoc=$self; my $lisence= get_license_header("verilator_tiles"); my $warning=autogen_warning(); my $verilator=$lisence.$warning; @@ -1475,59 +1453,44 @@ my $noc_param_v= " \`ifdef INCLUDE_PARAM \n \n $noc_param - /* verilator lint_off WIDTH */ - localparam P=(TOPOLOGY==\"RING\" || TOPOLOGY==\"LINE\")? 3 : 5; - localparam ROUTE_TYPE = (ROUTE_NAME == \"XY\" || ROUTE_NAME == \"TRANC_XY\" )? \"DETERMINISTIC\" : - (ROUTE_NAME == \"DUATO\" || ROUTE_NAME == \"TRANC_DUATO\" )? \"FULL_ADAPTIVE\": \"PAR_ADAPTIVE\"; - /* verilator lint_on WIDTH */ + //simulation parameter \n \n \`endif" ; - save_file("$target_dir/src_verilator/parameter.v",$noc_param_v); + save_file("$target_verilator_dr/parameter.v",$noc_param_v); - - - my %tops = ( - "Vrouter" => "router_verilator.v", - "Vnoc" => "noc_connection.sv" - ); - for (my $y=0;$y<$ny;$y++){ - for (my $x=0; $x<$nx;$x++){ - - my $tile_num= $y*$nx+$x; + + + my ($nr,$ne,$router_p,$ref_tops)= get_noc_verilator_top_modules_info($self); + my %tops = %{$ref_tops}; + + for (my $tile_num=0;$tile_num<$ne;$tile_num++){ + #print "$tile_num\n"; my ($soc_name,$num)= $mpsoc->mpsoc_get_tile_soc_name($tile_num); - if(!defined $soc_name){ - #this tile is not connected to any ip. the noc input ports will be connected to ground - my $soc_v="\n\n // Tile:$tile_num (x=$x,y=$y) is not assigned to any ip\n"; - $soc_v="$soc_v - - assign ni_credit_out[$tile_num]={V{1'b0}}; - assign ni_flit_out[$tile_num]={Fw{1'b0}}; - assign ni_flit_out_wr[$tile_num]=1'b0; - "; - next; - - } + my $soc=eval_soc($mpsoc,$soc_name,$outtext); my $top=$mpsoc->mpsoc_get_soc($soc_name); - my $soc_num= $y*$nx+$x; + my $soc_num= $tile_num; - - #update core id $soc->object_add_attribute('global_param','CORE_ID',$tile_num); + #update NoC param - #my %nocparam = %{$mpsoc->object_get_attribute('noc_param',undef)}; my $nocparam =$mpsoc->object_get_attribute('noc_param',undef); + my ($NE, $NR, $RAw, $EAw, $Fw) = get_topology_info($mpsoc); + my %y=%{$nocparam}; + $y{'EAw'} = $EAw; + $y{'RAw'} = $RAw; + $y{'Fw'} = $Fw; my @nis=get_NI_instance_list($top); - $soc->soc_add_instance_param($nis[0] ,$nocparam ); - my $tile=($nx*$y)+ $x; + $soc->soc_add_instance_param($nis[0] ,\%y ); + my $tile=$tile_num; my $setting=$mpsoc->mpsoc_get_tile_param_setting($tile); my %params; if ($setting eq 'Custom'){ @@ -1542,9 +1505,9 @@ $tops{"Vtile$tile_num"}= "tile_$tile.v"; - }} + } - save_file ("$target_dir/src_verilator/verilator_tiles.v",$verilator); + save_file ("$target_verilator_dr/verilator_tiles.v",$verilator); my $result = verilator_compilation (\%tops,$target_dir,$outtext); $self->object_add_attribute('verilator','libs',\%tops); return $result; @@ -1651,9 +1614,9 @@ my $path=$mpsoc->object_get_attribute('setting','soc_path'); $path=~ s/ /\\ /g; my $p = "$path/$soc_name.SOC"; - my $soc = eval { do $p }; - if ($@ || !defined $soc){ - show_info(\$outtext,"**Error reading $p file: $@\n"); + my ($soc,$r,$err) = regen_object($p); + if ($r){ + show_info(\$outtext,"**Error reading $p file: $err\n"); next; } return $soc; @@ -1664,17 +1627,18 @@ my ($mpsoc,$name,$top,$target_dir,$tview)=@_; my $verilator="$target_dir/verilator"; my $dir="$verilator/"; - #my $soc_top= $self->soc_get_top (); + my $parameter_h=gen_noc_param_h($mpsoc); - my $nx= $mpsoc->object_get_attribute('noc_param',"NX"); - my $ny= $mpsoc->object_get_attribute('noc_param',"NY"); + my ($nr,$ne,$router_p,$ref_tops,$includ_h)= get_noc_verilator_top_modules_info($mpsoc); + $parameter_h=$parameter_h.$includ_h; + + my $libh=""; my $inst= ""; my $newinst=""; - my $tile_x=""; - my $tile_y=""; + my $tile_addr=""; my $tile_flit_in=""; my $tile_flit_in_l=""; my $tile_credit=""; @@ -1693,9 +1657,14 @@ my $top_port_info="IO type\t port_size\t port_name\n"; my $no_connected=''; - for (my $y=0;$y<$ny;$y++){for (my $x=0; $x<$nx;$x++){ - my $t= $y*$nx+$x; - my ($soc_name,$num)= $mpsoc->mpsoc_get_tile_soc_name($t); + for (my $endp=0; $endp<$ne;$endp++){ + + my $e_addr=endp_addr_encoder($mpsoc,$endp); + my $router_num = get_connected_router_id_to_endp($mpsoc,$endp); + my $r_addr=router_addr_encoder($mpsoc,$router_num); + + + my ($soc_name,$num)= $mpsoc->mpsoc_get_tile_soc_name($endp); if(defined $soc_name) {#we have a conncted tile #get ni instance name @@ -1712,27 +1681,23 @@ } - $libh=$libh."#include \"Vtile${t}.h\"\n"; - $inst=$inst."Vtile${t}\t*tile${t};\t // Instantiation of tile${t}\n"; - $newinst = $newinst."\ttile${t}\t=\tnew Vtile${t};\n"; - $tile_flit_in = $tile_flit_in . "\ttile${t}->${ni_name}_flit_in = noc->ni_flit_out [${t}];\n"; - $tile_flit_in_l = $tile_flit_in_l . "\t\ttile${t}->${ni_name}_flit_in[j] = noc->ni_flit_out [${t}][j];\n"; - $tile_credit= $tile_credit."\ttile${t}->${ni_name}_credit_in= noc->ni_credit_out[${t}];\n"; - $noc_credit= $noc_credit."\tnoc->ni_credit_in[${t}] = tile${t}->${ni_name}_credit_out;\n"; - $noc_flit_in=$noc_flit_in."\tnoc->ni_flit_in [${t}] = tile${t}->${ni_name}_flit_out;\n"; - $noc_flit_in_l=$noc_flit_in_l."\t\t\tnoc->ni_flit_in [${t}][j] = tile${t}->${ni_name}_flit_out[j];\n"; - $noc_flit_in_wr= $noc_flit_in_wr."\tif(tile${t}->${ni_name}_flit_out_wr) noc->ni_flit_in_wr = noc->ni_flit_in_wr | ((vluint64_t)1<<${t});\n"; - $tile_flit_in_wr=$tile_flit_in_wr."\ttile${t}->${ni_name}_flit_in_wr= ((noc->ni_flit_out_wr >> ${t}) & 0x01);\n"; - $noc_flit_in_wr_l= $noc_flit_in_wr_l."\tif(tile${t}->${ni_name}_flit_out_wr) MY_VL_SETBIT_W(noc->ni_flit_in_wr ,${t});\n"; - $tile_flit_in_wr_l=$tile_flit_in_wr_l."\ttile${t}->${ni_name}_flit_in_wr= (VL_BITISSET_W(noc->ni_flit_out_wr,${t})>0);\n"; - $tile_eval=$tile_eval."\ttile${t}->eval();\n"; - $tile_final=$tile_final."\ttile${t}->final();\n"; + $libh=$libh."#include \"Vtile${endp}.h\"\n"; + $inst=$inst."Vtile${endp}\t*tile${endp};\t // Instantiation of tile${endp}\n"; + $newinst = $newinst."\ttile${endp}\t=\tnew Vtile${endp};\n"; + $tile_flit_in = $tile_flit_in . "\ttile${endp}->${ni_name}_flit_in = noc->ni_flit_out [${endp}];\n"; + $tile_flit_in_l = $tile_flit_in_l . "\t\ttile${endp}->${ni_name}_flit_in[j] = noc->ni_flit_out [${endp}][j];\n"; + $tile_credit= $tile_credit."\ttile${endp}->${ni_name}_credit_in= noc->ni_credit_out[${endp}];\n"; + $noc_credit= $noc_credit."\tnoc->ni_credit_in[${endp}] = tile${endp}->${ni_name}_credit_out;\n"; + $noc_flit_in=$noc_flit_in."\tnoc->ni_flit_in [${endp}] = tile${endp}->${ni_name}_flit_out;\n"; + $noc_flit_in_l=$noc_flit_in_l."\t\t\tnoc->ni_flit_in [${endp}][j] = tile${endp}->${ni_name}_flit_out[j];\n"; + $noc_flit_in_wr= $noc_flit_in_wr."\tif(tile${endp}->${ni_name}_flit_out_wr) noc->ni_flit_in_wr = noc->ni_flit_in_wr | ((vluint64_t)1<<${endp});\n"; + $tile_flit_in_wr=$tile_flit_in_wr."\ttile${endp}->${ni_name}_flit_in_wr= ((noc->ni_flit_out_wr >> ${endp}) & 0x01);\n"; + $noc_flit_in_wr_l= $noc_flit_in_wr_l."\tif(tile${endp}->${ni_name}_flit_out_wr) MY_VL_SETBIT_W(noc->ni_flit_in_wr ,${endp});\n"; + $tile_flit_in_wr_l=$tile_flit_in_wr_l."\ttile${endp}->${ni_name}_flit_in_wr= (VL_BITISSET_W(noc->ni_flit_out_wr,${endp})>0);\n"; + $tile_eval=$tile_eval."\ttile${endp}->eval();\n"; + $tile_final=$tile_final."\ttile${endp}->final();\n"; - - - - foreach my $intfc (@intfcs){ my $key=($intfc eq 'plug:clk[0]')? 'clk' : ($intfc eq 'plug:reset[0]')? 'reset': @@ -1742,26 +1707,28 @@ my @ports=$soc_top->top_get_intfc_ports_list($intfc); foreach my $p (@ports){ my($inst,$range,$type,$intfc_name,$intfc_port)= $soc_top->top_get_port($p); - $tile_reset=$tile_reset."\t\ttile${t}->$p=reset;\n" if $key eq 'reset'; - $tile_clk=$tile_clk."\t\ttile${t}->$p=clk;\n" if $key eq 'clk'; - $tile_en=$tile_en."\t\ttile${t}->$p=enable;\n" if $key eq 'en'; ; - $top_port_info="$top_port_info $type $range tile${t}->$p \n"; + $tile_reset=$tile_reset."\t\ttile${endp}->$p=reset;\n" if $key eq 'reset'; + $tile_clk=$tile_clk."\t\ttile${endp}->$p=clk;\n" if $key eq 'clk'; + $tile_en=$tile_en."\t\ttile${endp}->$p=enable;\n" if $key eq 'en'; ; + $top_port_info="$top_port_info $type $range tile${endp}->$p \n"; }#ports }#interface - $tile_x= $tile_x."\ttile${t}->${ni_name}_current_x=$x;\n"; - $tile_y= $tile_y."\ttile${t}->${ni_name}_current_y=$y;\n"; + $tile_addr= $tile_addr."\ttile${endp}->${ni_name}_current_r_addr=$r_addr; // noc->er_addr[${endp}];\n"; + $tile_addr= $tile_addr."\ttile${endp}->${ni_name}_current_e_addr=$e_addr;\n"; + }else{ #this tile is not connected to any ip. the noc input ports will be connected to ground - $no_connected=$no_connected."\n // Tile:$t (x=$x,y=$y) is not assigned to any ip\n"; - $no_connected=$no_connected."\t\tnoc->ni_credit_in[${t}]=0; \n"; + $no_connected=$no_connected."\n // Tile:$endp ($e_addr) is not assigned to any ip\n"; + $no_connected=$no_connected."\t\tnoc->ni_credit_in[${endp}]=0; \n"; } - }} + } my $main_c=get_license_header("testbench.cpp"); + $main_c="$main_c #include #include @@ -1770,35 +1737,21 @@ #include // Defines common routines #include \"Vnoc.h\" -#include \"Vrouter.h\" $libh +Vnoc *noc; +$inst +int reset,clk,enable; + +#include \"parameter.h\" + + /* $top_port_info */ -#ifndef NX - #define NX $nx -#endif - -#ifndef NY - #define NY $ny -#endif - -#ifndef NC - #define NC ($nx*$ny) -#endif - - -Vrouter *router[NC]; // Instantiation of router -Vnoc *noc; -$inst - - - -int reset,clk,enable; unsigned int main_time = 0; // Current simulation time void update_all_instances_inputs(void); @@ -1808,8 +1761,7 @@ int i,j,x,y; Verilated::commandArgs(argc, argv); // Remember args - - for(i=0;icurrent_x = x; - router[i]->current_y = y; - } -$tile_x -$tile_y + +$tile_addr + main_time=0; printf(\"Start Simulation\\n\"); while (!Verilated::gotFinish()) { @@ -1858,16 +1806,13 @@ $tile_reset $tile_clk $tile_en - for(i=0;ireset= reset; - router[i]->clk= clk; - } + + connect_routers_reset_clk(); //eval instances noc->eval(); - for(i=0;ieval(); - } + routers_eval(); + $tile_eval @@ -1877,10 +1822,8 @@ }//while - // Simulation is dne - for(i=0;ifinal(); - } + // Simulation is done + routers_final(); noc->final(); $tile_final } @@ -1893,7 +1836,7 @@ void update_all_instances_inputs(void){ int x,y,i,j; - int flit_out_all_size = sizeof(router[0]->flit_out_all)/sizeof(router[0]->flit_out_all[0]); + #if (NC<=64) noc->ni_flit_in_wr =0; @@ -1900,20 +1843,9 @@ #else for(j=0;j<(sizeof(noc->ni_flit_in_wr)/sizeof(noc->ni_flit_in_wr[0])); j++) noc->ni_flit_in_wr[j]=0; #endif - for(x=0;xflit_in_we_all = noc->router_flit_out_we_all[i]; - router[i]->credit_in_all = noc->router_credit_out_all[i]; - router[i]->congestion_in_all = noc->router_congestion_out_all[i]; - for(j=0;jflit_in_all[j] = noc->router_flit_out_all[i][j]; - noc->router_flit_in_we_all[i] = router[i]->flit_out_we_all ; - noc->router_credit_in_all[i] = router[i]->credit_out_all; - noc->router_congestion_in_all[i]= router[i]->congestion_out_all; - for(j=0;jrouter_flit_in_all[i][j] = router[i]->flit_out_all[j] ; - } //for - - + connect_all_routers_to_noc (); + #if (Fpay<=32) //tile[i]->flit_in = noc->ni_flit_out [i]; @@ -1963,6 +1895,7 @@ } "; + save_file("$dir/parameter.h",$parameter_h); save_file("$dir/testbench.cpp",$main_c); } @@ -1992,7 +1925,7 @@ $vfile_param_type= "Parameter" if ($vfile_param_type eq 1); $vfile_param_type= "Localparam" if ($vfile_param_type eq 0); $all_param{ $inst_param} = $params{ $p} if($vfile_param_type eq "Parameter" || $vfile_param_type eq "Localparam" ); - print"$all_param{ $inst_param} = $params{ $p} if($vfile_param_type eq \"Parameter\" || $vfile_param_type eq \"Localparam\" ); \n"; + #print"$all_param{ $inst_param} = $params{ $p} if($vfile_param_type eq \"Parameter\" || $vfile_param_type eq \"Localparam\" ); \n"; } } return %all_param; @@ -2194,9 +2127,11 @@ my $run = def_image_button('icons/run.png','Run'); my $back=def_image_button('icons/left.png','Previous'); + + $table->attach ($back,1,2,1,2,'shrink','shrink',0,0); $table->attach ($regen,3,4,1,2,'shrink','shrink',0,0); - $table->attach ($make,7, 8, 1,2,'shrink','shrink',0,0); + $table->attach ($make,6, 7, 1,2,'shrink','shrink',0,0); $table->attach ($run,9, 10, 1,2,'shrink','shrink',0,0); $back-> signal_connect("clicked" => sub{ @@ -2231,8 +2166,13 @@ $make -> signal_connect("clicked" => sub{ + $make->hide_all; + my $load= show_gif("icons/load.gif"); + $table->attach ($load,8, 9, 1,2,'shrink','shrink',0,0); + $table->show_all; $app->do_save(); copy("$dir/testbench.cpp", "$verilator/processed_rtl/obj_dir/testbench.cpp"); + copy("$dir/parameter.h", "$verilator/processed_rtl/obj_dir/parameter.h") if(-f "$dir/parameter.h"); my $tops_ref=$self->object_get_attribute('verilator','libs'); my %tops=%{$tops_ref}; @@ -2243,7 +2183,9 @@ $lib_num++; } run_make_file("$verilator/processed_rtl/obj_dir/",$tview,"sim"); - + $load->destroy; + $make->show_all; + }); $run -> signal_connect("clicked" => sub{
/diagram.pl
2,14 → 2,18
use Glib qw/TRUE FALSE/;
use strict;
use warnings;
 
use FindBin;
use lib $FindBin::Bin;
 
use soc;
require "widget.pl";
require "emulator.pl";
use File::Copy;
 
#use GraphViz;
 
 
 
sub get_dot_file{
my $self= shift;
my $self_name=$self->object_get_attribute('soc_name');
60,11 → 64,9
}
}
}
}
$dotfile=($first)? "$dotfile $instance_name" : "$dotfile}|$instance_name";
$first=1;
my @plugs= $self->soc_get_all_plugs_of_an_instance($instance_id);
211,42 → 213,96
}
 
 
sub show_topology_diagram {
my $self= shift;
 
my $table=def_table(20,20,FALSE);
my $window=def_popwin_size(80,80,"NoC-based MCSoC topology block diagram",'percent');
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
$scrolled_win->set_policy( "automatic", "automatic" );
$window->add ($table);
my $plus = def_image_button('icons/plus.png',undef,TRUE);
my $minues = def_image_button('icons/minus.png',undef,TRUE);
my $save = def_image_button('icons/save.png',undef,TRUE);
my $scale=$self->object_get_attribute("tile_diagram","scale");
$scale= 1 if (!defined $scale);
my $col=0;
$table->attach ($plus , $col, $col+1,0,1,'shrink','shrink',2,2); $col++;
$table->attach ($minues, $col, $col+1,0,1,'shrink','shrink',2,2); $col++;
$table->attach ($save, $col, $col+1,0,1,'shrink','shrink',2,2); $col++;
#$table->attach (gen_label_in_left(" Remove unconnected Interfaces"), $col, $col+1,0,1,'shrink','shrink',2,2); $col++;
#$table->attach (gen_label_in_left(" Remove Clk Interfaces"), $col, $col+1,0,1,'shrink','shrink',2,2); $col++;
#$table->attach (gen_label_in_left(" Remove Reset Interfaces"), $col, $col+1,0,1,'shrink','shrink',2,2); $col++;
while ($col<20){
my $tmp=gen_label_in_left('');
$table->attach_defaults ($tmp, $col, $col+1,0,1);$col++;
}
$plus -> signal_connect("clicked" => sub{
$scale*=1.1 if ($scale <10);
$self->object_add_attribute("topology_diagram","scale", $scale );
show_diagram ($self,$scrolled_win,$table,"topology_diagram");
});
$minues -> signal_connect("clicked" => sub{
$scale*=.9 if ($scale >0.1); ;
$self->object_add_attribute("topology_diagram","scale", $scale );
show_diagram ($self,$scrolled_win,$table,"topology_diagram");
});
$save-> signal_connect("clicked" => sub{
save_diagram_as ($self);
});
if(gen_diagram($self,'topology')){
show_diagram ($self,$scrolled_win,$table,"topology_diagram");
}
$window->show_all();
}
 
 
 
 
 
sub gen_diagram {
my ($self,$type)=@_;
 
my $dotfile;
$dotfile= get_dot_file($self) if ($type eq 'tile');
$dotfile= get_topology_dot_file($self) if ($type eq 'topology');
$dotfile= generate_custom_topology_dot_file($self) if ($type eq 'custom_topology');
$dotfile= generate_trace_dot_file($self) if ($type eq 'trace');
$dotfile= generate_map_dot_file($self) if ($type eq 'map');
my $tmp_dir = "$ENV{'PRONOC_WORK'}/tmp";
mkpath("$tmp_dir/",1,01777);
open(FILE, ">$tmp_dir/diagram.txt") || die "Can not open: $!";
print FILE $dotfile;
close(FILE) || die "Error closing file: $!";
#mkpath("$tmp_dir/",1,01777);
#open(FILE, ">$tmp_dir/diagram.txt") || die "Can not open: $!";
#print FILE $dotfile;
#close(FILE) || die "Error closing file: $!";
#unlink "$tmp_dir/diagram.png";
 
my $cmd;
$cmd= "dot $tmp_dir/diagram.txt | neato -n -Tpng -o $tmp_dir/diagram.png" if ($type eq 'tile' || $type eq 'trace');
$cmd = "dot $tmp_dir/diagram.txt -Kfdp -n -Tpng -o $tmp_dir/diagram.png" if ( $type eq 'map');
#$cmd= "dot $tmp_dir/diagram.txt | neato -n -Tpng -o $tmp_dir/diagram.png" if ($type eq 'tile' || $type eq 'trace' );
#$cmd = "dot $tmp_dir/diagram.txt -Kfdp -n -Tpng -o $tmp_dir/diagram.png" if ( $type eq 'map' || $type eq 'topology' || $type eq 'custom_topology' );
$cmd= " dot | neato -n -Tpng -o $tmp_dir/diagram.png" if ($type eq 'tile' || $type eq 'trace' );
$cmd = " dot -Kfdp -n -Tpng -o $tmp_dir/diagram.png" if ( $type eq 'map' || $type eq 'topology' || $type eq 'custom_topology' );
$cmd = "echo \'$dotfile\' | $cmd";
 
my ($stdout,$exit,$stderr)= run_cmd_in_back_ground_get_stdout ($cmd);
 
if ( length( $stderr || '' ) !=0) {
if ( length( $stderr || '' ) !=0) {
message_dialog("$stderr\nHave you installed graphviz? If not run \n \t \"sudo apt-get install graphviz\" \n in terminal");
return 0;
return 0 unless (-f "$tmp_dir/diagram.png");
}
else {
#my $diagram=show_gif("$tmp_dir/diagram.png");
return 1;
}
 
 
}
 
 
262,8 → 318,9
$scale= 1 if (!defined $scale);
my $tmp_dir = "$ENV{'PRONOC_WORK'}/tmp";
my $diagram=open_image("$tmp_dir/diagram.png",70*$scale,70*$scale,'percent');
$scrolled_win->add_with_viewport($diagram);
$scrolled_win->show_all();
$scrolled_win->add_with_viewport($diagram);
$scrolled_win->show_all();
 
352,53 → 409,6
 
 
 
sub generate_map_dot_file_old{
my $self=shift;
my $dotfile=
"digraph G {
graph [rankdir = LR , splines=ortho, overlap = false];
node[shape=record];
NoC [label=\"";
 
#add nodes
my $nx=$self->object_get_attribute('noc_param','NX');
my $ny=$self->object_get_attribute('noc_param','NY');
my $nc= $nx * $ny;
my @tasks=get_all_tasks($self);
 
 
for(my $y=0; $y<$ny; $y++){
for(my $x=0; $x<$nx; $x++){
my $task=get_task_assigned_to_tile($self,$x,$y);
my $id=$y*$nx+$x;
$dotfile= $dotfile."{" if ($x==0);
$dotfile= $dotfile." <$task> IP${id}(${y},$x)\n$task" if (defined $task);
$dotfile= $dotfile." IP${id}(${y},$x)" if (!defined $task);
$dotfile=$dotfile."|" if($nx != 1 && $x !=$nx-1 );
$dotfile= $dotfile."}" if ($x==$nx-1);
}
$dotfile=$dotfile."|" if($ny != 1 && $y !=$ny-1 );
}
$dotfile=$dotfile."\"];\n\n";
 
 
 
 
$dotfile=$dotfile."\n}\n";
return $dotfile;
}
 
sub generate_map_dot_file{
my $self=shift;
my $dotfile=
411,8 → 421,8
 
#add nodes
my $nx=$self->object_get_attribute('noc_param','NX');
my $ny=$self->object_get_attribute('noc_param','NY');
my $nx=$self->object_get_attribute('noc_param','T1');
my $ny=$self->object_get_attribute('noc_param','T2');
my $nc= $nx * $ny;
my @tasks=get_all_tasks($self);
540,4 → 550,500
 
 
}
 
 
 
 
 
 
sub node_connection{
my ($sn,$sx,$sy,$sp,$dn,$dx,$dy,$dp)=@_;
my $spp = (defined $sp) ? ":\"p$sp\"" : " ";
my $dpp = (defined $dp) ? ":\"p$dp\"" : " ";
my $sname = (defined $sy) ? "\"$sn${sx}_${sy}\"" : "\"$sn${sx}\"";
my $dname = (defined $dy) ? "\"$dn${dx}_${dy}\"" : "\"$dn${dx}\"";
my $t= "$sname $spp -> $dname $dpp [ dir=none];\n";
return $t;
}
 
sub node_connection2{
my ($sn,$sx,$sp,$dn,$dx,$dy,$dp)=@_;
my $spp = (defined $sp) ? ":\"p$sp\"" : " ";
my $dpp = (defined $dp) ? ":\"p$dp\"" : " ";
my $sname = "\"$sn${sx}\"";
my $dname = "\"$dn${dx}\"";
my $t= "$sname $spp -> $dname $dpp [ dir=none];\n";
return $t;
}
 
 
sub generate_mesh_dot_file_old{
my $self=shift;
my $dotfile=
"digraph G {
graph [rankdir = LR , splines = true, overlap = true];
node[shape=record];
";
#five_port_router [
# label="{ |2| } | {3|R0|1} | { |4|0}"
# shape=record
# color=blue
# style=filled
# fillcolor=blue
#];
#add nodes
my $nx=$self->object_get_attribute('noc_param','T1');
my $ny=$self->object_get_attribute('noc_param','T2');
my $nc= $nx * $ny;
my $topology=$self->object_get_attribute('noc_param','TOPOLOGY');
my $btrace= ($topology eq '"TORUS"' || $topology eq '"RING"');
my $oned = ($topology eq '"RING"' || $topology eq '"LINE"');
for(my $y=0; $y<$ny; $y++){
for(my $x=0; $x<$nx; $x++){
my $id=$y*$nx+$x;
my $n = "R${id}" ;
my $node = "${x}_$y";
my $label = ($oned)?
"\{ |<p2>| \} | \{<p3>2|$n|<p1>1\} | \{ |<p4>|<p0>0\}"
: "\{ |<p2>2| \} | \{<p3>3|$n|<p1>1\} | \{ |<p4>4|<p0>0\}";
my $xx=$x*2.5;
my $yy=($ny-$y-1)*2.5+1;
my $tx=$xx+0.75;
my $ty=$yy-1;
$dotfile=$dotfile."
\"R$node\"\[
label = \"$label\"
pos = \"$xx,$yy!\"
shape=record
color=blue
style=filled
fillcolor=blue
];
 
T$node\[
label = \"Tile_$id($node)\"
pos = \"$tx,$ty!\"
shape=record
color=orange
style=filled
fillcolor=orange
];";
 
;
}
}
 
$dotfile=$dotfile."\n\n";
#add connections
for(my $y=0; $y<$ny; $y++){
for(my $x=0; $x<$nx; $x++){
$dotfile=$dotfile.node_connection('R',$x,$y,1,'R',($x+1),$y,3) if($x <$nx-1);
$dotfile=$dotfile.node_connection('R',$x,$y,1,'R',0,$y,3) if($x == ($nx-1) && $btrace);
$dotfile=$dotfile.node_connection('R',$x,$y,2,'R',$x,($y-1),4)if($y>0) ;
$dotfile=$dotfile.node_connection('R',$x,$y,2,'R',$x,($ny-1),4) if($y ==0 && $btrace && !$oned);
$dotfile=$dotfile.node_connection('R',$x,$y,0,'T',$x,$y);
}}
 
 
 
$dotfile=$dotfile."\n}\n";
return $dotfile;
}
 
 
##################################
#
##################################
 
 
sub generate_mesh_dot_file{
my $self=shift;
my $dotfile=
"digraph G {
graph [rankdir = RL , splines = true, overlap = true];
node[shape=record];
";
#five_port_router [
# label="{ |2| } | {3|R0|1} | { |4|0}"
# shape=record
# color=blue
# style=filled
# fillcolor=blue
#];
#add nodes
my $nx=$self->object_get_attribute('noc_param','T1');
my $ny=$self->object_get_attribute('noc_param','T2');
my $nz=$self->object_get_attribute('noc_param','T3');
my $NE = $nx*$ny*$nz;
my $NR = $nx*$ny;
my $topology=$self->object_get_attribute('noc_param','TOPOLOGY');
my $btrace= ($topology eq '"TORUS"' || $topology eq '"RING"');
my $oned = ($topology eq '"RING"' || $topology eq '"LINE"');
#generate endpoints
for(my $y=0; $y<$ny; $y++){
for(my $x=0; $x<$nx; $x++){
for(my $z=0; $z<$nz; $z++){
my $id=($y*$nx+$x)*$nz+$z;
my $offsetx = ($z==0 || $z==3) ? 1.05 : -1.05;
my $offsety = ($z==0 || $z==1) ? -0.85 : +0.85;
my $tx=$x*3+$offsetx;
my $ty=($ny-$y-1)*2.5+1+$offsety;
 
$dotfile=$dotfile."
 
T$id\[
label = \"T${id}\"
pos = \"$tx,$ty!\"
shape=record
color=orange
style=filled
fillcolor=orange
];";
}}}
#generate routers
for(my $y=0; $y<$ny; $y++){
for(my $x=0; $x<$nx; $x++){
my $e0 = '0';
my $e1 = ($nz>1)? ( ($oned)? '3':'5') : ' ';
my $e2 = ($nz>2)? ( ($oned)? '4':'6') : ' ';
my $e3 = ($nz>3)? ( ($oned)? '5':'7') : ' ';
my $id=$y*$nx+$x;
my $n = "R${id}";
my $label = ($oned)?
"\{<p7>$e2 |<p2> |<p8>$e3 \} | \{<p3>2|$n|<p1>1\} | \{<p6>$e1 |<p4> |<p5>$e0\}"
:"\{<p7>$e2 |<p2>2|<p8>$e3 \} | \{<p3>3|$n|<p1>1\} | \{<p6>$e1 |<p4>4|<p5>$e0\}";
my $xx=$x*3;
my $yy=($ny-$y-1)*2.5+1;
 
 
$dotfile=$dotfile."
\"$n\"\[
label = \"$label\"
pos = \"$xx,$yy!\"
shape=record
color=blue
style=filled
fillcolor=blue
];
 
";
 
}}
 
$dotfile=$dotfile."\n\n";
#add connections
for(my $y=0; $y<$ny; $y++){
for(my $x=0; $x<$nx; $x++){
$dotfile=$dotfile.node_connection('R',get_router_num($self,$x,$y),undef,1,'R',get_router_num($self,($x+1),$y),undef,3) if($x <$nx-1);
$dotfile=$dotfile.node_connection('R',get_router_num($self,$x,$y),undef,1,'R',get_router_num($self,0,$y),undef,3) if($x == ($nx-1) && $btrace);
$dotfile=$dotfile.node_connection('R',get_router_num($self,$x,$y),undef,2,'R',get_router_num($self,$x,($y-1)),undef,4)if($y>0) ;
$dotfile=$dotfile.node_connection('R',get_router_num($self,$x,$y),undef,2,'R',get_router_num($self,$x,($ny-1)),undef,4) if($y ==0 && $btrace && !$oned);
# $dotfile=$dotfile.node_connection('R',$x,$y,0,'T',$x,$y);
}}
 
for(my $id=0; $id<$NE; $id++){
my $rid=int($id/$nz);
my $p = $id%$nz+5;
$dotfile=$dotfile.node_connection('R',$rid,undef,$p,'T',$id,undef);
}
$dotfile=$dotfile."\n}\n";
return $dotfile;
 
 
 
}
 
 
 
sub generate_fattree_dot_file{
my $self=shift;
my $dotfile=
"digraph G {
graph [rankdir = LR , splines = true, overlap = true];
node[shape=record];
";
#add nodes
my $k=$self->object_get_attribute('noc_param','T1');
my $nl=$self->object_get_attribute('noc_param','T2');
my @bp;
my @hp;
for(my $p=0; $p<$k; $p++) {push (@bp,"<p$p>$p");}
for(my $p=$k; $p<2*$k; $p++) {push (@hp,"<p$p>$p");}
my $bp= join("|",@bp);
my $hp= join("|",@hp);
my $NC= powi( $k,$nl ); #total endpoints
my $NL= $NC/$k ; #number of nodes in each layer
 
 
#add endpoints
for(my $i=0; $i<$NC; $i++){
my $x=$i%$k;
my $y=int($i/$k);
 
$dotfile=$dotfile."T$i\[
label = \"T$i\"
pos = \"$i,0!\"
shape=house
margin=0
color=orange
style=filled
fillcolor=orange
];
";
}
 
#add roots
for(my $pos=0; $pos<$NL; $pos++){
my $x=($k)*$pos+($k/2)-0.5;
my $y= 1.5*($nl-1)+1;
my $r=$pos;
my $lable = "\{R$r\}|\{$bp\}";
$dotfile=$dotfile."
\"R$r\"\[
label=\"$lable\"
pos = \"$x,$y!\"
shape=record
color=blue
style=filled
fillcolor=blue
];
";
}
 
#add leaves
for(my $l=1; $l<$nl; $l++){
for(my $pos=0; $pos<$NL; $pos++){
my $x=($k)*$pos+($k/2)-0.5;
my $y= 1.5*($nl-$l-1)+1;
my $r=$NL*$l+$pos;
my $lable = "\{$hp\}|\{R$r\}|\{$bp\}";
$dotfile=$dotfile."
\"R$r\"\[
label=\"$lable\"
pos = \"$x,$y!\"
shape=record
color=blue
style=filled
fillcolor=blue
];
";
}
}
 
 
 
#connect all down input channels
my $n=$nl;
my $nPos = powi( $k, $n-1);
my $chan_per_direction = ($k * powi( $k , $n-1 )); #up or down
my $chan_per_level = 2*($k * powi( $k , $n-1 )); #up+down
for (my $level = 0; $level<$n-1; $level++){
#input channel are numbered interleavely, the interleaev depends on level
my $routers_per_neighborhood = powi($k,$n-1-($level));
my $routers_per_branch = powi($k,$n-1-($level+1));
my $level_offset = $routers_per_neighborhood*$k;
for ( my $pos = 0; $pos < $nPos; ++$pos ) {
my $neighborhood = int($pos/$routers_per_neighborhood);
my $neighborhood_pos = $pos % $routers_per_neighborhood;
for ( my $port = 0; $port < $k; ++$port ) {
my $link =
(($level+1)*$chan_per_level - $chan_per_direction) #which levellevel
+$neighborhood*$level_offset #region in level
+$port*$routers_per_branch*$k #sub region in region
+($neighborhood_pos)%$routers_per_branch*$k #router in subregion
+($neighborhood_pos)/$routers_per_branch; #port on router
#int link = (level*chan_per_level - chan_per_direction) + pos*k + port ;
my $connect_l= int(($link+$chan_per_direction)/$chan_per_level);
my $tmp=(($link+$chan_per_direction) % $chan_per_level);
my $connect_pos= int($tmp/$k);
my $connect_port= ($tmp%$k)+$k;
my $id1=$NL*$level+$pos;
my $connect_id=$NL*$connect_l+$connect_pos;
$dotfile=$dotfile.node_connection('R',$id1,undef,$port,'R',$connect_id,undef,$connect_port);
}
}
}
 
#add endpoints connection
for(my $i=0; $i<$NC; $i++){
my $r= $NL*($nl-1)+int($i/$k);
$dotfile=$dotfile.node_connection('T',$i,undef,undef,'R',$r,undef,$i%($k));
}
$dotfile=$dotfile."\n}\n";
return $dotfile;
}
 
 
 
 
sub generate_tree_dot_file{
my $self=shift;
my $dotfile=
"digraph G {
graph [rankdir = LR , splines = true, overlap = true];
node[shape=record];
";
 
my $k=$self->object_get_attribute('noc_param','T1');
my $nl=$self->object_get_attribute('noc_param','T2');
#generate routres port interface
my @bp;
my @hp;
for(my $p=0; $p<$k; $p++) {
push (@bp,"<n$p>") if(($k%2)==0 && $p==$k/2);#if k is odd number add one empty space in the middle
push (@bp,"<p$p>$p");
}
for(my $p=$k; $p<2*$k; $p++) {
if($p==$k+int(($k-1)/2)){
push (@hp,"<n$p>") if(($k%2)==0);#if k is odd number add one empty space in the middle
push (@hp,"<p$k>$k");
}else{
push (@hp,"<n$p>");
}
}
my $bp= join("|",@bp);
my $hp= join("|",@hp);
my ($NE,$NR)=get_topology_info($self);
 
 
#add endpoints
for(my $i=0; $i<$NE; $i++){
$dotfile=$dotfile."T$i\[
label = \"T$i\"
pos = \"$i,0!\"
shape=house
margin=0
color=orange
style=filled
fillcolor=orange
];
";
}
 
#add roots
my $lable = "\{R0\}|\{$bp\}";
my $x=(($NE-1)/2);
my $y= 1.5*($nl-1)+1;
$dotfile=$dotfile."
\"R0\"\[
label=\"$lable\"
pos = \"$x,$y!\"
shape=record
color=blue
style=filled
fillcolor=blue
];
";
#add leaves
my $t=1;
for(my $l=$nl-1; $l>0; $l--){
my $NL = powi($k,$l);
$t*=$k;
for(my $pos=0; $pos<$NL; $pos++){
my $x= $t*$pos + ($t-1)/2 ;
my $y= 1.5*($nl-$l)-.5;
my $r=sum_powi($k,$l)+$pos;
my $lable = "\{$hp\}|\{R$r\}|\{$bp\}";
$dotfile=$dotfile."
\"R$r\"\[
label=\"$lable\"
pos = \"$x,$y!\"
shape=record
color=blue
style=filled
fillcolor=blue
];
";
}
}
#add leave connections
for(my $l=$nl-1; $l>0; $l--){
my $NL = powi($k,$l);
for(my $pos=0; $pos<$NL; $pos++){
my $id1=sum_powi($k,$l)+$pos;
my $id2=sum_powi($k,$l-1)+int($pos/$k);
$dotfile=$dotfile.node_connection('R',$id1,undef,$k,'R',$id2,undef,$pos % $k);
}
}
#add endpoints connection
for(my $i=0; $i<$NE; $i++){
my $r= sum_powi($k,$nl-1)+int($i/$k);
$dotfile=$dotfile.node_connection('T',$i,undef,undef,'R',$r,undef,$i%($k));
}
 
$dotfile=$dotfile."\n}\n";
return $dotfile;
}
 
 
sub get_topology_dot_file{
my $self=shift;
my $topology=$self->object_get_attribute('noc_param','TOPOLOGY');
return generate_mesh_dot_file ($self) if($topology eq '"RING"' || $topology eq '"LINE"' || $topology eq '"MESH"' || $topology eq '"TORUS"' );
return generate_fattree_dot_file ($self) if($topology eq '"FATTREE"');
return generate_tree_dot_file($self);
}
 
 
 
 
 
 
 
 
 
 
 
 
return 1;
/emulate_ram_gen.pl
3,6 → 3,7
use warnings;
use List::Util 'shuffle';
require "widget.pl";
require "traffic_pattern.pl";
 
 
use constant SIM_RAM_GEN => 0;
43,7 → 44,6
my $cmd = "sh $jtag_intfc \" -n ".JTAG_DONE_RESET_INDEX." -d I:1,D:2:$reset_vector,I:0 \" ";
#print "$cmd\n";
return $cmd;
 
}
 
sub set_time_limit_cmd {
50,7 → 50,7
my ($time_limit,$jtag_intfc)=@_;
my $hex = sprintf("0x%X", $time_limit);
my $cmd = "sh $jtag_intfc \" -n ".JTAG_COUNTER_INDEX." -d I:1,D:".CLK_CNTw.":$hex,I:0 \" ";
print "$cmd\n";
#print "$cmd\n";
return $cmd;
}
 
72,9 → 72,6
 
 
 
 
 
 
sub random_dest_gen {
my $n=shift;
my @c=(0..$n-1);
102,63 → 99,12
}
 
 
sub synthetic_destination{
my($traffic,$x,$y,$xn,$yn,$line_num,$rnd)=@_;
my $dest_x;
my $dest_y;
my $xw = log2($xn);
my $yw = log2($yn);
 
if( $traffic eq "transposed 1"){
$dest_x= $xn-$y-1;
$dest_y= $yn-$x-1;
} elsif( $traffic eq "transposed 2"){
$dest_x = $y;
$dest_y = $x;
} elsif( $traffic eq "bit reverse"){
my $joint_addr= ($x << log2($xn))+$y;
my $reverse_addr=0;
my $pos=0;
for(my $i=0; $i<($xw+$yw); $i++){#reverse the address
$pos= ((($xw+$yw)-1)-$i);
$reverse_addr|= (($joint_addr >> $pos) & 0x01) << $i;
# reverse_addr[i] = joint_addr [((Xw+Yw)-1)-i];
}
$dest_x = $reverse_addr>>$yw;
$dest_y = $reverse_addr&(0xFF>> (8-$yw));
} elsif( $traffic eq "bit complement") {
 
$dest_x = (~$x) &(0xFF>> (8-$xw));
$dest_y = (~$y) &(0xFF>> (8-$yw));
 
 
}elsif( $traffic eq "tornado") {
#[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
$dest_x = (($x + (($xn/2)-1))%$xn);
$dest_y = (($y + (($yn/2)-1))%$yn);
}elsif( $traffic eq "random") {
#my $num=($y * $xn) + $x;
my $xc=$xn * $yn;
my @randoms=@{$rnd};
my $num=($y * $xn) + $x;
my $dest = @{$randoms[$num]}[$line_num-1];
#print "$num:$dest, "; # \@{ \$randoms\[$num\]\}\[$line_num\]";
$dest_x = $dest % $xn;
$dest_y = $dest / $xn;
} else{#off
print "***********************************$traffic is not defined*******************************************\n";
$dest_x= $x;
$dest_y= $y;
}
 
return ($dest_x,$dest_y);
 
sub synthetic_destination{
my($self,$sample,$traffic,$endp,$line_num,$rnd)=@_;
return pck_dst_gen ($self,$sample,$traffic,$endp,$line_num,$rnd);
}
 
 
167,16 → 113,15
 
 
sub gen_synthetic_traffic_ram_line{
my ($emulate, $x, $y, $sample,$ratio ,$line_num,$rnd)=@_;
 
my ($emulate, $endp, $sample,$ratio ,$line_num,$rnd)=@_;
my ($topology, $T1, $T2, $T3, $V, $Fpay) = get_sample_emulation_param($emulate,$sample);
my ($NE, $NR, $RAw, $EAw, $Fw) = get_topology_info_sub ($topology, $T1, $T2, $T3, $V, $Fpay);
my $ref=$emulate->object_get_attribute("$sample","noc_info");
my %noc_info= %$ref;
my $xn=$noc_info{NX};
my $yn=$noc_info{NY};
my $traffic=$emulate->object_get_attribute($sample,"traffic");
 
my $pck_num_to_send=$emulate->object_get_attribute($sample,"PCK_NUM_LIMIT");
my $pck_size=$emulate->object_get_attribute($sample,"PCK_SIZE");
185,20 → 130,19
if($line_num==0){ #first ram line shows how many times the ram content must be read
#In random traffic each node sends 2 packets to other NC-1 nodes for (pck_num_to_send/2) times
my $ram_cnt= ($traffic eq 'random')? ($pck_num_to_send/(2*(($xn * $yn)-1)))+1:0 ;
my $ram_cnt= ($traffic eq 'random')? ($pck_num_to_send/(2*($NE-1)))+1:0 ;
return (0,$ram_cnt);
}
return (0,0) if($line_num>1 && $traffic ne 'random');
return (0,0) if( $line_num>= $xn * $yn);
return (0,0) if( $line_num>= $NE);
 
 
#assign {pck_num_to_send_in,ratio_in, pck_size_in,dest_x_in, dest_y_in,pck_class_in, last_adr_in}= q_a;
my $last_adr = ( $traffic ne 'random') ? 1 :
($line_num ==($xn * $yn)-1)? 1 :0;
($line_num ==$NE-1)? 1 :0;
 
my ($dest_x, $dest_y)=synthetic_destination($traffic,$x,$y,$xn,$yn,$line_num,$rnd);
my $dest_e_addr=synthetic_destination($emulate,$sample,$traffic,$endp,$line_num,$rnd);
#print "$endp->$dest_e_addr\n";
 
my $vs= ( $traffic eq 'random')? 2 : $pck_num_to_send;
$vs=($vs << 2 )+ ($ratio >>5) ;
205,35 → 149,25
 
my $vl= ($ratio %32);
$vl=($vl << PCK_SIZw )+$pck_size;
$vl=($vl << MAXXw )+$dest_x;
$vl=($vl << MAXYw )+$dest_y;
$vl=($vl << MAX_EAw )+$dest_e_addr;
$vl=($vl << MAXCw )+$pck_class_in;
$vl=($vl << 1 )+$last_adr;
$vl=($vl << 1 )+$last_adr;
return ($vs,$vl);
 
 
 
}
 
 
 
 
 
sub generate_synthetic_traffic_ram{
my ($emulate,$x,$y,$sample,$ratio , $file,$rnd,$num)=@_;
my ($emulate,$endp,$sample,$ratio , $file,$rnd)=@_;
my $line_num;
my $line_value;
my $ram;
if(SIM_RAM_GEN){
my $ext= sprintf("%02u.txt",$num);
my $ext= sprintf("%02u.txt",$endp);
open( $ram, '>', "$ENV{'PRONOC_WORK'}/emulate/ram".$ext) || die "Can not create: \"$ENV{'PRONOC_WORK'}/emulate/ram.$ext\" $!";
}
for ($line_num= 0; $line_num<RAM_SIZE; $line_num++ ) {
my ($value_s,$value_l)=gen_synthetic_traffic_ram_line ($emulate, $x, $y, $sample, $ratio ,$line_num,$rnd);
my ($value_s,$value_l)=gen_synthetic_traffic_ram_line ($emulate, $endp, $sample, $ratio ,$line_num,$rnd);
#printf ("\n%08x\t",$value_s);
271,32 → 205,28
 
sub generate_emulator_ram {
my ($emulate, $sample,$ratio_in,$info)=@_;
my $ref=$emulate->object_get_attribute($sample,"noc_info");
my %noc_info= %$ref;
my $C=$noc_info{C};
my $xn=$noc_info{NX};
my $yn=$noc_info{NY};
my $xc=$xn*$yn;
my $rnd=random_dest_gen($xc); # generate a matrix of sudo random number
my ($topology, $T1, $T2, $T3, $V, $Fpay) = get_sample_emulation_param($emulate,$sample);
my ($NE, $NR, $RAw, $EAw, $Fw) = get_topology_info_sub ($topology, $T1, $T2, $T3, $V, $Fpay);
my $rnd=random_dest_gen($NE); # generate a matrix of sudo random number
my $traffic=$emulate->object_get_attribute($sample,"traffic");
my @traffics=("tornado", "transposed 1", "transposed 2", "bit reverse", "bit complement","random", "hot spot" );
my @traffics=("tornado", "transposed 1", "transposed 2", "bit reverse", "bit complement","random", "hot spot", "shuffle", "neighbor", "bit rotation" );
if ( !defined $xn || $xn!~ /\s*\d+\b/ ){ add_info($info,"programe_pck_gens:invalid X value\n"); help(); return 0;}
if ( !defined $yn || $yn!~ /\s*\d+\b/ ){ add_info($info,"programe_pck_gens:invalid Y value\n"); help(); return 0;}
#if ( !defined $xn || $xn!~ /\s*\d+\b/ ){ add_info($info,"programe_pck_gens:invalid X value\n"); help(); return 0;}
#if ( !defined $yn || $yn!~ /\s*\d+\b/ ){ add_info($info,"programe_pck_gens:invalid Y value\n"); help(); return 0;}
if ( !grep( /^$traffic$/, @traffics ) ){add_info($info,"programe_pck_gens:$traffic is an invalid Traffic name\n"); help(); return 0;}
if ( $xn <2 || $xn >16 ){ add_info($info,"programe_pck_gens:invalid X value: ($xn). should be between 2 and 16 \n"); help(); return 0;}
if ( $yn <2 || $yn >16 ){ add_info($info,"programe_pck_gens:invalid Y value:($yn). should be between 2 and 16 \n"); help(); return 0;}
if ( $EAw >8 ){ add_info($info,"programe_pck_gens:invalid EAw value: ($EAw). should be between 1 and 8 \n"); help(); return 0;}
#if ( $yn <2 || $yn >16 ){ add_info($info,"programe_pck_gens:invalid Y value:($yn). should be between 2 and 16 \n"); help(); return 0;}
#open file pointer
#open(my $file, '>', RAM_BIN_FILE) || die "Can not create: \">lib/emulate/emulate_ram.bin\" $!";
open(my $file, '>', "$ENV{'PRONOC_WORK'}/emulate/emulate_ram.bin") || die "Can not create: \"$ENV{'PRONOC_WORK'}/emulate/emulate_ram.bin\" $!";
#generate each node ram data
for (my $y=0; $y<$yn; $y=$y+1){
for (my $x=0; $x<$xn; $x=$x+1){
my $num=($y * $xn) + $x;
generate_synthetic_traffic_ram($emulate,$x,$y,$sample,$ratio_in, $file,$rnd,$num);
 
}
for (my $endp=0; $endp<$NE; $endp++){
#print "generate_synthetic_traffic_ram($emulate,$endp,$sample,$ratio_in, $file,$rnd);\n";
generate_synthetic_traffic_ram($emulate,$endp,$sample,$ratio_in, $file,$rnd);
}
close($file);
return 1;
314,8 → 244,11
 
#reset the FPGA board
#run_cmd_in_back_ground("quartus_stp -t ./lib/tcl/mem.tcl reset");
#print "#reset both noc and jtag\n";
return 0 if(run_cmd_update_info(reset_cmd(1,1,$jtag_intfc),$info)); #reset both noc and jtag
#print "#enable jtag keep noc in reset\n";
return 0 if(run_cmd_update_info(reset_cmd(0,1,$jtag_intfc),$info)); #enable jtag keep noc in reset
#print "#set time limit\n";
#set time limit
my $time_limit = $emulate->object_get_attribute($sample,"SIM_CLOCK_LIMIT");
return 0 if(run_cmd_update_info(set_time_limit_cmd($time_limit,$jtag_intfc),$info));
361,14 → 294,13
 
 
sub read_statistic_mem {
my($yn,$xn,$jtag_intfc,$info)=@_;
my($NE,$jtag_intfc,$info)=@_;
my %results;
my $sum_of_latency=0;
my $sum_of_pck=0;
my $total_router=0;
for (my $y=0; $y<$yn; $y=$y+1){
for (my $x=0; $x<$xn; $x=$x+1){
my $num=($y * $xn) + $x;
for (my $num=0; $num<$NE; $num++){
my $read_addr=($num * STATISTIC_NUM);
 
my $sent_pck_addr= sprintf ("%X",$read_addr);
386,7 → 318,7
$sum_of_pck+=$results{$num}{got_pck};
$total_router++ if($results{$num}{sent_pck}>0);
#$i=$i+2;
}}
}
398,13 → 330,13
 
 
sub read_statistic_mem_fast {
my($yn,$xn,$jtag_intfc,$info)=@_;
my($NE,$jtag_intfc,$info)=@_;
my %results;
my $sum_of_latency=0;
my $sum_of_pck=0;
my $total_router=0;
#read static memory
my $end= STATISTIC_NUM * 8 *$yn * $xn;
my $end= STATISTIC_NUM * 8 *$NE;
$end=sprintf ("%X",$end);
my $cmd= "sh $jtag_intfc \"-n ".JTAG_STATIC_INDEX." -w 8 -r -s 0 -e $end\"";
#print "$cmd\n";
423,9 → 355,9
for (my $y=0; $y<$yn; $y=$y+1){
for (my $x=0; $x<$xn; $x=$x+1){
my $num=($y * $xn) + $x;
for (my $endp=0; $endp<$NE; $endp=$endp+1){
my $num=$endp;
my $read_addr=($num * STATISTIC_NUM);
 
my $sent_pck_addr= $read_addr;
438,12 → 370,13
$results{$num}{latency}=hex($data[$latency_addr]);
$results{$num}{worst_latency}=hex($data[$worst_latency_addr]);
#add_info($info, "$num, ");
#print "$results{$num}{sent_pck}=hex($data[$sent_pck_addr]);\n";
$sum_of_latency+=$results{$num}{latency};
$sum_of_pck+=$results{$num}{got_pck};
$total_router++ if($results{$num}{sent_pck}>0);
#$i=$i+2;
}}
}
457,9 → 390,8
sub read_pack_gen{
my ($emulate,$sample,$info,$jtag_intfc,$ratio_in)= @_;
my $ref=$emulate->object_get_attribute($sample,"noc_info");
my %noc_info= %$ref;
my $xn=$noc_info{NX};
my $yn=$noc_info{NY};
my ($topology, $T1, $T2, $T3, $V, $Fpay) = get_sample_emulation_param($emulate,$sample);
my ($NE, $NR, $RAw, $EAw, $Fw) = get_topology_info_sub ($topology, $T1, $T2, $T3, $V, $Fpay);
#wait for done
add_info($info, "wait for done\n");
my $done=0;
498,8 → 430,8
add_info($info,"Done is asserted\nStart reading statistic data from cores:\n\t");
#print" Done is asserted\n";
#my $i=0;
#my ($results_ref,$sum_of_latency,$sum_of_pck,$total_router)= read_statistic_mem($yn,$xn,$jtag_intfc,$info);
my ($results_ref,$sum_of_latency,$sum_of_pck,$total_router)= read_statistic_mem_fast($yn,$xn,$jtag_intfc,$info);
#my ($results_ref,$sum_of_latency,$sum_of_pck,$total_router)= read_statistic_mem($NE,$jtag_intfc,$info);
my ($results_ref,$sum_of_latency,$sum_of_pck,$total_router)= read_statistic_mem_fast($NE,$jtag_intfc,$info);
my %results=%$results_ref;
/emulator.pl
2,6 → 2,10
use Glib qw/TRUE FALSE/;
use strict;
use warnings;
 
use FindBin;
use lib $FindBin::Bin;
 
use Gtk2;
use Gtk2::Ex::Graph::GD;
use GD::Graph::Data;
22,6 → 26,7
require "mpsoc_verilog_gen.pl";
require "readme_gen.pl";
require "graph.pl";
require "topology.pl";
 
use List::MoreUtils qw(uniq);
 
29,8 → 34,7
# hardware parameters taken from noc_emulator.v
use constant PCK_CNTw =>30; # packet counter width in bits (results in maximum of 2^30 = 1 G packets)
use constant PCK_SIZw =>14; # packet size width in bits (results in maximum packet size of 2^14 = 16 K flit)
use constant MAXXw =>4; # maximum nodes in x dimention is 2^MAXXw equal to 16 nodes in x dimention
use constant MAXYw =>4; # 16 nodes in y dimention : hence max emulator size is 16X16
use constant MAX_EAw =>8; # maximum destination address width
use constant MAXCw =>4; # 16 message classes
use constant RATIOw =>7; # log2(100)
use constant RAM_Aw =>7;
50,6 → 54,9
use constant EMULATION_TOP => "/mpsoc/src_emulate/emulator_top.v";
 
 
sub get_MAX_PCK_NUM(){MAX_PCK_NUM}
sub get_MAX_SIM_CLKs(){MAX_SIM_CLKs}
sub get_MAX_PCK_SIZ(){MAX_PCK_SIZ}
 
sub check_inserted_ratios {
my $str=shift;
134,7 → 141,7
my $table=def_table(10,2,FALSE);
my $row=0;
my $traffics="tornado,transposed 1,transposed 2,bit reverse,bit complement,random"; #TODO hot spot for emulator
my $traffics="tornado,transposed 1,transposed 2,bit reverse,bit complement,random,shuffle,bit rotation,neighbor"; #TODO hot spot for emulator
#search path
my $dir = Cwd::getcwd();
227,21 → 234,21
my @info= ($mode eq "simulate")? @siminfo : @emulateinfo;
my $coltmp=0;
foreach my $d ( @info) {
$row=noc_param_widget ($emulate, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
($row,$coltmp)=add_param_widget ($emulate, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
}
my $traffic=$emulate->object_get_attribute($sample,"traffic");
 
if ($traffic eq 'hot spot'){
foreach my $d ( @hotspot_info) {
$row=noc_param_widget ($emulate, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
($row,$coltmp)=add_param_widget ($emulate, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
}
my $num=$emulate->object_get_attribute($sample,"HOTSPOT_NUM");
for (my $i=0;$i<$num;$i++){
my $m=$i+1;
$row=noc_param_widget ($emulate, "Hotspot $m tile num:", "HOTSPOT_CORE_$m", 0, 'Spin-button', "0,256,1",
"Defne the tile number which is hotspt. All other nodes will send [Hot Spot traffic percentage] of their traffic to this node ", $table,$row,1,$sample );
($row,$coltmp)=add_param_widget ($emulate, "Hotspot $m tile num:", "HOTSPOT_CORE_$m", 0, 'Spin-button', "0,256,1",
"Defne the tile number which is hotspt. All other nodes will send [Hot Spot traffic percentage] of their traffic to this node ", $table,$row,undef,1,$sample);
}
353,6 → 360,18
my $r=$emulate->object_get_attribute($sample,"ratios");
if(defined $s && defined $name){
$l=gen_label_in_center($name);
$l=def_image_button('icons/diagram.png',$name);
$l-> signal_connect("clicked" => sub{
my $st = ($mode eq "simulate" )? check_sim_sample($emulate,$sample,$info) : check_sample($emulate,$sample,$info);
return if $st==0;
my ($topology, $T1, $T2, $T3, $V, $Fpay) = get_sample_emulation_param($emulate,$sample);
$emulate->object_add_attribute('noc_param','T1',$T1);
$emulate->object_add_attribute('noc_param','T2',$T2);
$emulate->object_add_attribute('noc_param','T3',$T3);
$emulate->object_add_attribute('noc_param','TOPOLOGY',$topology);
show_topology_diagram ($emulate);
});
} else {
$l=gen_label_in_left("Define NoC configuration");
$l->set_markup("<span foreground= 'red' ><b>Define NoC configuration</b></span>");
484,7 → 503,7
# print "\n $sof \t $sof_info\n";
if(!(-f $sof_info)){
add_colored_info($info, "Error: Could not find $name.inf file in $path. An information file is required for each sof file containig the device name and NoC configuration. Press F4 for more help.\n",'red');
add_colored_info($info, "Error: Could not find $name.inf file in $path. An information file is required for each sof file containig the device name and NoC configuration. Press F3 for more help.\n",'red');
$emulate->object_add_attribute ($sample,"status","failed");
$status=0;
}else { #add info
607,7 → 626,7
my $vbox = Gtk2::HBox->new (TRUE,1);
$image = Gtk2::Image->new_from_file ("icons/load.gif") if($status eq "run");
$image = def_icon("icons/button_ok.png") if($status eq "done");
$image = def_icon("icons/warnning.png") if($status eq "failed");
$image = def_icon("icons/warning.png") if($status eq "failed");
#$image_file = "icons/load.gif" if($status eq "run");
if (defined $image) {
807,16 → 826,22
);
}
foreach my $d (@fpgainfo) {
$row=noc_param_widget ($emulate, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,1, $d->{param_parent}, $d->{ref_delay});
my $coltmp=0;
foreach my $d (@fpgainfo) {
($row,$coltmp)=add_param_widget ($emulate, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay});
}
my $generate = def_image_button('icons/gen.png','Generate');
$table->attach ($generate, 0,3, $row, $row+1,'expand','shrink',2,2);
my $generate = def_image_button('icons/gen.png','Gener_ate',FALSE,1);
my $diagram = def_image_button('icons/diagram.png','Diagram');
$table->attach ($generate, 0,2, $row, $row+1,'expand','shrink',2,2);
$table->attach ($diagram, 2,4, $row, $row+1,'expand','shrink',2,2);
$diagram-> signal_connect("clicked" => sub{
show_topology_diagram ($emulate);
});
$generate->signal_connect ('clicked'=> sub{
generate_sof_file($emulate,$info_text) if($mode eq "emulate");
generate_sim_bin_file($emulate,$info_text) if($mode eq "simulate");
});
return $scrolled_win;
828,12 → 853,10
 
 
sub generate_sof_file {
my ($self,$info)=@_;
 
my ($self,$info)=@_;
my $name=$self->object_get_attribute ('fpga_param',"SAVE_NAME");
my $target_dir = "$ENV{'PRONOC_WORK'}/emulate/$name";
my $top = "$target_dir/src_verilog/${name}_top.v";
 
if (!defined $name){
message_dialog("Please define the Save as filed!");
1097,9 → 1120,10
$file = $dialog->get_filename;
my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
if($suffix eq '.EML'){
my $pp= eval { do $file };
if ($@ || !defined $pp){
add_colored_info($info,"**Error reading $file file: $@\n",'red');
my ($pp,$r,$err) = regen_object($file);
if ($r ){
add_colored_info($info,"**Error reading $file file: $err\n",'red');
$dialog->destroy;
return;
}
1141,10 → 1165,53
return %result;
}
 
sub gen_sim_parameter_h {
my ($param_h,$includ_h,$ne,$nr,$router_p,$fifow)=@_;
$param_h =~ s/\d\'b/ /g;
my $text= "
#ifndef INCLUDE_PARAM
#define INCLUDE_PARAM \n \n
 
$param_h
#define NE $ne
#define NR $nr
#define ROUTER_P_NUM $router_p
//simulation parameter
#define MAX_RATIO ".MAX_RATIO."
#define AVG_LATENCY_METRIC \"HEAD_2_TAIL\"
#define TIMSTMP_FIFO_NUM $fifow
$includ_h
\n \n \#endif" ;
return $text;
}
 
sub gen_vrouter_param_v {
my ($simulate,$src_verilog_dr)=@_;
# generate NoC parameter file
my ($noc_param,$pass_param)=gen_noc_param_v($simulate);
open(FILE, ">$src_verilog_dr/parameter.v") || die "Can not open: $!";
my $fifow=$simulate->object_get_attribute('fpga_param','TIMSTMP_FIFO_NUM');
 
 
 
print FILE " \`ifdef INCLUDE_PARAM \n \n
$noc_param
//simulation parameter
localparam MAX_RATIO = ".MAX_RATIO.";
localparam MAX_PCK_NUM = ".MAX_SIM_CLKs.";
localparam MAX_PCK_SIZ = ".MAX_PCK_SIZ.";
localparam MAX_SIM_CLKs= ".MAX_SIM_CLKs.";
localparam TIMSTMP_FIFO_NUM = $fifow;
\n \n \`endif" ;
close FILE;
}
 
 
############
# main
############
1158,7 → 1225,7
my $right_table = Gtk2::Table->new (25, 6, FALSE);
my $main_table = Gtk2::Table->new (25, 12, FALSE);
my ($infobox,$info)= create_text();
add_colors_to_textview($info);
my @pages =(
{page_name=>" Avg. throughput/latency", page_num=>0},
1184,6 → 1251,7
my $generate = def_image_button('icons/forward.png','Run all');
my $open = def_image_button('icons/browse.png','Load');
my $diagram = def_image_button('icons/diagram.png','Diagram');
my ($entrybox,$entry) = def_h_labeled_entry('Save as:',undef);
1201,9 → 1269,10
#$table->attach_defaults ($event_box, $col, $col+1, $row, $row+1);
$main_table->attach_defaults ($h1 , 0, 12, 0,24);
$main_table->attach ($open,0, 3, 24,25,'expand','shrink',2,2);
$main_table->attach ($entrybox,3, 6, 24,25,'expand','shrink',2,2);
$main_table->attach ($generate, 6, 9, 24,25,'expand','shrink',2,2);
$main_table->attach ($open,0, 2, 24,25,'expand','shrink',2,2);
# $main_table->attach ($diagram, 2, 4, 24,25,'expand','shrink',2,2);
$main_table->attach ($entrybox,4, 7, 24,25,'expand','shrink',2,2);
$main_table->attach ($generate, 7, 9, 24,25,'expand','shrink',2,2);
#check soc status every 0.5 second. referesh device table if there is any changes
Glib::Timeout->add (100, sub{
1244,8 → 1313,11
return TRUE;
} );
$diagram-> signal_connect("clicked" => sub{
show_topology_diagram ($emulate);
});
$generate-> signal_connect("clicked" => sub{
my @samples =$emulate->object_get_attribute_order("samples");
foreach my $sample (@samples){
/graph.pl
16,8 → 16,21
$notebook->set_scrollable(TRUE);
$notebook->can_focus(FALSE);
 
 
 
#check if we ned to save all graph results
my $save_all_status = $self->object_get_attribute ("graph_save","save_all_result");
$save_all_status=0 if (!defined $save_all_status);
$self->object_add_attribute ("graph_save","save_all_result",0);
if ($save_all_status ==1){
my $save_path = $self->object_get_attribute ('sim_param','ALL_RESULT_DIR');
if (-d $save_path){
my $results_path = "$save_path/all_results";
rmtree("$results_path");
mkpath("$results_path",1,01777);
save_all_results($self,$pageref,$charts_ref,$results_path);
}
}
foreach my $page (@pages){
my @selects;
my $page_id= "P$page->{page_num}";
70,7 → 83,68
}
 
 
sub save_all_results{
my ($self,$pageref,$charts_ref,$results_path)=@_;
my @pages=@{$pageref};
my @charts=@{$charts_ref};
foreach my $chart (@charts){
my $result_name= "$chart->{result_name}";
my $charttype= "$chart->{type}";
if($charttype eq '2D_line'){
my $file_name = "$results_path/${result_name}.txt";
write_graph_results_in_file($self,$file_name,$result_name,undef,$charttype);
next;
};#3d
my @ratios;
my @x;
my @samples =$self->object_get_attribute_order("samples");
foreach my $sample (@samples){
my $ref=$self->object_get_attribute ($sample,$result_name);
if(defined $ref){
@ratios=get_uniq_keys($ref,@ratios);
}
foreach my $ratio (@ratios){
my @results;
foreach my $sample2 (@samples){
my $ref=$self->object_get_attribute ($sample2,"$result_name");
@x=get_uniq_keys($ref->{$ratio},@x) if(defined $ref);
}
my $i=1;
foreach my $sample (@samples){
my @y;
my $ref=$self->object_get_attribute ($sample,"$result_name");
if(defined $ref){
foreach my $v (@x){
my $w=$ref->{$ratio}->{$v};
push(@y,$w);
}#for v
$results[$i]=\@y if(scalar @x);
$i++;
}#if
}#sample
$results[0]=\@x if(scalar @x);
my $file_name = "$results_path/${result_name}_r$ratio.txt";
write_graph_results_in_file($self,$file_name,$result_name,\@results,$charttype);
}#ratio
}#sample
}#chart
#done saving clear the saving status
}
 
 
sub get_uniq_keys {
my ($ref,@x)=@_;
365,6 → 439,7
#$table->attach ($minues, 9, 10, $row, $row+1,'shrink','shrink',2,2); $row++;
$table->attach ($setting, 9, 10, $row, $row+1,'shrink','shrink',2,2); $row++;
$table->attach ($save, 9, 10, $row, $row+1,'shrink','shrink',2,2); $row++;
while ($row<10){
my $tmp=gen_label_in_left('');
775,8 → 850,10
 
 
my @data=@$ref;
my $coltmp;
foreach my $d (@data) {
$row=noc_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,1, $d->{param_parent}, $d->{ref_delay});
#$row=noc_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row, 1, $d->{param_parent}, $d->{ref_delay});
($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay} ,undef,undef);
}
807,9 → 884,8
 
sub write_image {
my ($self,$graph_name,$image)=@_;
my $save=$self->object_get_attribute("graph_save","save");
my $save=$self->object_get_attribute("graph_save","save");
my $active_graph=$self->object_get_attribute("graph_save","graph_name");
$save=0 if (!defined $save);
$active_graph = 0 if(!defined $active_graph);
842,51 → 918,55
my $save=$self->object_get_attribute("graph_save","save_result");
my $active_graph=$self->object_get_attribute("graph_save","graph_name");
$save=0 if (!defined $save);
$active_graph = 0 if(!defined $active_graph);
$active_graph = 0 if(!defined $active_graph);
if ($save ==1 && $active_graph eq $graph_name){
my $file=$self->object_get_attribute("graph_save","name");
my $ext=$self->object_get_attribute("graph_save","extension");
$self->object_add_attribute("graph_save","save_result",0);
open( my $out, '>', "$file.txt");
if (tell $out )
{
warn "Cannot open $file.txt to write: $!";
}
else
{
if($charttype eq '2D_line'){
my @samples =$self->object_get_attribute_order("samples");
foreach my $sample (@samples){
my $l_name= $self->object_get_attribute($sample,"line_name");
my $ref=$self->object_get_attribute ($sample,$result_name);
my @x;
if(defined $ref) {
print $out "$l_name\n";
foreach my $x (sort {$a<=>$b} keys %{$ref}) {
my $y=$ref->{$x};
print $out "\t$x , $y\n";
}
print $out "\n\n";
}
}#for
} else{
write_3d_graph_results($self,$out,$result_ref);
}
close $out;
}
write_graph_results_in_file($self,"$file.txt",$result_name,$result_ref,$charttype);
}
}
 
sub write_graph_results_in_file{
my ($self,$file_name,$result_name,$result_ref,$charttype)=@_;
open( my $out, '>', $file_name);
if (tell $out )
{
warn "Cannot open $file_name to write: $!";
return;
}
else
{
if($charttype eq '2D_line'){
write_2d_graph_results($self,$out,$result_name);
} else{
write_3d_graph_results($self,$out,$result_ref);
}
close $out;
}
}
 
 
sub write_2d_graph_results{
my ($self,$out,$result_name)=@_;
my @samples =$self->object_get_attribute_order("samples");
foreach my $sample (@samples){
my $l_name= $self->object_get_attribute($sample,"line_name");
my $ref=$self->object_get_attribute ($sample,$result_name);
my @x;
if(defined $ref) {
print $out "$l_name\n";
foreach my $x (sort {$a<=>$b} keys %{$ref}) {
my $y=$ref->{$x};
print $out "\t$x , $y\n";
}
print $out "\n\n";
}
}#for
}
 
 
sub write_3d_graph_results{
my ($self,$out,$result_ref)=@_;
/interface_gen.pl
767,10 → 767,12
}
elsif($state eq "load_file"){
my $file=$intfc_gen->intfc_get_interface_file();
my $pp= eval { do $file };
clone_obj($intfc_gen,$pp);
my ($pp,$r,$err) = regen_object($file);
if ($r){
add_info(\$info,"**Error reading $file file: $err\n");
return;
}
clone_obj($intfc_gen,$pp);
set_gui_status($intfc_gen,"ref",1);
/ip_gen.pl
2,6 → 2,10
use Glib qw/TRUE FALSE/;
use strict;
use warnings;
 
use FindBin;
use lib $FindBin::Bin;
 
use wb_addr;
use interface;
use intfc_gen;
400,6 → 404,8
$lib_hdl->signal_connect("clicked"=> sub{
my $help1="The files and folder that selected here will be copied in genertated processing tile RTL folder.";
my $help2="The file listed here can contain some variable with \${var_name} format. The file genertor will replace them with their values during file generation. The variable can be selected from above listed global vairables";
my $help3='The content here will be added to the generated tile.v file. You can define functions/ tasks etc...';
my %page_info;
$page_info{0}{page_name} = "_Add exsiting HDL file/folder";
$page_info{0}{filed_name}= "hdl_files";
414,6 → 420,14
$page_info{1}{rename_file}=1;
$page_info{1}{folder_en}=0;
$page_info{1}{help}=$help2;
$page_info{2}{page_name} = "_Add to tile.v";
$page_info{2}{filed_name}= "system_v";
$page_info{2}{filed_type}= "file_content";
$page_info{2}{rename_file}=undef;
$page_info{2}{folder_en}=0;
$page_info{2}{help}=$help3;
 
get_source_file($ipgen,$info,0,"Add HDL file(s)", "hw",\%page_info);
 
1152,7 → 1166,7
my ($saved_addr,$saved_width)=$ipgen->ipgen_get_wb_addr($q,0);
my $addr;
if(!defined $saved_addr){
$addr= def_image_button('icons/warnning.png');
$addr= def_image_button('icons/warning.png');
$addr->signal_connect ('clicked'=> sub{
message_dialog("Wishbone slave address range has not been set yet! ");
2093,10 → 2107,13
my ($state,$timeout)= get_gui_status($ipgen);
if($state eq "load_file"){
my $file=$ipgen->ipgen_get("file_name");
my $pp= eval { do $file };
my ($pp,$r,$err) = regen_object($file);
if ($r){
add_info(\$info,"**Error reading $file file: $err\n");
return;
}
clone_obj($ipgen,$pp);
set_gui_status($ipgen,"ref",1);
/mpsoc_gen.pl
2,6 → 2,8
use Glib qw/TRUE FALSE/;
use strict;
use warnings;
use FindBin;
use lib $FindBin::Bin;
 
use mpsoc;
use soc;
12,252 → 14,105
 
use File::Path;
use File::Copy;
 
use Cwd 'abs_path';
 
 
use Gtk2;
use Gtk2::Pango;
 
 
 
 
require "widget.pl";
require "mpsoc_verilog_gen.pl";
require "hdr_file_gen.pl";
require "readme_gen.pl";
require "soc_gen.pl";
require "diagram.pl";
 
sub get_pos{
my ($item,@list)=@_;
my $pos=0;
foreach my $p (@list){
#print "$p eq $item\n";
if ($p eq $item){return $pos;}
$pos++;
}
return undef;
}
my ($item,@list)=@_;
my $pos=0;
foreach my $p (@list){
#print "$p eq $item\n";
if ($p eq $item){return $pos;}
$pos++;
}
return undef;
}
 
 
sub noc_param_widget{
my ($mpsoc,$name,$param, $default,$type,$content,$info, $table,$row,$show,$attribut1,$ref_delay,$new_status)=@_;
my $label =gen_label_in_left(" $name");
my $widget;
my $value=$mpsoc->object_get_attribute($attribut1,$param);
if(! defined $value) {
$mpsoc->object_add_attribute($attribut1,$param,$default);
$mpsoc->object_add_attribute_order($attribut1,$param);
$value=$default;
}
if(! defined $new_status){
$new_status='ref';
}
if ($type eq "Entry"){
$widget=gen_entry($value);
$widget-> signal_connect("changed" => sub{
my $new_param_value=$widget->get_text();
$mpsoc->object_add_attribute($attribut1,$param,$new_param_value);
set_gui_status($mpsoc,$new_status,$ref_delay) if(defined $ref_delay);
 
});
}
elsif ($type eq "Combo-box"){
my @combo_list=split(",",$content);
my $pos=get_pos($value, @combo_list) if(defined $value);
if(!defined $pos){
$mpsoc->object_add_attribute($attribut1,$param,$default);
$pos=get_item_pos($default, @combo_list) if (defined $default);
}
#print " my $pos=get_item_pos($value, @combo_list);\n";
$widget=gen_combo(\@combo_list, $pos);
$widget-> signal_connect("changed" => sub{
my $new_param_value=$widget->get_active_text();
$mpsoc->object_add_attribute($attribut1,$param,$new_param_value);
set_gui_status($mpsoc,$new_status,$ref_delay) if(defined $ref_delay);
 
 
});
}
elsif ($type eq "Spin-button"){
my ($min,$max,$step)=split(",",$content);
$value=~ s/\D//g;
$min=~ s/\D//g;
$max=~ s/\D//g;
$step=~ s/\D//g;
$widget=gen_spin($min,$max,$step);
$widget->set_value($value);
$widget-> signal_connect("value_changed" => sub{
my $new_param_value=$widget->get_value_as_int();
$mpsoc->object_add_attribute($attribut1,$param,$new_param_value);
set_gui_status($mpsoc,$new_status,$ref_delay) if(defined $ref_delay);
 
});
# $box=def_label_spin_help_box ($param,$info, $value,$min,$max,$step, 2);
}
elsif ( $type eq "Check-box"){
$widget = def_hbox(FALSE,0);
my @check;
for (my $i=0;$i<$content;$i++){
$check[$i]= Gtk2::CheckButton->new;
}
for (my $i=0;$i<$content;$i++){
$widget->pack_end( $check[$i], FALSE, FALSE, 0);
my @chars = split("",$value);
#check if saved value match the size of check box
if($chars[0] ne $content ) {
$mpsoc->object_add_attribute($attribut1,$param,$default);
$value=$default;
@chars = split("",$value);
}
#set initial value
#print "\@chars=@chars\n";
for (my $i=0;$i<$content;$i++){
my $loc= (scalar @chars) -($i+1);
if( $chars[$loc] eq '1') {$check[$i]->set_active(TRUE);}
else {$check[$i]->set_active(FALSE);}
}
 
 
#get new value
$check[$i]-> signal_connect("toggled" => sub{
my $new_val="$content\'b";
for (my $i=$content-1; $i >= 0; $i--){
if($check[$i]->get_active()) {$new_val="${new_val}1" ;}
else {$new_val="${new_val}0" ;}
}
$mpsoc->object_add_attribute($attribut1,$param,$new_val);
#print "\$new_val=$new_val\n";
set_gui_status($mpsoc,$new_status,$ref_delay) if(defined $ref_delay);
});
}
 
 
 
 
}
elsif ( $type eq "DIR_path"){
$widget =get_dir_in_object ($mpsoc,$attribut1,$param,$value,'ref',10);
set_gui_status($mpsoc,$new_status,$ref_delay) if(defined $ref_delay);
}
else {
$widget =gen_label_in_left("unsuported widget type!");
}
 
my $inf_bt= gen_button_message ($info,"icons/help.png");
if($show==1){
attach_widget_to_table ($table,$row,$label,$inf_bt,$widget);
$row++;
}
return $row;
}
 
 
 
 
sub initial_default_param{
my $mpsoc=shift;
my @socs=$mpsoc->mpsoc_get_soc_list();
foreach my $soc_name (@socs){
my %param_value;
my $top=$mpsoc->mpsoc_get_soc($soc_name);
my @insts=$top->top_get_all_instances();
my @exceptions=get_NI_instance_list($top);
@insts=get_diff_array(\@insts,\@exceptions);
foreach my $inst (@insts){
my @params=$top->top_get_parameter_list($inst);
foreach my $p (@params){
my ($default,$type,$content,$info,$global_param,$redefine)=$top->top_get_parameter($inst,$p);
$param_value{$p}=$default;
}
}
$top->top_add_default_soc_param(\%param_value);
}
my $mpsoc=shift;
my @socs=$mpsoc->mpsoc_get_soc_list();
foreach my $soc_name (@socs){
my %param_value;
my $top=$mpsoc->mpsoc_get_soc($soc_name);
my @insts=$top->top_get_all_instances();
my @exceptions=get_NI_instance_list($top);
@insts=get_diff_array(\@insts,\@exceptions);
foreach my $inst (@insts){
my @params=$top->top_get_parameter_list($inst);
foreach my $p (@params){
my ($default,$type,$content,$info,$global_param,$redefine)=$top->top_get_parameter($inst,$p);
$param_value{$p}=$default;
}
}
$top->top_add_default_soc_param(\%param_value);
}
}
 
#############
# get_soc_lists
# get_soc_lists
############
 
sub get_soc_list {
my ($mpsoc,$info)=@_;
my ($mpsoc,$info)=@_;
 
my $path=$mpsoc->object_get_attribute('setting','soc_path');
$path =~ s/ /\\ /g;
my @socs;
my @files = glob "$path/*.SOC";
for my $p (@files){
# Read
my $soc = eval { do $p };
if ($@ || !defined $soc){
add_info(\$info,"**Error reading $p file: $@\n");
next;
}
my $top=$soc->soc_get_top();
if (defined $top){
my @instance_list=$top->top_get_all_instances();
#check if the soc has ni port
foreach my $instanc(@instance_list){
my $category=$top->top_get_def_of_instance($instanc,'category');
if($category eq 'NoC')
{
my $name=$soc->object_get_attribute('soc_name');
$mpsoc->mpsoc_add_soc($name,$top);
#print" $name\n";
}
}
}
}#files
# initial default soc parameter
initial_default_param($mpsoc);
return $mpsoc->mpsoc_get_soc_list;
 
 
 
my $path=$mpsoc->object_get_attribute('setting','soc_path');
$path =~ s/ /\\ /g;
my @socs;
my @files = glob "$path/*.SOC";
for my $p (@files){
my ($soc,$r,$err) = regen_object($p);
# Read
if ($r){
add_info(\$info,"**Error reading $p file: $err\n");
next;
}
my $top=$soc->soc_get_top();
if (defined $top){
my @instance_list=$top->top_get_all_instances();
#check if the soc has ni port
foreach my $instanc(@instance_list){
my $category=$top->top_get_def_of_instance($instanc,'category');
if($category eq 'NoC')
{
my $name=$soc->object_get_attribute('soc_name');
$mpsoc->mpsoc_add_soc($name,$top);
#print" $name\n";
}
}
}
}# files
# initial default soc parameter
initial_default_param($mpsoc);
return $mpsoc->mpsoc_get_soc_list;
}
 
 
sub get_NI_instance_list {
my $top=shift;
my @nis;
my @instance_list=$top->top_get_all_instances();
#check if the soc has ni port
foreach my $instanc(@instance_list){
my $category=$top->top_get_def_of_instance($instanc,'category');
push(@nis,$instanc) if($category eq 'NoC') ;
}
return @nis;
my $top=shift;
my @nis;
my @instance_list=$top->top_get_all_instances();
#check if the soc has ni port
foreach my $instanc(@instance_list){
my $category=$top->top_get_def_of_instance($instanc,'category');
push(@nis,$instanc) if($category eq 'NoC') ;
}
return @nis;
}
 
####################
265,255 → 120,247
###########################
sub b_box{
# create a new button
my @label=@_;
my $button = Gtk2::Button->new_from_stock(@label);
my $box=def_vbox(FALSE,5);
$box->pack_start($button, FALSE, FALSE,0);
return ($box,$button);
my @label=@_;
my $button = Gtk2::Button->new_from_stock(@label);
my $box=def_vbox(FALSE,5);
$box->pack_start($button, FALSE, FALSE,0);
return ($box,$button);
 
}
 
sub get_conflict_decision{
my ($mpsoc,$name,$inserted,$conflicts,$msg)=@_;
$msg="\tThe inserted tile number(s) have been mapped previously to \n\t\t\"$msg\".\n\tDo you want to remove the conflicted tiles number(s) in newly \n\tinsterd range or remove them from the previous ones? ";
my $wind=def_popwin_size(10,30,"warning",'percent');
my $label= gen_label_in_left($msg);
my $table=def_table(2,6,FALSE);
$table->attach_defaults ($label , 0, 6, 0,1);
$wind->add($table);
my ($mpsoc,$name,$inserted,$conflicts,$msg)=@_;
$msg="\tThe inserted tile number(s) have been mapped previously to \n\t\t\"$msg\".\n\tDo you want to remove the conflicted tiles number(s) in newly \n\tinsterd range or remove them from the previous ones? ";
my $wind=def_popwin_size(10,30,"warning",'percent');
my $label= gen_label_in_left($msg);
my $table=def_table(2,6,FALSE);
$table->attach_defaults ($label , 0, 6, 0,1);
$wind->add($table);
 
my ($box1,$b1)= b_box("Remove Previous");
my ($box2,$b2)= b_box("Remove Current");
my ($box3,$b3)= b_box("Cancel");
$table->attach_defaults ($box1 , 0, 1, 1,2);
$table->attach_defaults ($box2 , 3, 4, 1,2);
$table->attach_defaults ($box3 , 5, 6, 1,2);
my ($box1,$b1)= b_box("Remove Previous");
my ($box2,$b2)= b_box("Remove Current");
my ($box3,$b3)= b_box("Cancel");
$table->attach_defaults ($box1 , 0, 1, 1,2);
$table->attach_defaults ($box2 , 3, 4, 1,2);
$table->attach_defaults ($box3 , 5, 6, 1,2);
 
$wind->show_all();
$b1->signal_connect( "clicked"=> sub{ #Remove Previous
my @socs=$mpsoc->mpsoc_get_soc_list();
foreach my $p (@socs){
if($p ne $name){
my @taken_tiles=$mpsoc->mpsoc_get_soc_tiles_num($p);
my @diff=get_diff_array(\@taken_tiles,$inserted);
$mpsoc->mpsoc_add_soc_tiles_num($p,\@diff) if(scalar @diff );
$mpsoc->mpsoc_add_soc_tiles_num($p,undef) if(scalar @diff ==0 );
}
}
$mpsoc->mpsoc_add_soc_tiles_num($name,$inserted) if(defined $inserted );
set_gui_status($mpsoc,"ref",1);
$wind->destroy();
});
$b2->signal_connect( "clicked"=> sub{#Remove Current
my @new= get_diff_array($inserted,$conflicts);
$mpsoc->mpsoc_add_soc_tiles_num($name,\@new) if(scalar @new );
$mpsoc->mpsoc_add_soc_tiles_num($name,undef) if(scalar @new ==0 );
set_gui_status($mpsoc,"ref",1);
$wind->destroy();
});
$b3->signal_connect( "clicked"=> sub{
$wind->destroy();
});
}
$wind->show_all();
$b1->signal_connect( "clicked"=> sub{ #Remove Previous
my @socs=$mpsoc->mpsoc_get_soc_list();
foreach my $p (@socs){
if($p ne $name){
my @taken_tiles=$mpsoc->mpsoc_get_soc_tiles_num($p);
my @diff=get_diff_array(\@taken_tiles,$inserted);
$mpsoc->mpsoc_add_soc_tiles_num($p,\@diff) if(scalar @diff );
$mpsoc->mpsoc_add_soc_tiles_num($p,undef) if(scalar @diff ==0 );
}
}
$mpsoc->mpsoc_add_soc_tiles_num($name,$inserted) if(defined $inserted );
set_gui_status($mpsoc,"ref",1);
$wind->destroy();
});
$b2->signal_connect( "clicked"=> sub{#Remove Current
my @new= get_diff_array($inserted,$conflicts);
$mpsoc->mpsoc_add_soc_tiles_num($name,\@new) if(scalar @new );
$mpsoc->mpsoc_add_soc_tiles_num($name,undef) if(scalar @new ==0 );
set_gui_status($mpsoc,"ref",1);
$wind->destroy();
});
$b3->signal_connect( "clicked"=> sub{
$wind->destroy();
});
}
 
 
 
#############
# check_inserted_ip_nums
# check_inserted_ip_nums
##########
 
 
sub check_inserted_ip_nums{
my ($mpsoc,$name,$str)=@_;
my @all_num=();
$str= remove_all_white_spaces ($str);
if($str !~ /^[0-9.:,]+$/){ message_dialog ("The Ip numbers contains invalid character" ); return; }
my @chunks=split(',',$str);
foreach my $p (@chunks){
my @range=split(':',$p);
my $size= scalar @range;
if($size==1){ # its a number
if ( grep( /^$range[0]$/, @all_num ) ) { message_dialog ("Multiple definition for Ip number $range[0]" ); return; }
push(@all_num,$range[0]);
}elsif($size ==2){# its a range
my($min,$max)=@range;
if($min>$max) {message_dialog ("invalid range: [$p]" ); return;}
for (my $i=$min; $i<=$max; $i++){
if ( grep( /^$i$/, @all_num ) ) { message_dialog ("Multiple definition for Ip number $i in $p" ); return; }
push(@all_num,$i);
}
}else{message_dialog ("invalid range: [$p]" ); return; }
}
#check if range does not exceed the tile numbers
my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
my $max_tile_num=$nx*$ny;
my @f=sort { $a <=> $b } @all_num;
my @l;
foreach my $num (@f){
push(@l,$num) if($num<$max_tile_num);
}
@all_num=@l;
#check if any ip number exists in the rest
my $conflicts_msg;
my @conflicts;
my @socs=$mpsoc->mpsoc_get_soc_list();
foreach my $p (@socs){
if($p ne $name){
my @taken_tiles=$mpsoc->mpsoc_get_soc_tiles_num($p);
my @c=get_common_array(\@all_num,\@taken_tiles);
if (scalar @c) {
my $str=join(',', @c);
$conflicts_msg = (defined $conflicts_msg)? "$conflicts_msg\n\t\t $str->$p" : "$str->$p";
@conflicts= (defined $conflicts_msg)? (@conflicts,@c): @c;
}
}#if
}
if (defined $conflicts_msg) {
get_conflict_decision($mpsoc,$name,\@all_num,\@conflicts,$conflicts_msg);
}else {
#save the entered ips
if( scalar @all_num>0){ $mpsoc->mpsoc_add_soc_tiles_num($name,\@all_num);}
else {$mpsoc->mpsoc_add_soc_tiles_num($name,undef);}
set_gui_status($mpsoc,"ref",1);
}
 
 
my ($mpsoc,$name,$str)=@_;
my @all_num=();
$str= remove_all_white_spaces ($str);
if($str !~ /^[0-9.:,]+$/){ message_dialog ("The Ip numbers contains invalid character" ); return; }
my @chunks=split(',',$str);
foreach my $p (@chunks){
my @range=split(':',$p);
my $size= scalar @range;
if($size==1){ # its a number
if ( grep( /^$range[0]$/, @all_num ) ) { message_dialog ("Multiple definition for Ip number $range[0]" ); return; }
push(@all_num,$range[0]);
}elsif($size ==2){# its a range
my($min,$max)=@range;
if($min>$max) {message_dialog ("invalid range: [$p]" ); return;}
for (my $i=$min; $i<=$max; $i++){
if ( grep( /^$i$/, @all_num ) ) { message_dialog ("Multiple definition for Ip number $i in $p" ); return; }
push(@all_num,$i);
}
}else{message_dialog ("invalid range: [$p]" ); return; }
}
#check if range does not exceed the tile numbers
my ($max_tile_num)=get_topology_info($mpsoc);
my @f=sort { $a <=> $b } @all_num;
my @l;
foreach my $num (@f){
push(@l,$num) if($num<$max_tile_num);
}
@all_num=@l;
#check if any ip number exists in the rest
my $conflicts_msg;
my @conflicts;
my @socs=$mpsoc->mpsoc_get_soc_list();
foreach my $p (@socs){
if($p ne $name){
my @taken_tiles=$mpsoc->mpsoc_get_soc_tiles_num($p);
my @c=get_common_array(\@all_num,\@taken_tiles);
if (scalar @c) {
my $str=join(',', @c);
$conflicts_msg = (defined $conflicts_msg)? "$conflicts_msg\n\t\t $str->$p" : "$str->$p";
@conflicts= (defined $conflicts_msg)? (@conflicts,@c): @c;
}
}#if
}
if (defined $conflicts_msg) {
get_conflict_decision($mpsoc,$name,\@all_num,\@conflicts,$conflicts_msg);
}else {
#save the entered ips
if( scalar @all_num>0){ $mpsoc->mpsoc_add_soc_tiles_num($name,\@all_num);}
else {$mpsoc->mpsoc_add_soc_tiles_num($name,undef);}
set_gui_status($mpsoc,"ref",1);
}
}
 
 
 
 
#################
# get_soc_parameter_setting
################
 
sub get_soc_parameter_setting{
my ($mpsoc,$soc_name,$tile)=@_;
my $window = (defined $tile)? def_popwin_size(40,40,"Parameter setting for $soc_name located in tile($tile) ",'percent'):def_popwin_size(40,40,"Default Parameter setting for $soc_name ",'percent');
my $table = def_table(10, 7, TRUE);
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
$scrolled_win->set_policy( "automatic", "automatic" );
$scrolled_win->add_with_viewport($table);
my $row=0;
my $top=$mpsoc->mpsoc_get_soc($soc_name);
#read soc parameters
my %param_value=(defined $tile) ? $top->top_get_custom_soc_param($tile) : $top->top_get_default_soc_param();
my @insts=$top->top_get_all_instances();
my @exceptions=get_NI_instance_list($top);
@insts=get_diff_array(\@insts,\@exceptions);
foreach my $inst (@insts){
my @params=$top->top_get_parameter_list($inst);
foreach my $p (@params){
my ($default,$type,$content,$info,$global_param,$redefine)=$top->top_get_parameter($inst,$p);
if ($type eq "Entry"){
my $entry=gen_entry($param_value{$p});
$table->attach_defaults ($entry, 3, 6, $row, $row+1);
$entry-> signal_connect("changed" => sub{$param_value{$p}=$entry->get_text();});
}
elsif ($type eq "Combo-box"){
my @combo_list=split(",",$content);
my $pos=get_item_pos($param_value{$p}, @combo_list) if(defined $param_value{$p});
my $combo=gen_combo(\@combo_list, $pos);
$table->attach_defaults ($combo, 3, 6, $row, $row+1);
$combo-> signal_connect("changed" => sub{$param_value{$p}=$combo->get_active_text();});
}
elsif ($type eq "Spin-button"){
my ($min,$max,$step)=split(",",$content);
$param_value{$p}=~ s/\D//g;
$min=~ s/\D//g;
$max=~ s/\D//g;
$step=~ s/\D//g;
my $spin=gen_spin($min,$max,$step);
$spin->set_value($param_value{$p});
$table->attach_defaults ($spin, 3, 4, $row, $row+1);
$spin-> signal_connect("value_changed" => sub{$param_value{$p}=$spin->get_value_as_int();});
# $box=def_label_spin_help_box ($param,$info, $value,$min,$max,$step, 2);
}
my $label =gen_label_in_center($p);
$table->attach_defaults ($label, 0, 3, $row, $row+1);
if (defined $info){
my $info_button=def_image_button('icons/help.png');
$table->attach_defaults ($info_button, 6, 7, $row, $row+1);
$info_button->signal_connect('clicked'=>sub{
message_dialog($info);
});
}
$row++;
}
}
my $ok = def_image_button('icons/select.png','OK');
my $okbox=def_hbox(TRUE,0);
$okbox->pack_start($ok, FALSE, FALSE,0);
my $mtable = def_table(10, 1, TRUE);
my ($mpsoc,$soc_name,$tile)=@_;
my $window = (defined $tile)? def_popwin_size(40,40,"Parameter setting for $soc_name located in tile($tile) ",'percent'):def_popwin_size(40,40,"Default Parameter setting for $soc_name ",'percent');
my $table = def_table(10, 7, TRUE);
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
$scrolled_win->set_policy( "automatic", "automatic" );
$scrolled_win->add_with_viewport($table);
my $row=0;
my $top=$mpsoc->mpsoc_get_soc($soc_name);
#read soc parameters
my %param_value=(defined $tile) ? $top->top_get_custom_soc_param($tile) : $top->top_get_default_soc_param();
my @insts=$top->top_get_all_instances();
my @exceptions=get_NI_instance_list($top);
@insts=get_diff_array(\@insts,\@exceptions);
foreach my $inst (@insts){
my @params=$top->top_get_parameter_list($inst);
foreach my $p (@params){
my ($default,$type,$content,$info,$global_param,$redefine)=$top->top_get_parameter($inst,$p);
if ($type eq "Entry"){
my $entry=gen_entry($param_value{$p});
$table->attach_defaults ($entry, 3, 6, $row, $row+1);
$entry-> signal_connect("changed" => sub{$param_value{$p}=$entry->get_text();});
}
elsif ($type eq "Combo-box"){
my @combo_list=split(",",$content);
my $pos=get_item_pos($param_value{$p}, @combo_list) if(defined $param_value{$p});
my $combo=gen_combo(\@combo_list, $pos);
$table->attach_defaults ($combo, 3, 6, $row, $row+1);
$combo-> signal_connect("changed" => sub{$param_value{$p}=$combo->get_active_text();});
}
elsif ($type eq "Spin-button"){
my ($min,$max,$step)=split(",",$content);
$param_value{$p}=~ s/\D//g;
$min=~ s/\D//g;
$max=~ s/\D//g;
$step=~ s/\D//g;
my $spin=gen_spin($min,$max,$step);
$spin->set_value($param_value{$p});
$table->attach_defaults ($spin, 3, 4, $row, $row+1);
$spin-> signal_connect("value_changed" => sub{$param_value{$p}=$spin->get_value_as_int();});
# $box=def_label_spin_help_box ($param,$info, $value,$min,$max,$step, 2);
}
my $label =gen_label_in_center($p);
$table->attach_defaults ($label, 0, 3, $row, $row+1);
if (defined $info){
my $info_button=def_image_button('icons/help.png');
$table->attach_defaults ($info_button, 6, 7, $row, $row+1);
$info_button->signal_connect('clicked'=>sub{
message_dialog($info);
});
}
$row++;
}
}
my $ok = def_image_button('icons/select.png','OK');
my $okbox=def_hbox(TRUE,0);
$okbox->pack_start($ok, FALSE, FALSE,0);
my $mtable = def_table(10, 1, TRUE);
 
$mtable->attach_defaults($scrolled_win,0,1,0,9);
$mtable->attach_defaults($okbox,0,1,9,10);
$window->add ($mtable);
$window->show_all();
$ok-> signal_connect("clicked" => sub{
$window->destroy;
#save new values
if(!defined $tile ) {
$top->top_add_default_soc_param(\%param_value);
}
else {
$top->top_add_custom_soc_param(\%param_value,$tile);
}
#set_gui_status($mpsoc,"refresh_soc",1);
#$$refresh_soc->clicked;
});
$mtable->attach_defaults($scrolled_win,0,1,0,9);
$mtable->attach_defaults($okbox,0,1,9,10);
$window->add ($mtable);
$window->show_all();
$ok-> signal_connect("clicked" => sub{
$window->destroy;
#save new values
if(!defined $tile ) {
$top->top_add_default_soc_param(\%param_value);
}
else {
$top->top_add_custom_soc_param(\%param_value,$tile);
}
#set_gui_status($mpsoc,"refresh_soc",1);
#$$refresh_soc->clicked;
});
}
 
 
 
521,58 → 368,58
 
 
################
# tile_set_widget
# tile_set_widget
################
 
sub tile_set_widget{
my ($mpsoc,$soc_name,$num,$table,$show,$row)=@_;
#my $lable=gen_label_in_left($soc);
my @all_num= $mpsoc->mpsoc_get_soc_tiles_num($soc_name);
my $init=compress_nums(@all_num);
my $entry;
if (defined $init){$entry=gen_entry($init) ;}
else {$entry=gen_entry();}
my $set= def_image_button('icons/right.png');
my $remove= def_image_button('icons/cancel.png');
#my $setting= def_image_button('icons/setting.png','setting');
my $button = def_colored_button($soc_name,$num);
$button->signal_connect("clicked"=> sub{
get_soc_parameter_setting($mpsoc,$soc_name,undef);
});
$set->signal_connect("clicked"=> sub{
my $data=$entry->get_text();
check_inserted_ip_nums($mpsoc,$soc_name,$data);
});
$remove->signal_connect("clicked"=> sub{
$mpsoc->mpsoc_remove_soc($soc_name);
set_gui_status($mpsoc,"ref",1);
my ($mpsoc,$soc_name,$num,$table,$show,$row)=@_;
#my $lable=gen_label_in_left($soc);
my @all_num= $mpsoc->mpsoc_get_soc_tiles_num($soc_name);
my $init=compress_nums(@all_num);
my $entry;
if (defined $init){$entry=gen_entry($init) ;}
else {$entry=gen_entry();}
my $set= def_image_button('icons/right.png');
my $remove= def_image_button('icons/cancel.png');
#my $setting= def_image_button('icons/setting.png','setting');
my $button = def_colored_button($soc_name,$num);
$button->signal_connect("clicked"=> sub{
get_soc_parameter_setting($mpsoc,$soc_name,undef);
});
$set->signal_connect("clicked"=> sub{
my $data=$entry->get_text();
check_inserted_ip_nums($mpsoc,$soc_name,$data);
});
$remove->signal_connect("clicked"=> sub{
$mpsoc->mpsoc_remove_soc($soc_name);
set_gui_status($mpsoc,"ref",1);
 
});
});
 
if($show){
$table->attach ( $button, 0, 1, $row,$row+1,'fill','fill',2,2);
$table->attach ( $remove, 1, 2, $row,$row+1,'fill','shrink',2,2);
$table->attach ( $entry , 2, 3, $row,$row+1,'fill','shrink',2,2);
$table->attach ( $set, 3, 4, $row,$row+1,'fill','shrink',2,2);
$table->attach ( $button, 0, 1, $row,$row+1,'fill','fill',2,2);
$table->attach ( $remove, 1, 2, $row,$row+1,'fill','shrink',2,2);
$table->attach ( $entry , 2, 3, $row,$row+1,'fill','shrink',2,2);
$table->attach ( $set, 3, 4, $row,$row+1,'fill','shrink',2,2);
 
$row++;
}
return $row;
}
$row++;
}
return $row;
}
 
 
 
579,116 → 426,112
 
 
##################
# defualt_tilles_setting
# defualt_tilles_setting
###################
 
sub defualt_tilles_setting {
my ($mpsoc,$table,$show,$row,$info)=@_;
#title
my $separator1 = Gtk2::HSeparator->new;
my $separator2 = Gtk2::HSeparator->new;
my $title2=gen_label_in_center("Tile Configuration");
my $box1=def_vbox(FALSE, 1);
$box1->pack_start( $separator1, FALSE, FALSE, 3);
$box1->pack_start( $title2, FALSE, FALSE, 3);
$box1->pack_start( $separator2, FALSE, FALSE, 3);
if($show){$table->attach_defaults ($box1 ,0,4, $row,$row+1);$row++;}
my $label = gen_label_in_left("Tiles path:");
my $entry = Gtk2::Entry->new;
my $browse= def_image_button("icons/browse.png");
my $file= $mpsoc->object_get_attribute('setting','soc_path');
if(defined $file){$entry->set_text($file);}
$browse->signal_connect("clicked"=> sub{
my $entry_ref=$_[1];
my $file;
my ($mpsoc,$table,$show,$row,$info)=@_;
#title
my $separator1 = Gtk2::HSeparator->new;
my $separator2 = Gtk2::HSeparator->new;
my $title2=gen_label_in_center("Tile Configuration");
my $box1=def_vbox(FALSE, 1);
$box1->pack_start( $separator1, FALSE, FALSE, 3);
$box1->pack_start( $title2, FALSE, FALSE, 3);
$box1->pack_start( $separator2, FALSE, FALSE, 3);
if($show){$table->attach_defaults ($box1 ,0,4, $row,$row+1);$row++;}
my $label = gen_label_in_left("Tiles path:");
my $entry = Gtk2::Entry->new;
my $browse= def_image_button("icons/browse.png");
my $file= $mpsoc->object_get_attribute('setting','soc_path');
if(defined $file){$entry->set_text($file);}
$browse->signal_connect("clicked"=> sub{
my $entry_ref=$_[1];
my $file;
 
 
 
 
 
my $dialog = Gtk2::FileChooserDialog->new(
'Select tile directory', undef,
# 'open',
'select-folder',
'gtk-cancel' => 'cancel',
'gtk-ok' => 'ok',
);
'Select tile directory', undef,
# 'open',
'select-folder',
'gtk-cancel' => 'cancel',
'gtk-ok' => 'ok',
);
if ( "ok" eq $dialog->run ) {
$file = $dialog->get_filename;
$$entry_ref->set_text($file);
$mpsoc->object_add_attribute('setting','soc_path',$file);
$mpsoc->mpsoc_remove_all_soc();
set_gui_status($mpsoc,"ref",1);
#check_input_file($file,$socgen,$info);
#print "file = $file\n";
}
$dialog->destroy;
if ( "ok" eq $dialog->run ) {
$file = $dialog->get_filename;
$$entry_ref->set_text($file);
$mpsoc->object_add_attribute('setting','soc_path',$file);
$mpsoc->mpsoc_remove_all_soc();
set_gui_status($mpsoc,"ref",1);
#check_input_file($file,$socgen,$info);
#print "file = $file\n";
}
$dialog->destroy;
 
 
} , \$entry);
$entry->signal_connect("activate"=>sub{
my $file_name=$entry->get_text();
$mpsoc->object_add_attribute('setting','soc_path',$file_name);
$mpsoc->mpsoc_remove_all_soc();
set_gui_status($mpsoc,"ref",1);
#check_input_file($file_name,$socgen,$info);
});
if($show){
my $tmp=gen_label_in_left(" ");
$table->attach ($label, 0, 1 , $row,$row+1,'fill','shrink',2,2);
$table->attach ($tmp, 1, 2 , $row,$row+1,'fill','shrink',2,2);
$table->attach ($entry, 2, 3 , $row,$row+1,'fill','shrink',2,2);
$table->attach ($browse, 3, 4, $row,$row+1,'fill','shrink',2,2);
$row++;
}
my @socs=$mpsoc->mpsoc_get_soc_list();
if( scalar @socs == 0){
@socs=get_soc_list($mpsoc,$info);
}
@socs=$mpsoc->mpsoc_get_soc_list();
my $lab1=gen_label_in_center(' Tile name');
my $lab2=gen_label_help('Define the tile numbers that each IP is mapped to.
} , \$entry);
$entry->signal_connect("activate"=>sub{
my $file_name=$entry->get_text();
$mpsoc->object_add_attribute('setting','soc_path',$file_name);
$mpsoc->mpsoc_remove_all_soc();
set_gui_status($mpsoc,"ref",1);
#check_input_file($file_name,$socgen,$info);
});
if($show){
my $tmp=gen_label_in_left(" ");
$table->attach ($label, 0, 1 , $row,$row+1,'fill','shrink',2,2);
$table->attach ($tmp, 1, 2 , $row,$row+1,'fill','shrink',2,2);
$table->attach ($entry, 2, 3 , $row,$row+1,'fill','shrink',2,2);
$table->attach ($browse, 3, 4, $row,$row+1,'fill','shrink',2,2);
$row++;
}
my @socs=$mpsoc->mpsoc_get_soc_list();
if( scalar @socs == 0){
@socs=get_soc_list($mpsoc,$info);
}
@socs=$mpsoc->mpsoc_get_soc_list();
my $lab1=gen_label_in_center(' Tile name');
my $lab2=gen_label_help('Define the tile numbers that each IP is mapped to.
you can add individual numbers or ranges as follow
eg: 0,2,5:10
', ' Tile numbers ');
if($show){
$table->attach_defaults ($lab1 ,0,1, $row,$row+1);
$table->attach_defaults ($lab2 ,2,3, $row,$row+1);$row++;
}
my $soc_num=0;
foreach my $soc_name (@socs){
$row=tile_set_widget ($mpsoc,$soc_name,$soc_num,$table,$show,$row);
$soc_num++;
}
return $row;
eg: 0,2,5:10
', ' Tile numbers ');
if($show){
$table->attach_defaults ($lab1 ,0,1, $row,$row+1);
$table->attach_defaults ($lab2 ,2,3, $row,$row+1);$row++;
}
my $soc_num=0;
foreach my $soc_name (@socs){
$row=tile_set_widget ($mpsoc,$soc_name,$soc_num,$table,$show,$row);
$soc_num++;
}
return $row;
}
 
 
699,488 → 542,484
######################
 
sub noc_config{
my ($mpsoc,$table)=@_;
my ($mpsoc,$table)=@_;
 
#title
my $row=0;
my $title=gen_label_in_center("NoC Configuration");
$table->attach ($title , 0, 4, $row, $row+1,'expand','shrink',2,2); $row++;
my $separator = Gtk2::HSeparator->new;
$table->attach ($separator , 0, 4 , $row, $row+1,'fill','fill',2,2); $row++;
#title
my $row=0;
my $title=gen_label_in_center("NoC Configuration");
$table->attach ($title , 0, 4, $row, $row+1,'expand','shrink',2,2); $row++;
my $separator = Gtk2::HSeparator->new;
$table->attach ($separator , 0, 4 , $row, $row+1,'fill','fill',2,2); $row++;
 
my $label;
my $param;
my $default;
my $type;
my $content;
my $info;
#parameter start
my $b1;
my $show_noc=$mpsoc->object_get_attribute('setting','show_noc_setting');
if(!defined $show_noc){
$show_noc=1;
$mpsoc->object_add_attribute('setting','show_noc_setting',$show_noc);
}
if($show_noc == 0){
$b1= def_image_button("icons/down.png","NoC Parameters");
$label=gen_label_in_center(' ');
$table->attach ( $label , 2, 3, $row,$row+1 ,'fill','shrink',2,2);
$table->attach ( $b1 , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
#Router type
$label='Router Type';
$param='ROUTER_TYPE';
$default='"VC_BASED"';
$content='"INPUT_QUEUED","VC_BASED"';
$type='Combo-box';
my $label;
my $param;
my $default;
my $type;
my $content;
my $info;
#parameter start
my $b1;
my $show_noc=$mpsoc->object_get_attribute('setting','show_noc_setting');
if(!defined $show_noc){
$show_noc=1;
$mpsoc->object_add_attribute('setting','show_noc_setting',$show_noc);
}
if($show_noc == 0){
$b1= def_image_button("icons/down.png","NoC Parameters");
$label=gen_label_in_center(' ');
$table->attach ( $label , 2, 3, $row,$row+1 ,'fill','shrink',2,2);
$table->attach ( $b1 , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
my $coltmp=0;
#Router type
$label='Router Type';
$param='ROUTER_TYPE';
$default='"VC_BASED"';
$content='"INPUT_QUEUED","VC_BASED"';
$type='Combo-box';
$info=" Input-queued: simple router with low performance and does not support fully adaptive routing.
VC-based routers offer higher performance, fully adaptive routing and traffic isolation for different packet classes.";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_type',1);
my $router_type=$mpsoc->object_get_attribute('noc_type',"ROUTER_TYPE");
#topology
$label='Topology';
$param='TOPOLOGY';
$default='"MESH"';
$content='"MESH","TORUS","RING","LINE"';
$type='Combo-box';
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$show_noc,'noc_type',1);
my $router_type=$mpsoc->object_get_attribute('noc_type',"ROUTER_TYPE");
#topology
$label='Topology';
$param='TOPOLOGY';
$default='"MESH"';
$content='"MESH","TORUS","RING","LINE","FATTREE","TREE"';
$type='Combo-box';
$info="NoC topology";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
my $topology=$mpsoc->object_get_attribute('noc_param','TOPOLOGY');
#Routers per row
$label= 'Routers per row';
$param= 'NX';
$default=' 2';
$content=($topology eq '"MESH"' || $topology eq '"TORUS"') ? '2,16,1':'2,64,1';
$info= 'Number of NoC routers in row (X dimention)';
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$show_noc,'noc_param',1);
my $topology=$mpsoc->object_get_attribute('noc_param','TOPOLOGY');
#topology T1 parameter
$label= ($topology eq '"FATTREE"' || $topology eq '"TREE"')? 'K' : 'Routers per row';
$param= 'T1';
$default= '2';
$content=($topology eq '"MESH"' || $topology eq '"TORUS"') ? '2,16,1':
($topology eq '"FATTREE"' || $topology eq '"TREE"' )? '2,6,1':'2,64,1';
$info= ($topology eq '"FATTREE"' || $topology eq '"TREE"' )? 'number of last level individual router`s endpoints.' :'Number of NoC routers in row (X dimention)';
$type= 'Spin-button';
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$show_noc,'noc_param',1);
 
#Routers per column
if($topology eq '"MESH"' || $topology eq '"TORUS"') {
$label= 'Routers per column';
$param= 'NY';
$default=' 2';
$content='2,16,1';
$info= 'Number of NoC routers in column (Y dimention)';
$type= 'Spin-button';
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
} else {
$mpsoc->object_add_attribute('noc_param','NY',1);
}
#VC number per port
if($router_type eq '"VC_BASED"'){
my $v=$mpsoc->object_get_attribute('noc_param','V');
if(defined $v){ $mpsoc->object_add_attribute('noc_param','V',2) if($v eq 1);}
$label='VC number per port';
$param='V';
$default='2';
$type='Spin-button';
$content='2,16,1';
$info='Number of Virtual Channel per each router port';
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
} else {
$mpsoc->object_add_attribute('noc_param','V',1);
$mpsoc->object_add_attribute('noc_param','C',0);
}
#buffer width per VC
$label=($router_type eq '"VC_BASED"')? 'Buffer flits per VC': "Buffer flits";
$param='B';
#Topology T2 parameter
if($topology eq '"MESH"' || $topology eq '"TORUS"' || $topology eq '"FATTREE"' || $topology eq '"TREE"' ) {
$label= ($topology eq '"FATTREE"' || $topology eq '"TREE"')? 'L' :'Routers per column';
$param= 'T2';
$default='2';
$content='2,16,1';
$info= ($topology eq '"FATTREE"' || $topology eq '"TREE"')? 'Fattree layer number (The height of FT)':'Number of NoC routers in column (Y dimention)';
$type= 'Spin-button';
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$show_noc,'noc_param',1);
} else {
$mpsoc->object_add_attribute('noc_param','T2',1);
}
#Topology T3 parameter
if($topology eq '"MESH"' || $topology eq '"TORUS"' || $topology eq '"RING"' || $topology eq '"LINE"') {
$label="Router's endpoint number";
$param= 'T3';
$default='1';
$content='1,4,1';
$info= "In $topology topology, each router can have up to 4 endpoint processing tile.";
$type= 'Spin-button';
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$show_noc,'noc_param',1);
}
 
#VC number per port
if($router_type eq '"VC_BASED"'){
my $v=$mpsoc->object_get_attribute('noc_param','V');
if(defined $v){ $mpsoc->object_add_attribute('noc_param','V',2) if($v eq 1);}
$label='VC number per port';
$param='V';
$default='2';
$type='Spin-button';
$content='2,16,1';
$info='Number of Virtual Channel per each router port';
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$show_noc,'noc_param',1);
} else {
$mpsoc->object_add_attribute('noc_param','V',1);
$mpsoc->object_add_attribute('noc_param','C',0);
}
#buffer width per VC
$label=($router_type eq '"VC_BASED"')? 'Buffer flits per VC': "Buffer flits";
$param='B';
$default='4';
$content='2,256,1';
$type='Spin-button';
$info=($router_type eq '"VC_BASED"')? 'Buffer queue size per VC in flits' : 'Buffer queue size in flits';
$row= noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',undef);
#packet payload width
$label='Payload width';
$param='Fpay';
$default='32';
$content='32,256,32';
$type='Spin-button';
$info=($router_type eq '"VC_BASED"')? 'Buffer queue size per VC in flits' : 'Buffer queue size in flits';
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$show_noc,'noc_param',undef);
#packet payload width
$label='Payload width';
$param='Fpay';
$default='32';
$content='32,256,32';
$type='Spin-button';
$info="The packet payload width in bits";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info,$table,$row,$show_noc,'noc_param',undef);
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info,$table,$row,undef,$show_noc,'noc_param',undef);
 
 
#routing algorithm
$label='Routing Algorithm';
$param="ROUTE_NAME";
$type="Combo-box";
if($router_type eq '"VC_BASED"'){
$content=($topology eq '"MESH"')? '"XY","WEST_FIRST","NORTH_LAST","NEGETIVE_FIRST","ODD_EVEN","DUATO"' :
($topology eq '"TORUS"')? '"TRANC_XY","TRANC_WEST_FIRST","TRANC_NORTH_LAST","TRANC_NEGETIVE_FIRST","TRANC_DUATO"':
($topology eq '"RING"')? '"TRANC_XY"' : '"XY"';
}else{
$content=($topology eq '"MESH"')? '"XY","WEST_FIRST","NORTH_LAST","NEGETIVE_FIRST","ODD_EVEN"' :
($topology eq '"TORUS"')? '"TRANC_XY","TRANC_WEST_FIRST","TRANC_NORTH_LAST","TRANC_NEGETIVE_FIRST"':
($topology eq '"RING"')? '"TRANC_XY"' : '"XY"';
}
$default=($topology eq '"MESH"' || $topology eq '"LINE"' )? '"XY"':'"TRANC_XY"';
$info="Select the routing algorithm: XY(DoR) , partially adaptive (Turn models). Fully adaptive (Duato) ";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',1);
#routing algorithm
$label='Routing Algorithm';
$param="ROUTE_NAME";
$type="Combo-box";
if($router_type eq '"VC_BASED"'){
$content=($topology eq '"MESH"')? '"XY","WEST_FIRST","NORTH_LAST","NEGETIVE_FIRST","ODD_EVEN","DUATO"' :
($topology eq '"TORUS"')? '"TRANC_XY","TRANC_WEST_FIRST","TRANC_NORTH_LAST","TRANC_NEGETIVE_FIRST","TRANC_DUATO"':
($topology eq '"RING"')? '"TRANC_XY"' :
($topology eq '"LINE"')? '"XY"':
($topology eq '"FATTREE"')? '"NCA_RND_UP","NCA_STRAIGHT_UP","NCA_DST_UP"':
($topology eq '"TREE"')? '"NCA"' : '"UNKNOWN"';
}else{
$content=($topology eq '"MESH"')? '"XY","WEST_FIRST","NORTH_LAST","NEGETIVE_FIRST","ODD_EVEN"' :
($topology eq '"TORUS"')? '"TRANC_XY","TRANC_WEST_FIRST","TRANC_NORTH_LAST","TRANC_NEGETIVE_FIRST"':
($topology eq '"RING"')? '"TRANC_XY"' :
($topology eq '"LINE"')? '"XY"':
($topology eq '"FATTREE"')? '"NCA_RND_UP","NCA_STRAIGHT_UP","NCA_DST_UP"' :
($topology eq '"TREE"')? '"NCA"' : '"UNKNOWN"';
}
$default=($topology eq '"MESH"' || $topology eq '"LINE"' )? '"XY"':
($topology eq '"TORUS"'|| $topology eq '"RING"')? '"TRANC_XY"' :
($topology eq '"FATTREE"')? '"NCA_STRAIGHT_UP"' :
($topology eq '"TREE"')? '"NCA"' : '"UNKNOWN"';
my $info_mesh="Select the routing algorithm: XY(DoR) , partially adaptive (Turn models). Fully adaptive (Duato) ";
my $info_fat="Nearest common ancestor (NCA) where the up port is selected randomly (RND), based on destination endpoint address (DST) or it is the top port that is located in front of the the port which has received the packet (STRAIGHT) ";
$info=($topology eq '"FATTREE"')? $info_fat :
($topology eq '"TREE"') ? "Nearest common ancestor": $info_mesh;
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$show_noc,'noc_param',1);
 
 
#SSA
$label='SSA Ebable';
$param='SSA_EN';
$default='"NO"';
$content='"YES","NO"';
$type='Combo-box';
$info="Enable single cycle latency on packets traversing in the same direction using static straight allocator (SSA)";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$show_noc,'noc_param',undef);
#MIN_PCK_SIZE
# 2 //minimum packet size in flits. The minimum value is 1.
$label='Minimum packet size';
$param='MIN_PCK_SIZE';
$default='2';
$content='1,65535,1';
$type='Spin-button';
$info="The minimum packet size in flits. In atomic VC re-allocation, it is just important to define if the single-flit sized packets are allowed to be injected to the NoC by defining this parameter value as one. Setting any larger value than one results in the same architecture and the NoC works correctly even if it receives smaller packets size as while as they are not single flit -sized packets. However, for non-atomic VC reallocation NoCs, you have to define the exact value as it defines the NoC control registers' internal buffers. The NoC may crash once it receives packets having smaler size than the defined minimum packet size.";
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$show_noc,'noc_param',undef);
 
 
#SSA
$label='SSA Ebable';
$param='SSA_EN';
$default='"NO"';
$content='"YES","NO"';
$type='Combo-box';
$info="Enable single cycle latency on packets traversing in the same direction using static straight allocator (SSA)";
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$show_noc,'noc_param',undef);
 
if($show_noc == 1){
$b1= def_image_button("icons/up.png","NoC Parameters");
$table->attach ( $b1 , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
$b1->signal_connect("clicked" => sub{
$show_noc=($show_noc==1)?0:1;
$mpsoc->object_add_attribute('setting','show_noc_setting',$show_noc);
set_gui_status($mpsoc,"ref",1);
});
 
 
#advance parameter start
my $advc;
my $adv_set=$mpsoc->object_get_attribute('setting','show_adv_setting');
if($adv_set == 0){
$advc= def_image_button("icons/down.png","Advance Parameters");
$table->attach ( $advc , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
#Fully and partially adaptive routing setting
my $route=$mpsoc->object_get_attribute('noc_param',"ROUTE_NAME");
$label="Congestion index";
$param="CONGESTION_INDEX";
$type="Spin-button";
$content="0,12,1";
$info="Congestion index determines how congestion information is collected from neighboring routers. Please refer to the usere manual for more information";
$default=3;
if($route ne '"XY"' and $route ne '"TRANC_XY"' ){
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
} else {
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0,'noc_param',undef);
}
#Fully adaptive routing setting
my $v=$mpsoc->object_get_attribute('noc_param',"V");
$label="Select Escap VC";
$param="ESCAP_VC_MASK";
$type="Check-box";
$content=$v;
$default="$v\'b";
for (my $i=1; $i<=$v-1; $i++){$default= "${default}0";}
$default= "${default}1";
$info="Select the escap VC for fully adaptive routing.";
if( $route eq '"TRANC_DUATO"' or $route eq '"DUATO"' ){
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set, 'noc_param',undef);
}
else{
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0, 'noc_param',undef);
}
# VC reallocation type
$label=($router_type eq '"VC_BASED"')? 'VC reallocation type': 'Queue reallocation type';
$param='VC_REALLOCATION_TYPE';
if($show_noc == 1){
$b1= def_image_button("icons/up.png","NoC Parameters");
$table->attach ( $b1 , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
$b1->signal_connect("clicked" => sub{
$show_noc=($show_noc==1)?0:1;
$mpsoc->object_add_attribute('setting','show_noc_setting',$show_noc);
set_gui_status($mpsoc,"ref",1);
});
 
 
#advance parameter start
my $advc;
my $adv_set=$mpsoc->object_get_attribute('setting','show_adv_setting');
if($adv_set == 0){
$advc= def_image_button("icons/down.png","Advance Parameters");
$table->attach ( $advc , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
#Fully and partially adaptive routing setting
my $route=$mpsoc->object_get_attribute('noc_param',"ROUTE_NAME");
$label="Congestion index";
$param="CONGESTION_INDEX";
$type="Spin-button";
$content="0,12,1";
$info="Congestion index determines how congestion information is collected from neighboring routers. Please refer to the usere manual for more information";
$default=3;
if($route ne '"XY"' and $route ne '"TRANC_XY"' ){
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$adv_set,'noc_param',undef);
} else {
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,0,'noc_param',undef);
}
#Fully adaptive routing setting
my $v=$mpsoc->object_get_attribute('noc_param',"V");
$label="Select Escap VC";
$param="ESCAP_VC_MASK";
$type="Check-box";
$content=$v;
$default="$v\'b";
for (my $i=1; $i<=$v-1; $i++){$default= "${default}0";}
$default= "${default}1";
$info="Select the escap VC for fully adaptive routing.";
if( $route eq '"TRANC_DUATO"' or $route eq '"DUATO"' ){
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$adv_set, 'noc_param',undef);
}
else{
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,0, 'noc_param',undef);
}
# VC reallocation type
$label=($router_type eq '"VC_BASED"')? 'VC reallocation type': 'Queue reallocation type';
$param='VC_REALLOCATION_TYPE';
$info="VC reallocation type: If set as atomic only empty VCs can be allocated for new packets. Whereas, in non-atomic a non-empty VC which has received the last packet tail flit can accept a new packet";
$default='"NONATOMIC"';
$content='"ATOMIC","NONATOMIC"';
$type='Combo-box';
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$adv_set,'noc_param',undef);
 
 
#vc/sw allocator type
$label = 'VC/SW combination type';
$param='COMBINATION_TYPE';
#vc/sw allocator type
$label = 'VC/SW combination type';
$param='COMBINATION_TYPE';
$default='"COMB_NONSPEC"';
$content='"BASELINE","COMB_SPEC1","COMB_SPEC2","COMB_NONSPEC"';
$type='Combo-box';
$info="The joint VC/ switch allocator type. using canonical combination is not recommanded";
if ($router_type eq '"VC_BASED"'){
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
} else{
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0,'noc_param',undef);
}
# Crossbar mux type
$label='Crossbar mux type';
$param='MUX_TYPE';
$default='"BINARY"';
$content='"ONE_HOT","BINARY"';
$type='Combo-box';
$info="Crossbar multiplexer type";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',undef);
if ($router_type eq '"VC_BASED"'){
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$adv_set,'noc_param',undef);
} else{
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,0,'noc_param',undef);
}
# Crossbar mux type
$label='Crossbar mux type';
$param='MUX_TYPE';
$default='"BINARY"';
$content='"ONE_HOT","BINARY"';
$type='Combo-box';
$info="Crossbar multiplexer type";
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$adv_set,'noc_param',undef);
#class
if($router_type eq '"VC_BASED"'){
$label='class number';
$param='C';
$default= 0;
$info='Number of message classes. Each specific class can use different set of VC';
$content='0,16,1';
$type='Spin-button';
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',5);
if($router_type eq '"VC_BASED"'){
$label='class number';
$param='C';
$default= 0;
$info='Number of message classes. Each specific class can use different set of VC';
$content='0,16,1';
$type='Spin-button';
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$adv_set,'noc_param',5);
 
my $class=$mpsoc->object_get_attribute('noc_param',"C");
my $v=$mpsoc->object_get_attribute('noc_param',"V");
$default= "$v\'b";
for (my $i=1; $i<=$v; $i++){
$default= "${default}1";
}
#print "\$default=$default\n";
for (my $i=0; $i<=$class-1; $i++){
$label="Class $i Permitted VCs";
$param="Cn_$i";
$type="Check-box";
$content=$v;
$info="Select the permitted VCs which the message class $i can be sent via them.";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'class_param',undef);
}
}#($router_type eq '"VC_BASED"')
my $class=$mpsoc->object_get_attribute('noc_param',"C");
my $v=$mpsoc->object_get_attribute('noc_param',"V");
$default= "$v\'b";
for (my $i=1; $i<=$v; $i++){
$default= "${default}1";
}
#print "\$default=$default\n";
for (my $i=0; $i<=$class-1; $i++){
$label="Class $i Permitted VCs";
$param="Cn_$i";
$type="Check-box";
$content=$v;
$info="Select the permitted VCs which the message class $i can be sent via them.";
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$adv_set,'class_param',undef);
}
}#($router_type eq '"VC_BASED"')
 
#simulation debuge enable
$label='Debug enable';
$param='DEBUG_EN';
#simulation debuge enable
$label='Debug enable';
$param='DEBUG_EN';
$info= "Add extra verilog code for debuging NoC for simulation";
$default='0';
$content='0,1';
$type='Combo-box';
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param');
$default='0';
$content='0,1';
$type='Combo-box';
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$adv_set,'noc_param');
 
#pipeline reg
$label="Add pipeline reg after crossbar";
$param="ADD_PIPREG_AFTER_CROSSBAR";
$type="Check-box";
$content=1;
$default="1\'b0";
$info="If enabeled it adds a pipline register at the output port of the router.";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param');
#MAX_SBP_NUM = 4 //
$label="Number of multiple router bypassing ";
$param="MAX_SBP_NUM ";
$type='Spin-button';
$content='0,1,1';
$default=0;
$info="maximum number of routers which a packet can by pass during one clock cycle. Define it as zero will disable bypassing.";
#$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param');
#FIRST_ARBITER_EXT_P_EN
$label='Swich allocator first level
#pipeline reg
$label="Add pipeline reg after crossbar";
$param="ADD_PIPREG_AFTER_CROSSBAR";
$type="Check-box";
$content=1;
$default="1\'b0";
$info="If enabeled it adds a pipline register at the output port of the router.";
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$adv_set,'noc_param');
#MAX_SBP_NUM = 4 //
$label="Number of multiple router bypassing ";
$param="MAX_SBP_NUM ";
$type='Spin-button';
$content='0,1,1';
$default=0;
$info="maximum number of routers which a packet can by pass during one clock cycle. Define it as zero will disable bypassing.";
#($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param');
#FIRST_ARBITER_EXT_P_EN
$label='Swich allocator first level
arbiters external priority enable';
$param='FIRST_ARBITER_EXT_P_EN';
$default= 1;
$info='If set as 1 then the switch allocator\'s input (first) arbiters\' priority registers are enabled only when a request get both input and output arbiters\' grants';
$content='0,1';
$type="Combo-box";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info,$table,$row,$adv_set,'noc_param');
#Arbiter type
$label='SW allocator arbitration type';
$param='SWA_ARBITER_TYPE';
$default='"RRA"';
$content='"RRA","WRRA"'; #,"WRRA_CLASSIC"';
$type='Combo-box';
$param='FIRST_ARBITER_EXT_P_EN';
$default= 1;
$info='If set as 1 then the switch allocator\'s input (first) arbiters\' priority registers are enabled only when a request get both input and output arbiters\' grants';
$content='0,1';
$type="Combo-box";
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info,$table,$row,undef,$adv_set,'noc_param');
#Arbiter type
$label='SW allocator arbitration type';
$param='SWA_ARBITER_TYPE';
$default='"RRA"';
$content='"RRA","WRRA"'; #,"WRRA_CLASSIC"';
$type='Combo-box';
$info="Switch allocator arbitertion type:
RRA: Round robin arbiter. Only local fairness in a router.
WRRA: Weighted round robin arbiter. Results in global fairness in the NoC.
Switch allocation requests are grated acording to their weight which increases due to contention";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$adv_set,'noc_param',1);
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$adv_set,'noc_param',1);
my $arbiter=$mpsoc->object_get_attribute('noc_param',"SWA_ARBITER_TYPE");
my $wrra_show = ($arbiter ne '"RRA"' && $adv_set == 1 )? 1 : 0;
# weight width
$label='Weight width';
$param='WEIGHTw';
$default='4';
$content='2,7,1';
$info= 'Maximum weight width';
$type= 'Spin-button';
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$wrra_show,'noc_param',undef);
#WRRA_CONFIG_INDEX
$label='Weight configuration index';
$param='WRRA_CONFIG_INDEX';
$default='0';
$content='0,7,1';
$info= 'WRRA_CONFIG_INDEX:
# weight width
$label='Weight width';
$param='WEIGHTw';
$default='4';
$content='2,7,1';
$info= 'Maximum weight width';
$type= 'Spin-button';
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,$wrra_show,'noc_param',undef);
#WRRA_CONFIG_INDEX
$label='Weight configuration index';
$param='WRRA_CONFIG_INDEX';
$default='0';
$content='0,7,1';
$info= 'WRRA_CONFIG_INDEX:
 
';
$type= 'Spin-button';
#$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$wrra_show,'noc_param',undef);
if($adv_set == 1){
$advc= def_image_button("icons/up.png","Advance Parameters");
$table->attach ( $advc , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
$advc->signal_connect("clicked" => sub{
$adv_set=($adv_set==1)?0:1;
$mpsoc->object_add_attribute('setting','show_adv_setting',$adv_set);
set_gui_status($mpsoc,"ref",1);
});
#other fixed parameters
$type= 'Spin-button';
#($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,$wrra_show,'noc_param',undef);
# AVC_ATOMIC_EN
$label='AVC_ATOMIC_EN';
$param='AVC_ATOMIC_EN';
$default= 0;
$info='AVC_ATOMIC_EN';
$content='0,1';
$type="Combo-box";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0,'noc_param');
#ROUTE_SUBFUNC
$label='ROUTE_SUBFUNC';
$param='ROUTE_SUBFUNC';
$default= '"XY"';
$info='ROUTE_SUBFUNC';
$content='"XY"';
$type="Combo-box";
$row=noc_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,0,'noc_param');
return $row;
if($adv_set == 1){
$advc= def_image_button("icons/up.png","Advance Parameters");
$table->attach ( $advc , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
$advc->signal_connect("clicked" => sub{
$adv_set=($adv_set==1)?0:1;
$mpsoc->object_add_attribute('setting','show_adv_setting',$adv_set);
set_gui_status($mpsoc,"ref",1);
});
#other fixed parameters
# AVC_ATOMIC_EN
$label='AVC_ATOMIC_EN';
$param='AVC_ATOMIC_EN';
$default= 0;
$info='AVC_ATOMIC_EN';
$content='0,1';
$type="Combo-box";
($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,0,'noc_param');
#ROUTE_SUBFUNC
#$label='ROUTE_SUBFUNC';
#$param='ROUTE_SUBFUNC';
#$default= '"XY"';
#$info='ROUTE_SUBFUNC';
#$content='"XY"';
#$type="Combo-box";
#($row,$coltmp)=add_param_widget ($mpsoc,$label,$param, $default,$type,$content,$info, $table,$row,undef,0,'noc_param');
return $row;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
#######################
# get_config
######################
 
sub get_config{
my ($mpsoc,$info)=@_;
my $table=def_table(20,10,FALSE);# my ($row,$col,$homogeneous)=@_;
#my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
#$scrolled_win->set_policy( "automatic", "automatic" );
#$scrolled_win->add_with_viewport($table);
my ($mpsoc,$info)=@_;
my $table=def_table(20,10,FALSE);# my ($row,$col,$homogeneous)=@_;
#my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
#$scrolled_win->set_policy( "automatic", "automatic" );
#$scrolled_win->add_with_viewport($table);
 
#noc_setting
my $row=noc_config ($mpsoc,$table);
#tile setting
my $tile_set;
my $show=$mpsoc->object_get_attribute('setting','show_tile_setting');
if($show == 0){
$tile_set= def_image_button("icons/down.png","Tiles setting");
$table->attach ( $tile_set , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
$row=defualt_tilles_setting($mpsoc,$table,$show,$row,$info);
#noc_setting
my $row=noc_config ($mpsoc,$table);
#tiles setting
my $tile_set;
my $show=$mpsoc->object_get_attribute('setting','show_tile_setting');
if($show == 0){
$tile_set= def_image_button("icons/down.png","Tiles setting");
$table->attach ( $tile_set , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
$row=defualt_tilles_setting($mpsoc,$table,$show,$row,$info);
 
#end tile setting
if($show == 1){
$tile_set= def_image_button("icons/up.png","Tiles setting");
$table->attach ( $tile_set , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
$tile_set->signal_connect("clicked" => sub{
$show=($show==1)?0:1;
$mpsoc->object_add_attribute('setting','show_tile_setting',$show);
set_gui_status($mpsoc,"ref",1);
 
 
});
 
#end tile setting
if($show == 1){
$tile_set= def_image_button("icons/up.png","Tiles setting");
$table->attach ( $tile_set , 0, 2, $row,$row+1,'fill','shrink',2,2);
$row++;
}
$tile_set->signal_connect("clicked" => sub{
$show=($show==1)?0:1;
$mpsoc->object_add_attribute('setting','show_tile_setting',$show);
set_gui_status($mpsoc,"ref",1);
 
 
});
#for(my $i=$row; $i<25; $i++){
#my $empty_col=gen_label_in_left(' ');
#$table->attach_defaults ($empty_col , 0, 1, $i,$i+1);
 
 
 
#for(my $i=$row; $i<25; $i++){
#my $empty_col=gen_label_in_left(' ');
#$table->attach_defaults ($empty_col , 0, 1, $i,$i+1);
 
#}
 
 
 
 
#}
return $table;
 
}
 
 
#############
#
# gen_all_tiles
###########
 
 
1187,286 → 1026,284
 
 
sub gen_all_tiles{
my ($mpsoc,$info, $hw_dir,$sw_dir)=@_;
my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
#remove old rtl files that were copied by ProNoC
my $old_file_ref= eval { do "$hw_dir/file_list" };
if (defined $old_file_ref){
remove_file_and_folders($old_file_ref,$target_dir);
}
my @generated_tiles;
unlink "$hw_dir/file_list";
#print "nx=$nx,ny=$ny\n";
for (my $y=0;$y<$ny;$y++){for (my $x=0; $x<$nx;$x++){
my $tile_num= $y*$nx+$x;
#print "$tile_num\n";
my ($soc_name,$num)= $mpsoc->mpsoc_get_tile_soc_name($tile_num);
next if(!defined $soc_name);
my $path=$mpsoc->object_get_attribute('setting','soc_path');
$path=~ s/ /\\ /g;
my $p = "$path/$soc_name.SOC";
my $soc = eval { do $p };
if ($@ || !defined $soc){
show_info(\$info,"**Error reading $p file: $@\n");
next;
}
#update core id
$soc->object_add_attribute('global_param','CORE_ID',$tile_num);
#update NoC param
#my %nocparam = %{$mpsoc->object_get_attribute('noc_param',undef)};
my $nocparam =$mpsoc->object_get_attribute('noc_param',undef);
my $top=$mpsoc->mpsoc_get_soc($soc_name);
my @nis=get_NI_instance_list($top);
$soc->soc_add_instance_param($nis[0] ,$nocparam );
#foreach my $p ( sort keys %nocparam ) {
# print "$p = $nocparam{$p} \n";
#}
my ($mpsoc,$info, $hw_dir,$sw_dir)=@_;
my ($NE, $NR, $RAw, $EAw, $Fw)=get_topology_info($mpsoc);
my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
my @generated_tiles;
for (my $tile_num=0;$tile_num<$NE;$tile_num++){
#print "$tile_num\n";
my ($soc_name,$num)= $mpsoc->mpsoc_get_tile_soc_name($tile_num);
next if(!defined $soc_name);
my $path=$mpsoc->object_get_attribute('setting','soc_path');
$path=~ s/ /\\ /g;
my $p = "$path/$soc_name.SOC";
my ($soc,$r,$err) = regen_object($p);
if ($r){
show_info(\$info,"**Error reading $p file: $err\n");
next;
}
#update core id
$soc->object_add_attribute('global_param','CORE_ID',$tile_num);
#update NoC param
#my %nocparam = %{$mpsoc->object_get_attribute('noc_param',undef)};
my $nocparam =$mpsoc->object_get_attribute('noc_param',undef);
my $top=$mpsoc->mpsoc_get_soc($soc_name);
my @nis=get_NI_instance_list($top);
$soc->soc_add_instance_param($nis[0] ,$nocparam );
#foreach my $p ( sort keys %nocparam ) {
# print "$p = $nocparam{$p} \n";
#}
 
my $sw_path = "$sw_dir/tile$tile_num";
#print "$sw_path\n";
if( grep (/^$soc_name$/,@generated_tiles)){ # This soc is generated before only create the software file
generate_soc($soc,$info,$target_dir,$hw_dir,$sw_path,0,0);
}else{
generate_soc($soc,$info,$target_dir,$hw_dir,$sw_path,0,1);
move ("$hw_dir/$soc_name.v","$hw_dir/tiles/");
my @tmp= ("$hw_dir/tiles/$soc_name.v");
add_to_project_file_list(\@tmp,"$hw_dir/tiles",$hw_dir);
}
}}
my $sw_path = "$sw_dir/tile$tile_num";
#print "$sw_path\n";
if( grep (/^$soc_name$/,@generated_tiles)){ # This soc is generated before only create the software file
generate_soc($soc,$info,$target_dir,$hw_dir,$sw_path,0,0);
}else{
generate_soc($soc,$info,$target_dir,$hw_dir,$sw_path,0,1,"merge");
move ("$hw_dir/$soc_name.v","$hw_dir/tiles/");
my @tmp= ("$hw_dir/tiles/$soc_name.v");
add_to_project_file_list(\@tmp,"$hw_dir/tiles",$hw_dir);
}
}#$tile_num
}
 
 
################
# generate_soc
# generate_soc
#################
 
sub generate_soc_files{
my ($mpsoc,$soc,$info)=@_;
my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
my $soc_name=$soc->object_get_attribute('soc_name');
# copy all files in project work directory
my $dir = Cwd::getcwd();
my $project_dir = abs_path("$dir/../../");
#make target dir
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
mkpath("$target_dir/src_verilog/lib/",1,0755);
mkpath("$target_dir/src_verilog/tiles/",1,0755);
mkpath("$target_dir/sw",1,0755);
my ($mpsoc,$soc,$info)=@_;
my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
my $soc_name=$soc->object_get_attribute('soc_name');
# copy all files in project work directory
my $dir = Cwd::getcwd();
my $project_dir = abs_path("$dir/../../");
#make target dir
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
mkpath("$target_dir/src_verilog/lib/",1,0755);
mkpath("$target_dir/src_verilog/tiles/",1,0755);
mkpath("$target_dir/sw",1,0755);
 
my ($file_v,$tmp)=soc_generate_verilog($soc,"$target_dir/sw");
# Write object file
open(FILE, ">lib/soc/$soc_name.SOC") || die "Can not open: $!";
print FILE perl_file_header("$soc_name.SOC");
print FILE Data::Dumper->Dump([\%$soc],['soc']);
close(FILE) || die "Error closing file: $!";
# Write verilog file
open(FILE, ">lib/verilog/$soc_name.v") || die "Can not open: $!";
print FILE $file_v;
close(FILE) || die "Error closing file: $!";
my ($file_v,$tmp)=soc_generate_verilog($soc,"$target_dir/sw");
# Write object file
open(FILE, ">lib/soc/$soc_name.SOC") || die "Can not open: $!";
print FILE perl_file_header("$soc_name.SOC");
print FILE Data::Dumper->Dump([\%$soc],['soc']);
close(FILE) || die "Error closing file: $!";
# Write verilog file
open(FILE, ">lib/verilog/$soc_name.v") || die "Can not open: $!";
print FILE $file_v;
close(FILE) || die "Error closing file: $!";
#copy hdl codes in src_verilog
my ($hdl_ref,$warnings)= get_all_files_list($soc,"hdl_files");
foreach my $f(@{$hdl_ref}){
my $n="$project_dir$f";
if (-f "$n") {
copy ("$n","$target_dir/src_verilog/lib");
}elsif(-f "$f" ){
copy ("$f","$target_dir/src_verilog/lib");
}
my $n="$project_dir$f";
if (-f "$n") {
copy ("$n","$target_dir/src_verilog/lib");
}elsif(-f "$f" ){
copy ("$f","$target_dir/src_verilog/lib");
}
}
show_info(\$info,$warnings) if(defined $warnings);
show_info(\$info,$warnings) if(defined $warnings);
#save project hdl file/folder list
my @new_file_ref;
foreach my $f(@{$hdl_ref}){
my ($name,$path,$suffix) = fileparse("$f",qr"\..[^.]*$");
push(@new_file_ref,"$target_dir/src_verilog/lib/$name$suffix");
}
foreach my $f(@{$hdl_ref}){
my ($name,$path,$suffix) = fileparse("$f",qr"\..[^.]*$");
push(@new_file_ref,"$target_dir/src_verilog/lib/$name$suffix");
}
open(FILE, ">$target_dir/src_verilog/file_list") || die "Can not open: $!";
print FILE Data::Dumper->Dump([\@new_file_ref],['files']);
close(FILE) || die "Error closing file: $!";
#my @pathes=("$dir/../src_peripheral","$dir/../src_noc","$dir/../src_processor");
#foreach my $p(@pathes){
# find(
# sub {
# return unless ( -f $_ );
# $_ =~ /\.v$/ && copy( $File::Find::name, "$target_dir/src_verilog/lib/" );
# },
# $p
# );
#}
move ("$dir/lib/verilog/$soc_name.v","$target_dir/src_verilog/tiles/");
copy_noc_files($project_dir,"$target_dir/src_verilog/lib");
# Write header file
generate_header_file($soc,$project_dir,$target_dir,$target_dir,$dir);
#use File::Copy::Recursive qw(dircopy);
#dircopy("$dir/../src_processor/aeMB/compiler","$target_dir/sw/") or die("$!\n");
my $msg="SoC \"$soc_name\" has been created successfully at $target_dir/ ";
return $msg;
}
print FILE Data::Dumper->Dump([\@new_file_ref],['files']);
close(FILE) || die "Error closing file: $!";
#my @pathes=("$dir/../src_peripheral","$dir/../src_noc","$dir/../src_processor");
#foreach my $p(@pathes){
# find(
# sub {
# return unless ( -f $_ );
# $_ =~ /\.v$/ && copy( $File::Find::name, "$target_dir/src_verilog/lib/" );
# },
# $p
# );
#}
move ("$dir/lib/verilog/$soc_name.v","$target_dir/src_verilog/tiles/");
copy_noc_files($project_dir,"$target_dir/src_verilog/lib");
# Write header file
generate_header_file($soc,$project_dir,$target_dir,$target_dir,$dir);
#use File::Copy::Recursive qw(dircopy);
#dircopy("$dir/../src_processor/aeMB/compiler","$target_dir/sw/") or die("$!\n");
my $msg="SoC \"$soc_name\" has been created successfully at $target_dir/ ";
return $msg;
}
 
 
sub generate_mpsoc_lib_file {
my ($mpsoc,$info) = @_;
my $name=$mpsoc->object_get_attribute('mpsoc_name');
$mpsoc->mpsoc_remove_all_soc_tops();
open(FILE, ">lib/mpsoc/$name.MPSOC") || die "Can not open: $!";
print FILE perl_file_header("$name.MPSOC");
print FILE Data::Dumper->Dump([\%$mpsoc],['mpsoc']);
close(FILE) || die "Error closing file: $!";
get_soc_list($mpsoc,$info);
}
my ($mpsoc,$info) = @_;
my $name=$mpsoc->object_get_attribute('mpsoc_name');
$mpsoc->mpsoc_remove_all_soc_tops();
open(FILE, ">lib/mpsoc/$name.MPSOC") || die "Can not open: $!";
print FILE perl_file_header("$name.MPSOC");
print FILE Data::Dumper->Dump([\%$mpsoc],['mpsoc']);
close(FILE) || die "Error closing file: $!";
get_soc_list($mpsoc,$info);
}
 
 
 
 
################
# generate_mpsoc
# generate_mpsoc
#################
 
sub generate_mpsoc{
my ($mpsoc,$info,$show_sucess_msg)=@_;
my $name=$mpsoc->object_get_attribute('mpsoc_name');
my $error = check_verilog_identifier_syntax($name);
if ( defined $error ){
message_dialog("The \"$name\" is given with an unacceptable formatting. The mpsoc name will be used as top level verilog module name so it must follow Verilog identifier declaration formatting:\n $error");
return 0;
}
my $size= (defined $name)? length($name) :0;
if ($size ==0) {
message_dialog("Please define the MPSoC name!");
return 0;
}
# make target dir
my $dir = Cwd::getcwd();
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$name";
my $hw_dir = "$target_dir/src_verilog";
my $sw_dir = "$target_dir/sw";
mkpath("$hw_dir/lib/",1,0755);
mkpath("$hw_dir/tiles",1,0755);
mkpath("$sw_dir",1,0755);
#generate/copy all tiles HDL/SW codes
gen_all_tiles($mpsoc,$info, $hw_dir,$sw_dir );
#copy all NoC HDL files
my @files = glob( "$dir/../src_noc/*.v" );
copy_file_and_folders(\@files,$dir,"$hw_dir/lib/");
my ($file_v,$top_v)=mpsoc_generate_verilog($mpsoc,$sw_dir);
# Write object file
generate_mpsoc_lib_file($mpsoc,$info);
# Write verilog file
open(FILE, ">lib/verilog/$name.v") || die "Can not open: $!";
print FILE $file_v;
close(FILE) || die "Error closing 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: $!";
my ($mpsoc,$info,$show_sucess_msg)=@_;
my $name=$mpsoc->object_get_attribute('mpsoc_name');
my $error = check_verilog_identifier_syntax($name);
if ( defined $error ){
#message_dialog("The \"$name\" is given with an unacceptable formatting. The mpsoc name will be used as top level verilog module name so it must follow Verilog identifier declaration formatting:\n $error");
my $message = "The \"$name\" is given with an unacceptable formatting. The mpsoc name will be used as top level verilog module name so it must follow Verilog identifier declaration formatting:\n $error";
add_colored_info(\$info, $message,'red' );
return 0;
}
my $size= (defined $name)? length($name) :0;
if ($size ==0) {
message_dialog("Please define the MPSoC name!");
return 0;
}
# make target dir
my $dir = Cwd::getcwd();
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$name";
my $hw_dir = "$target_dir/src_verilog";
my $sw_dir = "$target_dir/sw";
# rmtree ($hw_dir);
mkpath("$hw_dir",1,01777);
mkpath("$hw_dir/lib/",1,0755);
mkpath("$hw_dir/tiles",1,0755);
mkpath("$sw_dir",1,0755);
#remove old rtl files that were copied by ProNoC
my ($old_file_ref,$r,$err) = regen_object("$hw_dir/file_list");
if (defined $old_file_ref){
remove_file_and_folders($old_file_ref,$target_dir);
}
unlink "$hw_dir/file_list";
#generate/copy all tiles HDL/SW codes
gen_all_tiles($mpsoc,$info, $hw_dir,$sw_dir );
#generate header file containig the tiles physical addresses
gen_tiles_physical_addrsses_header_file($mpsoc,"$sw_dir/phy_addr.h");
#copy all NoC HDL files
my @files = glob( "$dir/../src_noc/*.v" );
copy_file_and_folders(\@files,$dir,"$hw_dir/lib/");
add_to_project_file_list(\@files,"$hw_dir/lib/",$hw_dir);
my ($file_v,$top_v)=mpsoc_generate_verilog($mpsoc,$sw_dir);
# Write object file
generate_mpsoc_lib_file($mpsoc,$info);
# Write verilog file
open(FILE, ">lib/verilog/$name.v") || die "Can not open: $!";
print FILE $file_v;
close(FILE) || die "Error closing 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: $!";
#gen_socs($mpsoc,$info);
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/${name}_top.v","$target_dir/src_verilog/");
#generate makefile
open(FILE, ">$sw_dir/Makefile") || die "Can not open: $!";
print FILE mpsoc_sw_make();
close(FILE) || die "Error closing file: $!";
#generate prog_mem
print FILE mpsoc_sw_make();
close(FILE) || die "Error closing file: $!";
#generate prog_mem
open(FILE, ">$sw_dir/program.sh") || die "Can not open: $!";
print FILE mpsoc_mem_prog();
close(FILE) || die "Error closing file: $!";
print FILE mpsoc_mem_prog();
close(FILE) || die "Error closing file: $!";
my @ff= ("$target_dir/src_verilog/$name.v","$target_dir/src_verilog/${name}_top.v");
add_to_project_file_list(\@ff,"$hw_dir/lib/",$hw_dir);
message_dialog("MPSoC \"$name\" has been created successfully at $target_dir/ " ) if($show_sucess_msg);
return 1;
}
return 1;
}
 
sub mpsoc_sw_make {
my $make='
SUBDIRS := $(wildcard */.)
all: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@
my $make="SUBDIRS := \$(wildcard */.)
all: \$(SUBDIRS)
\$(SUBDIRS):
\t\$(MAKE) -C \$@
 
.PHONY: all $(SUBDIRS)
clean:
$(MAKE) -C $(CODE_DIR) clean
';
.PHONY: all \$(SUBDIRS)
clean:
\t\$(MAKE) -C \$(CODE_DIR) clean
";
return $make;
}
 
 
sub mpsoc_mem_prog {
my $string='
my $string='
#!/bin/sh
 
 
1479,11 → 1316,11
$JTAG_INTFC -n 127 -d "I:1,D:2:3,D:2:2,I:0"
 
# jtag instruction
# 0: bypass
# 1: getting data
# 0: bypass
# 1: getting data
# jtag data :
# bit 0 is reset
# bit 1 is disable
# bit 0 is reset
# bit 1 is disable
# I:1 set jtag_enable in active mode
# D:2:3 load jtag_enable data register with 0x3 reset=1 disable=1
# D:2:2 load jtag_enable data register with 0x2 reset=0 disable=1
1493,10 → 1330,10
 
#programe the memory
for i in $(ls -d */); do
echo "Enter ${i%%/}"
cd ${i%%/}
sh write_memory.sh
cd ..
echo "Enter ${i%%/}"
cd ${i%%/}
sh write_memory.sh
cd ..
done
#Enable the cpu
1506,42 → 1343,42
# I:0 set jtag_enable in bypass mode
';
return $string;
}
 
 
sub get_tile_LIST{
my ($mpsoc,$x,$y,$soc_num,$row,$table)=@_;
my $instance_name=$mpsoc->mpsoc_get_instance_info($soc_num);
if(!defined $instance_name){
$mpsoc->mpsoc_set_default_ip($soc_num);
$instance_name=$mpsoc->mpsoc_get_instance_info($soc_num);
my ($mpsoc,$x,$y,$soc_num,$row,$table)=@_;
my $instance_name=$mpsoc->mpsoc_get_instance_info($soc_num);
if(!defined $instance_name){
$mpsoc->mpsoc_set_default_ip($soc_num);
$instance_name=$mpsoc->mpsoc_get_instance_info($soc_num);
 
}
}
 
#ipname
my $col=0;
my $label=gen_label_in_left("IP_$soc_num($x,$y)");
$table->attach_defaults ( $label, $col, $col+1 , $row, $row+1);$col+=2;
#instance name
my $entry=gen_entry($instance_name);
$table->attach_defaults ( $entry, $col, $col+1 , $row, $row+1);$col+=2;
$entry->signal_connect( 'changed'=> sub{
my $new_instance=$entry->get_text();
$mpsoc->mpsoc_set_ip_inst_name($soc_num,$new_instance);
set_gui_status($mpsoc,"ref",20);
print "changed to $new_instance\n ";
#ipname
my $col=0;
my $label=gen_label_in_left("IP_$soc_num($x,$y)");
$table->attach_defaults ( $label, $col, $col+1 , $row, $row+1);$col+=2;
#instance name
my $entry=gen_entry($instance_name);
$table->attach_defaults ( $entry, $col, $col+1 , $row, $row+1);$col+=2;
$entry->signal_connect( 'changed'=> sub{
my $new_instance=$entry->get_text();
$mpsoc->mpsoc_set_ip_inst_name($soc_num,$new_instance);
set_gui_status($mpsoc,"ref",20);
print "changed to $new_instance\n ";
 
});
});
 
 
#combo box
my @list=('A','B');
my $combo=gen_combo(\@list,0);
$table->attach_defaults ( $combo, $col, $col+1 , $row, $row+1);$col+=2;
#setting
my $setting= def_image_button("icons/setting.png","Browse");
$table->attach_defaults ( $setting, $col, $col+1 , $row, $row+1);$col+=2;
#combo box
my @list=('A','B');
my $combo=gen_combo(\@list,0);
$table->attach_defaults ( $combo, $col, $col+1 , $row, $row+1);$col+=2;
#setting
my $setting= def_image_button("icons/setting.png","Browse");
$table->attach_defaults ( $setting, $col, $col+1 , $row, $row+1);$col+=2;
 
 
}
1548,223 → 1385,144
 
 
 
 
##########
#
#########
 
sub gen_tiles_LIST{
my ($mpsoc)=@_;
 
my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
 
# print "($nx,$ny);\n";
my $table=def_table($nx*$ny,4,FALSE);# my ($row,$col,$homogeneous)=@_;
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
$scrolled_win->set_policy( "automatic", "automatic" );
$scrolled_win->add_with_viewport($table);
 
 
my @titles=("IP_num(x,y)","Instance name","IP module name","setting");
my $col=0;
my $row=0;
foreach my$p(@titles){
my $label=gen_label_in_left($p);
$table->attach_defaults ($label, $col, $col+1 , $row, $row+1);$col++;
my $sepv = Gtk2::VSeparator->new;
$table->attach_defaults ($sepv, $col , $col+1 ,0 , 2*($nx*$ny)+2 );$col++;
}$row+=2;
 
$col=0;
for (my $y=0;$y<$ny;$y++){
 
for (my $x=0; $x<$nx;$x++){
my $soc_num= $y*$nx+$x;
my $seph = Gtk2::HSeparator->new;
$table->attach_defaults ($seph, 0, 8 , $row, $row+1);$row++;
get_tile($mpsoc,$x,$y,$soc_num,$row,$table);$row++;
 
 
}}
my $seph = Gtk2::HSeparator->new;
$table->attach_defaults ($seph, 0, 8 , $row, $row+1);$row++;
 
while( $row<30){
my $label=gen_label_in_left(' ');
$table->attach_defaults ($label, $col, $col+1 , $row, $row+1);$row++;
 
 
 
}
 
 
return $scrolled_win;
}
 
 
 
 
 
 
 
 
 
sub get_tile{
my ($mpsoc,$tile,$x,$y)=@_;
my ($mpsoc,$tile)=@_;
 
my ($soc_name,$num)= $mpsoc->mpsoc_get_tile_soc_name($tile);
my $button;
my $topology=$mpsoc->object_get_attribute('noc_param','TOPOLOGY');
my $cordibate = ($topology eq '"RING"' || $topology eq '"LINE"' ) ? "" : "($x,$y)";
if( defined $soc_name){
my $setting=$mpsoc->mpsoc_get_tile_param_setting($tile);
$button=($setting eq 'Custom')? def_colored_button("Tile $tile ${cordibate}*\n$soc_name",$num) : def_colored_button("Tile $tile ${cordibate}\n$soc_name",$num) ;
}else {
$button =def_colored_button("Tile $tile ${cordibate}\n",50) if(! defined $soc_name);
}
$button->signal_connect("clicked" => sub{
my $window = def_popwin_size(40,40,"Parameter setting for Tile $tile ",'percent');
my $table = def_table(6, 2, TRUE);
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
$scrolled_win->set_policy( "automatic", "automatic" );
$scrolled_win->add_with_viewport($table);
my $row=0;
my ($soc_name,$g,$t)=$mpsoc->mpsoc_get_tile_soc_name($tile);
my @socs=$mpsoc->mpsoc_get_soc_list();
my @list=(' ',@socs);
my $pos=(defined $soc_name)? get_scolar_pos($soc_name,@list): 0;
my $combo=gen_combo(\@list, $pos);
my $lable=gen_label_in_left(" Processing tile name:");
$table->attach_defaults($lable,0,3,$row,$row+1);
$table->attach_defaults($combo,3,7,$row,$row+1);$row++;
my $separator1 = Gtk2::HSeparator->new;
$table->attach_defaults($separator1,0,7,$row,$row+1);$row++;
my $ok = def_image_button('icons/select.png','OK');
my $okbox=def_hbox(TRUE,0);
$okbox->pack_start($ok, FALSE, FALSE,0);
my $param_setting=$mpsoc->mpsoc_get_tile_param_setting($tile);
@list=('Default','Custom');
$pos=(defined $param_setting)? get_scolar_pos($param_setting,@list): 0;
my $nn=(defined $soc_name)? $soc_name : 'soc';
my ($box2,$combo2)=gen_combo_help("Defualt: the tail will get defualt parameter setting of $nn.\n Custom: it will allow custom parameter setting for this tile only." , \@list, $pos);
my $lable2=gen_label_in_left(" Parameter Setting:");
$table->attach_defaults($lable2,0,3,$row,$row+1);
$table->attach_defaults($box2,3,7,$row,$row+1);$row++;
$combo2->signal_connect('changed'=>sub{
my $in=$combo2->get_active_text();
$mpsoc->mpsoc_set_tile_param_setting($tile,$in);
});
$combo->signal_connect('changed'=>sub{
my $new_soc=$combo->get_active_text();
if ($new_soc eq ' '){
#unconnect tile
$mpsoc->mpsoc_set_tile_free($tile);
}else {
$mpsoc->mpsoc_set_tile_soc_name($tile,$new_soc);
}
});
my $mtable = def_table(10, 1, TRUE);
my ($soc_name,$num)= $mpsoc->mpsoc_get_tile_soc_name($tile);
my $button;
my $topology=$mpsoc->object_get_attribute('noc_param','TOPOLOGY');
if( defined $soc_name){
my $setting=$mpsoc->mpsoc_get_tile_param_setting($tile);
$button=($setting eq 'Custom')? def_colored_button("Tile $tile*\n$soc_name",$num) : def_colored_button("Tile $tile\n$soc_name",$num) ;
}else {
$button =def_colored_button("Tile $tile\n",50) if(! defined $soc_name);
}
$button->signal_connect("clicked" => sub{
my $window = def_popwin_size(40,40,"Parameter setting for Tile $tile ",'percent');
my $table = def_table(6, 2, TRUE);
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
$scrolled_win->set_policy( "automatic", "automatic" );
$scrolled_win->add_with_viewport($table);
my $row=0;
my ($soc_name,$g,$t)=$mpsoc->mpsoc_get_tile_soc_name($tile);
my @socs=$mpsoc->mpsoc_get_soc_list();
my @list=(' ',@socs);
my $pos=(defined $soc_name)? get_scolar_pos($soc_name,@list): 0;
my $combo=gen_combo(\@list, $pos);
my $lable=gen_label_in_left(" Processing tile name:");
$table->attach_defaults($lable,0,3,$row,$row+1);
$table->attach_defaults($combo,3,7,$row,$row+1);$row++;
my $separator1 = Gtk2::HSeparator->new;
$table->attach_defaults($separator1,0,7,$row,$row+1);$row++;
my $ok = def_image_button('icons/select.png','OK');
my $okbox=def_hbox(TRUE,0);
$okbox->pack_start($ok, FALSE, FALSE,0);
my $param_setting=$mpsoc->mpsoc_get_tile_param_setting($tile);
@list=('Default','Custom');
$pos=(defined $param_setting)? get_scolar_pos($param_setting,@list): 0;
my $nn=(defined $soc_name)? $soc_name : 'soc';
my ($box2,$combo2)=gen_combo_help("Defualt: the tail will get defualt parameter setting of $nn.\n Custom: it will allow custom parameter setting for this tile only." , \@list, $pos);
my $lable2=gen_label_in_left(" Parameter Setting:");
$table->attach_defaults($lable2,0,3,$row,$row+1);
$table->attach_defaults($box2,3,7,$row,$row+1);$row++;
$combo2->signal_connect('changed'=>sub{
my $in=$combo2->get_active_text();
$mpsoc->mpsoc_set_tile_param_setting($tile,$in);
});
$combo->signal_connect('changed'=>sub{
my $new_soc=$combo->get_active_text();
if ($new_soc eq ' '){
#unconnect tile
$mpsoc->mpsoc_set_tile_free($tile);
}else {
$mpsoc->mpsoc_set_tile_soc_name($tile,$new_soc);
}
});
my $mtable = def_table(10, 1, TRUE);
 
$mtable->attach_defaults($scrolled_win,0,1,0,9);
$mtable->attach_defaults($okbox,0,1,9,10);
$window->add ($mtable);
$window->show_all();
$ok-> signal_connect("clicked" => sub{
$window->destroy;
set_gui_status($mpsoc,"refresh_soc",1);
my $soc_name=$combo->get_active_text();
my $setting=$combo2->get_active_text();
if ($soc_name ne ' ' && $setting ne 'Default'){
get_soc_parameter_setting ($mpsoc,$soc_name,$tile);
}
#save new values
#$top->top_add_default_soc_param(\%param_value);
#set_gui_status($mpsoc,"refresh_soc",1);
#$$refresh_soc->clicked;
});
});
#$button->show_all;
return $button;
$mtable->attach_defaults($scrolled_win,0,1,0,9);
$mtable->attach_defaults($okbox,0,1,9,10);
$window->add ($mtable);
$window->show_all();
$ok-> signal_connect("clicked" => sub{
$window->destroy;
set_gui_status($mpsoc,"refresh_soc",1);
my $soc_name=$combo->get_active_text();
my $setting=$combo2->get_active_text();
if ($soc_name ne ' ' && $setting ne 'Default'){
get_soc_parameter_setting ($mpsoc,$soc_name,$tile);
}
#save new values
#$top->top_add_default_soc_param(\%param_value);
#set_gui_status($mpsoc,"refresh_soc",1);
#$$refresh_soc->clicked;
});
});
#$button->show_all;
return $button;
 
 
}
 
 
 
 
 
##########
#
# gen_tiles
#########
 
sub gen_tiles{
my ($mpsoc)=@_;
 
my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
 
#print "($nx,$ny);\n";
my $table=def_table($nx,$ny,FALSE);# my ($row,$col,$homogeneous)=@_;
my ($mpsoc)=@_;
my ($NE, $NR, $RAw, $EAw, $Fw)=get_topology_info($mpsoc);
my $topology=$mpsoc->object_get_attribute('noc_param','TOPOLOGY');
my $table;
my $dim_y = floor(sqrt($NE));
 
 
 
 
for (my $y=0;$y<$ny;$y++){
for (my $x=0; $x<$nx;$x++){
my $tile_num=($nx*$y)+ $x;
my $tile=get_tile($mpsoc,$tile_num,$x,$y);
#print "($x,$y);\n";
$table->attach_defaults ($tile, $x, $x+1 , $y, $y+1);
 
 
}}
return $table;
$table=def_table($NE%8,$NE/8,FALSE);# my ($row,$col,$homogeneous)=@_;
for (my $i=0; $i<$NE;$i++){
my $tile=get_tile($mpsoc,$i);
my $y= int($i/$dim_y);
my $x= $i % $dim_y;
$table->attach_defaults ($tile, $x, $x+1 , $y, $y+1);
}
return $table;
}
 
 
1773,73 → 1531,76
 
 
sub software_edit_mpsoc {
my $self=shift;
my $name=$self->object_get_attribute('mpsoc_name');
if (length($name)==0){
message_dialog("Please define the MPSoC name!");
return ;
}
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$name";
my $sw = "$target_dir/sw";
my ($app,$table,$tview) = software_main($sw);
my $self=shift;
my $name=$self->object_get_attribute('mpsoc_name');
if (length($name)==0){
message_dialog("Please define the MPSoC name!");
return ;
}
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$name";
my $sw = "$target_dir/sw";
my ($app,$table,$tview) = software_main($sw);
 
 
my $make = def_image_button('icons/gen.png','Compile');
my $prog= def_image_button('icons/write.png','Program the memories');
$table->attach ($make,5, 6, 1,2,'shrink','shrink',0,0);
$table->attach ($prog,9, 10, 1,2,'shrink','shrink',0,0);
my $make = def_image_button('icons/gen.png','Compile');
my $prog= def_image_button('icons/write.png','Program the memories');
$table->attach ($make,5, 6, 1,2,'shrink','shrink',0,0);
$table->attach ($prog,9, 10, 1,2,'shrink','shrink',0,0);
 
$make -> signal_connect("clicked" => sub{
$app->do_save();
append_to_textview($tview,' ');
run_make_file($sw,$tview);
$make -> signal_connect("clicked" => sub{
my $load= show_gif("icons/load.gif");
$table->attach ($load,7, 8, 1,2,'shrink','shrink',0,0);
$load->show_all;
$app->do_save();
append_to_textview($tview,' ');
run_make_file($sw,$tview);
$load->destroy;
 
});
#Programe the board
$prog-> signal_connect("clicked" => sub{
my $error = 0;
my $bash_file="$sw/program.sh";
my $jtag_intfc="$sw/jtag_intfc.sh";
add_info(\$tview,"Programe the board using quartus_pgm and $bash_file file\n");
#check if the programming file exists
unless (-f $bash_file) {
add_colored_info(\$tview,"\tThe $bash_file does not exists! \n", 'red');
$error=1;
}
#check if the jtag_intfc.sh file exists
unless (-f $jtag_intfc) {
add_colored_info(\$tview,"\tThe $jtag_intfc does not exists!. Press the compile button and select your FPGA board first to generate $jtag_intfc file\n", 'red');
$error=1;
}
return if($error);
my $command = "cd $sw; sh program.sh";
add_info(\$tview,"$command\n");
my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout($command);
if(length $stderr>1){
add_colored_info(\$tview,"$stderr\n",'red');
add_colored_info(\$tview,"Memory was not programed successfully!\n",'red');
}else {
});
#Programe the board
$prog-> signal_connect("clicked" => sub{
my $error = 0;
my $bash_file="$sw/program.sh";
my $jtag_intfc="$sw/jtag_intfc.sh";
add_info(\$tview,"Programe the board using quartus_pgm and $bash_file file\n");
#check if the programming file exists
unless (-f $bash_file) {
add_colored_info(\$tview,"\tThe $bash_file does not exists! \n", 'red');
$error=1;
}
#check if the jtag_intfc.sh file exists
unless (-f $jtag_intfc) {
add_colored_info(\$tview,"\tThe $jtag_intfc does not exists!. Press the compile button and select your FPGA board first to generate $jtag_intfc file\n", 'red');
$error=1;
}
return if($error);
my $command = "cd $sw; sh program.sh";
add_info(\$tview,"$command\n");
my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout($command);
if(length $stderr>1){
add_colored_info(\$tview,"$stderr\n",'red');
add_colored_info(\$tview,"Memory was not programed successfully!\n",'red');
}else {
 
if($exit){
add_colored_info(\$tview,"$stdout\n",'red');
add_colored_info(\$tview,"Memory was not programed successfully!\n",'red');
}else{
add_info(\$tview,"$stdout\n");
add_colored_info(\$tview,"Memory is programed successfully!\n",'blue');
if($exit){
add_colored_info(\$tview,"$stdout\n",'red');
add_colored_info(\$tview,"Memory was not programed successfully!\n",'red');
}else{
add_info(\$tview,"$stdout\n");
add_colored_info(\$tview,"Memory is programed successfully!\n",'blue');
 
}
}
});
}
}
});
 
}
 
1846,63 → 1607,63
 
 
#############
# load_mpsoc
# load_mpsoc
#############
 
sub load_mpsoc{
my ($mpsoc,$info)=@_;
my $file;
my $dialog = Gtk2::FileChooserDialog->new(
'Select a File', undef,
'open',
'gtk-cancel' => 'cancel',
'gtk-ok' => 'ok',
);
my ($mpsoc,$info)=@_;
my $file;
my $dialog = Gtk2::FileChooserDialog->new(
'Select a File', undef,
'open',
'gtk-cancel' => 'cancel',
'gtk-ok' => 'ok',
);
 
my $filter = Gtk2::FileFilter->new();
$filter->set_name("MPSoC");
$filter->add_pattern("*.MPSOC");
$dialog->add_filter ($filter);
my $dir = Cwd::getcwd();
$dialog->set_current_folder ("$dir/lib/mpsoc") ;
my @newsocs=$mpsoc->mpsoc_get_soc_list();
add_info(\$info,'');
if ( "ok" eq $dialog->run ) {
$file = $dialog->get_filename;
my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
if($suffix eq '.MPSOC'){
my $pp= eval { do $file };
if ($@ || !defined $pp){
add_info(\$info,"**Error: cannot open $file file: $@\n");
$dialog->destroy;
return;
}
my $filter = Gtk2::FileFilter->new();
$filter->set_name("MPSoC");
$filter->add_pattern("*.MPSOC");
$dialog->add_filter ($filter);
my $dir = Cwd::getcwd();
$dialog->set_current_folder ("$dir/lib/mpsoc") ;
my @newsocs=$mpsoc->mpsoc_get_soc_list();
add_info(\$info,'');
if ( "ok" eq $dialog->run ) {
$file = $dialog->get_filename;
my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
if($suffix eq '.MPSOC'){
my ($pp,$r,$err) = regen_object($file );
if ($r){
add_info(\$info,"**Error: cannot open $file file: $err\n");
$dialog->destroy;
return;
}
 
clone_obj($mpsoc,$pp);
#read save mpsoc socs
my @oldsocs=$mpsoc->mpsoc_get_soc_list();
#add exsiting SoCs and add them to mpsoc
my $error;
#print "old: @oldsocs\n new @newsocs \n";
foreach my $p (@oldsocs) {
#print "$p\n";
my @num= $mpsoc->mpsoc_get_soc_tiles_num($p);
if (scalar @num && ( grep (/^$p$/,@newsocs)==0)){
my $m="Processing tile $p that has been used for ties @num but is not located in librray anymore\n";
$error = (defined $error ) ? "$error $m" : $m;
}
$mpsoc->mpsoc_remove_soc ($p) if (grep (/^$p$/,@newsocs)==0);
clone_obj($mpsoc,$pp);
#read save mpsoc socs
my @oldsocs=$mpsoc->mpsoc_get_soc_list();
#add exsiting SoCs and add them to mpsoc
my $error;
#print "old: @oldsocs\n new @newsocs \n";
foreach my $p (@oldsocs) {
#print "$p\n";
my @num= $mpsoc->mpsoc_get_soc_tiles_num($p);
if (scalar @num && ( grep (/^$p$/,@newsocs)==0)){
my $m="Processing tile $p that has been used for ties @num but is not located in librray anymore\n";
$error = (defined $error ) ? "$error $m" : $m;
}
$mpsoc->mpsoc_remove_soc ($p) if (grep (/^$p$/,@newsocs)==0);
 
}
@newsocs=get_soc_list($mpsoc,$info); # add all existing socs
add_info(\$info,"**Error: \n $error\n") if(defined $error);
}
@newsocs=get_soc_list($mpsoc,$info); # add all existing socs
add_info(\$info,"**Error: \n $error\n") if(defined $error);
 
set_gui_status($mpsoc,"load_file",0);
}
set_gui_status($mpsoc,"load_file",0);
}
}
$dialog->destroy;
}
1911,138 → 1672,142
# main
############
sub mpsocgen_main{
my $infc = interface->interface_new();
my $soc = ip->lib_new ();
my $mpsoc= mpsoc->mpsoc_new();
set_gui_status($mpsoc,"ideal",0);
my $main_table = Gtk2::Table->new (25, 12, FALSE);
# The box which holds the info, warning, error ... mesages
my ($infobox,$info)= create_text();
my $noc_conf_box=get_config ($mpsoc,$info);
my $noc_tiles=gen_tiles($mpsoc);
my $infc = interface->interface_new();
my $soc = ip->lib_new ();
my $mpsoc= mpsoc->mpsoc_new();
set_gui_status($mpsoc,"ideal",0);
my $main_table = Gtk2::Table->new (25, 12, FALSE);
# The box which holds the info, warning, error ... mesages
my ($infobox,$info)= create_text();
my $noc_conf_box=get_config ($mpsoc,$info);
my $noc_tiles=gen_tiles($mpsoc);
 
my $scr_conf = new Gtk2::ScrolledWindow (undef, undef);
$scr_conf->set_policy( "automatic", "automatic" );
$scr_conf->add_with_viewport($noc_conf_box);
my $scr_tile = new Gtk2::ScrolledWindow (undef, undef);
$scr_tile->set_policy( "automatic", "automatic" );
$scr_tile->add_with_viewport($noc_tiles);
my $scr_conf = new Gtk2::ScrolledWindow (undef, undef);
$scr_conf->set_policy( "automatic", "automatic" );
$scr_conf->add_with_viewport($noc_conf_box);
my $scr_tile = new Gtk2::ScrolledWindow (undef, undef);
$scr_tile->set_policy( "automatic", "automatic" );
$scr_tile->add_with_viewport($noc_tiles);
 
$main_table->set_row_spacings (4);
$main_table->set_col_spacings (1);
my $generate = def_image_button('icons/gen.png','Generate RTL');
my $open = def_image_button('icons/browse.png','Load MPSoC');
my $compile = def_image_button('icons/gate.png','Compile RTL');
my $software = def_image_button('icons/binary.png','Software');
my $entry=gen_entry_object($mpsoc,'mpsoc_name',undef,undef,undef,undef);
my $entrybox=labele_widget_info(" MPSoC name:",$entry);
my $h1=gen_hpaned($scr_conf,.3,$scr_tile);
my $v2=gen_vpaned($h1,.55,$infobox);
$main_table->set_row_spacings (4);
$main_table->set_col_spacings (1);
my $generate = def_image_button('icons/gen.png','Generate RTL');
my $open = def_image_button('icons/browse.png','Load MPSoC');
my $compile = def_image_button('icons/gate.png','Compile RTL');
my $software = def_image_button('icons/binary.png','Software');
my $entry=gen_entry_object($mpsoc,'mpsoc_name',undef,undef,undef,undef);
my $entrybox=labele_widget_info(" MPSoC name:",$entry);
my $diagram = def_image_button('icons/diagram.png','Diagram');
my $h1=gen_hpaned($scr_conf,.3,$scr_tile);
my $v2=gen_vpaned($h1,.55,$infobox);
 
$main_table->attach_defaults ($v2 , 0, 12, 0,24);
$main_table->attach ($open,0, 3, 24,25,'expand','shrink',2,2);
$main_table->attach_defaults ($entrybox,3, 7, 24,25);
$main_table->attach ($generate, 8, 9, 24,25,'expand','shrink',2,2);
$main_table->attach ($software, 9, 10, 24,25,'expand','shrink',2,2);
$main_table->attach ($compile, 10, 12, 24,25,'expand','shrink',2,2);
$main_table->attach_defaults ($v2 , 0, 12, 0,24);
$main_table->attach ($open,0, 3, 24,25,'expand','shrink',2,2);
$main_table->attach_defaults ($entrybox,3, 6, 24,25);
$main_table->attach ($diagram, 6, 7, 24,25,'expand','shrink',2,2);
$main_table->attach ($generate, 8, 9, 24,25,'expand','shrink',2,2);
$main_table->attach ($software, 9, 10, 24,25,'expand','shrink',2,2);
$main_table->attach ($compile, 10, 12, 24,25,'expand','shrink',2,2);
 
 
 
#check soc status every 0.5 second. referesh device table if there is any changes
Glib::Timeout->add (100, sub{
my ($state,$timeout)= get_gui_status($mpsoc);
#check soc status every 0.5 second. referesh device table if there is any changes
Glib::Timeout->add (100, sub{
my ($state,$timeout)= get_gui_status($mpsoc);
 
if ($timeout>0){
$timeout--;
set_gui_status($mpsoc,$state,$timeout);
}elsif ($state eq 'save_project'){
# Write object file
my $name=$mpsoc->object_get_attribute('mpsoc_name');
open(FILE, ">lib/mpsoc/$name.MPSOC") || die "Can not open: $!";
print FILE perl_file_header("$name.MPSOC");
print FILE Data::Dumper->Dump([\%$mpsoc],[$name]);
close(FILE) || die "Error closing file: $!";
set_gui_status($mpsoc,"ideal",0);
}
elsif( $state ne "ideal" ){
$noc_conf_box->destroy();
$noc_conf_box=get_config ($mpsoc,$info);
$scr_conf->add_with_viewport($noc_conf_box);
$noc_tiles->destroy();
$noc_tiles=gen_tiles($mpsoc);
$scr_tile->add_with_viewport($noc_tiles);
$h1 -> pack1($scr_conf, TRUE, TRUE);
$h1 -> pack2($scr_tile, TRUE, TRUE);
$v2-> pack1($h1, TRUE, TRUE);
$h1->show_all;
$main_table->show_all();
my $saved_name=$mpsoc->object_get_attribute('mpsoc_name');
if(defined $saved_name) {$entry->set_text($saved_name);}
set_gui_status($mpsoc,"ideal",0);
}
return TRUE;
} );
$generate-> signal_connect("clicked" => sub{
generate_mpsoc($mpsoc,$info,1);
set_gui_status($mpsoc,"refresh_soc",1);
if ($timeout>0){
$timeout--;
set_gui_status($mpsoc,$state,$timeout);
}elsif ($state eq 'save_project'){
# Write object file
my $name=$mpsoc->object_get_attribute('mpsoc_name');
open(FILE, ">lib/mpsoc/$name.MPSOC") || die "Can not open: $!";
print FILE perl_file_header("$name.MPSOC");
print FILE Data::Dumper->Dump([\%$mpsoc],[$name]);
close(FILE) || die "Error closing file: $!";
set_gui_status($mpsoc,"ideal",0);
}
elsif( $state ne "ideal" ){
$noc_conf_box->destroy();
$noc_conf_box=get_config ($mpsoc,$info);
$scr_conf->add_with_viewport($noc_conf_box);
$noc_tiles->destroy();
$noc_tiles=gen_tiles($mpsoc);
$scr_tile->add_with_viewport($noc_tiles);
$h1 -> pack1($scr_conf, TRUE, TRUE);
$h1 -> pack2($scr_tile, TRUE, TRUE);
$v2-> pack1($h1, TRUE, TRUE);
$h1->show_all;
$main_table->show_all();
my $saved_name=$mpsoc->object_get_attribute('mpsoc_name');
if(defined $saved_name) {$entry->set_text($saved_name);}
set_gui_status($mpsoc,"ideal",0);
}
return TRUE;
} );
$generate-> signal_connect("clicked" => sub{
generate_mpsoc($mpsoc,$info,1);
set_gui_status($mpsoc,"refresh_soc",1);
 
});
});
 
 
$open-> signal_connect("clicked" => sub{
set_gui_status($mpsoc,"ref",5);
load_mpsoc($mpsoc,$info);
});
$open-> signal_connect("clicked" => sub{
set_gui_status($mpsoc,"ref",5);
load_mpsoc($mpsoc,$info);
});
 
 
$compile -> signal_connect("clicked" => sub{
$mpsoc->object_add_attribute('compile','compilers',"QuartusII,Verilator,Modelsim");
my $name=$mpsoc->object_get_attribute('mpsoc_name');
if (length($name)==0){
message_dialog("Please define the MPSoC name!");
return ;
}
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$name";
my $top_file = "$target_dir/src_verilog/${name}_top.v";
if (-f $top_file){
generate_mpsoc($mpsoc,$info,0);
select_compiler($mpsoc,$name,$top_file,$target_dir);
} else {
message_dialog("Cannot find $top_file file. Please run RTL Generator first!");
return;
}
});
$software -> signal_connect("clicked" => sub{
software_edit_mpsoc($mpsoc);
$compile -> signal_connect("clicked" => sub{
$mpsoc->object_add_attribute('compile','compilers',"QuartusII,Verilator,Modelsim");
my $name=$mpsoc->object_get_attribute('mpsoc_name');
if (length($name)==0){
message_dialog("Please define the MPSoC name!");
return ;
}
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$name";
my $top_file = "$target_dir/src_verilog/${name}_top.v";
if (-f $top_file){
generate_mpsoc($mpsoc,$info,0);
select_compiler($mpsoc,$name,$top_file,$target_dir);
} else {
message_dialog("Cannot find $top_file file. Please run RTL Generator first!");
return;
}
});
$software -> signal_connect("clicked" => sub{
software_edit_mpsoc($mpsoc);
 
});
});
 
my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
$sc_win->set_policy( "automatic", "automatic" );
$sc_win->add_with_viewport($main_table);
$diagram-> signal_connect("clicked" => sub{
show_topology_diagram ($mpsoc);
});
my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
$sc_win->set_policy( "automatic", "automatic" );
$sc_win->add_with_viewport($main_table);
 
return $sc_win;
return $sc_win;
 
}
 
/mpsoc_verilog_gen.pl
2,6 → 2,10
 
use strict;
use warnings;
 
use FindBin;
use lib $FindBin::Bin;
 
use mpsoc;
use soc;
use ip;
38,7 → 42,7
my ($noc_param,$pass_param)=gen_noc_param_v($mpsoc);
#generate the noc
my $noc_v=gen_noc_v($pass_param);
my $noc_v=gen_noc_v($mpsoc,$pass_param);
#generate socs
my $socs_v=gen_socs_v($mpsoc,\$io_v,\$io_def_v,\$top_io,$top_ip,$sw_dir);
106,23 → 110,10
end
endfunction // log2
function integer CORE_NUM;
input integer x,y;
begin
CORE_NUM = ((y * NX) + x);
end
endfunction
 
localparam Fw = 2+V+Fpay,
NC = (TOPOLOGY=="RING" || TOPOLOGY=="LINE" )? NX : NX*NY, //number of cores
Xw = log2(NX),
Yw = log2(NY) ,
Cw = (C>1)? log2(C): 1,
NCw = log2(NC),
NCV = NC * V,
NCFw = NC * Fw;
';
return $p;
136,21 → 127,17
my $mpsoc=shift;
my $socs_param="
//SOC parameters\n";
my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
my $processors_en=0;
for (my $y=0;$y<$ny;$y++){
for (my $x=0; $x<$nx;$x++){
my $tile=($nx*$y)+ $x;
my ($NE, $NR, $RAw, $EAw, $Fw) = get_topology_info($mpsoc);
my $processors_en=0;
for (my $tile=0;$tile<$NE;$tile++){
my ($soc_name,$n,$soc_num)=$mpsoc->mpsoc_get_tile_soc_name($tile);
if(defined $soc_name) {
my $param= gen_soc_param($mpsoc,$soc_name,$soc_num,$tile);
add_text_to_string(\$socs_param,$param);
}
}}#x&y
}#$tile
$socs_param="$socs_param \n";
return $socs_param;
return $socs_param;
}
 
 
271,33 → 258,47
 
 
sub gen_noc_v{
my $pass_param = shift;
my ($mpsoc,$pass_param) = @_;
my ($NE, $NR, $RAw, $EAw, $Fw) = get_topology_info($mpsoc);
my $noc = read_verilog_file("../src_noc/noc.v");
my @noc_param=$noc->get_modules_parameters_not_local_order('noc');
my $noc_v='
my $noc_v="
//NoC ports
wire [Fw-1 : 0] ni_flit_out [NC-1 :0];
wire [NC-1 : 0] ni_flit_out_wr;
wire [V-1 : 0] ni_credit_in [NC-1 :0];
wire [Fw-1 : 0] ni_flit_in [NC-1 :0];
wire [NC-1 : 0] ni_flit_in_wr;
wire [V-1 : 0] ni_credit_out [NC-1 :0];
wire [NCFw-1 : 0] flit_out_all;
wire [NC-1 : 0] flit_out_wr_all;
wire [NCV-1 : 0] credit_in_all;
wire [NCFw-1 : 0] flit_in_all;
wire [NC-1 : 0] flit_in_wr_all;
wire [NCV-1 : 0] credit_out_all;
wire noc_clk,noc_reset;
';
 
localparam
NE = $NE,
NR = $NR,
RAw = $RAw,
EAw = $EAw,
Fw = $Fw,
NEFw = NE * Fw,
NEV = NE * V;
 
//NoC ports
// connection to NI modules
wire [Fw-1 : 0] ni_flit_out [NE-1 :0];
wire [NE-1 : 0] ni_flit_out_wr;
wire [V-1 : 0] ni_credit_in [NE-1 :0];
wire [Fw-1 : 0] ni_flit_in [NE-1 :0];
wire [NE-1 : 0] ni_flit_in_wr;
wire [V-1 : 0] ni_credit_out [NE-1 :0];
//connection wire to NoC
wire [NEFw-1 : 0] flit_out_all;
wire [NE-1 : 0] flit_out_wr_all;
wire [NEV-1 : 0] credit_in_all;
wire [NEFw-1 : 0] flit_in_all;
wire [NE-1 : 0] flit_in_wr_all;
wire [NEV-1 : 0] credit_out_all;
wire noc_clk,noc_reset;
";
$noc_v="$noc_v
//NoC\n \tnoc #(\n";
my $i=0;
339,13 → 340,10
add_text_to_string(\$noc_v,'
 
//NoC port assignment
genvar x,y;
genvar IP_NUM;
generate
for (x=0; x<NX; x=x+1) begin :x_loop1
for (y=0; y<NY; y=y+1) begin: y_loop1
localparam IP_NUM = ((y * NX) + x);
for (IP_NUM=0; IP_NUM<NE; IP_NUM=IP_NUM+1) begin :endp
assign ni_flit_in [IP_NUM] = flit_out_all [(IP_NUM+1)*Fw-1 : IP_NUM*Fw];
assign ni_flit_in_wr [IP_NUM] = flit_out_wr_all [IP_NUM];
assign credit_in_all [(IP_NUM+1)*V-1 : IP_NUM*V] = ni_credit_out [IP_NUM];
352,37 → 350,12
assign flit_in_all [(IP_NUM+1)*Fw-1 : IP_NUM*Fw] = ni_flit_out [IP_NUM];
assign flit_in_wr_all [IP_NUM] = ni_flit_out_wr [IP_NUM];
assign ni_credit_in [IP_NUM] = credit_out_all [(IP_NUM+1)*V-1 : IP_NUM*V];
end
end
endgenerate
 
'
);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
return $noc_v;
}
393,82 → 366,35
sub gen_socs_v{
my ($mpsoc,$io_v_ref,$io_def_v,$top_io_ref,$top_ip,$sw_dir)=@_;
#generate loop
# my $socs_v='
# genvar x,y;
#
# generate
# for (x=0; x<NX; x=x+1) begin :x_loop1
# for (y=0; y<NY; y=y+1) begin: y_loop1
# localparam IP_NUM = CORE_NUM(x,y);' ;
# my @socs= $mpsoc->mpsoc_get_soc_list();
# foreach my $soc (@socs){
# #tile num condition
# my @tiles= $mpsoc->mpsoc_get_soc_tiles_num($soc);
# if(scalar @tiles>0){
# my $condition="\n\t\tif(";
# my $s=compress_nums( @tiles);
# my @sep=split(',',$s);
# my $i=0;
# foreach my $p (@sep){
# my @range=split(':',$p);
# my $tt;
# if($i==0){
# $tt= (scalar @range>1)? "(IP_NUM>=$range[0] && IP_NUM<=$range[1])":"(IP_NUM==$range[0])" ;
# }else{
# }
# add_text_to_string(\$condition,$tt);
# $i=1;
# }
# add_text_to_string(\$condition,") begin :${soc}_if\n ");
# #soc instance
# my $soc_v= gen_soc_v($mpsoc,$soc);
#
# add_text_to_string(\$socs_v,$condition );
# add_text_to_string(\$socs_v,$soc_v);
# add_text_to_string(\$socs_v,"\t\tend // ${soc}_if \n");
# }#scalar @tile
# } #froeach soc
my $socs_v;
my $socs_v;
my ($NE, $NR, $RAw, $EAw, $EYw)= get_topology_info ($mpsoc);
my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
my $processors_en=0;
for (my $y=0;$y<$ny;$y++){
for (my $x=0; $x<$nx;$x++){
my $tile_num=($nx*$y)+ $x;
my ($soc_name,$n,$soc_num)=$mpsoc->mpsoc_get_tile_soc_name($tile_num);
if(defined $soc_name) {
my ($soc_v,$en)= gen_soc_v($mpsoc,$soc_name,$tile_num,$x,$y,$soc_num,$io_v_ref,$io_def_v,$top_io_ref,$top_ip,$sw_dir);
my $processors_en=0;
for (my $id=0;$id<$NE;$id++){
my ($soc_name,$n,$soc_num)=$mpsoc->mpsoc_get_tile_soc_name($id);
if(defined $soc_name) {
my ($soc_v,$en)= gen_soc_v($mpsoc,$soc_name,$id,$soc_num,$io_v_ref,$io_def_v,$top_io_ref,$top_ip,$sw_dir);
add_text_to_string(\$socs_v,$soc_v);
$processors_en|=$en;
}else{
#this tile is not connected to any ip. the noc input ports will be connected to ground
my $soc_v="\n\n // Tile:$tile_num (x=$x,y=$y) is not assigned to any ip\n";
my $soc_v="\n\n // Tile:$id is not assigned to any ip\n";
$soc_v="$soc_v
assign ni_credit_out[$tile_num]={V{1'b0}};
assign ni_flit_out[$tile_num]={Fw{1'b0}};
assign ni_flit_out_wr[$tile_num]=1'b0;
assign ni_credit_out[$id]={V{1'b0}};
assign ni_flit_out[$id]={Fw{1'b0}};
assign ni_flit_out_wr[$id]=1'b0;
";
add_text_to_string(\$socs_v,$soc_v);
}
}}
}
if($processors_en){
add_text_to_string($io_v_ref,",\n\tprocessors_en");
490,16 → 416,22
 
 
sub gen_soc_v{
my ($mpsoc,$soc_name,$tile_num,$x,$y,$soc_num,$io_v_ref,$io_def_v,$top_io_ref,$top_ip,$sw_path)=@_;
my ($mpsoc,$soc_name,$tile_num,$soc_num,$io_v_ref,$io_def_v,$top_io_ref,$top_ip,$sw_path)=@_;
my $soc_v;
my $processor_en=0;
my $xw= log2($mpsoc->object_get_attribute('noc_param',"NX"));
my $yw= log2($mpsoc->object_get_attribute('noc_param',"NY"));
$soc_v="\n\n // Tile:$tile_num (x=$x,y=$y)\n \t$soc_name #(\n";
my ($NE, $NR, $RAw, $EAw, $Fw)= get_topology_info ($mpsoc);
my $e_addr=endp_addr_encoder($mpsoc,$tile_num);
my $router_num = get_connected_router_id_to_endp($mpsoc,$tile_num);
my $r_addr=router_addr_encoder($mpsoc,$router_num);
$soc_v="\n\n // Tile:$tile_num ($e_addr)\n \t$soc_name #(\n";
# Global parameter
add_text_to_string(\$soc_v,"\t\t.CORE_ID($tile_num),\n\t\t.SW_LOC(\"$sw_path/tile$tile_num\")");
# ni parameter
my $top=$mpsoc->mpsoc_get_soc($soc_name);
my @nis=get_NI_instance_list($top);
509,6 → 441,8
#other parameters
my %params=$top->top_get_default_soc_param();
foreach my $p (@noc_param){
my $parm_next = $p;
$parm_next =~ s/${inst_name}_//;
546,8 → 480,9
foreach my $p (@ports){
my($inst,$range,$type,$intfc_name,$intfc_port)= $top->top_get_port($p);
my $q=($intfc_port eq "current_x")? "$xw\'d$x" :
($intfc_port eq "current_y")? "$yw\'d$y" :"ni_$intfc_port\[$tile_num\]";
my $q= ($intfc_port eq "current_e_addr")? "$EAw\'d$e_addr" :
($intfc_port eq "current_r_addr")? "$RAw\'d$r_addr" :
"ni_$intfc_port\[$tile_num\]";
add_text_to_string(\$soc_v,',') if ($i);
add_text_to_string(\$soc_v,"\n\t\t.$p($q)");
$i=1;
/simulator.pl
2,6 → 2,9
use Glib qw/TRUE FALSE/;
use strict;
use warnings;
use FindBin;
use lib $FindBin::Bin;
 
use Gtk2;
use Gtk2::Ex::Graph::GD;
use GD::Graph::Data;
23,17 → 26,22
require "readme_gen.pl";
require "graph.pl";
 
 
use List::MoreUtils qw(uniq);
 
 
 
 
sub generate_sim_bin_file() {
sub generate_sim_bin_file {
my ($simulate,$info_text) =@_;
$simulate->object_add_attribute('status',undef,'run');
set_gui_status($simulate,"ref",1);
my ($nr,$ne,$router_p,$ref_tops,$includ_h)= get_noc_verilator_top_modules_info($simulate);
my %tops = %{$ref_tops};
$tops{Vtraffic} = "traffic_gen_verilator.v";
my $target_dir= "$ENV{PRONOC_WORK}/simulate";
my $dir = Cwd::getcwd();
43,54 → 51,45
my $script_dir="$project_dir/script";
my $testbench_file= "$src_verilator_dir/simulator.cpp";
my $src_verilog_dr ="$target_dir/src_verilog";
my $target_verilog_dr ="$target_dir/src_verilog";
my $obj_dir ="$target_dir/verilator/processed_rtl/obj_dir/";
rmtree("$src_verilog_dr");
mkpath("$src_verilog_dr/",1,01777);
rmtree("$target_dir/verilator");
rmtree("$target_verilog_dr");
mkpath("$target_verilog_dr/",1,01777);
#copy src_verilator files
my @files=(
$src_noc_dir,
"$src_verilator_dir/noc_connection.sv",
"$src_verilator_dir/router_verilator.v",
"$src_verilator_dir/traffic_gen_verilator.v"
);
my @files_list = File::Find::Rule->file()
->name( '*.v','*.V','*.sv' )
->in( "$src_verilator_dir" );
 
#make sure source files have key word 'module'
my @files;
foreach my $p (@files_list){
push (@files,$p) if(check_file_has_string($p,'module'));
}
push (@files,$src_noc_dir);
copy_file_and_folders (\@files,$project_dir,$src_verilog_dr);
#my @files=(
# $src_noc_dir,
# "$src_verilator_dir/noc_connection.sv",
# "$src_verilator_dir/mesh_torus_noc_connection.sv",
# "$src_verilator_dir/router_verilator.v",
# "$src_verilator_dir/traffic_gen_verilator.v"
#);
copy_file_and_folders (\@files,$project_dir,$target_verilog_dr);
# generate NoC parameter file
my ($noc_param,$pass_param)=gen_noc_param_v($simulate);
open(FILE, ">$src_verilog_dr/parameter.v") || die "Can not open: $!";
open(FILE, ">$target_verilog_dr/parameter.v") || die "Can not open: $!";
my $fifow=$simulate->object_get_attribute('fpga_param','TIMSTMP_FIFO_NUM');
gen_vrouter_param_v($simulate,$target_verilog_dr);
 
 
 
print FILE " \`ifdef INCLUDE_PARAM \n \n
$noc_param
/* verilator lint_off WIDTH */
localparam P=(TOPOLOGY==\"RING\" || TOPOLOGY==\"LINE\")? 3 : 5;
localparam ROUTE_TYPE = (ROUTE_NAME == \"XY\" || ROUTE_NAME == \"TRANC_XY\" )? \"DETERMINISTIC\" :
(ROUTE_NAME == \"DUATO\" || ROUTE_NAME == \"TRANC_DUATO\" )? \"FULL_ADAPTIVE\": \"PAR_ADAPTIVE\";
/* verilator lint_on WIDTH */
//simulation parameter
localparam MAX_RATIO = ".MAX_RATIO.";
localparam MAX_PCK_NUM = ".MAX_SIM_CLKs.";
localparam MAX_PCK_SIZ = ".MAX_PCK_SIZ.";
localparam MAX_SIM_CLKs= ".MAX_SIM_CLKs.";
localparam TIMSTMP_FIFO_NUM = $fifow;
\n \n \`endif" ;
close FILE;
#generate routers with different port num
my %tops = (
"Vrouter" => "router_verilator.v",
"Vnoc" => "noc_connection.sv",
"Vtraffic"=> "traffic_gen_verilator.v"
);
my $result = verilator_compilation (\%tops,$target_dir,$$info_text);
if ($result){
99,40 → 98,26
add_colored_info($info_text,"Verilator compilation failed!\n","red");
$simulate->object_add_attribute('status',undef,'programer_failed');
set_gui_status($simulate,"ref",1);
print "gen-ended!\n";
return;
}
}
 
 
#copy simulation c header files
@files = File::Find::Rule->file()
->name( '*.h')
->in( "$src_verilator_dir" );
@files=(
"$src_verilator_dir/traffic_task_graph.h",
);
 
copy_file_and_folders (\@files,$project_dir,$obj_dir);
copy($testbench_file,"$obj_dir/testbench.cpp");
#compile the testbench
my $param_h=gen_noc_param_h($simulate);
my $text = gen_sim_parameter_h($param_h,$includ_h,$ne,$nr,$router_p,$fifow);
$param_h =~ s/\d\'b/ /g;
open(FILE, ">$obj_dir/parameter.h") || die "Can not open: $!";
print FILE "
#ifndef INCLUDE_PARAM
#define INCLUDE_PARAM \n \n
 
$param_h
print FILE "$text";
int P=(strcmp (TOPOLOGY,\"RING\")==0 || strcmp (TOPOLOGY,\"LINE\")==0 ) ? 3 : 5;
//simulation parameter
#define MAX_RATIO ".MAX_RATIO."
#define AVG_LATENCY_METRIC \"HEAD_2_TAIL\"
#define TIMSTMP_FIFO_NUM $fifow
\n \n \#endif" ;
close FILE;
142,6 → 127,7
if ($result ==0){
$simulate->object_add_attribute('status',undef,'programer_failed');
set_gui_status($simulate,"ref",1);
print "gen-ended!\n";
return;
}
149,6 → 135,7
if ($result ==0){
$simulate->object_add_attribute('status',undef,'programer_failed');
set_gui_status($simulate,"ref",1);
print "gen-ended!\n";
return;
}
166,7 → 153,7
#create project directory if it does not exist
my ($stdout,$exit)=run_cmd_in_back_ground_get_stdout("mkdir -p $path" );
if($exit != 0 ){ print "$stdout\n"; message_dialog($stdout,'error'); return;}
if($exit != 0 ){ print "$stdout\n"; print "gen-ended!\n"; message_dialog($stdout,'error'); return;}
 
176,6 → 163,7
add_colored_info($info_text,"Verilator compilation failed!\n","red");
$simulate->object_add_attribute('status',undef,'programer_failed');
set_gui_status($simulate,"ref",1);
print "gen-ended!\n";
return;
}
182,7 → 170,7
#copy ($bin,"$path/$name") or die "Can not copy: $!";
($stdout,$exit)=run_cmd_in_back_ground_get_stdout("cp -f $bin $path/$name");
if($exit != 0 ){ print "$stdout\n"; message_dialog($stdout,'error'); return;}
if($exit != 0 ){ print "$stdout\n"; print "gen-ended!\n"; message_dialog($stdout,'error'); return;}
#save noc info
open(FILE, ">$path/$name.inf") || die "Can not open: $!";
192,11 → 180,13
$pp{'sim_param'}= $simulate->{'sim_param'};
print FILE Data::Dumper->Dump([\%pp],["emulate_info"]);
close(FILE) || die "Error closing file: $!";
 
print "gen-ended successfully!\n";
message_dialog("The simulation binary file has been successfully generated in $path!");
 
$simulate->object_add_attribute('status',undef,'ideal');
set_gui_status($simulate,"ref",1);
#make project dir
#my $dir= $simulate->object_get_attribute ("sim_param","BIN_DIR");
#my $name=$simulate->object_get_attribute ("sim_param","SAVE_NAME");
203,11 → 193,6
#my $path= "$dir/$name";
#add_info($info_text, "$src_verilator_dir!\n");
#mkpath("$path",1,01777);
 
 
 
 
}
 
 
258,9 → 243,9
$file = $dialog->get_filename;
my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
if($suffix eq '.SIM'){
my $pp= eval { do $file };
if ($@ || !defined $pp){
add_info($info,"**Error reading $file file: $@\n");
my ($pp,$r,$err) = regen_object($file);
if ($r){
add_info($info,"**Error reading $file file: $err\n");
$dialog->destroy;
return;
}
465,21 → 450,17
attach_widget_to_table ($table,$row,gen_label_in_left(" Verilated Model:"),gen_button_message ("Select the verilator simulation file. Different NoC simulators can be generated using Generate NoC configuration tab.","icons/help.png"),
gen_combobox_object ($self,$sample, "sof_file", $exe_files, undef, undef, undef)); $row++;
 
$row=noc_param_widget ($self, "Traffic Type", "TRAFFIC_TYPE", "Synthetic", 'Combo-box', "Synthetic,Task-graph", undef, $table,$row,1, $sample, 1,'ref_set_win');
 
my $coltmp=0;
($row,$coltmp)=add_param_widget ($self, "Traffic Type", "TRAFFIC_TYPE", "Synthetic", 'Combo-box', "Synthetic,Task-graph", undef, $table,$row,undef,1, $sample, 1,'ref_set_win');
my $traffictype=$self->object_get_attribute($sample,"TRAFFIC_TYPE");
my $MIN_PCK_SIZE=$self->object_get_attribute($sample,"MIN_PCK_SIZE");
 
 
my $max_pck_num = get_MAX_PCK_NUM();
my $max_sim_clk = get_MAX_SIM_CLKs();
 
if($traffictype eq "Synthetic"){
my $min=$self->object_get_attribute($sample,'MIN_PCK_SIZE');
487,7 → 468,10
$min=$max=5 if(!defined $min);
my $avg=floor(($min+$max)/2);
my $traffics="tornado,transposed 1,transposed 2,bit reverse,bit complement,random,hot spot";
my $max_pck_size = get_MAX_PCK_SIZ();
my $traffics="tornado,transposed 1,transposed 2,bit reverse,bit complement,random,hot spot,shuffle,bit rotation,neighbor";
my @synthinfo = (
497,28 → 481,25
{ label=>"Traffic name", param_name=>'traffic', type=>'Combo-box', default_val=>'random', content=>$traffics, info=>"Select traffic pattern", param_parent=>$sample, ref_delay=>1, new_status=>'ref_set_win'},
{ label=>"Min pck size :", param_name=>'MIN_PCK_SIZE', type=>'Spin-button', default_val=>5, content=>"2,$max,1", info=>"Minimum packet size in flit. The injected packet size is randomly selected between minimum and maximum packet size", param_parent=>$sample, ref_delay=>10, new_status=>'ref_set_win'},
{ label=>"Max pck size :", param_name=>'MAX_PCK_SIZE', type=>'Spin-button', default_val=>5, content=>"$min,".MAX_PCK_SIZ.",1", info=>"Maximum packet size in flit. The injected packet size is randomly selected between minimum and maximum packet size", param_parent=>$sample, ref_delay=>10, new_status=>'ref_set_win'},
{ label=>"Min pck size :", param_name=>'MIN_PCK_SIZE', type=>'Spin-button', default_val=>5, content=>"1,$max,1", info=>"Minimum packet size in flit. The injected packet size is randomly selected between minimum and maximum packet size", param_parent=>$sample, ref_delay=>10, new_status=>'ref_set_win'},
{ label=>"Max pck size :", param_name=>'MAX_PCK_SIZE', type=>'Spin-button', default_val=>5, content=>"$min,$max_pck_size,1", info=>"Maximum packet size in flit. The injected packet size is randomly selected between minimum and maximum packet size", param_parent=>$sample, ref_delay=>10, new_status=>'ref_set_win'},
{ label=>"Avg. Packet size:", param_name=>'PCK_SIZE', type=>'Combo-box', default_val=>$avg, content=>"$avg", info=>undef, param_parent=>$sample, ref_delay=>undef},
{ label=>"Total packet number limit:", param_name=>'PCK_NUM_LIMIT', type=>'Spin-button', default_val=>200000, content=>"2,".MAX_PCK_NUM.",1", info=>"Simulation will stop when total numbr of sent packets by all nodes reaches packet number limit or total simulation clock reach its limit", param_parent=>$sample, ref_delay=>undef, new_status=>undef},
{ label=>"Total packet number limit:", param_name=>'PCK_NUM_LIMIT', type=>'Spin-button', default_val=>200000, content=>"2,$max_pck_num,1", info=>"Simulation will stop when total numbr of sent packets by all nodes reaches packet number limit or total simulation clock reach its limit", param_parent=>$sample, ref_delay=>undef, new_status=>undef},
{ label=>"Simulator clocks limit:", param_name=>'SIM_CLOCK_LIMIT', type=>'Spin-button', default_val=>100000, content=>"2,".MAX_SIM_CLKs.",1", info=>"Each node stops sending packets when it reaches packet number limit or simulation clock number limit", param_parent=>$sample, ref_delay=>undef, new_status=>undef},
{ label=>"Simulator clocks limit:", param_name=>'SIM_CLOCK_LIMIT', type=>'Spin-button', default_val=>100000, content=>"2,$max_sim_clk,1", info=>"Each node stops sending packets when it reaches packet number limit or simulation clock number limit", param_parent=>$sample, ref_delay=>undef, new_status=>undef},
);
my $coltmp=0;
foreach my $d (@synthinfo) {
$row=noc_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
}
 
my $traffic=$self->object_get_attribute($sample,"traffic");
 
526,7 → 507,7
my $htable=def_table(10,2,FALSE);
my $d= { label=>'number of Hot Spot nodes:', param_name=>'HOTSPOT_NUM', type=>'Spin-button', default_val=>1, content=>"1,256,1", info=>"Number of hot spot nodes in the network", param_parent=>$sample, ref_delay=> 1, new_status=>'ref_set_win'};
$row=noc_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
my $l1=gen_label_help("Defne the tile number which is hotspt. All other nodes will send [Hot Spot traffic percentage] of their traffic to this node"," Hot Spot tile number \%");
my $l2=gen_label_help("If it is set as \"n\" then each node sends n % of its traffic to each hotspot node"," Hot Spot traffic \%");
594,7 → 575,6
}
if($traffictype eq "Task-graph"){
my @custominfo = (
604,15 → 584,14
{ label=>"Number of Files", param_name=>"TRAFFIC_FILE_NUM", type=>'Spin-button', default_val=>1, content=>"1,100,1", info=>"Select number of input files", param_parent=>$sample, ref_delay=>1, new_status=>'ref_set_win'},
{ label=>"Simulator clocks limit:", param_name=>'SIM_CLOCK_LIMIT', type=>'Spin-button', default_val=>100000, content=>"2,".MAX_SIM_CLKs.",1", info=>"Each node stops sending packets when it reaches packet number limit or simulation clock number limit", param_parent=>$sample, ref_delay=>undef, new_status=>undef},
{ label=>"Simulator clocks limit:", param_name=>'SIM_CLOCK_LIMIT', type=>'Spin-button', default_val=>100000, content=>"2,$max_sim_clk,1", info=>"Each node stops sending packets when it reaches packet number limit or simulation clock number limit", param_parent=>$sample, ref_delay=>undef, new_status=>undef},
);
foreach my $d (@custominfo) {
$row=noc_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
}
($row,$coltmp)=add_param_widget ($self, $d->{label}, $d->{param_name}, $d->{default_val}, $d->{type}, $d->{content}, $d->{info}, $table,$row,undef,1, $d->{param_parent}, $d->{ref_delay}, $d->{new_status});
}
my $open_in = "$ENV{'PRONOC_WORK'}/traffic_pattern";
686,6 → 665,7
}
add_info($info, "Simulation is done!\n");
printf "Simulation is done!\n";
$simulate->object_add_attribute('status',undef,'ideal');
set_gui_status($simulate,"ref",1);
}
697,9 → 677,7
my $r= $simulate->object_get_attribute($sample,"ratios");
my @ratios=@{check_inserted_ratios($r)};
#$emulate->object_add_attribute ("sample$i","status","run");
my $bin_path=$simulate->object_get_attribute ($sample,"sof_path");
my $bin_file=$simulate->object_get_attribute ($sample,"sof_file");
my $bin="$bin_path/$bin_file";
my $bin=get_sim_bin_path($simulate,$sample,$info);
#load traffic configuration
my $patern=$simulate->object_get_attribute ($sample,'traffic');
796,9 → 774,9
my ($simulate,$info,$sample,$name)=@_;
my $log= (defined $name)? "$ENV{PRONOC_WORK}/simulate/$name.log": "$ENV{PRONOC_WORK}/simulate/sim.log";
my $SIM_CLOCK_LIMIT=$simulate->object_get_attribute ($sample,"SIM_CLOCK_LIMIT");
my $bin_path=$simulate->object_get_attribute ($sample,"sof_path");
my $bin_file=$simulate->object_get_attribute ($sample,"sof_file");
my $bin="$bin_path/$bin_file";
my $bin=get_sim_bin_path($simulate,$sample,$info);
my $dir = Cwd::getcwd();
my $project_dir = abs_path("$dir/../.."); #mpsoc directory address
$bin= "$project_dir/$bin" if(!(-f $bin));
864,17 → 842,29
# check_sample
##########
 
sub check_sim_sample{
sub get_sim_bin_path {
my ($self,$sample,$info)=@_;
my $status=1;
my $bin_path=$self->object_get_attribute ($sample,"sof_path");
unless (-d $bin_path){
my $path= $self->object_get_attribute ("sim_param","BIN_DIR");
if(-d $path){
add_colored_info($info, "Warning: The given path ($bin_path) for searcing $sample bin file does not exist. The system search in default $path instead.\n",'green');
$bin_path=$path;
}
}
my $bin_file=$self->object_get_attribute ($sample,"sof_file");
my $sof="$bin_path/$bin_file";
return $sof;
}
 
sub check_sim_sample{
my ($self,$sample,$info)=@_;
my $status=1;
my $sof=get_sim_bin_path($self,$sample,$info);
# ckeck if sample have sof file
if(!defined $sof){
add_info($info, "Error: bin file has not set for $sample!\n");
add_colored_info($info, "Error: bin file has not set for $sample!\n",'red');
$self->object_add_attribute ($sample,"status","failed");
$status=0;
} else {
882,7 → 872,7
my ($name,$path,$suffix) = fileparse("$sof",qr"\..[^.]*$");
my $sof_info= "$path$name.inf";
if(!(-f $sof_info)){
add_info($info, "Could not find $name.inf file in $path. An information file is required for each sof file containig the device name and NoC configuration. Press F4 for more help.\n");
add_info($info, "Could not find $name.inf file in $path. An information file is required for each sof file containig the device name and NoC configuration. Press F3 for more help.\n");
$self->object_add_attribute ($sample,"status","failed");
$status=0;
}else { #add info
899,12 → 889,27
}
}
}
#check if sample min packet size matches in simulation
my $p= $self->object_get_attribute ($sample,"noc_info");
my $HW_MIN_PCK_SIZE=$p->{"MIN_PCK_SIZE"};
my $SIM_MIN_PCK_SIZE=$self->object_get_attribute ($sample,"MIN_PCK_SIZE");
if(!defined $HW_MIN_PCK_SIZE){
$HW_MIN_PCK_SIZE= 2;
#print "undef\n";
}
if($HW_MIN_PCK_SIZE>$SIM_MIN_PCK_SIZE){
add_colored_info($info, "Error: The minimum simulation packet size of $SIM_MIN_PCK_SIZE flit(s) is smaller than $HW_MIN_PCK_SIZE which is defined in generating verilog model of NoC!\n",'red');
$self->object_add_attribute ($sample,"status","failed");
$status=0;
}
#print "$HW_MIN_PCK_SIZE>$SIM_MIN_PCK_SIZE\n";
return $status;
}
 
 
 
 
############
# main
############
917,8 → 922,8
 
my $main_table = Gtk2::Table->new (25, 12, FALSE);
my ($infobox,$info)= create_text();
add_colors_to_textview($info);
 
my @pages =(
{page_name=>" Avg. throughput/latency", page_num=>0},
953,18 → 958,16
#my $device_win=show_active_dev($soc,$soc,$infc,$soc_state,\$refresh,$info);
my $generate = def_image_button('icons/forward.png','Run all');
my $open = def_image_button('icons/browse.png','Load');
my $generate = def_image_button('icons/forward.png','R_un all',FALSE,1);
my $open = def_image_button('icons/browse.png',"_Load",FALSE,1);
my $save = def_image_button('icons/save.png','Sav_e',FALSE,1);
my $save_all_results = def_image_button('icons/copy.png',"E_xtract all results",FALSE,1);
my ($entrybox,$entry) = def_h_labeled_entry('Save as:',undef);
my ($entrybox,$entry) = def_h_labeled_entry('Save as:',undef);
$entry->signal_connect( 'changed'=> sub{
my $name=$entry->get_text();
$simulate->object_add_attribute ("simulate_name",undef,$name);
});
my $save = def_image_button('icons/save.png','Save');
$entrybox->pack_end($save, FALSE, FALSE,0);
 
981,10 → 984,16
$main_table->attach_defaults ($h1 , 0, 12, 0,24);
$main_table->attach ($open,0, 3, 24,25,'expand','shrink',2,2);
$main_table->attach ($entrybox,3, 6, 24,25,'expand','shrink',2,2);
$main_table->attach ($generate, 6, 9, 24,25,'expand','shrink',2,2);
$main_table->attach ($open,0, 2, 24,25,'expand','shrink',2,2);
#$main_table->attach ($diagram, 2, 4, 24,25,'expand','shrink',2,2);
$main_table->attach ($entrybox,4, 7, 24,25,'expand','shrink',2,2);
$main_table->attach ($save_all_results, 7, 8, 24,25,'shrink','shrink',2,2);
$main_table->attach ($generate, 8, 9, 24,25,'expand','shrink',2,2);
$entry->signal_connect( 'changed'=> sub{
my $name=$entry->get_text();
$simulate->object_add_attribute ("simulate_name",undef,$name);
});
 
 
#check soc status every 0.5 second. referesh device table if there is any changes
1033,6 → 1042,8
} );
$generate-> signal_connect("clicked" => sub{
my @samples =$simulate->object_get_attribute_order("samples");
foreach my $sample (@samples){
1062,6 → 1073,14
});
$save_all_results-> signal_connect("clicked" => sub{
#Get the path where to save all the simulation results
my $open_in = $simulate->object_get_attribute ('sim_param','BIN_DIR');
get_dir_name($simulate,"Select the target directory","sim_param","ALL_RESULT_DIR",$open_in,'ref',1);
$simulate->object_add_attribute ("graph_save","save_all_result",1);
});
 
my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
$sc_win->set_policy( "automatic", "automatic" );
/soc_gen.pl
441,7 → 441,7
 
my ($old_v,$new_v)= get_old_new_ip_version ($soc,$ip,$instance_id);
if($old_v != $new_v){
my $warn=def_image_button("icons/warnning.png");
my $warn=def_image_button("icons/warning.png");
$table->attach ($warn,1,2,$offset+2,$offset+3,'expand','shrink',2,2); #$box2->pack_start($warn, FALSE, FALSE, 3);
$warn->signal_connect (clicked => sub{
message_dialog("Warning: ${module}'s version (V.$old_v) missmatches with the one exsiting in librray (V.$new_v). The generated system may not work correctly. Please remove and then add $module again to update it with current version")
949,7 → 949,8
my ($name,$path,$suffix) = fileparse("$f",qr"\..[^.]*$");
push(@new_file_ref,"$files_path/$name$suffix");
}
my $old_file_ref= eval { do "$list_path/file_list" };
my ($old_file_ref,$r,$err) = regen_object("$list_path/file_list" );
if (defined $old_file_ref){
foreach my $f(@{$old_file_ref}){
unless ( grep( /^$f$/, @new_file_ref ) ){
970,9 → 971,9
#################
 
sub generate_soc{
my ($soc,$info,$target_dir,$hw_path,$sw_path,$gen_top,$gen_hw_lib)=@_;
my ($soc,$info,$target_dir,$hw_path,$sw_path,$gen_top,$gen_hw_lib,$oldfiles)=@_;
my $name=$soc->object_get_attribute('soc_name');
$oldfiles = "remove" if(!defined $oldfiles);
my ($file_v,$top_v,$readme,$prog)=soc_generate_verilog($soc,$sw_path);
1023,12 → 1024,13
mkpath("$hw_lib/",1,01777);
mkpath("$sw_path/",1,01777);
#remove old rtl files that were copied by ProNoC
my $old_file_ref= eval { do "$hw_path/file_list" };
if (defined $old_file_ref){
remove_file_and_folders($old_file_ref,$target_dir);
}
if ($oldfiles eq "remove"){
#remove old rtl files that were copied by ProNoC
my ($old_file_ref,$r,$err) = regen_object("$hw_path/file_list");
if (defined $old_file_ref){
remove_file_and_folders($old_file_ref,$target_dir);
}
}
#copy hdl codes in src_verilog
my ($file_ref,$warnings)= get_all_files_list($soc,"hdl_files");
copy_file_and_folders($file_ref,$project_dir,$hw_lib);
1050,7 → 1052,8
}
#remove old software files that were copied by ProNoC
my $old_file_ref= eval { do "$sw_path/file_list" };
my ($old_file_ref,$r,$err) = regen_object("$sw_path/file_list" );
if (defined $old_file_ref){
remove_file_and_folders($old_file_ref,$project_dir);
}
1456,7 → 1459,7
}
my $status=(defined $info)? gen_button_message ($info,'icons/warnning.png'):
my $status=(defined $info)? gen_button_message ($info,'icons/warning.png'):
gen_button_message (undef,'icons/select.png');
$box->pack_start($label,FALSE,FALSE,3);
1576,9 → 1579,9
$file = $dialog->get_filename;
my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
if($suffix eq '.SOC'){
my $pp= eval { do $file };
if ($@ || !defined $pp){
show_info(\$info,"**Error reading $file file: $@\n");
my ($pp,$r,$err) = regen_object($file);
if ($r || !defined $pp){
show_info(\$info,"**Error reading $file file: $err\n");
$dialog->destroy;
return;
}
1716,8 → 1719,11
 
$make -> signal_connect("clicked" => sub{
$app->do_save();
my $load= show_gif("icons/load.gif");
$table->attach ($load,7, 8, 1,2,'shrink','shrink',0,0);
$load->show_all;
run_make_file($sw,$tview);
 
$load->destroy;
});
 
#Programe the board
/software_editor.pl
82,7 → 82,7
 
my ($scwin_info,$tview)= create_text();
add_colors_to_textview($tview);
$vpaned-> pack1 ($hpaned, TRUE, TRUE);
$vpaned ->set_position ($hight*.5);
$vpaned-> pack2 ($scwin_info, TRUE, TRUE);
/temp.pl
1,92 → 1,15
#!/usr/bin/perl
 
#!/usr/bin/perl -w
use strict;
use warnings;
use Gtk2;
use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep clock_gettime clock_getres clock_nanosleep clock stat );
use Proc::Background;
use IO::CaptureOutput qw(capture qxx qxy);
 
$ENV{TEMP}="ALIREZA";
 
 
my $cmd = "xterm -e sh t.sh";
my ($stdout,$exit)=run_cmd_in_back_ground_get_stdout( $cmd);
 
 
 
##########
# run external commands
##########
 
sub run_cmd_in_back_ground
{
my $command = shift;
#print "\t$command\n";
use GraphViz;
### Start running the Background Job:
my $proc = Proc::Background->new($command);
my $PID = $proc->pid;
my $start_time = $proc->start_time;
my $alive = $proc->alive;
 
### While $alive is NOT '0', then keep checking till it is...
# *When $alive is '0', it has finished executing.
while($alive ne 0)
{
$alive = $proc->alive;
 
# This while loop will cause Gtk2 to conti processing events, if
# there are events pending... *which there are...
while (Gtk2->events_pending) {
Gtk2->main_iteration;
}
Gtk2::Gdk->flush;
 
usleep(1000);
}
my $end_time = $proc->end_time;
# print "*Command Completed at $end_time, with PID = $PID\n\n";
 
# Since the while loop has exited, the BG job has finished running:
# so close the pop-up window...
# $popup_window->hide;
 
# Get the RETCODE from the Background Job using the 'wait' method
my $retcode = $proc->wait;
$retcode /= 256;
 
print "\t*RETCODE == $retcode\n\n";
Gtk2::Gdk->flush;
### Check if the RETCODE returned with an Error:
if ($retcode ne 0) {
print "Error: The Background Job ($command) returned with an Error...!\n";
return 1;
} else {
#print "Success: The Background Job Completed Successfully...!\n";
return 0;
}
}
 
 
 
sub run_cmd_in_back_ground_get_stdout
{
my $cmd=shift;
my $exit;
my ($stdout, $stderr);
capture { $exit=run_cmd_in_back_ground($cmd) } \$stdout, \$stderr;
return ($stdout,$exit,$stderr);
}
 
 
 
 
 
 
 
#system ("sh t.sh");
my $g = GraphViz->new();
$g->add_node('London');
$g->add_node('Paris', label => 'City of\nlurve');
$g->add_node('New York');
$g->add_edge('London' => 'Paris');
$g->add_edge('London' => 'New York', label => 'Far');
$g->add_edge('Paris' => 'London');
print $g->as_png;
/topology.pl
0,0 → 1,442
#!/usr/bin/perl -w
 
#this fle contains NoC topology related subfunctions
 
use Glib qw/TRUE FALSE/;
use strict;
use warnings;
 
use FindBin;
use lib $FindBin::Bin;
 
sub get_topology_info {
my ($self) =@_;
my $topology=$self->object_get_attribute('noc_param','TOPOLOGY');
my $T1=$self->object_get_attribute('noc_param','T1');
my $T2=$self->object_get_attribute('noc_param','T2');
my $T3=$self->object_get_attribute('noc_param','T3');
my $V = $self->object_get_attribute('noc_param','V');
my $Fpay = $self->object_get_attribute('noc_param','Fpay');
return get_topology_info_sub($topology, $T1, $T2, $T3,$V, $Fpay);
}
 
 
 
sub get_topology_info_sub {
 
my ($topology, $T1, $T2, $T3,$V, $Fpay)=@_;
my $NE; # number of end points
my $NR; # number of routers
my $RAw; # routers address width
my $EAw; # Endpoints address width
my $Fw = 2+$V+$Fpay;
if($topology eq '"TREE"') {
my $K = $T1;
my $L = $T2;
$NE = powi( $K,$L );
$NR = sum_powi ( $K,$L );
my $Kw=log2($K);
my $LKw=$L*$Kw;
my $Lw=log2($L);
$RAw=$LKw + $Lw;
$EAw = $RAw;
}elsif($topology eq '"FATTREE"') {
my $K = $T1;
my $L = $T2;
$NE = powi( $K,$L );
$NR = $L * powi( $L , $L - 1 );
my $Kw=log2($K);
my $LKw=$L*$Kw;
my $Lw=log2($L);
$RAw=$LKw + $Lw;
$EAw = $RAw;
}elsif ($topology eq '"RING"' || $topology eq '"LINE"'){
my $NX=$T1;
my $NY=1;
my $NL=$T3;
$NE = $NX*$NY*$NL;
$NR = $NX*$NY;
my $Xw=log2($NX);
my $Yw=log2($NY);
my $Lw=log2($NL);
$RAw = $Xw;
$EAw = ($NL==1) ? $RAw : $RAw + $Lw;
}else {#mesh torus
my $NX=$T1;
my $NY=$T2;
my $NL=$T3;
$NE = $NX*$NY*$NL;
$NR = $NX*$NY;
my $Xw=log2($NX);
my $Yw=log2($NY);
my $Lw=log2($NL);
$RAw = $Xw + $Yw;
$EAw = ($NL==1) ? $RAw : $RAw + $Lw;
}
return ($NE, $NR, $RAw, $EAw, $Fw);
}
 
 
sub fattree_addrencode {
my ( $pos, $k, $l)=@_;
my $pow; my $ tmp;
my $addrencode=0;
my $kw=log2($k);
$pow=1;
for (my $i = 0; $i <$l; $i=$i+1 ) {
$tmp=int($pos/$pow);
$tmp=$tmp % $k;
$tmp=$tmp<<($i)*$kw;
$addrencode=$addrencode | $tmp;
$pow=$pow * $k;
}
return $addrencode;
}
 
sub fattree_addrdecode{
my ($addrencode, $k, $l)=@_;
my $kw=0;
my $mask=0;
my $pow; my $tmp;
my $pos=0;
while((0x1<<$kw) < $k){
$kw++;
$mask<<=1;
$mask|=0x1;
}
$pow=1;
for (my $i = 0; $i <$l; $i=$i+1 ) {
$tmp = $addrencode & $mask;
#printf("tmp1=%u\n",tmp);
$tmp=($tmp*$pow);
$pos= $pos + $tmp;
$pow=$pow * $k;
$addrencode>>=$kw;
}
return $pos;
}
 
sub get_connected_router_id_to_endp{
my ($self,$endp_id)=@_;
my $topology=$self->object_get_attribute('noc_param','TOPOLOGY');
my $T1=$self->object_get_attribute('noc_param','T1');
my $T2=$self->object_get_attribute('noc_param','T2');
my $T3=$self->object_get_attribute('noc_param','T3');
if($topology eq '"FATTREE"' || $topology eq '"TREE"') {
return int($endp_id/$T1);
}else{
return int($endp_id/$T3);
}
}
 
 
sub get_router_num {
my ($self,$x, $y)=@_;
my $topology=$self->object_get_attribute('noc_param','TOPOLOGY');
my $T1=$self->object_get_attribute('noc_param','T1');
my $T2=$self->object_get_attribute('noc_param','T2');
if($topology eq '"FATTREE"') {
return fattree_addrdecode($x, $T1, $T2);
}else{
return ($y*$T1)+$x;
}
}
 
sub router_addr_encoder{
my ($self, $id)=@_;
my $topology=$self->object_get_attribute('noc_param','TOPOLOGY');
my $T1=$self->object_get_attribute('noc_param','T1');
my $T2=$self->object_get_attribute('noc_param','T2');
my $T3=$self->object_get_attribute('noc_param','T3');
if($topology eq '"FATTREE"' || $topology eq '"TREE"') {
return fattree_addrencode($id, $T1, $T2);
}else{
return mesh_tori_addrencode($id,$T1, $T2,1);
}
}
 
sub endp_addr_encoder{
my ($self, $id)=@_;
my $topology=$self->object_get_attribute('noc_param','TOPOLOGY');
my $T1=$self->object_get_attribute('noc_param','T1');
my $T2=$self->object_get_attribute('noc_param','T2');
my $T3=$self->object_get_attribute('noc_param','T3');
if($topology eq '"FATTREE"' || $topology eq '"TREE"') {
return fattree_addrencode($id, $T1, $T2);
}else{
return mesh_tori_addrencode($id,$T1, $T2,$T3);
}
}
 
sub endp_addr_decoder {
my ($self,$code)=@_;
my $topology=$self->object_get_attribute('noc_param','TOPOLOGY');
my $T1=$self->object_get_attribute('noc_param','T1');
my $T2=$self->object_get_attribute('noc_param','T2');
my $T3=$self->object_get_attribute('noc_param','T3');
if($topology eq '"FATTREE"' || $topology eq '"TREE"') {
return fattree_addrdecode($code, $T1, $T2);
}
else{
my ($x, $y, $l) = mesh_tori_addr_sep($code,$T1, $T2,$T3);
return (($y*$T1)+$x)*$T3+$l;
}
}
 
sub mask_gen{
my $k=shift;
my $kw=0;
my $mask=0;
while((0x1<<$kw) < $k){
$kw++;
$mask<<=1;
$mask|=0x1;
}
return $mask;
}
 
 
sub mesh_tori_addr_sep {
my ($code,$NX, $NY,$NL)=@_;
my ($x, $y, $l);
my $NXw=log2($NX);
my $NYw=log2($NY);
$x = $code & mask_gen($NX);
$code>>=$NXw;
$y = $code & mask_gen($NY);
$code>>=$NYw;
$l = $code;
}
 
sub mesh_tori_addrencode{
my ($id,$T1, $T2,$T3)=@_;
my ($x,$y,$l)=mesh_tori_addrencod_sep($id,$T1,$T2,$T3);
return mesh_tori_addr_join($x,$y,$l,$T1, $T2,$T3);
}
 
sub mesh_tori_addrencod_sep{
my ($id,$T1,$T2,$T3)=@_;
my ($x,$y,$l);
$l=$id % $T3; # id%NL
my $R= int($id / $T3);
$x= $R % $T1;# (id/NL)%NX
$y=int($R / $T1);# (id/NL)/NX
return ($x,$y,$l);
}
 
sub mesh_tori_addr_join {
my ($x, $y, $l,$T1, $T2,$T3)=@_;
my $NXw=log2($T1);
my $NYw=log2($T2);
my $addrencode=0;
$addrencode =($T3==1)? ($y << $NXw | $x) : ($l<<($NXw+$NYw)| ($y << $NXw) | $x);
return $addrencode;
}
 
 
 
 
 
sub get_noc_verilator_top_modules_info {
my ($self) =@_;
my $topology=$self->object_get_attribute('noc_param','TOPOLOGY');
my $T1=$self->object_get_attribute('noc_param','T1');
my $T2=$self->object_get_attribute('noc_param','T2');
my $T3=$self->object_get_attribute('noc_param','T3');
my %tops;
my %nr_p; # number of routers have $p port num
my $router_p; #number of routers with different port number in topology
my ($ne,$nr) =get_topology_info($self);
if($topology eq '"FATTREE"') {
my $K = $T1;
my $L = $T2;
my $p2 = 2*$K;
$router_p=2;
my $NRL= $ne/$K; #number of router in each layer
$nr_p{1}=$NRL;
$nr_p{2}=$nr-$NRL;
$nr_p{p1}=$K;
$nr_p{p2}=2*$K;
%tops = (
"Vrouter1" => "router_verilator_p${K}.v",
"Vrouter2" => "router_verilator_p${p2}.v",
"Vnoc" => "noc_connection.sv",
);
}elsif ($topology eq '"TREE"'){
my $K = $T1;
my $L = $T2;
my $p2 = $K+1;
$router_p=2;# number of router with different port number
$nr_p{1}=1;
$nr_p{2}=$nr-1;
$nr_p{p1}=$K;
$nr_p{p2}=$K+1;
%tops = (
"Vrouter1" => "router_verilator_p${K}.v",
"Vrouter2" => "router_verilator_p${p2}.v",
"Vnoc" => "noc_connection.sv",
);
}elsif ($topology eq '"RING"' || $topology eq '"LINE"'){
$router_p=1;
$nr_p{1}=$nr;
my $ports= 3+$T3-1;
$nr_p{p1}=$ports;
%tops = (
"Vrouter1" => "router_verilator_p${ports}.v",
"Vnoc" => "noc_connection.sv",
);
}else {#mesh torus
$router_p=1;
$nr_p{1}=$nr;
my $ports= 5+$T3-1;
$nr_p{p1}=$ports;
%tops = (
"Vrouter1" => "router_verilator_p${ports}.v",
"Vnoc" => "noc_connection.sv",
);
}
my $includ_h="\n";
for (my $p=1; $p<=$router_p ; $p++){
$includ_h=$includ_h."#include \"Vrouter$p.h\" \n";
}
for (my $p=1; $p<=$router_p ; $p++){
$includ_h=$includ_h."#define NR${p} $nr_p{$p}\n";
$includ_h=$includ_h."Vrouter${p} *router${p}[ $nr_p{$p} ]; // Instantiation of router with port number\n";
}
for (my $p=1; $p<=$router_p ; $p++){
$includ_h=$includ_h."
#define NE $ne
#define NR $nr
#define ROUTER_P_NUM $router_p
extern Vnoc *noc;
extern int reset,clk;
void router${p}_connect_to_noc (unsigned int r, unsigned int n){
unsigned int j;
int flit_out_all_size = sizeof(router${p}[0]->flit_out_all)/sizeof(router${p}[0]->flit_out_all[0]);
router${p}[r]->current_r_addr = noc->current_r_addr[n];
router${p}[r]->neighbors_r_addr = noc->neighbors_r_addr[n];
 
router${p}[r]->flit_in_we_all = noc->router_flit_out_we_all[n];
router${p}[r]->credit_in_all = noc->router_credit_out_all[n];
router${p}[r]->congestion_in_all = noc->router_congestion_out_all[n];
for(j=0;j<flit_out_all_size;j++)router${p}[r]->flit_in_all[j] = noc->router_flit_out_all[n][j];
noc->router_flit_in_we_all[n] = router${p}[r]->flit_out_we_all ;
noc->router_credit_in_all[n] = router${p}[r]->credit_out_all;
noc->router_congestion_in_all[n]= router${p}[r]->congestion_out_all;
for(j=0;j<flit_out_all_size;j++) noc->router_flit_in_all[n][j] = router${p}[r]->flit_out_all[j] ;
}
";
}
$includ_h=$includ_h."
void inline connect_all_routers_to_noc ( ){
int i;
if((strcmp(TOPOLOGY ,\"FATTREE\")==0) || (strcmp(TOPOLOGY ,\"TREE\")==0) ){
for(i=0;i<NR1;i++) router1_connect_to_noc (i, i);
#if ROUTER_P_NUM >1
for(i=0;i<NR2;i++) router2_connect_to_noc (i, i+NR1);
#endif
}else{
for (i=0;i<NR1;i++) router1_connect_to_noc (i, i);
}
}
 
void Vrouter_new(){
int i=0;
for(i=0;i<NR1;i++) router1[i] = new Vrouter1; // root nodes
#if ROUTER_P_NUM >1
for(i=0;i<NR2;i++) router2[i] = new Vrouter2; // leaves
#endif
 
}
 
void inline connect_routers_reset_clk(){
int i;
for(i=0;i<NR1;i++) {
router1[i]->reset= reset;
router1[i]->clk= clk ;
}
#if ROUTER_P_NUM >1
for(i=0;i<NR2;i++) {
router2[i]->reset= reset;
router2[i]->clk= clk ;
}
#endif
}
 
 
void inline routers_eval(){
int i=0;
for(i=0;i<NR1;i++) router1[i]->eval();
#if ROUTER_P_NUM >1
for(i=0;i<NR2;i++) router2[i]->eval();
#endif
}
 
void inline routers_final(){
int i;
for(i=0;i<NR1;i++) router1[i]->final();
#if ROUTER_P_NUM >1
for(i=0;i<NR2;i++) router2[i]->final();
#endif
}
";
return ($nr,$ne,$router_p,\%tops,$includ_h);
}
 
 
sub gen_tiles_physical_addrsses_header_file{
my ($self,$file)=@_;
my $topology=$self->object_get_attribute('noc_param','TOPOLOGY');
my $txt = "#ifndef PHY_ADDR_H
#define PHY_ADDR_H\n\n";
#add phy addresses
my ($NE, $NR, $RAw, $EAw)=get_topology_info($self);
for (my $id=0; $id<$NE; $id++){
my $phy= endp_addr_encoder($self,$id);
my $hex = sprintf("0x%x", $phy);
$txt=$txt."\t#define PHY_ADDR_ENDP_$id $hex\n";
}
$txt=$txt."#endif\n";
save_file($file,$txt);
}
 
 
 
1
topology.pl Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: trace_gen.pl =================================================================== --- trace_gen.pl (revision 42) +++ trace_gen.pl (revision 43) @@ -378,8 +378,8 @@ my @info = ( - { label=>'Routers per Row', param_name=>'NX', type=>"Spin-button", default_val=>2, content=>"2,64,1", info=>undef, param_parent=>'noc_param', ref_delay=>1,placement=>'vertical'}, - { label=>"Routers per Column", param_name=>"NY", type=>"Spin-button", default_val=>2, content=>"1,64,1", info=>undef, param_parent=>'noc_param',ref_delay=>1, placement=>'vertical'}, + { label=>'Routers per Row', param_name=>'T1', type=>"Spin-button", default_val=>2, content=>"2,64,1", info=>undef, param_parent=>'noc_param', ref_delay=>1,placement=>'vertical'}, + { label=>"Routers per Column", param_name=>"T2", type=>"Spin-button", default_val=>2, content=>"1,64,1", info=>undef, param_parent=>'noc_param',ref_delay=>1, placement=>'vertical'}, { label=>"Mapping Algorithm", param_name=>"Map_Algrm", type=>"Combo-box", default_val=>'Random', content=>"Nmap,Random,Reverse-NMAP,Direct", info=>undef, param_parent=>'map_param',ref_delay=>undef,placement=>'horizental'}, ); @@ -415,8 +415,8 @@ my $task_num= scalar @tasks; return if($task_num ==0); my ($nx,$ny) =network_dim_cal($task_num); - $self->object_add_attribute('noc_param','NX',$nx); - $self->object_add_attribute('noc_param','NY',$ny); + $self->object_add_attribute('noc_param','T1',$nx); + $self->object_add_attribute('noc_param','T2',$ny); set_gui_status($self,"ref",1); }); @@ -610,10 +610,10 @@ $col=0; $row++; - # { label=>'Routers per Row', param_name=>'NX', type=>"Spin-button", default_val=>2, content=>"2,64,1", info=>undef, param_parent=>'noc_param', ref_delay=>undef}, + # { label=>'Routers per Row', param_name=>'T1', type=>"Spin-button", default_val=>2, content=>"2,64,1", info=>undef, param_parent=>'noc_param', ref_delay=>undef}, - my $nx=$self->object_get_attribute('noc_param','NX'); - my $ny=$self->object_get_attribute('noc_param','NY'); + my $nx=$self->object_get_attribute('noc_param','T1'); + my $ny=$self->object_get_attribute('noc_param','T2'); @@ -871,10 +871,10 @@ if ( "ok" eq $dialog->run ) { $file = $dialog->get_filename; my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$"); - if($suffix eq '.TRC'){ - my $pp= eval { do $file }; - if ($@ || !defined $pp){ - message_dialog("**Error reading $file file: $@\n"); + if($suffix eq '.TRC'){ + my ($pp,$r,$err) = regen_object($file); + if ($r){ + message_dialog("**Error reading $file file: $err\n"); $dialog->destroy; return; } @@ -951,7 +951,7 @@ sub get_tile_id{ my ($self,$task)=@_; - my $nx=$self->object_get_attribute('noc_param','NX'); + my $nx=$self->object_get_attribute('noc_param','T1'); my $tile=$self->object_get_attribute("MAP_TILE",$task); my ($x, $y) = $tile =~ /(\d+)/g; $y=0 if(!defined $y); @@ -1149,8 +1149,8 @@ - my $nx=$self->object_get_attribute('noc_param','NX'); - my $ny=$self->object_get_attribute('noc_param','NY'); + my $nx=$self->object_get_attribute('noc_param','T1'); + my $ny=$self->object_get_attribute('noc_param','T2'); my $nc= $nx * $ny; @@ -1182,8 +1182,8 @@ sub direct_map { my $self=shift; - my $nx=$self->object_get_attribute('noc_param','NX'); - my $ny=$self->object_get_attribute('noc_param','NY'); + my $nx=$self->object_get_attribute('noc_param','T1'); + my $ny=$self->object_get_attribute('noc_param','T2'); my $nc= $nx * $ny; my @tasks=get_nlock_tasks($self); my @tiles=get_nlock_tiles($self); @@ -1249,8 +1249,8 @@ sub get_tiles_name{ my $self=shift; my @tiles; - my $nx=$self->object_get_attribute('noc_param','NX'); - my $ny=$self->object_get_attribute('noc_param','NY'); + my $nx=$self->object_get_attribute('noc_param','T1'); + my $ny=$self->object_get_attribute('noc_param','T2'); if(defined $ny){ if($ny == 1){ for(my $x=0; $x<$nx; $x++){ @@ -1259,8 +1259,8 @@ } else{ - for(my $y=0; $y<$ny; $y++){my $nx=$self->object_get_attribute('noc_param','NX'); - my $ny=$self->object_get_attribute('noc_param','NY'); + for(my $y=0; $y<$ny; $y++){my $nx=$self->object_get_attribute('noc_param','T1'); + my $ny=$self->object_get_attribute('noc_param','T2'); for(my $x=0; $x<$nx; $x++){ push(@tiles,"tile(${x}_$y)"); } @@ -1274,8 +1274,8 @@ sub get_tile_name{ my ($self,$x,$y)=@_; - my $nx=$self->object_get_attribute('noc_param','NX'); - my $ny=$self->object_get_attribute('noc_param','NY'); + my $nx=$self->object_get_attribute('noc_param','T1'); + my $ny=$self->object_get_attribute('noc_param','T2'); if(defined $ny){ return "tile($x)" if($ny == 1); } @@ -1341,8 +1341,8 @@ sub find_max_neighbor_tile{ my $self=shift; - my $nx=$self->object_get_attribute('noc_param','NX'); - my $ny=$self->object_get_attribute('noc_param','NY'); + my $nx=$self->object_get_attribute('noc_param','T1'); + my $ny=$self->object_get_attribute('noc_param','T2'); my $x_mid = floor($nx/2); my $y_mid = floor($ny/2); #my $centered_tile= get_tile_name($self,$x_mid ,$y_mid); @@ -1367,8 +1367,8 @@ sub find_min_neighbor_tile { my $self=shift; - my $nx=$self->object_get_attribute('noc_param','NX'); - my $ny=$self->object_get_attribute('noc_param','NY'); + my $nx=$self->object_get_attribute('noc_param','T1'); + my $ny=$self->object_get_attribute('noc_param','T2'); my $x_mid = 0; my $y_mid = 0; #my $centered_tile= get_tile_name($self,$x_mid ,$y_mid); @@ -1397,8 +1397,8 @@ my $self=shift; - my $nx=$self->object_get_attribute('noc_param','NX'); - my $ny=$self->object_get_attribute('noc_param','NY'); + my $nx=$self->object_get_attribute('noc_param','T1'); + my $ny=$self->object_get_attribute('noc_param','T2'); my $nc= $nx * $ny; my @tasks=get_all_tasks($self); @@ -1568,8 +1568,8 @@ my $self=shift; - my $nx=$self->object_get_attribute('noc_param','NX'); - my $ny=$self->object_get_attribute('noc_param','NY'); + my $nx=$self->object_get_attribute('noc_param','T1'); + my $ny=$self->object_get_attribute('noc_param','T2'); my $nc= $nx * $ny; my @tasks=get_all_tasks($self);
/traffic_pattern.pl
0,0 → 1,208
#!/usr/bin/perl -w
use Glib qw/TRUE FALSE/;
use strict;
use warnings;
 
use FindBin;
use lib $FindBin::Bin;
sub get_sample_emulation_param {
my ($emulate,$sample)=@_;
my $ref=$emulate->object_get_attribute($sample,"noc_info");
my %noc_info= %$ref;
my $topology=$noc_info{'TOPOLOGY'};
my $C=$noc_info{C};
my $T1=$noc_info{'T1'};
my $T2=$noc_info{'T2'};
my $T3=$noc_info{'T3'};
my $V =$noc_info{'V'};
my $Fpay = $noc_info{'Fpay'};
return ($topology, $T1, $T2, $T3, $V, $Fpay);
}
 
 
 
sub getBit{
my ($num, $b, $W)=@_;
while($b<0) {$b=$b+$W; }
$b=$b % $W;
return ($num >> $b) & 1;
}
 
# number; b:bit location; W: number width log2(num); v: 1 assert the bit, 0 deassert the bit;
sub setBit{
my ($num ,$b,$W,$v)=@_;
while($b<0) {$b=$b+$W;}
$b=$b % $W;
my $mask = 1 << $b;
if ($v == 0) {$$num = $$num & ~$mask;} # assert bit
else {$$num = $$num | $mask;} #deassert bit
}
 
sub pck_dst_gen_2D {
my ($self,$sample,$traffic,$core_num,$line_num,$rnd)=@_;
my ($topology, $T1, $T2, $T3, $V, $Fpay) = get_sample_emulation_param($self,$sample);
my ($NE, $NR, $RAw, $EAw, $Fw) = get_topology_info_sub ($topology, $T1, $T2, $T3, $V, $Fpay);
my $NEw=log2($NE);
#for mesh-tori
my ($current_l,$current_x, $current_y);
my ($dest_l,$dest_x,$dest_y);
($current_x,$current_y,$current_l)=mesh_tori_addrencod_sep($core_num,$T1, $T2,$T3);
 
if( $traffic eq "random") {
my @randoms=@{$rnd};
my $tmp = @{$randoms[$core_num]}[$line_num-1];
return endp_addr_encoder($self,$tmp);
}
if( $traffic eq "transposed 1"){
$dest_x = $T1-$current_y-1;
$dest_y = $T2-$current_x-1;
$dest_l = $T3-$current_l-1;
return mesh_tori_addr_join($dest_x,$dest_y,$dest_l,$T1, $T2,$T3);
}
 
if( $traffic eq "transposed 2"){
$dest_x = $current_y;
$dest_y = $current_x;
$dest_l = $current_l;
return mesh_tori_addr_join($dest_x,$dest_y,$dest_l,$T1, $T2,$T3);
}
 
if( $traffic eq "bit reverse"){
#di = sb−i−1
my $tmp=0;
for(my $i=0; $i< $NEw; $i++) {setBit(\$tmp, $i, $NEw, getBit($core_num, $NEw-$i-1, $NEw));}
return endp_addr_encoder($self,$tmp);
}
 
if( $traffic eq "bit complement") {
my $tmp=0;
for(my $i=0; $i< $NEw; $i++) { setBit(\$tmp, $i, $NEw, getBit($core_num, $i, $NEw)==0)};
return endp_addr_encoder($self,$tmp);
}
 
if( $traffic eq "tornado") {
#[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
$dest_x = (($current_x + (int($T1/2)-1)) % $T1);
$dest_y = (($current_y + (int($T2/2)-1)) % $T2);
$dest_l = $current_l;
return mesh_tori_addr_join($dest_x,$dest_y,$dest_l,$T1, $T2,$T3);
}
 
if($traffic eq "shuffle"){
#di = si−1 mod b
my $tmp=0;
for(my $i=0; $i< $NEw; $i++) { setBit(\$tmp, $i, $NEw, getBit($core_num, $i-1, $NEw));}
return endp_addr_encoder($self,$tmp);
}
 
if($traffic eq "bit rotation"){
#di = si+1 mod b
my $tmp=0;
for(my $i=0; $i< $NEw; $i++) { setBit(\$tmp, $i, $NEw, getBit($core_num, $i+1, $NEw));}
return endp_addr_encoder($self,$tmp);
}
 
if($traffic eq "neighbor"){
#dx = sx + 1 mod k
#if ($current_x==0 && $current_y==0 && $current_l ==0) {
# $dest_x = 2;
# $dest_y = 2;
# $dest_l = 0;
#}else {
# $dest_x = $current_x;
# $dest_y = $current_y;
# $dest_l = $current_l;
#}
#return mesh_tori_addr_join($dest_x,$dest_y,$dest_l,$T1, $T2,$T3);
$dest_x = ($current_x + 1) % $T1;
$dest_y = ($current_y + 1) % $T2;
$dest_l = $current_l;
return mesh_tori_addr_join($dest_x,$dest_y,$dest_l,$T1, $T2,$T3);
}
print ("$traffic is an unsupported traffic pattern\n");
$dest_x = $current_x;
$dest_y = $current_y;
$dest_l = $current_l;
return mesh_tori_addr_join($dest_x,$dest_y,$dest_l,$T1, $T2,$T3);
}
 
 
 
 
sub pck_dst_gen_1D {
my ($self,$sample,$traffic,$core_num,$line_num,$rnd)=@_;
my ($topology, $T1, $T2, $T3, $V, $Fpay) = get_sample_emulation_param($self,$sample);
my ($NE, $NR, $RAw, $EAw, $Fw) = get_topology_info_sub ($topology, $T1, $T2, $T3, $V, $Fpay);
my $NEw=log2($NE);
if( $traffic eq "random") {
my @randoms=@{$rnd};
my $tmp = @{$randoms[$core_num]}[$line_num-1];
return endp_addr_encoder($self,$tmp);
}
if( $traffic eq "transposed 1"){
return endp_addr_encoder($self,$NE-$core_num-1);
}
if( $traffic eq "transposed 2"){
return endp_addr_encoder($self,$NE-$core_num-1);
}
if( $traffic eq "bit reverse"){
my $tmp=0;
for(my $i=0; $i< $NEw; $i++) {setBit(\$tmp, $i, $NEw, getBit($core_num, $NEw-$i-1, $NEw));}
return endp_addr_encoder($self,$tmp);
}
if( $traffic eq "bit complement") {
my $tmp=0;
for(my $i=0; $i< $NEw; $i++) { setBit(\$tmp, $i, $NEw, getBit($core_num, $i, $NEw)==0)};
return endp_addr_encoder($self,$tmp);
}
if( $traffic eq "tornado") {
#[(x+(k/2-1)) mod k, (y+(k/2-1)) mod k],
return endp_addr_encoder($self, ($core_num + (int($NE/2)-1)) % $NE);
}
 
if($traffic eq "shuffle"){
#di = si−1 mod b
my $tmp=0;
for(my $i=0; $i< $NEw; $i++) { setBit(\$tmp, $i, $NEw, getBit($core_num, $i-1, $NEw));}
return endp_addr_encoder($self,$tmp);
}
 
if($traffic eq "bit rotation"){
#di = si+1 mod b
my $tmp=0;
for(my $i=0; $i< $NEw; $i++) { setBit(\$tmp, $i, $NEw, getBit($core_num, $i+1, $NEw));}
return endp_addr_encoder($self,$tmp);
}
 
if($traffic eq "neighbor"){
#dx = sx + 1 mod k
return endp_addr_encoder($self,($core_num + 1) % $NE);
}
printf ("$traffic is an unsupported traffic pattern\n");
return endp_addr_encoder($self,$core_num);
}
 
 
sub pck_dst_gen{
my ($self,$sample,$traffic,$core_num,$line_num,$rnd)=@_;
my ($topology, $T1, $T2, $T3, $V, $Fpay) = get_sample_emulation_param($self,$sample);
return pck_dst_gen_2D ($self,$sample,$traffic,$core_num,$line_num,$rnd) if(( $topology eq '"MESH"') ||( $topology eq '"TORUS"'));
return pck_dst_gen_1D ($self,$sample,$traffic,$core_num,$line_num,$rnd);
}
 
1;
traffic_pattern.pl Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: verilog_gen.pl =================================================================== --- verilog_gen.pl (revision 42) +++ verilog_gen.pl (revision 43) @@ -5,6 +5,11 @@ use strict; use warnings; + + +use FindBin; +use lib $FindBin::Bin; + use soc; use ip; use ip_gen; @@ -35,7 +40,7 @@ - + my $system_v=""; my $param_pass_v="\t.CORE_ID(CORE_ID),\n\t.SW_LOC(SW_LOC)"; my $body_v; @@ -44,7 +49,7 @@ my $intfc=interface->interface_new(); foreach my $id (@instances){ - my ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v,$io_top_full_v)=gen_module_inst($id,$soc,\$io_sim_v,\$io_top_sim_v,\$param_as_in_v,$top_ip,$intfc,$wires,\$param_pass_v); + my ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v,$io_top_full_v)=gen_module_inst($id,$soc,\$io_sim_v,\$io_top_sim_v,\$param_as_in_v,$top_ip,$intfc,$wires,\$param_pass_v,\$system_v); my $inst = $soc->soc_get_instance_name($id); add_text_to_string(\$body_v,"/*******************\n*\n*\t$inst\n*\n*\n*********************/\n"); @@ -56,6 +61,8 @@ add_text_to_string(\$io_full_v_all,"$io_full_v\n") if(defined($io_full_v)); add_text_to_string(\$io_top_full_v_all,"$io_top_full_v\n") if(defined($io_top_full_v)); + + #print "$param_v $local_param_v $wire_def_v $inst_v $plugs_assign_v $sockets_assign_v $io_full_v"; } @@ -71,9 +78,11 @@ close($file1); my $unused_wiers_v=assign_unconnected_wires($wires,$intfc); + my $soc_v = (defined $param_as_in_v )? "module $soc_name #(\n $param_as_in_v\n)(\n$io_sim_v\n);\n": "module $soc_name (\n$io_sim_v\n);\n"; add_text_to_string(\$soc_v,$functions_all); + add_text_to_string(\$soc_v,$system_v); add_text_to_string(\$soc_v,$local_param_v_all); add_text_to_string(\$soc_v,$addr_localparam); add_text_to_string(\$soc_v,$module_addr_localparam); @@ -108,7 +117,7 @@ ############### sub gen_module_inst { - my ($id,$soc,$io_sim_v,$io_top_sim_v,$param_as_in_v,$top_ip, $intfc,$wires,$param_pass_v)=@_; + my ($id,$soc,$io_sim_v,$io_top_sim_v,$param_as_in_v,$top_ip, $intfc,$wires,$param_pass_v,$system_v)=@_; my $module =$soc->soc_get_module($id); my $module_name =$soc->soc_get_module_name($id); my $category =$soc->soc_get_category($id); @@ -135,21 +144,15 @@ $top_ip->top_add_def_to_instance($id,'category',$category); $top_ip->top_add_def_to_instance($id,'instance',$inst); + # - - - #module name $inst_v=( defined $instance_param_v )? "$module_name #(\n": $module_name ; - - - #module parameters $inst_v=( defined $instance_param_v)? "$inst_v $instance_param_v\n\t)": $inst_v; #module instance name - $inst_v="$inst_v $inst \t(\n"; - + $inst_v="$inst_v $inst \t(\n"; #module ports $counter=0; foreach my $port (@ports){ @@ -304,9 +307,13 @@ } $inst_v="$inst_v\t);\n"; + my $hdr =$ip->ip_get($category,$module,'system_v'); + if(defined $hdr){ + $hdr=replace_golb_var($hdr,\%params); + $$system_v= "$$system_v $hdr\n"; + } - return ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v,$io_top_full_v,$param_pass_v); @@ -928,13 +935,13 @@ my $param_pass_v="\t.CORE_ID(CORE_ID),\n\t.SW_LOC(SW_LOC)"; 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,$io_top_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,$io_top_full_v_all,$system_v); my $wires=soc->new_wires(); my $intfc=interface->interface_new(); foreach my $id (@instances){ - my ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v,$io_top_full_v)=gen_module_inst($id,$soc,\$io_sim_v,\$io_top_sim_v,\$param_as_in_v,$top_ip,$intfc,$wires,\$param_pass_v); + my ($param_v, $local_param_v, $wire_def_v, $inst_v, $plugs_assign_v, $sockets_assign_v,$io_full_v,$io_top_full_v,$system_v)=gen_module_inst($id,$soc,\$io_sim_v,\$io_top_sim_v,\$param_as_in_v,$top_ip,$intfc,$wires,\$param_pass_v,\$system_v); my $inst = $soc->soc_get_instance_name($id); add_text_to_string(\$body_v,"/*******************\n*\n*\t$inst\n*\n*\n*********************/\n");
/widget.pl
3,32 → 3,17
use strict;
use warnings;
 
require "common.pl";
 
use FindBin;
use lib $FindBin::Bin;
 
use ColorButton;
 
use Gtk2::Pango;
#use Tk::Animation;
 
use String::Similarity;
 
sub find_the_most_similar_position{
my ($item ,@list)=@_;
my $most_similar_pos=0;
my $lastsim=0;
my $i=0;
# convert item to lowercase
$item = lc $item;
foreach my $p(@list){
my $similarity= similarity $item, $p;
if ($similarity > $lastsim){
$lastsim=$similarity;
$most_similar_pos=$i;
}
$i++;
}
return $most_similar_pos;
}
 
##############
# combo box
202,7 → 187,7
}
 
###########
#
# checkbutton
###########
 
sub def_h_labeled_checkbutton{
337,13 → 322,36
my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file_at_scale($image_file,$x,$y,TRUE);
my $image = Gtk2::Image->new_from_pixbuf($pixbuf);
return $image;
}
 
sub open_inline_image{
my ($image_string,$x,$y,$unit)=@_;
if(defined $unit){
my($width,$hight)=max_win_size();
if($unit eq 'percent'){
$x= ($x * $width)/100;
$y= ($y * $hight)/100;
} # else its pixels
}
my $pixbuf = do {
my $loader = Gtk2::Gdk::PixbufLoader->new();
$loader->set_size( $x,$y );
$loader->write( $image_string );
$loader->close();
$loader->get_pixbuf();
};
 
my $image = Gtk2::Image->new_from_pixbuf($pixbuf);
return $image;
}
 
 
 
sub def_image_button{
my ($image_file, $label_text, $homogeneous)=@_;
my ($image_file, $label_text, $homogeneous, $mnemonic)=@_;
# create box for image and label
$homogeneous = FALSE if(!defined $homogeneous);
my $box = def_hbox($homogeneous,0);
357,7 → 365,9
$box->set_spacing (0);
# Create a label for the button
if(defined $label_text ) {
my $label = Gtk2::Label->new(" $label_text");
my $label;
$label = Gtk2::Label->new(" $label_text") unless (defined $mnemonic);
$label = Gtk2::Label->new_with_mnemonic (" $label_text") if (defined $mnemonic);
$box->pack_start($label, FALSE, FALSE, 0);
}
372,7 → 382,7
 
 
sub def_image_label{
my ($image_file, $label_text)=@_;
my ($image_file, $label_text,$mnemonic)=@_;
# create box for image and label
my $box = def_hbox(FALSE,1);
# now on to the image stuff
380,7 → 390,9
$box->pack_start($image, TRUE, FALSE, 0);
# Create a label for the button
if(defined $label_text ) {
my $label = Gtk2::Label->new($label_text);
my $label;
$label = Gtk2::Label->new(" $label_text") unless (defined $mnemonic);
$label = Gtk2::Label->new_with_mnemonic (" $label_text") if (defined $mnemonic);
$box->pack_start($label, TRUE, FALSE, 0);
}
414,23 → 426,10
# create box for image and label
my $box = def_hbox(FALSE,0);
my $font_size=get_defualt_font_size();
my $size=($font_size==10)? 25:
($font_size==9 )? 22:
($font_size==8 )? 18:
($font_size==7 )? 15:12 ;
$box->set_border_width(0);
$box->set_spacing (0);
# Create a label for the button
if(defined $label_text ) {
my $label = gen_label_in_center("$label_text");
$box->pack_start($label, TRUE, TRUE, 0);
}
my @clr_code=get_color($color_num);
my $color = Gtk2::Gdk::Color->new (@clr_code);
my $button = Gtk2::Button->new();
$button->modify_bg('normal',$color);
$button->add($box);
my ($red,$green,$blue) = get_color($color_num);
my $button = ColorButton->new (red => $red, green => $green, blue => $blue, label=>"$label_text");
$button->set_border_width(0);
$button->show_all;
return $button;
438,54 → 437,23
}
 
 
 
 
sub show_gif{
 
my $gif = shift;
#my $mw=def_popwin_size(400,200,'hey');
my $vbox = Gtk2::HBox->new (TRUE, 8);
my $filename;
eval {
## $filename = demo_find_file ("floppybuddy.gif");
$filename = main::demo_find_file ($gif);
};
my $image = Gtk2::Image->new_from_file ($gif);
$vbox->set_border_width (4);
my $align = Gtk2::Alignment->new (0.5, 0.5, 0, 0);
my $image = Gtk2::Image->new_from_file ($gif);
$vbox->set_border_width (4);
my $align = Gtk2::Alignment->new (0.5, 0.5, 0, 0);
my $frame = Gtk2::Frame->new;
$frame->set_shadow_type ('in');
 
# Animation
$frame->add ($image);
$align->add ($frame);
 
$vbox->pack_start ($align, FALSE, FALSE, 0);
# $mw->add ($vbox);
 
# Progressive
#$mw->show_all();
return $vbox;
 
 
 
 
# Animation
$frame->add ($image);
$align->add ($frame);
$vbox->pack_start ($align, FALSE, FALSE, 0);
return $vbox;
}
 
############
771,6 → 739,7
$tview->set_pixels_above_lines (2);
$tview->set_pixels_below_lines (2);
# $scrolled_window->set_placement('bottom_left' );
add_colors_to_textview($tview);
return ($scrolled_window,$tview);
}
 
800,51 → 769,7
}
 
 
#sub attach_widget_to_table2 {
# my ($table,$row,$label,$inf_bt,$widget)=@_;
# my $tmp=gen_label_in_left(" ");
# $table->attach ($label , 0, 4, $row,$row+1,'fill','shrink',2,2);
# $table->attach ($inf_bt , 4, 5, $row,$row+1,'fill','shrink',2,2);
# $table->attach ($widget , 5, 9, $row,$row+1,'fill','shrink',2,2);
# $table->attach ($tmp , 9, 10, $row,$row+1,'fill','shrink',2,2);
#}
 
 
######
# state
#####
 
sub def_state{
my ($initial)=@_;
my $entry = Gtk2::Entry->new;
$entry->set_text($initial);
my $timeout=0;
my @state= ($entry,$timeout);
return \@state
 
}
 
 
 
 
 
sub set_gui_status{
my ($object,$status,$timeout)=@_;
$object->object_add_attribute('gui_status','status',$status);
$object->object_add_attribute('gui_status','timeout',$timeout);
}
 
 
sub get_gui_status{
my ($object)=@_;
my $status= $object->object_get_attribute('gui_status','status');
my $timeout=$object->object_get_attribute('gui_status','timeout');
return ($status,$timeout);
}
 
 
 
##################
# show_info
##################
913,34 → 838,6
$buffer->create_tag ("${color}_tag", foreground => $color);
}
 
 
####################
# file
##################
 
 
sub read_verilog_file{
my @files = @_;
my %cmd_line_defines = ();
my $quiet = 1;
my @inc_dirs = ();
my @lib_dirs = ();
my @lib_exts = ();
my $vdb = rvp->read_verilog(\@files,[],\%cmd_line_defines,
$quiet,\@inc_dirs,\@lib_dirs,\@lib_exts);
 
my @problems = $vdb->get_problems();
if (@problems) {
foreach my $problem ($vdb->get_problems()) {
print STDERR "$problem.\n";
}
# die "Warnings parsing files!";
}
 
return $vdb;
}
 
sub add_color_to_gd{
foreach (my $i=0;$i<32;$i++ ) {
my ($red,$green,$blue)=get_color($i);
951,305 → 848,11
 
 
 
sub append_text_to_file {
my ($file_path,$text)=@_;
open(my $fd, ">>$file_path") or die "could not open $file_path: $!";
print $fd $text;
close $fd;
}
 
 
 
 
sub save_file {
my ($file_path,$text)=@_;
open my $fd, ">$file_path" or die "could not open $file_path: $!";
print $fd $text;
close $fd;
}
 
sub load_file {
my $file_path=shift;
my $str;
if (-f "$file_path") {
$str = do {
local $/ = undef;
open my $fh, "<", $file_path
or die "could not open $file_path: $!";
<$fh>;
};
 
}
return $str;
}
 
 
 
 
sub merg_files {
my ($source_file_path,$dest_file_path)=@_;
local $/=undef;
open FILE, $source_file_path or die "Couldn't open file: $!";
my $string = <FILE>;
close FILE;
append_text_to_file ($dest_file_path,$string);
}
 
 
 
sub copy_file_and_folders{
my ($file_ref,$project_dir,$target_dir)=@_;
 
foreach my $f(@{$file_ref}){
my $name= basename($f);
my $n="$project_dir$f";
if (-f "$n") { #copy file
copy ("$n","$target_dir");
}elsif(-f "$f" ){
copy ("$f","$target_dir");
}elsif (-d "$n") {#copy folder
dircopy ("$n","$target_dir/$name");
}elsif(-d "$f" ){
dircopy ("$f","$target_dir/$name");
}
}
 
}
 
 
sub remove_file_and_folders{
my ($file_ref,$project_dir)=@_;
 
foreach my $f(@{$file_ref}){
my $name= basename($f);
my $n="$project_dir$f";
if (-f "$n") { #copy file
unlink ("$n");
}elsif(-f "$f" ){
unlink ("$f");
}elsif (-d "$n") {#copy folder
rmtree ("$n");
}elsif(-d "$f" ){
rmtree ("$f");
}
}
 
}
 
sub read_file_cntent {
my ($f,$project_dir)=@_;
my $n="$project_dir$f";
my $str;
if (-f "$n") {
$str = do {
local $/ = undef;
open my $fh, "<", $n
or die "could not open $n: $!";
<$fh>;
};
 
}elsif(-f "$f" ){
$str = do {
local $/ = undef;
open my $fh, "<", $f
or die "could not open $f: $!";
<$fh>;
};
}
return $str;
 
}
 
 
sub check_file_has_string {
my ($file,$string)=@_;
my $r;
open(FILE,$file);
if (grep{/$string/} <FILE>){
$r= 1; #print "word found\n";
}else{
$r= 0; #print "word not found\n";
}
close FILE;
return $r;
}
 
 
###########
# color
#########
 
 
 
 
 
sub get_color {
my $num=shift;
my @colors=(
0x6495ED,#Cornflower Blue
0xFAEBD7,#Antiquewhite
0xC71585,#Violet Red
0xC0C0C0,#silver
0xADD8E6,#Lightblue
0x6A5ACD,#Slate Blue
0x00CED1,#Dark Turquoise
0x008080,#Teal
0x2E8B57,#SeaGreen
0xFFB6C1,#Light Pink
0x008000,#Green
0xFF0000,#red
0x808080,#Gray
0x808000,#Olive
0xFF69B4,#Hot Pink
0xFFD700,#Gold
0xDAA520,#Goldenrod
0xFFA500,#Orange
0x32CD32,#LimeGreen
0x0000FF,#Blue
0xFF8C00,#DarkOrange
0xA0522D,#Sienna
0xFF6347,#Tomato
0x0000CD,#Medium Blue
0xFF4500,#OrangeRed
0xDC143C,#Crimson
0x9932CC,#Dark Orchid
0x800000,#marron
0x800080,#Purple
0x4B0082,#Indigo
0xFFFFFF,#white
0x000000 #Black
);
my $color= ($num< scalar (@colors))? $colors[$num]: 0xFFFFFF;
my $red= ($color & 0xFF0000) >> 8;
my $green= ($color & 0x00FF00);
my $blue= ($color & 0x0000FF) << 8;
return ($red,$green,$blue);
}
 
 
sub get_color_hex_string {
my $num=shift;
my @colors=(
"6495ED",#Cornflower Blue
"FAEBD7",#Antiquewhite
"C71585",#Violet Red
"C0C0C0",#silver
"ADD8E6",#Lightblue
"6A5ACD",#Slate Blue
"00CED1",#Dark Turquoise
"008080",#Teal
"2E8B57",#SeaGreen
"FFB6C1",#Light Pink
"008000",#Green
"FF0000",#red
"808080",#Gray
"808000",#Olive
"FF69B4",#Hot Pink
"FFD700",#Gold
"DAA520",#Goldenrod
"FFA500",#Orange
"32CD32",#LimeGreen
"0000FF",#Blue
"FF8C00",#DarkOrange
"A0522D",#Sienna
"FF6347",#Tomato
"0000CD",#Medium Blue
"FF4500",#OrangeRed
"DC143C",#Crimson
"9932CC",#Dark Orchid
"800000",#marron
"800080",#Purple
"4B0082",#Indigo
"FFFFFF",#white
"000000" #Black
);
my $color= ($num< scalar (@colors))? $colors[$num]: "FFFFFF";
return $color;
}
 
 
 
##############
# clone_obj
#############
 
sub clone_obj{
my ($self,$clone)=@_;
foreach my $p (keys %$self){
delete ($self->{$p});
}
foreach my $p (keys %$clone){
$self->{$p}= $clone->{$p};
my $ref= ref ($clone->{$p});
if( $ref eq 'HASH' ){
foreach my $q (keys %{$clone->{$p}}){
$self->{$p}{$q}= $clone->{$p}{$q};
my $ref= ref ($self->{$p}{$q});
if( $ref eq 'HASH' ){
foreach my $z (keys %{$clone->{$p}{$q}}){
$self->{$p}{$q}{$z}= $clone->{$p}{$q}{$z};
my $ref= ref ($self->{$p}{$q}{$z});
if( $ref eq 'HASH' ){
foreach my $w (keys %{$clone->{$p}{$q}{$z}}){
$self->{$p}{$q}{$z}{$w}= $clone->{$p}{$q}{$z}{$w};
my $ref= ref ($self->{$p}{$q}{$z}{$w});
if( $ref eq 'HASH' ){
foreach my $m (keys %{$clone->{$p}{$q}{$z}{$w}}){
$self->{$p}{$q}{$z}{$w}{$m}= $clone->{$p}{$q}{$z}{$w}{$m};
my $ref= ref ($self->{$p}{$q}{$z}{$w}{$m});
if( $ref eq 'HASH' ){
foreach my $n (keys %{$clone->{$p}{$q}{$z}{$w}{$m}}){
$self->{$p}{$q}{$z}{$w}{$m}{$n}= $clone->{$p}{$q}{$z}{$w}{$m}{$n};
my $ref= ref ($self->{$p}{$q}{$z}{$w}{$m}{$n});
if( $ref eq 'HASH' ){
foreach my $l (keys %{$clone->{$p}{$q}{$z}{$w}{$m}{$n}}){
$self->{$p}{$q}{$z}{$w}{$m}{$n}{$l}= $clone->{$p}{$q}{$z}{$w}{$m}{$n}{$l};
my $ref= ref ($self->{$p}{$q}{$z}{$w}{$m}{$n}{$l});
if( $ref eq 'HASH' ){
}
}
}#if
}#n
}#if
}#m
}#if
}#w
}#if
}#z
}#if
}#q
}#if
}#p
}#sub
 
 
############
# get file folder list
###########
 
sub get_directory_name {
sub get_directory_name_widget {
my ($object,$title,$entry,$attribute1,$attribute2,$status,$timeout)= @_;
my $browse= def_image_button("icons/browse.png");
 
1284,28 → 887,32
 
}
 
sub get_project_dir{ #mpsoc directory address
my $dir = Cwd::getcwd();
my $project_dir = abs_path("$dir/../../");
return $project_dir;
 
sub get_dir_name {
my ($object,$title,$attribute1,$attribute2,$open_in,$status,$timeout)= @_;
my $dir;
$title ='select directory' if(!defined $title);
my $dialog = Gtk2::FileChooserDialog->new(
$title, undef,
# 'open',
'select-folder',
'gtk-cancel' => 'cancel',
'gtk-ok' => 'ok',
);
if(defined $open_in){
$dialog->set_current_folder ($open_in);
}
if ( "ok" eq $dialog->run ) {
$dir = $dialog->get_filename;
$object->object_add_attribute($attribute1,$attribute2,$dir);
set_gui_status($object,$status,$timeout) if(defined $status);
$dialog->destroy;
}
}
 
 
sub remove_project_dir_from_addr{
my $file=shift;
my $project_dir = get_project_dir();
$file =~ s/$project_dir//;
return $file;
}
 
sub add_project_dir_to_addr{
my $file=shift;
my $project_dir = get_project_dir();
return $file if(-f $file );
return "$project_dir/$file";
}
 
sub get_file_name {
my ($object,$title,$entry,$attribute1,$attribute2,$extension,$lable,$open_in)= @_;
my $browse= def_image_button("icons/browse.png");
1543,15 → 1150,45
my $value=$object->object_get_attribute($attribute1,$attribute2);
$object->object_add_attribute($attribute1,$attribute2, $default) if (!defined $value );
$value = $default if (!defined $value );
if (defined $default){
$object->object_add_attribute($attribute1,$attribute2, $default) if !(-d $value );
$value = $default if !(-d $value );
};
my $warning;
my $entry=gen_entry($value);
$entry-> signal_connect("changed" => sub{
my $new_param_value=$entry->get_text();
$object->object_add_attribute($attribute1,$attribute2,$new_param_value);
set_gui_status($object,$status,$timeout) if (defined $status);
unless (-d $new_param_value ){
if (!defined $warning){
$warning = def_icon("icons/warning.png");
$widget->pack_start( $warning, FALSE, FALSE, 0);
set_tip($warning,"$new_param_value is not a valid directory");
$widget->show_all;
}
}else{
$warning->destroy if (defined $warning);
undef $warning;
}
});
my $browse= get_directory_name($object,undef,$entry,$attribute1,$attribute2,$status,$timeout);
my $browse= get_directory_name_widget($object,undef,$entry,$attribute1,$attribute2,$status,$timeout);
$widget->pack_start( $entry, FALSE, FALSE, 0);
$widget->pack_start( $browse, FALSE, FALSE, 0);
if(defined $value){
unless (-d $value ){
$warning= def_icon("icons/warning.png");
$widget->pack_start( $warning, FALSE, FALSE, 0);
set_tip($warning,"$value is not a valid directory path");
}
}
return $widget;
}
 
1580,45 → 1217,36
 
 
 
 
 
 
 
 
 
 
 
sub add_param_widget {
my ($mpsoc,$name,$param, $default,$type,$content,$info, $table,$row,$column,$show,$attribut1,$ref_delay,$new_status,$loc)=@_;
my ($self,$name,$param, $default,$type,$content,$info, $table,$row,$column,$show,$attribut1,$ref_delay,$new_status,$loc)=@_;
my $label;
$label =gen_label_in_left(" $name") if(defined $name);
my $widget;
my $value=$mpsoc->object_get_attribute($attribut1,$param);
my $value=$self->object_get_attribute($attribut1,$param);
if(! defined $value) {
$mpsoc->object_add_attribute($attribut1,$param,$default);
$mpsoc->object_add_attribute_order($attribut1,$param);
$self->object_add_attribute($attribut1,$param,$default);
$self->object_add_attribute_order($attribut1,$param);
$value=$default;
}
if(! defined $new_status){
$new_status='ref';
}
if (! defined $loc){
$loc = "vertical";
}
if ($type eq "Entry"){
$widget=gen_entry($value);
$widget-> signal_connect("changed" => sub{
my $new_param_value=$widget->get_text();
$mpsoc->object_add_attribute($attribut1,$param,$new_param_value);
set_gui_status($mpsoc,$new_status,$ref_delay) if(defined $ref_delay);
 
});
$self->object_add_attribute($attribut1,$param,$new_param_value);
set_gui_status($self,$new_status,$ref_delay) if(defined $ref_delay);
});
}
elsif ($type eq "Combo-box"){
my @combo_list=split(",",$content);
my $pos=get_pos($value, @combo_list) if(defined $value);
if(!defined $pos){
$mpsoc->object_add_attribute($attribut1,$param,$default);
$self->object_add_attribute($attribut1,$param,$default);
$pos=get_item_pos($default, @combo_list) if (defined $default);
}
1626,10 → 1254,8
$widget=gen_combo(\@combo_list, $pos);
$widget-> signal_connect("changed" => sub{
my $new_param_value=$widget->get_active_text();
$mpsoc->object_add_attribute($attribut1,$param,$new_param_value);
set_gui_status($mpsoc,$new_status,$ref_delay) if(defined $ref_delay);
 
 
$self->object_add_attribute($attribut1,$param,$new_param_value);
set_gui_status($self,$new_status,$ref_delay) if(defined $ref_delay);
});
}
1643,10 → 1269,9
$widget->set_value($value);
$widget-> signal_connect("value_changed" => sub{
my $new_param_value=$widget->get_value_as_int();
$mpsoc->object_add_attribute($attribut1,$param,$new_param_value);
set_gui_status($mpsoc,$new_status,$ref_delay) if(defined $ref_delay);
 
});
$self->object_add_attribute($attribut1,$param,$new_param_value);
set_gui_status($self,$new_status,$ref_delay) if(defined $ref_delay);
});
# $box=def_label_spin_help_box ($param,$info, $value,$min,$max,$step, 2);
}
1663,7 → 1288,7
my @chars = split("",$value);
#check if saved value match the size of check box
if($chars[0] ne $content ) {
$mpsoc->object_add_attribute($attribut1,$param,$default);
$self->object_add_attribute($attribut1,$param,$default);
$value=$default;
@chars = split("",$value);
}
1685,23 → 1310,20
if($check[$i]->get_active()) {$new_val="${new_val}1" ;}
else {$new_val="${new_val}0" ;}
}
$mpsoc->object_add_attribute($attribut1,$param,$new_val);
$self->object_add_attribute($attribut1,$param,$new_val);
#print "\$new_val=$new_val\n";
set_gui_status($mpsoc,$new_status,$ref_delay) if(defined $ref_delay);
set_gui_status($self,$new_status,$ref_delay) if(defined $ref_delay);
});
}
 
 
 
 
}
elsif ( $type eq "DIR_path"){
$widget =get_dir_in_object ($mpsoc,$attribut1,$param,$value,'ref',10);
set_gui_status($mpsoc,$new_status,$ref_delay) if(defined $ref_delay);
$widget =get_dir_in_object ($self,$attribut1,$param,$value,'ref',10,$default);
set_gui_status($self,$new_status,$ref_delay) if(defined $ref_delay);
}
elsif ( $type eq "FILE_path"){ # use $content as extention
$widget =get_file_name_object ($mpsoc,$attribut1,$param,$content,undef);
set_gui_status($mpsoc,$new_status,$ref_delay) if(defined $ref_delay);
$widget =get_file_name_object ($self,$attribut1,$param,$content,undef);
set_gui_status($self,$new_status,$ref_delay) if(defined $ref_delay);
}
else {
1751,200 → 1373,5
 
 
 
################
# general
#################
 
 
 
 
sub trim { my $s = shift; $s=~s/[\n]//gs; return $s };
 
sub remove_all_white_spaces($)
{
my $string = shift;
$string =~ s/\s+//g;
return $string;
}
 
 
 
 
sub get_scolar_pos{
my ($item,@list)=@_;
my $pos;
my $i=0;
foreach my $c (@list)
{
if( $c eq $item) {$pos=$i}
$i++;
}
return $pos;
}
 
sub remove_scolar_from_array{
my ($array_ref,$item)=@_;
my @array=@{$array_ref};
my @new;
foreach my $p (@array){
if($p ne $item ){
push(@new,$p);
}
}
return @new;
}
 
sub replace_in_array{
my ($array_ref,$item1,$item2)=@_;
my @array=@{$array_ref};
my @new;
foreach my $p (@array){
if($p eq $item1 ){
push(@new,$item2);
}else{
push(@new,$p);
}
}
return @new;
}
 
 
 
# return an array of common elemnts between two input arays
sub get_common_array{
my ($a_ref,$b_ref)=@_;
my @A=@{$a_ref};
my @B=@{$b_ref};
my @C;
foreach my $p (@A){
if( grep (/^\Q$p\E$/,@B)){push(@C,$p)};
}
return @C;
}
 
#a-b
sub get_diff_array{
my ($a_ref,$b_ref)=@_;
my @A=@{$a_ref};
my @B=@{$b_ref};
my @C;
foreach my $p (@A){
if( !grep (/^\Q$p\E$/,@B)){push(@C,$p)};
}
return @C;
}
 
 
 
sub compress_nums{
my @nums=@_;
my @f=sort { $a <=> $b } @nums;
my $s;
my $ls;
my $range=0;
my $x;
 
foreach my $p (@f){
if(!defined $x) {
$s="$p";
$ls=$p;
}
else{
if($p-$x>1){ #gap exist
if( $range){
$s=($x-$ls>1 )? "$s:$x,$p": "$s,$x,$p";
$ls=$p;
$range=0;
}else{
$s= "$s,$p";
$ls=$p;
 
}
}else {$range=1;}
 
 
}
$x=$p
}
if($range==1){ $s= ($x-$ls>1 )? "$s:$x": "$s,$x";}
#update $s($ls,$hs);
 
return $s;
}
 
 
 
sub metric_conversion{
my $size=shift;
my $size_text= $size==0 ? 'Error':
$size<(1 << 10)? $size:
$size<(1 << 20)? join (' ', ($size>>10,"K")) :
$size<(1 << 30)? join (' ', ($size>>20,"M")) :
join (' ', ($size>>30,"G")) ;
return $size_text;
}
 
 
 
sub check_verilog_identifier_syntax {
my $in=shift;
my $error=0;
my $message='';
# an Identifiers must begin with an alphabetic character or the underscore character
if ($in =~ /^[0-9\$]/){
return 'an Identifier must begin with an alphabetic character or the underscore character';
}
 
# Identifiers may contain alphabetic characters, numeric characters, the underscore, and the dollar sign (a-z A-Z 0-9 _ $ )
if ($in =~ /[^a-zA-Z0-9_\$]+/){
print "use of illegal character after\n" ;
my @w= split /([^a-zA-Z0-9_\$]+)/, $in;
return "Contain illegal character of \"$w[1]\". Identifiers may contain alphabetic characters, numeric characters, the underscore, and the dollar sign (a-z A-Z 0-9 _ \$ )\n";
}
 
 
# check Verilog reserved words
my @keys = ("always","and","assign","automatic","begin","buf","bufif0","bufif1","case","casex","casez","cell","cmos","config","deassign","default","defparam","design","disable","edge","else","end","endcase","endconfig","endfunction","endgenerate","endmodule","endprimitive","endspecify","endtable","endtask","event","for","force","forever","fork","function","generate","genvar","highz0","highz1","if","ifnone","incdir","include","initial","inout","input","instance","integer","join","large","liblist","library","localparam","macromodule","medium","module","nand","negedge","nmos","nor","noshowcancelled","not","notif0","notif1","or","output","parameter","pmos","posedge","primitive","pull0","pull1","pulldown","pullup","pulsestyle_onevent","pulsestyle_ondetect","remos","real","realtime","reg","release","repeat","rnmos","rpmos","rtran","rtranif0","rtranif1","scalared","showcancelled","signed","small","specify","specparam","strong0","strong1","supply0","supply1","table","task","time","tran","tranif0","tranif1","tri","tri0","tri1","triand","trior","trireg","unsigned","use","vectored","wait","wand","weak0","weak1","while","wire","wor","xnor","xor");
if( grep (/^$in$/,@keys)){
return "$in is a Verlig reserved word.";
}
return undef;
}
 
 
sub capture_number_after {
my ($after,$text)=@_;
my @q =split (/$after/,$text);
#my $d=$q[1];
my @d = split (/[^0-9. ]/,$q[1]);
return $d[0];
 
}
 
sub capture_string_between {
my ($start,$text,$end)=@_;
my @q =split (/$start/,$text);
my @d = split (/$end/,$q[1]);
return $d[0];
}
 
 
sub make_undef_as_string {
foreach my $p (@_){
$$p= 'undef' if (! defined $$p);
}
}
 
 
1

powered by: WebSVN 2.1.0

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