Line 1... |
Line 1... |
#! /usr/bin/perl -w
|
#! /usr/bin/perl -w
|
use Glib qw/TRUE FALSE/;
|
use Glib qw/TRUE FALSE/;
|
use strict;
|
use strict;
|
use warnings;
|
use warnings;
|
|
|
|
use FindBin;
|
|
use lib $FindBin::Bin;
|
|
|
use Gtk2;
|
use Gtk2;
|
use Gtk2::Ex::Graph::GD;
|
use Gtk2::Ex::Graph::GD;
|
use GD::Graph::Data;
|
use GD::Graph::Data;
|
use emulator;
|
use emulator;
|
use IO::CaptureOutput qw(capture qxx qxy);
|
use IO::CaptureOutput qw(capture qxx qxy);
|
Line 20... |
Line 24... |
require "emulate_ram_gen.pl";
|
require "emulate_ram_gen.pl";
|
require "mpsoc_gen.pl";
|
require "mpsoc_gen.pl";
|
require "mpsoc_verilog_gen.pl";
|
require "mpsoc_verilog_gen.pl";
|
require "readme_gen.pl";
|
require "readme_gen.pl";
|
require "graph.pl";
|
require "graph.pl";
|
|
require "topology.pl";
|
|
|
use List::MoreUtils qw(uniq);
|
use List::MoreUtils qw(uniq);
|
|
|
|
|
# hardware parameters taken from noc_emulator.v
|
# 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_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 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 MAX_EAw =>8; # maximum destination address width
|
use constant MAXYw =>4; # 16 nodes in y dimention : hence max emulator size is 16X16
|
|
use constant MAXCw =>4; # 16 message classes
|
use constant MAXCw =>4; # 16 message classes
|
use constant RATIOw =>7; # log2(100)
|
use constant RATIOw =>7; # log2(100)
|
use constant RAM_Aw =>7;
|
use constant RAM_Aw =>7;
|
use constant RAM_RESERVED_ADDR_NUM=>8;
|
use constant RAM_RESERVED_ADDR_NUM=>8;
|
use constant MAX_PATTERN => ((2**RAM_Aw)-(RAM_RESERVED_ADDR_NUM));
|
use constant MAX_PATTERN => ((2**RAM_Aw)-(RAM_RESERVED_ADDR_NUM));
|
Line 48... |
Line 52... |
use constant MAX_RATIO => 1000;# 0->0 1->0.1 ... 1000->100
|
use constant MAX_RATIO => 1000;# 0->0 1->0.1 ... 1000->100
|
use constant EMULATION_RTLS => "/mpsoc/src_emulate/rtl/ , /mpsoc/src_peripheral/jtag/jtag_wb/ , /mpsoc/src_peripheral/ram/ , /mpsoc/src_noc/ ,";
|
use constant EMULATION_RTLS => "/mpsoc/src_emulate/rtl/ , /mpsoc/src_peripheral/jtag/jtag_wb/ , /mpsoc/src_peripheral/ram/ , /mpsoc/src_noc/ ,";
|
use constant EMULATION_TOP => "/mpsoc/src_emulate/emulator_top.v";
|
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 {
|
sub check_inserted_ratios {
|
my $str=shift;
|
my $str=shift;
|
my @ratios;
|
my @ratios;
|
|
|
Line 132... |
Line 139... |
sub get_emulator_noc_configuration{
|
sub get_emulator_noc_configuration{
|
my ($emulate,$mode,$sample,$set_win) =@_;
|
my ($emulate,$mode,$sample,$set_win) =@_;
|
my $table=def_table(10,2,FALSE);
|
my $table=def_table(10,2,FALSE);
|
my $row=0;
|
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
|
#search path
|
my $dir = Cwd::getcwd();
|
my $dir = Cwd::getcwd();
|
my $open_in = abs_path("$ENV{PRONOC_WORK}/emulate/sof");
|
my $open_in = abs_path("$ENV{PRONOC_WORK}/emulate/sof");
|
attach_widget_to_table ($table,$row,gen_label_in_left("Search Path:"),gen_button_message ("Select the the Path where the verilator simulation files are located. Different NoC verilated models can be generated using Generate NoC configuration tab.","icons/help.png"),
|
attach_widget_to_table ($table,$row,gen_label_in_left("Search Path:"),gen_button_message ("Select the the Path where the verilator simulation files are located. Different NoC verilated models can be generated using Generate NoC configuration tab.","icons/help.png"),
|
Line 225... |
Line 232... |
);
|
);
|
|
|
|
|
my @info= ($mode eq "simulate")? @siminfo : @emulateinfo;
|
my @info= ($mode eq "simulate")? @siminfo : @emulateinfo;
|
|
|
|
my $coltmp=0;
|
foreach my $d ( @info) {
|
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");
|
my $traffic=$emulate->object_get_attribute($sample,"traffic");
|
|
|
if ($traffic eq 'hot spot'){
|
if ($traffic eq 'hot spot'){
|
foreach my $d ( @hotspot_info) {
|
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");
|
my $num=$emulate->object_get_attribute($sample,"HOTSPOT_NUM");
|
for (my $i=0;$i<$num;$i++){
|
for (my $i=0;$i<$num;$i++){
|
my $m=$i+1;
|
my $m=$i+1;
|
$row=noc_param_widget ($emulate, "Hotspot $m tile num:", "HOTSPOT_CORE_$m", 0, 'Spin-button', "0,256,1",
|
($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,1,$sample );
|
"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);
|
|
|
}
|
}
|
|
|
}
|
}
|
my $l= "Define injection ratios. You can define individual ratios seprating by comma (\',\') or define a range of injection ratios with \$min:\$max:\$step format.
|
my $l= "Define injection ratios. You can define individual ratios seprating by comma (\',\') or define a range of injection ratios with \$min:\$max:\$step format.
|
Line 351... |
Line 358... |
my $s=($mode eq "simulate" ) ? 1 : get_sof_file_full_addr($emulate,$sample);
|
my $s=($mode eq "simulate" ) ? 1 : get_sof_file_full_addr($emulate,$sample);
|
#check if injection ratios are valid
|
#check if injection ratios are valid
|
my $r=$emulate->object_get_attribute($sample,"ratios");
|
my $r=$emulate->object_get_attribute($sample,"ratios");
|
if(defined $s && defined $name){
|
if(defined $s && defined $name){
|
$l=gen_label_in_center($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 {
|
} else {
|
$l=gen_label_in_left("Define NoC configuration");
|
$l=gen_label_in_left("Define NoC configuration");
|
$l->set_markup("<span foreground= 'red' ><b>Define NoC configuration</b></span>");
|
$l->set_markup("<span foreground= 'red' ><b>Define NoC configuration</b></span>");
|
}
|
}
|
#my $box=def_pack_hbox(FALSE,0,(gen_label_in_left("$i- "),$l,$set));
|
#my $box=def_pack_hbox(FALSE,0,(gen_label_in_left("$i- "),$l,$set));
|
Line 482... |
Line 501... |
my $sof_info= "$path$name.inf";
|
my $sof_info= "$path$name.inf";
|
|
|
# print "\n $sof \t $sof_info\n";
|
# print "\n $sof \t $sof_info\n";
|
|
|
if(!(-f $sof_info)){
|
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");
|
$emulate->object_add_attribute ($sample,"status","failed");
|
$status=0;
|
$status=0;
|
}else { #add info
|
}else { #add info
|
my $pp= do $sof_info ;
|
my $pp= do $sof_info ;
|
|
|
Line 605... |
Line 624... |
$status='' if(!defined $status);
|
$status='' if(!defined $status);
|
my $image;
|
my $image;
|
my $vbox = Gtk2::HBox->new (TRUE,1);
|
my $vbox = Gtk2::HBox->new (TRUE,1);
|
$image = Gtk2::Image->new_from_file ("icons/load.gif") if($status eq "run");
|
$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/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");
|
#$image_file = "icons/load.gif" if($status eq "run");
|
|
|
if (defined $image) {
|
if (defined $image) {
|
my $align = Gtk2::Alignment->new (0.5, 0.5, 0, 0);
|
my $align = Gtk2::Alignment->new (0.5, 0.5, 0, 0);
|
my $frame = Gtk2::Frame->new;
|
my $frame = Gtk2::Frame->new;
|
Line 805... |
Line 824... |
{ label=>'Save as:', param_name=>'SAVE_NAME', type=>"Entry", default_val=>'simulate1', content=>undef, info=>undef, param_parent=>'sim_param', ref_delay=>undef},
|
{ label=>'Save as:', param_name=>'SAVE_NAME', type=>"Entry", default_val=>'simulate1', content=>undef, info=>undef, param_parent=>'sim_param', ref_delay=>undef},
|
{ label=>"Project directory", param_name=>"BIN_DIR", type=>"DIR_path", default_val=>"$ENV{'PRONOC_WORK'}/simulate", content=>undef, info=>"Define the working directory for generating simulation executable binarry file", param_parent=>'sim_param',ref_delay=>undef },
|
{ label=>"Project directory", param_name=>"BIN_DIR", type=>"DIR_path", default_val=>"$ENV{'PRONOC_WORK'}/simulate", content=>undef, info=>"Define the working directory for generating simulation executable binarry file", param_parent=>'sim_param',ref_delay=>undef },
|
);
|
);
|
}
|
}
|
|
|
|
my $coltmp=0;
|
foreach my $d (@fpgainfo) {
|
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});
|
($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');
|
my $generate = def_image_button('icons/gen.png','Gener_ate',FALSE,1);
|
$table->attach ($generate, 0,3, $row, $row+1,'expand','shrink',2,2);
|
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->signal_connect ('clicked'=> sub{
|
generate_sof_file($emulate,$info_text) if($mode eq "emulate");
|
generate_sof_file($emulate,$info_text) if($mode eq "emulate");
|
generate_sim_bin_file($emulate,$info_text) if($mode eq "simulate");
|
generate_sim_bin_file($emulate,$info_text) if($mode eq "simulate");
|
|
|
});
|
});
|
|
|
return $scrolled_win;
|
return $scrolled_win;
|
}
|
}
|
|
|
Line 827... |
Line 852... |
##########
|
##########
|
|
|
|
|
sub generate_sof_file {
|
sub generate_sof_file {
|
my ($self,$info)=@_;
|
my ($self,$info)=@_;
|
|
|
my $name=$self->object_get_attribute ('fpga_param',"SAVE_NAME");
|
my $name=$self->object_get_attribute ('fpga_param',"SAVE_NAME");
|
my $target_dir = "$ENV{'PRONOC_WORK'}/emulate/$name";
|
my $target_dir = "$ENV{'PRONOC_WORK'}/emulate/$name";
|
my $top = "$target_dir/src_verilog/${name}_top.v";
|
my $top = "$target_dir/src_verilog/${name}_top.v";
|
|
|
|
|
if (!defined $name){
|
if (!defined $name){
|
message_dialog("Please define the Save as filed!");
|
message_dialog("Please define the Save as filed!");
|
return;
|
return;
|
}
|
}
|
|
|
Line 1095... |
Line 1118... |
|
|
if ( "ok" eq $dialog->run ) {
|
if ( "ok" eq $dialog->run ) {
|
$file = $dialog->get_filename;
|
$file = $dialog->get_filename;
|
my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
|
my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
|
if($suffix eq '.EML'){
|
if($suffix eq '.EML'){
|
my $pp= eval { do $file };
|
|
if ($@ || !defined $pp){
|
my ($pp,$r,$err) = regen_object($file);
|
add_colored_info($info,"**Error reading $file file: $@\n",'red');
|
if ($r ){
|
|
add_colored_info($info,"**Error reading $file file: $err\n",'red');
|
$dialog->destroy;
|
$dialog->destroy;
|
return;
|
return;
|
}
|
}
|
|
|
clone_obj($emulate,$pp);
|
clone_obj($emulate,$pp);
|
Line 1139... |
Line 1163... |
$i++;
|
$i++;
|
}
|
}
|
return %result;
|
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
|
# main
|
############
|
############
|
sub emulator_main{
|
sub emulator_main{
|
Line 1156... |
Line 1223... |
$emulate->object_add_attribute('compile','compilers',"QuartusII");
|
$emulate->object_add_attribute('compile','compilers',"QuartusII");
|
my $left_table = Gtk2::Table->new (25, 6, FALSE);
|
my $left_table = Gtk2::Table->new (25, 6, FALSE);
|
my $right_table = Gtk2::Table->new (25, 6, FALSE);
|
my $right_table = Gtk2::Table->new (25, 6, FALSE);
|
my $main_table = Gtk2::Table->new (25, 12, FALSE);
|
my $main_table = Gtk2::Table->new (25, 12, FALSE);
|
my ($infobox,$info)= create_text();
|
my ($infobox,$info)= create_text();
|
add_colors_to_textview($info);
|
|
|
|
my @pages =(
|
my @pages =(
|
{page_name=>" Avg. throughput/latency", page_num=>0},
|
{page_name=>" Avg. throughput/latency", page_num=>0},
|
{page_name=>" Injected Packet ", page_num=>1},
|
{page_name=>" Injected Packet ", page_num=>1},
|
{page_name=>" Worst-Case Delay ",page_num=>2},
|
{page_name=>" Worst-Case Delay ",page_num=>2},
|
Line 1182... |
Line 1249... |
$main_table->set_row_spacings (4);
|
$main_table->set_row_spacings (4);
|
$main_table->set_col_spacings (1);
|
$main_table->set_col_spacings (1);
|
|
|
my $generate = def_image_button('icons/forward.png','Run all');
|
my $generate = def_image_button('icons/forward.png','Run all');
|
my $open = def_image_button('icons/browse.png','Load');
|
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);
|
my ($entrybox,$entry) = def_h_labeled_entry('Save as:',undef);
|
|
|
$entry->signal_connect( 'changed'=> sub{
|
$entry->signal_connect( 'changed'=> sub{
|
my $name=$entry->get_text();
|
my $name=$entry->get_text();
|
Line 1199... |
Line 1267... |
my $v2=gen_vpaned($infobox,.2,$chart);
|
my $v2=gen_vpaned($infobox,.2,$chart);
|
my $h1=gen_hpaned($v1,.4,$v2);
|
my $h1=gen_hpaned($v1,.4,$v2);
|
|
|
#$table->attach_defaults ($event_box, $col, $col+1, $row, $row+1);
|
#$table->attach_defaults ($event_box, $col, $col+1, $row, $row+1);
|
$main_table->attach_defaults ($h1 , 0, 12, 0,24);
|
$main_table->attach_defaults ($h1 , 0, 12, 0,24);
|
$main_table->attach ($open,0, 3, 24,25,'expand','shrink',2,2);
|
$main_table->attach ($open,0, 2, 24,25,'expand','shrink',2,2);
|
$main_table->attach ($entrybox,3, 6, 24,25,'expand','shrink',2,2);
|
# $main_table->attach ($diagram, 2, 4, 24,25,'expand','shrink',2,2);
|
$main_table->attach ($generate, 6, 9, 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
|
#check soc status every 0.5 second. referesh device table if there is any changes
|
Glib::Timeout->add (100, sub{
|
Glib::Timeout->add (100, sub{
|
my ($state,$timeout)= get_gui_status($emulate);
|
my ($state,$timeout)= get_gui_status($emulate);
|
|
|
Line 1243... |
Line 1312... |
|
|
return TRUE;
|
return TRUE;
|
|
|
} );
|
} );
|
|
|
|
$diagram-> signal_connect("clicked" => sub{
|
|
show_topology_diagram ($emulate);
|
|
});
|
|
|
$generate-> signal_connect("clicked" => sub{
|
$generate-> signal_connect("clicked" => sub{
|
my @samples =$emulate->object_get_attribute_order("samples");
|
my @samples =$emulate->object_get_attribute_order("samples");
|
foreach my $sample (@samples){
|
foreach my $sample (@samples){
|
$emulate->object_add_attribute ($sample,"status","run");
|
$emulate->object_add_attribute ($sample,"status","run");
|