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 32 to Rev 34
    Reverse comparison

Rev 32 → Rev 34

/compile.pl
0,0 → 1,1180
#! /usr/bin/perl -w
use Glib qw/TRUE FALSE/;
use strict;
use warnings;
use soc;
#use ip;
#use interface;
#use POSIX 'strtol';
 
use File::Path;
use File::Find::Rule;
use File::Copy;
use File::Copy::Recursive qw(dircopy);
use Cwd 'abs_path';
use Verilog::EditFiles;
 
use Gtk2;
#use Gtk2::Pango;
 
use List::MoreUtils qw( minmax );
 
 
 
################
# Comile
#################
 
 
 
sub is_capital_sensitive()
{
my ($cell_layout, $cell, $tree_model, $iter, $data) = @_;
my $sensitive = !$tree_model->iter_has_child($iter);
$cell->set('sensitive', $sensitive);
}
 
sub gen_combo_model{
my $ref=shift;
my %inputs=%{$ref};
my $store = Gtk2::TreeStore->new('Glib::String');
for my $i (sort { $a cmp $b} keys %inputs ) {
my $iter = $store->append(undef);
$store->set($iter, 0, $i);
for my $capital (sort { $a cmp $b} keys %{$inputs{$i}}) {
my $iter2 = $store->append($iter);
$store->set($iter2, 0, $capital);
}
}
return $store;
 
}
 
sub gen_tree_combo{
my $model=shift;
my $combo = Gtk2::ComboBox->new_with_model($model);
my $renderer = Gtk2::CellRendererText->new();
$combo->pack_start($renderer, TRUE);
$combo->set_attributes($renderer, "text", 0);
$combo->set_cell_data_func($renderer, \&is_capital_sensitive);
return $combo;
 
}
 
sub get_range {
my ($board,$self,$porttype,$assignname,$portrange,$portname) =@_;
my $box= def_hbox(FALSE,0);
my @range=$board->board_get_pin_range($porttype,$assignname);
if ($range[0] ne '*undefine*'){
my $content = join(",", @range);
my ($min, $max) = minmax @range;
if (length($portrange)!=0){
my $range_hsb=gen_combobox_object($self,'compile_pin_range_hsb',$portname,$content,$max,undef,undef);
$box->pack_start( $range_hsb, FALSE, FALSE, 0);
$box->pack_start(gen_label_in_center(':'),, FALSE, FALSE, 0);
}
 
my $range_lsb=gen_combobox_object($self,'compile_pin_range_lsb',$portname,$content,$min,undef,undef);
$box->pack_start( $range_lsb, FALSE, FALSE, 0);
}
return $box;
 
}
 
 
sub read_csv_file{
my $file=shift;
open(my $fh, "<$file") || die "Cannot open:$file; $!";
 
my $board = soc->board_new();
#read header format
my $header;
while (my $line= <$fh>){
chomp $line;
$line=remove_all_white_spaces($line);
#print "l:$line\n";
if(length ( $line)!=0){
if ($line !~ /\#/) {
$header= $line;
last;
}
}
}
 
my @headers = split (',',$header);
my $pin_name_col = get_scolar_pos('To',@headers);
if(!defined $pin_name_col){
message_dialog("Error: $file file has an unsupported format!");
return $board;
}
my $direction_col = get_scolar_pos('Direction',@headers);
close $fh;
 
#save pins
open( $fh, "<$file") || die "Cannot open:$file; $!";
 
while (my $line= <$fh>){
chomp $line;
my @fileds = split (',',$line);
my $to = $fileds[$pin_name_col];
my $direction = (defined $direction_col )? $fileds[$direction_col] : 'Unknown';
if(defined $direction && length($to)!=0){
if ($direction eq 'Input' || $direction eq 'Output' || $direction eq 'Bidir'){
$board->board_add_pin ($fileds[1],$to);
}elsif($direction eq 'Unknown'){
$board->board_add_pin ('Input',$to);
$board->board_add_pin ('Output',$to);
$board->board_add_pin ('Bidir',$to);
 
}
}
 
}
close $fh;
return $board;
}
 
 
 
 
sub gen_top_v{
my ($self,$board,$name,$top)=@_;
 
my $top_v=get_license_header("Top.v");
#read port list
my $vdb=read_verilog_file($top);
my %port_type=get_ports_type($vdb,"${name}_top");
my %port_range=get_ports_rang($vdb,"${name}_top");
my $io='';
my $io_def='';
my $io_assign='';
my %board_io;
my $first=1;
foreach my $p (sort keys %port_type){
my $porttype=$port_type{$p};
my $portrange=$port_range{$p};
my $assign_type = $self->object_get_attribute('compile_assign_type',$p);
my $assign_name = $self->object_get_attribute('compile_pin',$p);
my $range_hsb = $self->object_get_attribute('compile_pin_range_hsb',$p);
my $range_lsb = $self->object_get_attribute('compile_pin_range_lsb',$p);
my $assign="\t";
if (defined $assign_name){
if($assign_name eq '*VCC'){
$assign= (length($portrange)!=0)? '{32{1\'b1}}' : '1\'b1';
} elsif ($assign_name eq '*GND'){
$assign= (length($portrange)!=0)? '{32{1\'b0}}' : '1\'b0';
}elsif ($assign_name eq '*NOCONNECT'){
$assign="\t";
 
}else{
$board_io{$assign_name}=$porttype;
my $range = (defined $range_hsb) ? "[$range_hsb : $range_lsb]" :
(defined $range_lsb) ? "[ $range_lsb]" : " ";
my $l=(defined $assign_type)?
($assign_type eq 'Direct') ? '' : '~' : '';
$assign="$l $assign_name $range";
}
}
$io_assign= ($first)? "$io_assign \t .$p($assign)":"$io_assign,\n \t .$p($assign)";
$first=0;
}
$first=1;
foreach my $p (sort keys %board_io){
$io=($first)? "\t$p" : "$io,\n\t$p";
my $dir=$board_io{$p};
my $range;
my $type= ($dir eq 'input') ? 'Input' :
($dir eq 'output')? 'Output' : 'Bidir';
my @r= $board->board_get_pin_range($type,$p);
if ($r[0] eq '*undefine*'){
$range="\t\t\t";
} else {
my ($min, $max) = minmax @r;
$range="\t[$max : $min]\t";
}
$io_def = "$io_def \t $dir $range $p;\n";
$first=0;
}
$top_v="$top_v
module Top (
$io
);
$io_def
 
${name}_top uut(
$io_assign
);
 
 
endmodule
";
my ($fname,$fpath,$fsuffix) = fileparse("$top",qr"\..[^.]*$");
my $board_top_file= "$fpath/Top.v";
save_file($board_top_file,$top_v);
}
 
 
 
 
 
 
 
 
 
 
sub select_compiler {
my ($self,$name,$top,$target_dir)=@_;
my $window = def_popwin_size(40,40,"Step 1: Select Compiler",'percent');
#get the list of boards located in "boards/*" folder
my @dirs = grep {-d} glob("./lib/boards/*");
my ($fpgas,$init);
foreach my $dir (@dirs) {
my ($name,$path,$suffix) = fileparse("$dir",qr"\..[^.]*$");
$init=$name;
$fpgas= (defined $fpgas)? "$fpgas,$name" : "$name";
}
my $table = def_table(2, 2, FALSE);
my $col=0;
my $row=0;
 
my $compiler=gen_combobox_object ($self,'compile','type',"QuartusII,Verilator,Modelsim","QuartusII",undef,undef);
$table->attach(gen_label_in_center("Compiler tool"),$col,$col+1,$row,$row+1,'fill','shrink',2,2);$col++;
$table->attach($compiler,$col,$col+1,$row,$row+1,'fill','shrink',2,2);$col++;
$row++;$col=0;
my $old_board_name=$self->object_get_attribute('compile','board');
my $old_compiler=$self->object_get_attribute('compile','type');
my $compiler_options = ($old_compiler eq "QuartusII")? select_board ($self,$name,$top,$target_dir):
($old_compiler eq "Modelsim")? select_model_path ($self,$name,$top,$target_dir):
gen_label_in_center(" ");
$table->attach($compiler_options,$col,$col+2,$row,$row+1,'fill','shrink',2,2); $row++;
 
$col=1;
my $i;
for ($i=$row; $i<5; $i++){
my $temp=gen_label_in_center(" ");
$table->attach_defaults ($temp, 0, 1 , $i, $i+1);
}
$row=$i;
 
$window->add ($table);
$window->show_all();
my $next=def_image_button('icons/right.png','Next');
$table->attach($next,$col,$col+1,$row,$row+1,'shrink','shrink',2,2);$col++;
$next-> signal_connect("clicked" => sub{
my $compiler_type=$self->object_get_attribute('compile','type');
if($compiler_type eq "QuartusII"){
my $new_board_name=$self->object_get_attribute('compile','board');
if(defined $old_board_name) {
remove_pin_assignment($self) if ($old_board_name ne $new_board_name);
my ($fname,$fpath,$fsuffix) = fileparse("$top",qr"\..[^.]*$");
my $board_top_file= "$fpath/Top.v";
unlink $board_top_file if ($old_board_name ne $new_board_name);
 
 
}
get_pin_assignment($self,$name,$top,$target_dir);
}elsif($compiler_type eq "Modelsim"){
modelsim_compilation($self,$name,$top,$target_dir);
 
}else{#verilator
verilator_compilation($self,$name,$top,$target_dir);
 
}
 
$window->destroy;
});
 
$compiler->signal_connect("changed" => sub{
$compiler_options->destroy;
my $new_board_name=$self->object_get_attribute('compile','type');
$compiler_options = ($new_board_name eq "QuartusII")? select_board ($self,$name,$top,$target_dir):
($new_board_name eq "Modelsim")? select_model_path ($self,$name,$top,$target_dir):
gen_label_in_center(" ");
$table->attach($compiler_options,0,2,1,2,'fill','shrink',2,2);
$table->show_all;
 
});
 
}
 
 
 
 
 
sub select_board {
my ($self,$name,$top,$target_dir)=@_;
#get the list of boards located in "boards/*" folder
my @dirs = grep {-d} glob("./lib/boards/*");
my ($fpgas,$init);
foreach my $dir (@dirs) {
my ($name,$path,$suffix) = fileparse("$dir",qr"\..[^.]*$");
$init=$name;
$fpgas= (defined $fpgas)? "$fpgas,$name" : "$name";
}
my $table = def_table(2, 2, FALSE);
my $col=0;
my $row=0;
 
my $old_board_name=$self->object_get_attribute('compile','board');
$table->attach(gen_label_help("The list of supported boards are obtained from \"perl_gui/lib/boards/\" path. You can add your boards by adding its required files in aformentioned path. Note that currently only Altera FPGAs are supported. For boards from other vendors, you need to directly use their own compiler and call $name.v file in your top level module.",'Targeted Board:'),$col,$col+1,$row,$row+1,'fill','shrink',2,2);$col++;
$table->attach(gen_combobox_object ($self,'compile','board',$fpgas,$init,undef,undef),$col,$col+1,$row,$row+1,'fill','shrink',2,2);$row++;
my $bin = $self->object_get_attribute('compile','quartus_bin');
my $Quartus_bin= $ENV{QUARTUS_BIN};
$col=0;
$self->object_add_attribute('compile','quartus_bin',$ENV{QUARTUS_BIN}) if (!defined $bin && defined $Quartus_bin);
$table->attach(gen_label_help("Path to quartus/bin directory. You can set a default path as QUARTUS_BIN envirement variable in ~/.bashrc file.
e.g: export QUARTUS_BIN=/home/alireza/altera/13.0sp1/quartus/bin",'Quartus bin:'),$col,$col+1,$row,$row+1,'fill','shrink',2,2);$col++;
$table->attach(get_dir_in_object ($self,'compile','quartus_bin',undef,undef,undef),$col,$col+1,$row,$row+1,'fill','shrink',2,2);$row++;
return $table;
}
 
sub select_model_path {
my ($self,$name,$top,$target_dir)=@_;
my $table = def_table(2, 2, FALSE);
my $col=0;
my $row=0;
 
my $bin = $self->object_get_attribute('compile','modelsim_bin');
my $modelsim_bin= $ENV{MODELSIM_BIN};
$col=0;
$self->object_add_attribute('compile','modelsim_bin',$modelsim_bin) if (!defined $bin && defined $modelsim_bin);
$table->attach(gen_label_help("Path to modelsim/bin directory. You can set a default path as MODELSIM_BIN envirement variable in ~/.bashrc file.
e.g. export MODELSIM_BIN=/home/alireza/altera/modeltech/bin",'Modelsim bin:'),$col,$col+1,$row,$row+1,'fill','shrink',2,2);$col++;
$table->attach(get_dir_in_object ($self,'compile','modelsim_bin',undef,undef,undef),$col,$col+1,$row,$row+1,'fill','shrink',2,2);$row++;
return $table;
}
 
 
sub remove_pin_assignment{
my $self=shift;
$self->object_remove_attribute('compile_pin_pos');
$self->object_remove_attribute('compile_pin');
$self->object_remove_attribute('compile_assign_type');
$self->object_remove_attribute('compile_pin_range_hsb');
$self->object_remove_attribute('compile_pin_range_lsb');
}
 
 
sub get_pin_assignment{
my ($self,$name,$top,$target_dir)=@_;
my $window = def_popwin_size(80,80,"Step 2: Pin Assignment",'percent');
 
my $table = def_table(2, 2, FALSE);
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
$scrolled_win->set_policy( "automatic", "automatic" );
$scrolled_win->add_with_viewport($table);
 
 
my $mtable = def_table(10, 10, FALSE);
my $next=def_image_button('icons/right.png','Next');
my $back=def_image_button('icons/left.png','Previous');
 
 
$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);
 
 
 
 
#get boards pin list
my $board_name=$self->object_get_attribute('compile','board');
my @csv_file = glob("./lib/boards/$board_name/*.csv");
if(!defined $csv_file[0]){
message_dialog("Error: ./lib/boards/$board_name folder does not contain the csv file.!");
$window->destroy;
}
my $board=read_csv_file($csv_file[0]);
 
# Write object file
#open(FILE, ">lib/soc/tttttttt") || die "Can not open: $!";
#print FILE Data::Dumper->Dump([\%$board],['board']);
#close(FILE) || die "Error closing file: $!";
 
my @dirs = ('Input', 'Bidir', 'Output');
my %models;
foreach my $p (@dirs){
my %pins=$board->board_get_pin($p);
$models{$p}=gen_combo_model(\%pins);
}
my $row=0;
my $col=0;
my @lables= ('Port Direction','Port Range ','Port name ','Assigment Type','Board Port name ','Board Port Range');
foreach my $p (@lables){
my $l=gen_label_in_left($p);
$l->set_markup("<b> $p </b>");
$table->attach ($l, $col,$col+1, $row, $row+1,'fill','shrink',2,2);
$col++
}
$row++;
 
 
#read port list
my $vdb=read_verilog_file($top);
my %port_type=get_ports_type($vdb,"${name}_top");
my %port_range=get_ports_rang($vdb,"${name}_top");
my %param = $vdb->get_modules_parameters("${name}_top");
foreach my $p (sort keys %port_type){
my $porttype=$port_type{$p};
my $portrange=$port_range{$p};
 
if (length($portrange)!=0){
#replace parameter with their values
my @a= split (/\b/,$portrange);
foreach my $l (@a){
my $value=$param{$l};
if(defined $value){
chomp $value;
($portrange=$portrange)=~ s/\b$l\b/$value/g if(defined $param{$l});
}
}
$portrange = "[ $portrange ]" ;
}
my $label1= gen_label_in_left(" $porttype");
my $label2= gen_label_in_left(" $portrange");
my $label3= gen_label_in_left(" $p");
 
$table->attach($label1, 0,1, $row, $row+1,'fill','shrink',2,2);
$table->attach($label2, 1,2, $row, $row+1,'fill','shrink',2,2);
$table->attach($label3, 2,3, $row, $row+1,'fill','shrink',2,2);
my $assign_type= "Direct,Negate(~)";
if ($porttype eq 'input') {
my $assign_combo=gen_combobox_object($self,'compile_assign_type',$p,$assign_type,'Direct',undef,undef);
$table->attach( $assign_combo, 3,4, $row, $row+1,'fill','shrink',2,2);
}
 
my $type= ($porttype eq 'input') ? 'Input' :
($porttype eq 'output')? 'Output' : 'Bidir';
 
my $combo= gen_tree_combo($models{$type});
my $saved=$self->object_get_attribute('compile_pin_pos',$p);
my $box;
my $loc=$row;
if(defined $saved) {
my @indices=@{$saved};
my $path = Gtk2::TreePath->new_from_indices(@indices);
my $iter = $models{$type}->get_iter($path);
undef $path;
$combo->set_active_iter($iter);
$box->destroy if(defined $box);
my $text=$self->object_get_attribute('compile_pin',$p);
$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
my $treeiter= $combo->get_active_iter();
my $text = $models{$type}->get_value($treeiter, 0);
$self->object_add_attribute('compile_pin',$p,$text);
#get and saved value position in model
my $treepath = $models{$type}->get_path ($treeiter);
my @indices= $treepath->get_indices();
$self->object_add_attribute('compile_pin_pos',$p,\@indices);
#update borad port range
$box->destroy if(defined $box);
$box=get_range ($board,$self,$type,$text,$portrange,$p);
$table->attach($box, 5,6, $loc, $loc+1,'fill','shrink',2,2);
$table->show_all;
 
});
$table->attach($combo, 4,5, $row, $row+1,'fill','shrink',2,2);
 
 
 
 
 
 
$row++;
 
}
$next-> signal_connect("clicked" => sub{
$window->destroy;
quartus_compilation($self,$board,$name,$top,$target_dir);
});
$back-> signal_connect("clicked" => sub{
$window->destroy;
select_compiler($self,$name,$top,$target_dir);
});
 
 
$window->add ($mtable);
$window->show_all();
}
 
 
 
 
 
sub quartus_compilation{
my ($self,$board,$name,$top,$target_dir)=@_;
my $run=def_image_button('icons/run.png','run');
my $back=def_image_button('icons/left.png','Previous');
my $regen=def_image_button('icons/refresh.png','Regenerate Top.v');
 
 
my ($fname,$fpath,$fsuffix) = fileparse("$top",qr"\..[^.]*$");
my $board_top_file ="${fpath}Top.v";
unless (-e $board_top_file ){
gen_top_v($self,$board,$name,$top) ;
}
 
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,9, 10, 1,2,'shrink','shrink',0,0);
 
$regen-> signal_connect("clicked" => sub{
my $dialog = Gtk2::MessageDialog->new (my $window,
'destroy-with-parent',
'question', # message type
'yes-no', # which set of buttons?
"Are you sure you want to regenaret the Top.v file? Note that any changes you have made will be lost");
my $response = $dialog->run;
if ($response eq 'yes') {
gen_top_v($self,$board,$name,$top);
$app->load_source("$board_top_file");
}
$dialog->destroy;
});
$back-> signal_connect("clicked" => sub{
$window->destroy;
get_pin_assignment($self,$name,$top,$target_dir);
});
 
 
#compile
$run-> signal_connect("clicked" => sub{
set_gui_status($self,'save_project',1);
$app->do_save();
my $error = 0;
add_info(\$tview,"CREATE: start creating Quartus project in $target_dir\n");
 
#get list of source file
add_info(\$tview," Read the list of all source files $target_dir/src_verilog\n");
my @files = File::Find::Rule->file()
->name( '*.v','*.V','*.sv' )
->in( "$target_dir/src_verilog" );
 
#make sure source files have key word 'module'
my @sources;
foreach my $p (@files){
push (@sources,$p) if(check_file_has_string($p,'module'));
}
my $files = join ("\n",@sources);
add_info(\$tview,"$files\n");
 
#creat project qsf file
my $qsf_file="$target_dir/${name}.qsf";
save_file ($qsf_file,"# Generated using ProNoC\n");
 
#append global assignets to qsf file
my $board_name=$self->object_get_attribute('compile','board');
my @qsfs = glob("./lib/boards/$board_name/*.qsf");
if(!defined $qsfs[0]){
message_dialog("Error: ./lib/boards/$board_name folder does not contain the qsf file.!");
$window->destroy;
}
 
 
my $assignment_file = $qsfs[0];
if(-f $assignment_file){
merg_files ($assignment_file,$qsf_file);
}
 
#add the list of source fils to qsf file
my $s="\n\n\n set_global_assignment -name TOP_LEVEL_ENTITY Top\n";
foreach my $p (@sources){
my ($name,$path,$suffix) = fileparse("$p",qr"\..[^.]*$");
$s="$s set_global_assignment -name VERILOG_FILE $p\n" if ($suffix eq ".v");
$s="$s set_global_assignment -name SYSTEMVERILOG_FILE $p\n" if ($suffix eq ".sv");
}
append_text_to_file($qsf_file,$s);
add_info(\$tview,"\n Qsf file has been created\n");
 
#start compilation
my $Quartus_bin= $self->object_get_attribute('compile','quartus_bin');;
add_info(\$tview, "Start Quartus compilation.....\n");
my @compilation_command =(
"cd \"$target_dir/\" \n xterm -e sh -c '$Quartus_bin/quartus_map --64bit $name --read_settings_files=on; echo \$? > status' ",
"cd \"$target_dir/\" \n xterm -e sh -c '$Quartus_bin/quartus_fit --64bit $name --read_settings_files=on; echo \$? > status' ",
"cd \"$target_dir/\" \n xterm -e sh -c '$Quartus_bin/quartus_asm --64bit $name --read_settings_files=on; echo \$? > status' ",
"cd \"$target_dir/\" \n xterm -e sh -c '$Quartus_bin/quartus_sta --64bit $name;echo \$? > status' ");
foreach my $cmd (@compilation_command){
add_info(\$tview,"$cmd\n");
unlink "$target_dir/status";
my ($stdout,$exit)=run_cmd_in_back_ground_get_stdout( $cmd);
open(my $fh, "<$target_dir/status") || die "Can not open: $!";
read($fh,my $status,1);
close($fh);
if("$status" != "0"){
($stdout,$exit)=run_cmd_in_back_ground_get_stdout("cd \"$target_dir/output_files/\" \n grep -h \"Error (\" *");
add_colored_info(\$tview,"$stdout\n Quartus compilation failed !\n",'red');
$error=1;
last;
}
}
add_colored_info(\$tview,"Quartus compilation is done successfully in $target_dir!\n", 'blue') if($error==0);
 
});
 
 
 
 
 
 
 
}
 
 
 
 
 
 
sub modelsim_compilation{
my ($self,$name,$top,$target_dir)=@_;
#my $window = def_popwin_size(80,80,"Step 2: Compile",'percent');
my $run=def_image_button('icons/run.png','run');
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);
 
 
 
my ($app,$table,$tview,$window) = software_main("$target_dir/src_verilog",'testbench.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,9, 10, 1,2,'shrink','shrink',0,0);
$regen-> signal_connect("clicked" => sub{
my $dialog = Gtk2::MessageDialog->new (my $window,
'destroy-with-parent',
'question', # message type
'yes-no', # which set of buttons?
"Are you sure you want to regenaret the testbench.v file? Note that any changes you have made will be lost");
my $response = $dialog->run;
if ($response eq 'yes') {
gen_modelsim_soc_testbench ($self,$name,$top,$target_dir);
$app->load_source("$target_dir/src_verilog/testbench.v");
}
$dialog->destroy;
});
 
 
$back-> signal_connect("clicked" => sub{
$window->destroy;
select_compiler($self,$name,$top,$target_dir);
});
 
#creat modelsim dir
add_info(\$tview,"creat Modelsim dir in $target_dir\n");
my $model="$target_dir/Modelsim";
rmtree("$model");
mkpath("$model/rtl_work",1,01777);
#create modelsim.tcl file
my $tcl="#!/usr/bin/tclsh
 
 
transcript on
if {[file exists rtl_work]} {
vdel -lib rtl_work -all
}
vlib rtl_work
vmap work rtl_work
";
 
#Get the list of all verilog files in src_verilog folder
add_info(\$tview,"Get the list of all verilog files in src_verilog folder\n");
my @files = File::Find::Rule->file()
->name( '*.v','*.V','*.sv' )
->in( "$target_dir/src_verilog" );
#make sure source files have key word 'module'
my @sources;
foreach my $p (@files){
my ($name,$path,$suffix) = fileparse("$p",qr"\..[^.]*$");
if(check_file_has_string($p,'module')){
if ($suffix eq ".sv"){$tcl=$tcl."vlog -sv -work work +incdir+$path \{$p\}\n";}
else {$tcl=$tcl."vlog -vlog01compat -work work +incdir+$path \{$p\}\n";}
}
}
 
$tcl="$tcl
vsim -t 1ps -L rtl_work -L work -voptargs=\"+acc\" testbench
 
add wave *
view structure
view signals
run -all
";
 
save_file ("$model/run.tcl",$tcl);
$run -> signal_connect("clicked" => sub{
set_gui_status($self,'save_project',1);
$app->do_save();
my $modelsim_bin= $self->object_get_attribute('compile','modelsim_bin');
my $cmd="cd $target_dir; $modelsim_bin/vsim -do $model/run.tcl";
my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout($cmd);
if(length $stderr>1){
add_info(\$tview,"$stderr\n");
}else {
add_info(\$tview,"$stdout\n");
}
 
});
#$window->show_all();
}
 
 
 
 
sub verilator_compilation {
my ($self,$name,$top,$target_dir)=@_;
my $window = def_popwin_size(80,80,"Step 2: Compile",'percent');
my $mtable = def_table(10, 10, FALSE);
my ($outbox,$outtext)= create_text();
add_colored_tag($outtext,'red');
add_colored_tag($outtext,'blue');
my $next=def_image_button('icons/run.png','Next');
my $back=def_image_button('icons/left.png','Previous');
 
$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);
 
 
$back-> signal_connect("clicked" => sub{
$window->destroy;
select_compiler($self,$name,$top,$target_dir);
});
$next-> signal_connect("clicked" => sub{
$window->destroy;
verilator_testbench($self,$name,$top,$target_dir);
});
 
#creat verilator dir
add_info(\$outtext,"creat verilator dir in $target_dir\n");
my $verilator="$target_dir/verilator";
rmtree("$verilator/rtl_work");
rmtree("$verilator/processed_rtl");
mkpath("$verilator/rtl_work/",1,01777);
mkpath("$verilator/processed_rtl/",1,01777);
 
#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' )
->in( "$target_dir/src_verilog" );
foreach my $file (@files) {
copy($file,"$verilator/rtl_work/");
}
 
#"split all verilog modules in separate files"
add_info(\$outtext,"split all verilog modules in separate files\n");
my $split = Verilog::EditFiles->new
(outdir => "$verilator/processed_rtl",
translate_synthesis => 0,
celldefine => 0,
);
$split->read_and_split(glob("$verilator/rtl_work/*.v"));
$split->read_and_split(glob("$verilator/rtl_work/*.sv"));
$split->write_files();
#run verilator
#my $cmd= "cd \"$verilator/processed_rtl\" \n xterm -e sh -c ' verilator --cc $name.v --profile-cfuncs --prefix \"Vtop\" -O3 -CFLAGS -O3'";
my $cmd= "cd \"$verilator/processed_rtl\" \n verilator --cc $name.v --profile-cfuncs --prefix \"Vtop\" -O3 -CFLAGS -O3";
add_info(\$outtext,"$cmd\n");
my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout($cmd);
if(length $stderr>1){
add_info(\$outtext,"$stderr\n");
}else {
add_info(\$outtext,"$stdout\n");
}
 
#check if verilator model has been generated
if (-f "$verilator/processed_rtl/obj_dir/Vtop.cpp"){
add_colored_info(\$outtext,"Veriator model has been generated successfully!",'blue');
}else {
add_colored_info(\$outtext,"Verilator compilation failed!\n","red");
$next->destroy();
}
 
 
 
$window->add ($mtable);
$window->show_all();
 
 
 
}
 
sub gen_verilator_soc_testbench {
my ($self,$name,$top,$target_dir)=@_;
my $verilator="$target_dir/verilator";
my $dir="$verilator/";
my $soc_top= $self->soc_get_top ();
my @intfcs=$soc_top->top_get_intfc_list();
my %PP;
my $top_port_info="IO type\t port_size\t port_name\n";
foreach my $intfc (@intfcs){
my $key= ( $intfc eq 'plug:clk[0]')? 'clk' :
( $intfc eq 'plug:reset[0]')? 'reset':
( $intfc eq 'plug:enable[0]')? 'en' : 'other';
my $key1="${key}1";
my $key0="${key}0";
 
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);
$PP{$key1}= (defined $PP{$key1})? "$PP{$key1} top->$p=1;\n" : "top->$p=1;\n";
$PP{$key0}= (defined $PP{$key0})? "$PP{$key0} top->$p=0;\n" : "top->$p=0;\n";
$top_port_info="$top_port_info $type $range top->$p \n";
}
 
}
my $main_c=get_license_header("testbench.cpp");
$main_c="$main_c
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <verilated.h> // Defines common routines
#include \"Vtop.h\" // From Verilating \"$name.v\" file
 
Vtop *top;
/*
$top_port_info
*/
 
int reset,clk;
unsigned int main_time = 0; // Current simulation time
 
int main(int argc, char** argv) {
Verilated::commandArgs(argc, argv); // Remember args
top = new Vtop;
 
/********************
* initialize input
*********************/
 
$PP{reset1}
$PP{en1}
main_time=0;
printf(\"Start Simulation\\n\");
while (!Verilated::gotFinish()) {
if (main_time >= 10 ) {
$PP{reset0}
}
 
 
if ((main_time & 1) == 0) {
$PP{clk1} // Toggle clock
// you can change the inputs and read the outputs here in case they are captured at posedge of clock
 
 
 
}//if
else
{
$PP{clk0}
 
}//else
main_time ++;
top->eval();
}
top->final();
}
 
double sc_time_stamp () { // Called by \$time in Verilog
return main_time;
}
";
save_file("$dir/testbench.cpp",$main_c);
 
 
}
 
 
sub gen_modelsim_soc_testbench {
my ($self,$name,$top,$target_dir)=@_;
my $dir="$target_dir/src_verilog";
my $soc_top= $self->object_get_attribute('top_ip',undef);
my @intfcs=$soc_top->top_get_intfc_list();
my %PP;
my $top_port_def="// ${name}.v IO definition \n";
my $pin_assign;
my $rst_inputs='';
 
#read port list
my $vdb=read_verilog_file($top);
my %param = $vdb->get_modules_parameters("${name}_top");
 
 
 
 
foreach my $intfc (@intfcs){
my $key= ( $intfc eq 'plug:clk[0]')? 'clk' :
( $intfc eq 'plug:reset[0]')? 'reset':
( $intfc eq 'plug:enable[0]')? 'en' : 'other';
my $key1="${key}1";
my $key0="${key}0";
 
my @ports=$soc_top->top_get_intfc_ports_list($intfc);
my $f=1;
foreach my $p (@ports){
my($inst,$range,$type,$intfc_name,$intfc_port)= $soc_top->top_get_port($p);
$PP{$key1}= (defined $PP{$key1})? "$PP{$key1} $p=1;\n" : "$p=1;\n";
$PP{$key0}= (defined $PP{$key0})? "$PP{$key0} $p=0;\n" : "$p=0;\n";
 
 
if (length($range)!=0){
#replace parameter with their values
my @a= split (/\b/,$range);
foreach my $l (@a){
my $value=$param{$l};
if(defined $value){
chomp $value;
($range=$range)=~ s/\b$l\b/$value/g if(defined $param{$l});
}
}
$range = "[ $range ]" ;
}
 
 
 
if($type eq 'input'){
$top_port_def="$top_port_def reg $range $p;\n"
}else{
$top_port_def="$top_port_def wire $range $p;\n"
}
$pin_assign=(defined $pin_assign)? "$pin_assign,\n\t\t.$p($p)": "\t\t.$p($p)";
$rst_inputs= "$rst_inputs $p=0;\n" if ($key eq 'other' && $type eq 'input' );
}
 
}
 
my $test_v= get_license_header("testbench.v");
 
$test_v ="$test_v
 
`timescale 1ns/1ps
 
module testbench;
 
$top_port_def
 
 
$name uut (
$pin_assign
);
 
//clock defination
initial begin
forever begin
#5 $PP{clk0}
#5 $PP{clk1}
end
end
 
 
 
initial begin
// reset $name module at the start up
$PP{reset1}
$PP{en1}
$rst_inputs
// deasert the reset after 200 ns
#200
$PP{reset0}
 
// write your testbench here
 
 
 
 
end
 
endmodule
";
save_file("$dir/testbench.v",$test_v);
 
 
}
 
sub verilator_testbench{
my ($self,$name,$top,$target_dir)=@_;
my $verilator="$target_dir/verilator";
my $dir="$verilator";
gen_verilator_soc_testbench (@_) if((-f "$dir/testbench.cpp")==0);
#copy makefile
copy("../script/verilator_soc_make", "$verilator/processed_rtl/obj_dir/Makefile");
 
my ($app,$table,$tview,$window) = software_main($dir,'testbench.cpp');
 
 
my $make = def_image_button('icons/gen.png','Compile');
my $regen=def_image_button('icons/refresh.png','Regenerate Testbench.cpp');
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 ($run,9, 10, 1,2,'shrink','shrink',0,0);
 
$back-> signal_connect("clicked" => sub{
$window->destroy;
verilator_compilation($self,$name,$top,$target_dir);
});
 
$regen-> signal_connect("clicked" => sub{
my $dialog = Gtk2::MessageDialog->new (my $window,
'destroy-with-parent',
'question', # message type
'yes-no', # which set of buttons?
"Are you sure you want to regenaret the testbench.cpp file? Note that any changes you have made will be lost");
my $response = $dialog->run;
if ($response eq 'yes') {
gen_verilator_soc_testbench ($self,$name,$top,$target_dir);
$app->load_source("$dir/testbench.cpp");
}
$dialog->destroy;
});
$make -> signal_connect("clicked" => sub{
$app->do_save();
copy("$dir/testbench.cpp", "$verilator/processed_rtl/obj_dir/testbench.cpp");
run_make_file("$verilator/processed_rtl/obj_dir/",$tview);
 
});
 
$run -> signal_connect("clicked" => sub{
my $bin="$verilator/processed_rtl/obj_dir/testbench";
if (-f $bin){
my $cmd= "cd \"$verilator/processed_rtl/obj_dir/\" \n xterm -e sh -c $bin";
add_info(\$tview,"$cmd\n");
my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout($cmd);
if(length $stderr>1){
add_colored_info(\$tview,"$stderr\n",'red');
}else {
add_info(\$tview,"$stdout\n");
}
 
}else{
add_colored_info(\$tview,"Cannot find $bin executable binary file! make sure you have compiled the testbench successfully\n", 'red')
}
});
 
 
}
 
 
1;
/diagram.pl
0,0 → 1,334
#!/usr/bin/perl -w
use strict;
use warnings;
use soc;
require "widget.pl";
require "emulator.pl";
use File::Copy;
 
#use GraphViz;
 
 
sub get_dot_file{
my $soc= shift;
my $soc_name=$soc->object_get_attribute('soc_name');
my $remove_clk = $soc->object_get_attribute("diagrame","show_clk");
my $remove_reset = $soc->object_get_attribute("diagrame","show_reset");
my $remove_unused = $soc->object_get_attribute("diagrame","show_unused");
 
my $dotfile=
"digraph G {
graph [rankdir = LR , splines=polyline, overlap = false];
node[shape=record];
";
 
my @all_instances=$soc->soc_get_all_instances();
#print "@all_instances\n";
my $graph_connect= '';
my $n=0;
#my %socket_color;
foreach my $instance_id (@all_instances){
my $first=1;
my $instance_name=$soc->soc_get_instance_name($instance_id);
$dotfile="$dotfile \n\t$instance_id \[label=\"{ ";
my @sockets= $soc->soc_get_all_sockets_of_an_instance($instance_id);
@sockets = remove_scolar_from_array(\@sockets,'clk') if ($remove_clk);
@sockets = remove_scolar_from_array(\@sockets,'reset') if ($remove_reset);
 
foreach my $socket (@sockets){
 
my @nums=$soc->soc_list_socket_nums($instance_id,$socket);
foreach my $num (@nums){
my $name= $soc->soc_get_socket_name ($instance_id,$socket,$num);
my ($s_type,$s_value,$s_connection_num)=$soc->soc_get_socket_of_instance($instance_id,$socket);
my $v=$soc->soc_get_module_param_value($instance_id,$s_value);
$v=1 if ( length( $v || '' ) ==0);
#for(my $i=$v-1; $i>=0; $i--) {
for(my $i=0; $i<$v; $i++) {
#$socket_color{socket_${socket}\_$i}=$n;
#$n = ($n<30)? $n+1 : 0;
my ($ref1,$ref2)= $soc->soc_get_modules_plug_connected_to_socket($instance_id,$socket,$i);
my %connected_plugs=%$ref1;
my %connected_plug_nums=%$ref2;
if(%connected_plugs || $remove_unused==0){
$dotfile= ($first)? "$dotfile\{<socket_${socket}\_$i>$name\_$i" : "$dotfile |<socket_${socket}_${i}>$name\_${i}";
$first=0;
}
}
}
}
$dotfile=($first)? "$dotfile $instance_name" : "$dotfile}|$instance_name";
$first=1;
my @plugs= $soc->soc_get_all_plugs_of_an_instance($instance_id);
@plugs = remove_scolar_from_array(\@plugs,'clk') if ($remove_clk);
@plugs = remove_scolar_from_array(\@plugs,'reset') if ($remove_reset);
 
my %plug_order;
my @noconnect;
foreach my $plug (@plugs){
my @nums=$soc->soc_list_plug_nums($instance_id,$plug);
foreach my $num (@nums){
my ($addr,$base,$end,$name,$connect_id,$connect_socket,$connect_socket_num)=$soc->soc_get_plug($instance_id,$plug,$num);
if(defined $connect_socket || $remove_unused==0){
#$dotfile= ($first)? "$dotfile |{<plug_${plug}_${num}>$name" : "$dotfile|<plug_${plug}_${num}>$name";
if(defined $connect_id && defined $connect_socket){
my @sockets= $soc->soc_get_all_sockets_of_an_instance($connect_id);
my $order_val=0;
my $s1=get_pos($connect_id, @all_instances);
my $s2=get_pos($connect_socket, @sockets);
$order_val=$s1*1000000+$s2*10000+$connect_socket_num;
$plug_order{$order_val}= "<plug_${plug}_${num}>$name";
}else {push (@noconnect,"<plug_${plug}_${num}>$name");}
}
 
#my $connect_name=$soc->soc_get_instance_name($connect_id);
#my $color = get_color_hex_string($n);
#$n = ($n<30)? $n+1 : 0;
$graph_connect="$graph_connect $instance_id:plug_${plug}_${num} -> $connect_id:socket_${connect_socket}_${connect_socket_num} [ dir=none]\n" if(defined $connect_socket);
}
}
foreach my $p (sort {$a<=>$b} keys %plug_order){
my $k=$plug_order{$p};
#print "$instance_name : $k=\$plug_order{$p}\n";
$dotfile= ($first) ? "$dotfile |{ ${k}": "$dotfile |${k}";
$first=0;
 
}
 
foreach my $k (@noconnect){
$dotfile= ($first) ? "$dotfile |{ ${k}": "$dotfile |${k}";
$first=0;
}
 
$dotfile= "$dotfile} }\"];";
 
}
$dotfile="$dotfile\n\n$graph_connect";
$dotfile="$dotfile\n\n}\n";
 
 
return $dotfile;
 
 
}
 
 
 
 
 
sub show_tile_diagram {
my $soc= shift;
 
my $table=def_table(20,20,FALSE);
my $window=def_popwin_size(80,80,"Processing Tile functional 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 $unused = gen_check_box_object ($soc,"diagrame","show_unused",0,undef,undef);
my $save = def_image_button('icons/save.png',undef,TRUE);
my $clk = gen_check_box_object ($soc,"diagrame","show_clk",0,undef,undef);
my $reset = gen_check_box_object ($soc,"diagrame","show_reset",0,undef,undef);
#my $save = def_image_button('icons/save.png',undef,TRUE);
 
my $scale=$soc->object_get_attribute("diagrame","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 ($unused, $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 ($clk, $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++;
$table->attach ($reset, $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);
$soc->object_add_attribute("diagrame","scale", $scale );
show_diagram ($soc,$scrolled_win,$table);
});
$minues -> signal_connect("clicked" => sub{
$scale*=.9 if ($scale >0.1); ;
$soc->object_add_attribute("diagrame","scale", $scale );
show_diagram ($soc,$scrolled_win,$table);
});
$save-> signal_connect("clicked" => sub{
save_diagram_as ($soc);
});
$unused-> signal_connect("toggled" => sub{
if(gen_diagram($soc)){
show_diagram ($soc,$scrolled_win,$table);
}
 
});
$clk-> signal_connect("toggled" => sub{
if(gen_diagram($soc)){
show_diagram ($soc,$scrolled_win,$table);
}
 
});
$reset-> signal_connect("toggled" => sub{
if(gen_diagram($soc)){
show_diagram ($soc,$scrolled_win,$table);
}
 
});
 
 
 
if(gen_diagram($soc)){
show_diagram ($soc,$scrolled_win,$table);
}
$window->show_all();
 
 
 
 
}
 
 
 
sub gen_diagram {
my ($soc)=@_;
 
 
my $dotfile= get_dot_file($soc);
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: $!";
 
my $cmd = "dot $tmp_dir/diagram.txt | neato -n -Tpng -o $tmp_dir/diagram.png";
 
my ($stdout,$exit,$stderr)= run_cmd_in_back_ground_get_stdout ($cmd);
 
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;
}
else {
#my $diagram=show_gif("$tmp_dir/diagram.png");
return 1;
}
 
 
}
 
 
 
sub show_diagram {
my ($soc,$scrolled_win,$table)=@_;
 
$scrolled_win->destroy;
$scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
$scrolled_win->set_policy( "automatic", "automatic" );
$table->attach_defaults ($scrolled_win, 0, 20, 1, 20); #,'fill','shrink',2,2);
my $scale=$soc->object_get_attribute("diagrame","scale");
$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();
 
 
}
 
 
sub save_diagram_as {
my $soc= shift;
my $file;
my $title ='Save as';
 
 
 
my @extensions=('png');
my $open_in=undef;
my $dialog = Gtk2::FileChooserDialog->new(
'Save file', undef,
'save',
'gtk-cancel' => 'cancel',
'gtk-ok' => 'ok',
);
# if(defined $extension){
foreach my $ext (@extensions){
my $filter = Gtk2::FileFilter->new();
$filter->set_name($ext);
$filter->add_pattern("*.$ext");
$dialog->add_filter ($filter);
}
# }
if(defined $open_in){
$dialog->set_current_folder ($open_in);
# print "$open_in\n";
}
if ( "ok" eq $dialog->run ) {
$file = $dialog->get_filename;
my $ext = $dialog->get_filter;
$ext=$ext->get_name;
my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
$file = ($suffix eq ".$ext" )? $file : "$file.$ext";
$soc->object_add_attribute("graph_save","name",$file);
$soc->object_add_attribute("graph_save","extension",$ext);
my $tmp = "$ENV{'PRONOC_WORK'}/tmp/diagram.png";
copy ($tmp,$file);
 
 
}
$dialog->destroy;
 
 
 
 
}
 
 
 
return 1;
/emulator.pl
62,17 → 62,23
$results[1]= [0];
my $legend_info="This attribute controls placement of the legend within the graph image. The value is supplied as a two-letter string, where the first letter is placement (a B or an R for bottom or right, respectively) and the second is alignment (L, R, C, T, or B for left, right, center, top, or bottom, respectively). ";
my $fontsize="Tiny,Small,MediumBold,Large,Giant";
 
 
 
my @ginfo = (
{ label=>"Graph Title", param_name=>"G_Title", type=>"Entry", default_val=>undef, content=>undef, info=>undef, param_parent=>'graph_param', ref_delay=>undef },
#{ label=>"Graph Title", param_name=>"G_Title", type=>"Entry", default_val=>undef, content=>undef, info=>undef, param_parent=>'graph_param', ref_delay=>undef },
{ label=>"Y Axix Title", param_name=>"Y_Title", type=>"Entry", default_val=>'Latency (clock)', content=>undef, info=>undef, param_parent=>'graph_param', ref_delay=>undef },
{ label=>"X Axix Title", param_name=>"X_Title", type=>"Entry", default_val=>'Load per router (flits/clock (%))', content=>undef, info=>undef, param_parent=>'graph_param',ref_delay=>undef },
{ label=>"legend placement", param_name=>"legend_placement", type=>'Combo-box', default_val=>'BL', content=>"BL,BC,BR,RT,RC,RB", info=>$legend_info, param_parent=>'graph_param', ref_delay=>undef},
{ label=>"legend placement", param_name=>"legend_placement", type=>'Combo-box', default_val=>'BL', content=>"BL,BC,BR,RT,RC,RB", info=>$legend_info, param_parent=>'graph_param', ref_delay=>1},
{ label=>"Y min", param_name=>"Y_MIN", type=>'Spin-button', default_val=>0, content=>"0,1024,1", info=>"Y axix minimum value", param_parent=>'graph_param', ref_delay=> 5},
{ label=>"X min", param_name=>"X_MIN", type=>'Spin-button', default_val=>0, content=>"0,1024,1", info=>"X axix minimum value", param_parent=>'graph_param', ref_delay=> 5},
{ label=>"X max", param_name=>"X_MAX", type=>'Spin-button', default_val=>100, content=>"0,1024,1", info=>"X axix maximum value", param_parent=>'graph_param', ref_delay=> 5},
{ label=>"Line Width", param_name=>"LINEw", type=>'Spin-button', default_val=>3, content=>"1,20,1", info=>undef, param_parent=>'graph_param', ref_delay=> 5},
 
{ label=>"legend font size", param_name=>"legend_font", type=>'Combo-box', default_val=>'MediumBold', content=>$fontsize, info=>undef, param_parent=>'graph_param', ref_delay=>1},
{ label=>"label font size", param_name=>"label_font", type=>'Combo-box', default_val=>'MediumBold', content=>$fontsize, info=>undef, param_parent=>'graph_param', ref_delay=>1},
{ label=>"label font size", param_name=>"x_axis_font", type=>'Combo-box', default_val=>'MediumBold', content=>$fontsize, info=>undef, param_parent=>'graph_param', ref_delay=>1},
);
 
 
147,10 → 153,13
my $graphs_info;
foreach my $d ( @ginfo){
$graphs_info->{$d->{param_name}}=$emulate->object_get_attribute( 'graph_param',$d->{param_name});
$graphs_info->{$d->{param_name}}= $d->{default_val} if(!defined $graphs_info->{$d->{param_name}});
if(!defined $graphs_info->{$d->{param_name}}){
$graphs_info->{$d->{param_name}}= $d->{default_val};
$emulate->object_add_attribute( 'graph_param',$d->{param_name},$d->{default_val} );
}
}
 
$graph->set (
x_label => $graphs_info->{X_Title},
165,11 → 174,25
box_axis => 0,
skip_undef=> 1,
transparent => 1,
line_width => $graphs_info->{LINEw},
cycle_clrs => 'blue',
legend_placement => $graphs_info->{legend_placement},
dclrs=>\@color,
# transparent => 1,
 
transparent => '0',
bgclr => 'white',
boxclr => 'white',
fgclr => 'black',
textclr => 'black',
labelclr => 'black',
axislabelclr => 'black',
legendclr => 'black',
cycle_clrs => '1',
 
line_width => $graphs_info->{LINEw},
# cycle_clrs => 'black',
legend_placement => $graphs_info->{legend_placement},
dclrs=>\@color,
y_number_format=>"%.1f",
BACKGROUND=>'black',
);
}#if
$graph->set_legend(@legend_keys);
317,6 → 340,19
my ($emulate,$self, $data) = @_;
$self->{graphdata} = $data;
my $graph = $self->{graph};
my $font;
$font= $emulate->object_get_attribute( 'graph_param','label_font');
$graph->set_x_label_font(GD::Font->$font);
$graph->set_y_label_font(GD::Font->$font);
$font= $emulate->object_get_attribute( 'graph_param','legend_font');
$graph->set_legend_font(GD::Font->$font);
 
$font= $emulate->object_get_attribute( 'graph_param','x_axis_font');
#$graph->set_values_font(GD::gdGiantFont);
$graph->set_x_axis_font(GD::Font->$font);
$graph->set_y_axis_font(GD::Font->$font);
 
my $gd2=$graph->plot($data) or warn $graph->error;
my $loader = Gtk2::Gdk::PixbufLoader->new;
438,8 → 474,7
 
sub get_graph_setting {
my ($emulate,$ref)=@_;
my($width,$hight)=max_win_size();
my $window=def_popwin_size($width/3,$hight/3,'Graph Setting');
my $window=def_popwin_size(33,33,'Graph Setting','percent');
my $table = def_table(10, 2, FALSE);
my $row=0;
 
490,7 → 525,7
sub get_color_window{
my ($emulate,$atrebute1,$atrebute2)=@_;
my $window=def_popwin_size(800,600,"Select line color");
my $window=def_popwin_size(40,40,"Select line color",'percent');
my ($r,$c)=(4,8);
my $table= def_table(5,6,TRUE);
for (my $col=0;$col<$c;$col++){
746,8 → 781,7
my ($emulate,$mode, $row_num,$info)=@_;
my $table=def_table($row_num,10,FALSE);
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
my($width,$hight)=max_win_size();
my $set_win=def_popwin_size($width/2.5,$hight*.8,"NoC configuration setting");
my $set_win=def_popwin_size(40,80,"NoC configuration setting",'percent');
$scrolled_win->set_policy( "automatic", "automatic" );
$scrolled_win->add_with_viewport($table);
1062,8 → 1096,8
my $image;
my $vbox = Gtk2::HBox->new (TRUE,1);
$image = Gtk2::Image->new_from_file ("icons/load.gif") if($status eq "run");
$image = def_image("icons/button_ok.png") if($status eq "done");
$image = def_image("icons/cancel.png") if($status eq "failed");
$image = def_icon("icons/button_ok.png") if($status eq "done");
$image = def_icon("icons/cancel.png") if($status eq "failed");
#$image_file = "icons/load.gif" if($status eq "run");
if (defined $image) {
1631,7 → 1665,10
$simulate->object_add_attribute('status',undef,'run');
set_gui_status($simulate,"ref",1);
show_info($info, "Start Simulation\n");
 
my $name=$simulate->object_get_attribute ("simulate_name",undef);
my $log= (defined $name)? "$ENV{PRONOC_WORK}/simulate/$name.log": "$ENV{PRONOC_WORK}/simulate/sim.log";
#unlink $log; # remove old log file
my $sample_num=$simulate->object_get_attribute("emulate_num",undef);
for (my $i=1; $i<=$sample_num; $i++){
my $status=$simulate->object_get_attribute ("sample$i","status");
1676,11 → 1713,17
add_info($info, "Run $bin with injection ratio of $ratio_in \% \n");
my $cmd="$bin -t \"$patern\" -s $PCK_SIZE -n $PCK_NUM_LIMIT -c $SIM_CLOCK_LIMIT -i $ratio_in -p \"100,0,0,0,0\" -h \"$HOTSPOT_PERCENTAGE,$HOTSPOT_NUM,$HOTSPOT_CORE_1,$HOTSPOT_CORE_2,$HOTSPOT_CORE_3,$HOTSPOT_CORE_4,$HOTSPOT_CORE_5\"";
add_info($info, "$cmd \n");
my $time_strg = localtime;
append_text_to_file($log,"started at:$time_strg\n"); #save simulation output
my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout("$cmd");
if($exit){
add_info($info, "Error in running simulation: $stderr \n");
return;
}
append_text_to_file($log,$stdout); #save simulation output
$time_strg = localtime;
append_text_to_file($log,"Ended at:$time_strg\n"); #save simulation output
my @q =split (/average latency =/,$stdout);
my $d=$q[1];
@q =split (/\n/,$d);
/interface_gen.pl
17,7 → 17,7
if (!defined $file) {return; }
if (-e $file) {
my $vdb = read_file($file);
my $vdb = read_verilog_file($file);
my @modules=sort $vdb->get_modules($file);
#foreach my $p(@module_list) {print "$p\n"}
$intfc_gen->intfc_set_interface_file($file);
177,13 → 177,13
 
sub get_interface_ports {
my ($intfc_gen,$info)=@_;
my $window=def_popwin_size(800,600,"Import Ports");
my $window=def_popwin_size(60,60,"Import Ports",'percent');
 
my $file=$intfc_gen->intfc_get_interface_file();
if (!defined $file){show_info(\$info,"File name has not been defined yet!"); return;}
my $module=$intfc_gen->intfc_get_module_name();
if (!defined $module){ show_info(\$info,"Module name has not been selected yet!"); return;}
my $vdb=read_file($file);
my $vdb=read_verilog_file($file);
my %port_type=get_ports_type($vdb,$module);
my %port_range=get_ports_rang($vdb,$module);
331,8 → 331,8
my $combo=gen_combobox_object($intfc_gen,'connection_num',undef,"single connection,multi connection","single connection",'refresh',1);
my $combo_box=labele_widget_info(" Select soket type:",$combo,'Define the soket as multi connection if only all interfaces ports all output and they can feed more than one plug connection');
$table->attach_defaults ($entrybox, 0, 2 , $row, $row+1);
$table->attach_defaults ($combo_box, 3, 5 , $row, $row+1);
$table->attach ($entrybox, 0, 2 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($combo_box, 3, 6 , $row, $row+1,'expand','shrink',2,2);
}
 
349,7 → 349,7
my $size = keys %types;
if($size >0){
my $sep = Gtk2::HSeparator->new;
$table->attach_defaults ($sep, 0, 10 , $row, $row+1); $row++;
$table->attach ($sep, 0, 10 , $row, $row+1,'fill','fill',2,2); $row++;
my $swap= def_image_button("icons/swap.png","swap");
388,26 → 388,26
my $sep2 = Gtk2::HSeparator->new;
$table->attach ($lab1, 1, 2 , $row, $row+1,'shrink','shrink',2,2);
$table->attach ($swap, 3, 4 , $row, $row+1,'shrink','shrink',2,2);
$table->attach ($lab2, 5, 6 , $row, $row+1,'shrink','shrink',2,2); $row++;
$table->attach_defaults ($sep2, 0, 9 , $row, $row+1); $row++;
$table->attach ($lab1, 1, 2 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($swap, 3, 4 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($lab2, 5, 6 , $row, $row+1,'expand','shrink',2,2); $row++;
$table->attach ($sep2, 0, 9 , $row, $row+1,'fill','fill',2,2); $row++;
my $lab3= gen_label_in_center("Type");
my $lab4= gen_label_in_center("Range");
my $lab5= gen_label_in_center("Name");
$table->attach_defaults ($lab3, 0, 1 , $row, $row+1);
$table->attach_defaults ($lab4, 1, 2 , $row, $row+1);
$table->attach_defaults ($lab5, 2, 3 , $row, $row+1);
$table->attach ($lab3, 0, 1 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($lab4, 1, 2 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($lab5, 2, 3 , $row, $row+1,'expand','shrink',2,2);
my $lab6= gen_label_in_center("Type");
my $lab7= gen_label_in_center("Range");
my $lab8= gen_label_in_center("Name");
$table->attach_defaults ($lab6, 4, 5 , $row, $row+1);
$table->attach_defaults ($lab7, 5, 6 , $row, $row+1);
$table->attach_defaults ($lab8, 6, 7 , $row, $row+1);
$table->attach ($lab6, 4, 5 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($lab7, 5, 6 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($lab8, 6, 7 , $row, $row+1,'expand','shrink',2,2);
my $lab9= gen_label_help ("When an IP core does not have any of interface output port, the default value will be send to the IP core's input port which is supposed to be connected to that port","Output port Default ");
$table->attach_defaults ($lab9, 8, 9 , $row, $row+1);
$table->attach ($lab9, 8, 9 , $row, $row+1,'expand','shrink',2,2);
$row++;
foreach my $id (sort keys %ranges){
456,15 → 456,15
#$box->pack_start($entry3,TRUE,FALSE,3);
#$box->pack_start($separator,TRUE,FALSE,3);
$table->attach_defaults ($combo1, 0, 1 , $row, $row+1);
$table->attach_defaults ($entry2, 1, 2 , $row, $row+1);
$table->attach_defaults ($entry3, 2, 3 , $row, $row+1);
$table->attach ($combo1, 0, 1 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($entry2, 1, 2 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($entry3, 2, 3 , $row, $row+1,'expand','shrink',2,2);
$table->attach_defaults ($connect_type_lable, 4, 5 , $row, $row+1);
$table->attach_defaults ($entry4, 5, 6 , $row, $row+1);
$table->attach_defaults ($entry5, 6, 7 , $row, $row+1);
$table->attach_defaults ($combentry, 8, 9 , $row, $row+1);
$table->attach ($connect_type_lable, 4, 5 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($entry4, 5, 6 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($entry5, 6, 7 , $row, $row+1,'expand','shrink',2,2);
$table->attach ($combentry, 8, 9 , $row, $row+1,'expand','shrink',2,2);
$combo1->signal_connect("changed"=>sub{
my $new_type=$combo1->get_active_text();
546,7 → 546,7
my $row=port_select($intfc_gen,$info,$table,1);
for (my $i=$row; $i<20; $i++){
my $temp=gen_label_in_center(" ");
$table->attach_defaults ($temp, 0, 1 , $i, $i+1);
#$table->attach_defaults ($temp, 0, 1 , $i, $i+1);
}
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
$scrolled_win->set_policy( "automatic", "automatic" );
595,10 → 595,21
print FILE Data::Dumper->Dump([\%$intfc_gen],["HashRef"]);
close(FILE) || die "Error closing file: $!";
#store \%$intfc_gen, "lib/$name.ITC";
my $message="Interface $name has been generated successfully" ;
message_dialog($message);
exec($^X, $0, @ARGV);# reset ProNoC to apply changes
#$hashref = retrieve('file');
my $message="Interface $name has been generated successfully. In order to see this interface in IP generator you need to reset the ProNoC. Do you want to reset the ProNoC now?" ;
my $dialog = Gtk2::MessageDialog->new (my $window,
'destroy-with-parent',
'question', # message type
'yes-no', # which set of buttons?
"$message");
my $response = $dialog->run;
if ($response eq 'yes') {
exec($^X, $0, @ARGV);# reset ProNoC to apply changes
}
$dialog->destroy;
 
}else{
my $message="Category must be defined!";
message_dialog($message);
619,7 → 630,7
my ($intfc_gen,$info)=@_;
my $description = $intfc_gen->intfc_get_description();
my $table = Gtk2::Table->new (15, 15, TRUE);
my $window=def_popwin_size(500,500,"Add description");
my $window=def_popwin_size(50,50,"Add description",'percent');
my ($scrwin,$text_view)=create_text();
#my $buffer = $textbox->get_buffer();
my $ok=def_image_button("icons/select.png",' Ok ');
704,10 → 715,17
my $devbox=dev_box_show($intfc_gen,$info);
$main_table->attach_defaults ($fbox , 0, 12, 0,1);
$main_table->attach_defaults ($sbox , 0, 12, 1,2);
$main_table->attach_defaults ($devbox , 0, 12, 2,12);
$main_table->attach_defaults ($infobox , 0, 12, 12,14);
#$main_table->attach_defaults ($fbox , 0, 12, 0,1);
#$main_table->attach_defaults ($sbox , 0, 12, 1,2);
#$main_table->attach_defaults ($devbox , 0, 12, 2,12);
#$main_table->attach_defaults ($infobox , 0, 12, 12,14);
 
my $v1=def_pack_vbox(TRUE,0,$fbox,$sbox);
my $v2=gen_vpaned($v1,.1,$devbox);
my $v3=gen_vpaned($v2,.6,$infobox);
$main_table->attach_defaults ($v3 , 0, 12, 0,14);
 
 
$main_table->attach ($generate , 6, 8, 14,15,'shrink','shrink',2,2);
 
 
721,17 → 739,19
$devbox->destroy();
$fbox->destroy();
$sbox->destroy();
$v1->destroy();
select(undef, undef, undef, 0.1); #wait 10 ms
$devbox=dev_box_show($intfc_gen,$info);
$fbox=file_box($intfc_gen,$info);
$sbox=module_select($intfc_gen,$info);
$main_table->attach_defaults ($fbox , 0, 12, 0,1);
$main_table->attach_defaults ($sbox , 0, 12, 1,2);
$main_table->attach_defaults ($devbox , 0, 12, 3,12);
$sbox=module_select($intfc_gen,$info);
$v1=def_pack_vbox(TRUE,0,$fbox,$sbox);
$v2->pack1($v1,TRUE, TRUE);
$v2->pack2($devbox,TRUE, TRUE);
$v3-> pack1($v2, TRUE, TRUE);
#$main_table->attach_defaults ($v3 , 0, 12, 0,14);
$v3->show_all();
$devbox->show_all();
$sbox->show_all();
$fbox->show_all();
});
 
 
/ip.pm
436,7 → 436,7
ip_add_port($self,$category,$module,$port,$type,$range,$intfc_name,$intfc_port);
}
my @fileds =("system_h","hdl_files","sw_files","gen_sw_files","sw_params_list","unused","parameters_order","description");
my @fileds =("system_h","hdl_files","sw_files","gen_sw_files","sw_params_list","unused","parameters_order","description","version",'description_pdf');
foreach my $p (@fileds){
my $val=$ipgen->ipgen_get($p);
$self->{categories}{$category}{names}{$module}{$p}=$ipgen->ipgen_get($p) if(defined $val );
448,10 → 448,20
 
 
sub object_add_attribute{
my ($self,$attribute1,$attribute2,$value)=@_;
if(!defined $attribute2){$self->{$attribute1}=$value;}
else {$self->{$attribute1}{$attribute2}=$value;}
 
}
 
sub object_get_attribute{
my ($self,$attribute1,$attribute2)=@_;
if(!defined $attribute2) {return $self->{$attribute1};}
return $self->{$attribute1}{$attribute2};
 
 
}
 
 
 
475,4 → 485,7
 
 
 
 
 
 
1
/ip_gen.pl
72,7 → 72,7
if (!defined $file) {return; }
if (-e $file) {
my $vdb = read_file($file);
my $vdb = read_verilog_file($file);
my @modules=sort $vdb->get_modules($file);
#foreach my $p(@module_list) {print "$p\n"}
$ipgen->ipgen_add("file_name",$file);
438,7 → 438,7
my ($ipgen,$module)=@_;
my $file= $ipgen->ipgen_get("file_name");
$ipgen->ipgen_add("module_name",$module);
my $vdb =read_file($file);
my $vdb =read_verilog_file($file);
my %parameters = $vdb->get_modules_parameters_not_local($module);
my @parameters_order= $vdb->get_modules_parameters_not_local_order($module);
my @ports_order=$vdb->get_module_ports_order($module);
586,12 → 586,12
}
my $module = $ipgen->ipgen_get("module_name");
my($width,$hight)=max_win_size();
my $window = def_popwin_size(.85*$width,.5*$hight,"Define parameters detail");
my $window = def_popwin_size(85,50,"Define parameters detail",'percent');
my @widget_type_list=("Fixed","Entry","Combo-box","Spin-button");
my @param_type_list=("Parameter","Localparam","Don't include");
my $type_info="Define the parameter type:
656,7 → 656,7
my @allowed;
my $row=1;
my $error;
push(@parameters,"#new#");
foreach my $p (@parameters) {
my ($saved_deafult,$saved_widget_type,$saved_content,$saved_info,$vfile_param_type,$redefine_param)= $ipgen->ipgen_get_parameter_detail($p);
725,6 → 725,16
my $check_result=$check_redefine->get_active();
my $redefine_param=($check_result eq 1)? 1:0;
$ipgen->ipgen_add_parameter($p,$deafult,$type,$content,$saved_info,$vfile_param_type,$redefine_param);
if ($type eq "Spin-button"){
my @d=split(",",$content);
if( scalar @d != 3){
$error=$error."wrong content setting for parameter $p\n" ;
print "$error";
}
}
 
 
}
});
$add_remove->signal_connect (clicked => sub{
749,6 → 759,7
} else { #remove the parameter
$ipgen->ipgen_remove_parameter($p);
$ipgen->ipgen_remove_parameters_order($p);
$p = "#new#";
set_gui_status($ipgen,"change_parameter",0);
$ok->clicked;
#$window->destroy();
797,8 → 808,18
});
$ok->signal_connect (clicked => sub{
 
 
 
$window->destroy();
if (defined $error){
message_dialog("$error");
$error=undef;
}else {
$window->destroy();
}
 
});
823,8 → 844,7
my ($ipgen,$info)=@_;
my $table = Gtk2::Table->new (15, 15, TRUE);
my $table2 = Gtk2::Table->new (15, 15, TRUE);
my($width,$hight)=max_win_size();
my $window = def_popwin_size(.7*$width,.7*$hight,"Add definition file");
my $window = def_popwin_size(70,70,"Add definition file",'percent');
my $ok=def_image_button("icons/select.png",' Ok ');
my $scrwin= new Gtk2::ScrolledWindow (undef, undef);
$scrwin->set_policy( "automatic", "automatic" );
852,13 → 872,14
my ($ipgen,$info)=@_;
my $description = $ipgen->ipgen_get("description");
my $table = Gtk2::Table->new (15, 15, FALSE);
my($width,$hight)=max_win_size();
my $window = def_popwin_size(.4*$width,.4*$hight, "Add description");
my $window = def_popwin_size(40,40, "Add description",'percent');
my ($scrwin,$text_view)=create_text();
#my $buffer = $textbox->get_buffer();
my $ok=def_image_button("icons/select.png",' Ok ');
$table->attach_defaults($scrwin,0,15,0,14);
$table->attach_defaults(gen_label_help("User can open the PDF file when oppening IP parameter setting","IP Documentation file in PDF"),0,7,0,1);
$table->attach_defaults(gen_label_help("Description will be shown on IP generator text view when selecting this IP","Short Description"),5,10,1,2);
$table->attach_defaults(get_file_name_object ( $ipgen, 'description_pdf',undef,"pdf",undef),7,15,0,1);
$table->attach_defaults($scrwin,0,15,2,14);
$table->attach($ok,6,9,14,15,'expand','shrink',2,2);
my $text_buffer = $text_view->get_buffer;
if(defined $description) {$text_buffer->set_text($description)};
964,8 → 985,7
sub get_param_info{
my ($ipgen,$saved_info)=@_;
my $table = Gtk2::Table->new (15, 15, FALSE);
my($width,$hight)=max_win_size();
my $window = def_popwin_size(.5*$width,.5*$hight,"Add description");
my $window = def_popwin_size(50,50,"Add description",'percent');
my ($scrwin,$text_view)=create_text();
my $ok=def_image_button("icons/select.png",' Ok ');
1175,9 → 1195,7
sub get_intfc_setting{
my ($ipgen,$intfc_name, $intfc_type)=@_;
my($width,$hight)=max_win_size();
my $window = def_popwin_size(.7*$width,.7*$hight,"Interface parameter setting");
my $window = def_popwin_size(70,70,"Interface parameter setting",'percent');
my $table=def_table(7,6,FALSE);
my $ok = def_image_button('icons/select.png','OK');
1564,10 → 1582,43
}
 
 
sub write_ip{
my $ipgen=shift;
my $name=$ipgen->ipgen_get("module_name");
my $category=$ipgen->ipgen_get("category");
my $ip_name= $ipgen->ipgen_get("ip_name");
my $dir = Cwd::getcwd();
 
#Increase IP version
my $v=$ipgen->object_get_attribute("version",undef);
$v = 0 if(!defined $v);
$v++;
$ipgen->object_add_attribute("version",undef,$v);
#print "$v\n";
 
# Write
mkpath("$dir/lib/ip/$category/",1,01777);
open(FILE, ">lib/ip/$category/$ip_name.IP") || die "Can not open: $!";
print FILE perl_file_header("$ip_name.IP");
print FILE Data::Dumper->Dump([\%$ipgen],[$name]);
close(FILE) || die "Error closing file: $!";
my $message="IP $ip_name has been generated successfully. In order to see the generated IP in processing tile generator you need to reset the ProNoC. Do you want to reset the ProNoC now?" ;
my $dialog = Gtk2::MessageDialog->new (my $window,
'destroy-with-parent',
'question', # message type
'yes-no', # which set of buttons?
"$message");
my $response = $dialog->run;
if ($response eq 'yes') {
exec($^X, $0, @ARGV);# reset ProNoC to apply changes
}
$dialog->destroy;
 
}
 
 
 
sub generate_ip{
my $ipgen=shift;
my $name=$ipgen->ipgen_get("module_name");
1575,10 → 1626,19
my $ip_name= $ipgen->ipgen_get("ip_name");
my $dir = Cwd::getcwd();
 
#check if name has been set
if(defined ($name) && defined ($category)){
if (!defined $ip_name) {$ip_name= $name}
my $error = check_verilog_identifier_syntax($ip_name);
if ( defined $error ){
message_dialog("The IP name \"$ip_name\" is given with an unacceptable formatting. This name will be used as a verilog module name so it must follow Verilog identifier declaration formatting:\n $error");
return ;
}
 
 
 
#check if any source file has been added for this ip
my @l=$ipgen->ipgen_get_list("hdl_files");
if( scalar @l ==0){
1590,15 → 1650,9
"No hdl library file has been set for this IP. Do you want to generate this IP?");
my $response = $dialog->run;
if ($response eq 'yes') {
# Write
mkpath("$dir/lib/ip/$category/",1,01777);
open(FILE, ">lib/ip/$category/$ip_name.IP") || die "Can not open: \">lib/ip/$category/$ip_name.IP\" $!";
print FILE perl_file_header("$ip_name.IP");
print FILE Data::Dumper->Dump([\%$ipgen],[$name]);
close(FILE) || die "Error closing file: $!";
my $message="IP $ip_name has been generated successfully" ;
message_dialog($message);
exec($^X, $0, @ARGV);# reset ProNoC to apply changes
write_ip($ipgen);
}
$dialog->destroy;
 
1606,15 → 1660,8
#$dialog->show_all;
}else{
# Write
mkpath("$dir/lib/ip/$category/",1,01777);
open(FILE, ">lib/ip/$category/$ip_name.IP") || die "Can not open: $!";
print FILE perl_file_header("$ip_name.IP");
print FILE Data::Dumper->Dump([\%$ipgen],[$name]);
close(FILE) || die "Error closing file: $!";
my $message="IP $ip_name has been generated successfully" ;
message_dialog($message);
exec($^X, $0, @ARGV);# reset ProNoC to apply changes
 
write_ip($ipgen);
}
}else{
my $message;
1697,9 → 1744,9
;
my $var_help=gen_button_message($var_list,"icons/info.png","Global variables");
my($width,$hight)=max_win_size();
my $window = def_popwin_size($width*2/3,$hight*2/3,$title);
my $window = def_popwin_size(75,75,$title,'percent');
my $notebook=source_notebook($ipgen,$info,$window,$page,$dest,$page_info_ref);
my $table=def_table (15, 15, FALSE);
1862,7 → 1909,6
#my $hdr = $ipgen->ipgen_get_hdr();
my $hdr = $ipgen-> ipgen_get($page_info{filed_name});
my $table = Gtk2::Table->new (14, 15, FALSE);
#my $window=def_popwin_size(600,600,"Add header file");
my ($scrwin,$text_view)=create_text();
 
my $help=gen_label_help($page_info{help});
1981,7 → 2027,33
# The main table containg the lib tree, selected modules and info section
my $main_table = def_table (15, 12, FALSE);
 
 
 
 
#my $vpaned = Gtk2::VPaned -> new;
#$table->attach_defaults ($vpaned,0, 10, 0,1);
#my $make = def_image_button('icons/run.png','Compile');
#$table->attach ($make,9, 10, 1,2,'shrink','shrink',0,0);
#$make -> signal_connect("clicked" => sub{
#$self->do_save();
#run_make_file($sw,$tview);
 
#});
 
#$window -> add ( $table);
 
#my($width,$hight)=max_win_size();
#my $scwin_dirs = Gtk2::ScrolledWindow -> new;
#$scwin_dirs -> set_policy ('automatic', 'automatic');
 
 
 
 
# The box which holds the info, warning, error ... mesages
my ($infobox,$info)= create_text();
2009,12 → 2081,20
#$table->attach_defaults ($event_box, $col, $col+1, $row, $row+1);
$main_table->attach_defaults ($tree_box , 0, 2, 0, 13);
$main_table->attach_defaults ($file_info , 2, 12, 0, 2);
$main_table->attach_defaults ($intfc_info , 2, 12, 2, 6);
 
my $v1=gen_vpaned($file_info,.2,$intfc_info);
my $v2=gen_vpaned($v1,.4,$port_info);
my $h1=gen_hpaned($tree_box,.15,$v2);
my $v3=gen_vpaned($h1,.6,$infobox);
 
 
#$main_table->attach_defaults ($tree_box , 0, 2, 0, 13);
#$main_table->attach_defaults ($file_info , 2, 12, 0, 2);
#$main_table->attach_defaults ($intfc_info , 2, 12, 2, 6);
$main_table->attach_defaults ($port_info , 2, 12, 6,13);
$main_table->attach_defaults ($infobox , 0, 12, 13,14);
#$main_table->attach_defaults ($port_info , 2, 12, 6,13);
#$main_table->attach_defaults ($infobox , 0, 12, 13,14);
$main_table->attach_defaults ($v3, 0, 12, 0,14);
$main_table->attach ($generate, 6, 8, 14,15,'expand','shrink',2,2);
$main_table->attach ($open,0, 1, 14,15,'expand','shrink',2,2);
 
/mpsoc.pm
90,6 → 90,20
delete $self->{socs}{$name};
}
 
sub mpsoc_remove_soc_top{
my ($self,$name)=@_;
delete $self->{socs}{$name}{top};
}
 
 
sub mpsoc_remove_all_soc_tops{
my $self=shift;
foreach my $name (sort keys %{$self->{socs}}){
delete $self->{socs}{$name}{top};
}
}
 
 
sub mpsoc_remove_all_soc{
my ($self)=@_;
delete $self->{socs};
118,7 → 132,7
@nums = @{$self->{socs}{$name}{tile_nums}};
}
return @ nums;
return @nums;
}
 
sub mpsoc_get_scolar_pos{
239,7 → 253,17
return @{$self->{parameters_order}{$attribute}};
}
 
sub object_remove_attribute{
my ($self,$attribute1,$attribute2)=@_;
if(!defined $attribute2){
delete $self->{$attribute1} if ( exists( $self->{$attribute1}));
}
else {
delete $self->{$attribute1}{$attribute2} if ( exists( $self->{$attribute1}{$attribute2})); ;
 
}
 
}
 
1
 
/mpsoc_gen.pl
285,7 → 285,7
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(100,300,"warning");
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);
419,7 → 419,7
sub get_soc_parameter_setting{
my ($mpsoc,$soc_name,$tile)=@_;
my $window = (defined $tile)? def_popwin_size(600,400,"Parameter setting for $soc_name located in tile($tile) "):def_popwin_size(600,400,"Default Parameter setting for $soc_name ");
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);
1101,9 → 1101,9
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 $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);
1159,7 → 1159,7
 
 
 
return $scrolled_win;
return $table;
 
}
 
1237,7 → 1237,17
my ($mpsoc,$soc,$info)=@_;
my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
my $soc_name=$soc->object_get_attribute('soc_name');
my ($file_v,$tmp)=soc_generate_verilog($soc);
# 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: $!";
1253,14 → 1263,7
# 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);
#copy hdl codes in src_verilog
1316,6 → 1319,19
}
 
 
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],[$name]);
close(FILE) || die "Error closing file: $!";
get_soc_list($mpsoc,$info);
}
 
 
################
# generate_mpsoc
#################
1323,8 → 1339,9
sub generate_mpsoc{
my ($mpsoc,$info)=@_;
my $name=$mpsoc->object_get_attribute('mpsoc_name');
if ( $name =~ /\W+/ ){
message_dialog('The mpsoc name must not contain any non-word character:("./\()\':,.;<>~!@#$%^&*|+=[]{}`~?-")!")');
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;
1354,15 → 1371,12
my ($file_v,$top_v)=mpsoc_generate_verilog($mpsoc);
my ($file_v,$top_v)=mpsoc_generate_verilog($mpsoc,$sw_dir);
# Write object file
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: $!";
generate_mpsoc_lib_file($mpsoc,$info);
# Write verilog file
open(FILE, ">lib/verilog/$name.v") || die "Can not open: $!";
1581,7 → 1595,7
}
$button->signal_connect("clicked" => sub{
my $window = def_popwin_size(400,400,"Parameter setting for Tile $tile ");
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);
1717,14 → 1731,40
 
 
 
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/sw";
my $sw = "$target_dir";
my ($app,$table,$tview) = software_main($sw);
 
 
 
my $make = def_image_button('icons/gen.png','Compile');
$table->attach ($make,9, 10, 1,2,'shrink','shrink',0,0);
 
$make -> signal_connect("clicked" => sub{
$app->do_save();
run_make_file($sw,$tview);
 
});
 
}
 
 
 
 
 
 
 
############
# main
############
1753,8 → 1793,10
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);
 
 
$main_table->set_row_spacings (4);
$main_table->set_col_spacings (1);
1767,8 → 1809,8
my $open = def_image_button('icons/browse.png','Load MPSoC');
my $compile = def_image_button('icons/run.png','Compile');
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);
1775,27 → 1817,45
#$table->attach_defaults ($event_box, $col, $col+1, $row, $row+1);
$main_table->attach_defaults ($noc_conf_box , 0, 4, 0, 22);
$main_table->attach_defaults ($noc_tiles , 4, 12, 0, 22);
$main_table->attach_defaults ($infobox , 0, 12, 22,24);
#$main_table->attach_defaults ($noc_conf_box , 0, 4, 0, 22);
#$main_table->attach_defaults ($noc_tiles , 4, 12, 0, 22);
#$main_table->attach_defaults ($infobox , 0, 12, 22,24);
 
my $h1=gen_hpaned($scr_conf,.3,$noc_tiles);
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, 10, 12, 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);
 
#referesh the mpsoc generator
$refresh-> signal_connect("clicked" => sub{
$noc_conf_box->destroy();
$noc_conf_box=get_config ($mpsoc,$info);
$main_table->attach_defaults ($noc_conf_box , 0, 4, 0, 22);
$noc_conf_box->show_all();
$scr_conf->add_with_viewport($noc_conf_box);
#$main_table->attach_defaults ($noc_conf_box , 0, 4, 0, 22);
#$noc_conf_box->show_all();
 
 
$noc_tiles->destroy();
$noc_tiles=gen_tiles($mpsoc);
$main_table->attach_defaults ($noc_tiles , 4, 12, 0, 22);
#$h1->destroy();
#$h1=gen_hpaned($noc_conf_box,.3,$noc_tiles);
$h1 -> pack1($scr_conf, TRUE, TRUE);
$h1 -> pack2($noc_tiles, TRUE, TRUE);
$v2-> pack1($h1, TRUE, TRUE);
$h1->show_all;
#$main_table->attach_defaults ($noc_tiles , 4, 12, 0, 22);
 
$main_table->show_all();
 
1812,6 → 1872,14
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" ){
$refresh->clicked;
1841,8 → 1909,30
set_gui_status($mpsoc,"ref",5);
load_mpsoc($mpsoc,$info);
});
 
 
$compile -> signal_connect("clicked" => sub{
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){
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" );
1882,8 → 1972,8
$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"\..[^.]*$");
1890,13 → 1980,33
if($suffix eq '.MPSOC'){
my $pp= eval { do $file };
if ($@ || !defined $pp){
show_info(\$info,"**Error reading $file file: $@\n");
add_info(\$info,"**Error: cannot open $file file: $@\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);
}
@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);
}
/mpsoc_verilog_gen.pl
12,9 → 12,17
 
 
sub mpsoc_generate_verilog{
my $mpsoc=shift;
my ($mpsoc,$sw_dir)=@_;
my $mpsoc_name=$mpsoc->object_get_attribute('mpsoc_name');
my $top_ip=ip_gen->top_gen_new();
my $io_v="\tclk,\n\treset";
 
#$top_ip->top_add_port($inst,$port,$range,$type,$intfc_name,$intfc_port);
$top_ip->top_add_port('IO','reset','', 'input' ,'plug:reset[0]','reset_i');
$top_ip->top_add_port('IO','clk','', 'input' ,'plug:clk[0]','clk_i');
my $io_def_v="
//IO
\tinput\tclk,reset;\n";
33,15 → 41,16
my $noc_v=gen_noc_v($pass_param);
#generate socs
my $socs_v=gen_socs_v($mpsoc,\$io_v,\$io_def_v,\$top_io);
my $socs_v=gen_socs_v($mpsoc,\$io_v,\$io_def_v,\$top_io,$top_ip,$sw_dir);
#functions
my $functions=get_functions();
my $mpsoc_v = (defined $param_as_in_v )? "module $mpsoc_name #(\n $param_as_in_v\n)(\n$io_v\n);\n": "module $mpsoc_name (\n$io_v\n);\n";
add_text_to_string (\$mpsoc_v,$noc_param);
add_text_to_string (\$mpsoc_v,$functions);
add_text_to_string (\$mpsoc_v,$socs_param);
add_text_to_string (\$mpsoc_v,$noc_param);
add_text_to_string (\$mpsoc_v,$io_def_v);
add_text_to_string (\$mpsoc_v,$noc_v);
add_text_to_string (\$mpsoc_v,$socs_v);
80,6 → 89,7
 
#add_text_to_string(\$top_v,$local_param_v_all."\n".$io_full_v_all);
#add_text_to_string(\$top_v,$ins);
$mpsoc->object_add_attribute('top_ip',undef,$top_ip);
return ($mpsoc_v,$top_v);
}
 
262,7 → 272,7
sub gen_noc_v{
my $pass_param = shift;
my $noc = read_file("../src_noc/noc.v");
my $noc = read_verilog_file("../src_noc/noc.v");
my @noc_param=$noc->get_modules_parameters_not_local_order('noc');
380,7 → 390,7
 
 
sub gen_socs_v{
my ($mpsoc,$io_v_ref,$io_def_v,$top_io_ref)=@_;
my ($mpsoc,$io_v_ref,$io_def_v,$top_io_ref,$top_ip,$sw_dir)=@_;
#generate loop
427,7 → 437,7
my $socs_v;
my $nx= $mpsoc->object_get_attribute('noc_param',"NX");
my $ny= $mpsoc->object_get_attribute('noc_param',"NY");
my $processors_en=0;
440,7 → 450,7
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);
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);
add_text_to_string(\$socs_v,$soc_v);
$processors_en|=$en;
463,6 → 473,7
add_text_to_string($io_v_ref,",\n\tprocessors_en");
add_text_to_string($io_def_v,"\t input processors_en;");
add_text_to_string($top_io_ref,",\n\t\t.processors_en(processors_en_anded_jtag)");
$top_ip->top_add_port('IO','processors_en','' ,'input','plug:enable[0]','enable_i');
}
478,7 → 489,7
 
 
sub gen_soc_v{
my ($mpsoc,$soc_name,$tile_num,$x,$y,$soc_num,$io_v_ref,$io_def_v,$top_io_ref)=@_;
my ($mpsoc,$soc_name,$tile_num,$x,$y,$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"));
485,8 → 496,8
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";
# core id
add_text_to_string(\$soc_v,"\t\t.CORE_ID($tile_num)");
# 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);
521,7 → 532,7
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
my $soc_file="$target_dir/src_verilog/tiles/$soc_name.v";
my $vdb =read_file($soc_file);
my $vdb =read_verilog_file($soc_file);
my %soc_localparam = $vdb->get_modules_parameters($soc_name);
607,8 → 618,8
my $new_range = add_instantc_name_to_parameters(\%params,"${soc_name}_$soc_num",$range);
#my $new_range=$range;
my $port_def=(length ($range)>1 )? "\t$type\t [ $new_range ] $io_port;\n": "\t$type\t\t\t$io_port;\n";
$top_ip->top_add_port("${soc_name}_$tile_num" ,$io_port, $new_range ,$type,$intfc_name,$intfc_port);
add_text_to_string($io_def_v,"$port_def");
add_text_to_string(\$soc_v,',') if ($i);
add_text_to_string(\$soc_v,"\n\t\t.$p($io_port)");
/readme_gen.pl
1,15 → 1,16
#! /usr/bin/perl -w
 
use Time::Piece;
 
 
sub get_license_header {
my $file_name=shift;
 
my $t = Time::Piece->new();
my $year=$t->year;
my $head="
/**********************************************************************
** File: $file_name
**
** Copyright (C) 2014-2016 Alireza Monemi
** Copyright (C) 2014-$year Alireza Monemi
**
** This file is part of ProNoC $ProNOC::VERSION
**
16,7 → 17,7
** ProNoC ( stands for Prototype Network-on-chip) is free software:
** you can redistribute it and/or modify it under the terms of the GNU
** Lesser General Public License as published by the Free Software Foundation,
** either version 3 of the License, or (at your option) any later version.
** either version 2 of the License, or (at your option) any later version.
**
** ProNoC is distributed in the hope that it will be useful, but WITHOUT
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24,7 → 25,7
** Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with AEMB. If not, see <http:**www.gnu.org/licenses/>.
** License along with ProNoC. If not, see <http:**www.gnu.org/licenses/>.
******************************************************************************/
";
 
/simulator.pl
54,7 → 54,7
#verilate the noc
my $start = localtime;
add_info($info_text, "verilate the NoC and make the library files");
my $command = "cd \"$script_dir/\" \n xterm -l -lf logfile1.txt -e sh verilator_compile_hw.sh";
my ($stdout,$exit)=run_cmd_in_back_ground_get_stdout( $command);
92,7 → 92,7
add_info($info_text, "Verilator compilation failed !\n$command\n $stdout\n");
return;
}
my $end = localtime;
 
101,17 → 101,19
my $path=$simulate->object_get_attribute ('sim_param',"BIN_DIR");
my $name=$simulate->object_get_attribute ('sim_param',"SAVE_NAME");
#create project didrectory if its not exist
#create project directory if its not exist
($stdout,$exit)=run_cmd_in_back_ground_get_stdout("mkdir -p $path" );
if($exit != 0 ){ print "$stdout\n"; message_dialog($stdout); return;}
if($exit != 0 ){ print "$stdout\n"; message_dialog($stdout,'error'); return;}
#move the log file
move("$script_dir/logfile1.txt" , "$path/$name.log1");
move("$script_dir/logfile2.txt" , "$path/$name.log2");
unlink "$path/$name.log";
append_text_to_file("$path/$name.log","start:$start\n");
merg_files("$script_dir/logfile1.txt" , "$path/$name.log");
merg_files("$script_dir/logfile2.txt" , "$path/$name.log");
append_text_to_file("$path/$name.log","end:$end\n");
#check if the verilation was successful
if ((-e $bin)==0) {#something goes wrong
message_dialog("Verilator compilation was unsuccessful please check the $path/$name.log files for more information");
message_dialog("Verilator compilation was unsuccessful please check the $path/$name.log files for more information",'error');
return;
}
118,7 → 120,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); return;}
if($exit != 0 ){ print "$stdout\n"; message_dialog($stdout,'error'); return;}
#save noc info
open(FILE, ">$path/$name.inf") || die "Can not open: $!";
147,7 → 149,7
 
 
##########
# save_emulation
# save_simulation
##########
sub save_simulation {
my ($simulate)=@_;
/soc.pm
64,6 → 64,9
}
}
}
 
 
$self->{instances}{$instance_id}{description_pdf}=$ip->ip_get($category,$module,'description_pdf');
return 1;
}
150,6 → 153,11
}
 
 
sub soc_get_description_pdf{
my ($self,$instance_id)=@_;
return $self->{instances}{$instance_id}{description_pdf};
}
 
sub soc_get_plug_name {
my ($self,$instance_id,$plug,$num)=@_;
my $name;
278,9 → 286,23
}
return @list;
}
}
 
sub soc_get_all_sockets_of_an_instance{
my ($self,$instance_id)=@_;
my @list;
if(exists ($self->{instances}{$instance_id}{sockets})){
foreach my $p (sort keys %{$self->{instances}{$instance_id}{sockets}}){
push (@list,$p);
}
}
return @list;
}
 
 
##############################################
sub soc_get_modules_plug_connected_to_socket{
my ($self,$id,$socket,$socket_num)=@_;
536,7 → 558,19
}
}
return @list;
}
 
sub soc_list_socket_nums{
my ($self,$instance_id,$socket)=@_;
my @list;
if(exists($self->{instances}{$instance_id}{sockets}{$socket})){
foreach my $num (sort keys %{$self->{instances}{$instance_id}{sockets}{$socket}{nums}}){
push (@list,$num);
}
}
return @list;
}
 
 
sub soc_get_plug{
668,13 → 702,88
}
 
 
sub object_remove_attribute{
my ($self,$attribute1,$attribute2)=@_;
if(!defined $attribute2){
delete $self->{$attribute1} if ( exists( $self->{$attribute1}));
}
else {
delete $self->{$attribute1}{$attribute2} if ( exists( $self->{$attribute1}{$attribute2})); ;
 
}
 
}
 
 
sub board_new {
# be backwards compatible with non-OO call
my $class = ("ARRAY" eq ref $_[0]) ? "soc" : shift;
my $self;
$self->{'Input'}{'*VCC'}{'*VCC'} = ['*undefine*'];
$self->{'Input'}{'*GND'}{'*GND'} = ['*undefine*'];
$self->{'Input'}{'*NOCONNECT'}{'*NOCONNECT'} = ['*undefine*'];
$self->{'Output'}{'*NOCONNECT'}{'*NOCONNECT'} = ['*undefine*'];
$self->{'Bidir'}{'*NOCONNECT'}{'*NOCONNECT'} = ['*undefine*'];
bless($self,$class);
return $self;
}
 
 
 
sub board_add_pin {
my ($self,$direction,$name)=@_;
my ($intfc,$pin_name,$pin_num);
my @f= split('_',$name);
if(!defined $f[1]){ # There is no '_' in pin name
my @p= split(/\[/,$name);
$intfc=$p[0];
$pin_name=$p[0];
if(defined $p[1]){ #it is an array
my @q= split(/\]/,$p[1]);
$pin_num=$q[0]; #save pin num
}else{
$pin_num='*undefine*';
}
}
else{ # take the word before '_' as interface
$intfc=$f[0];
my @p= split(/\[/,$name);
$pin_name=$p[0];
if(defined $p[1]){
my @q= split(/\]/,$p[1]);
$pin_num=$q[0];
}else{
$pin_num='*undefine*';
}
}
my @a;
@a= @{$self->{$direction}{$intfc}{$pin_name}} if(exists $self->{$direction}{$intfc}{$pin_name});
push (@a,$pin_num);
@{$self->{$direction}{$intfc}{$pin_name}}=@a;
 
}
 
sub board_get_pin {
my ($self,$direction)=@_;
my %p=%{$self->{$direction}};
return %p;
 
}
 
sub board_get_pin_range {
my ($self,$direction,$pin_name)=@_;
my @f= split('_',$pin_name);
my $intfc = $f[0];
my $ref =$self->{$direction}{$intfc}{$pin_name};
my @range;
@range= @{$ref} if(defined $ref);
return @range;
}
 
 
1
/soc_gen.pl
19,6 → 19,7
 
 
 
 
# clean names for column numbers.
use constant DISPLAY_COLUMN => 0;
use constant CATRGORY_COLUMN => 1;
31,9 → 32,10
require "verilog_gen.pl";
require "readme_gen.pl";
require "hdr_file_gen.pl";
require "diagram.pl";
require "compile.pl";
require "software_editor.pl";
 
 
 
 
sub is_hex {
77,7 → 79,11
return;
}
$soc->soc_add_instance_order($instance_id);
# Add IP version
my $v=$ip->ip_get($category,$module,"version");
$v = 0 if(!defined $v);
#print "$v\n";
$soc->object_add_attribute($instance_id,"version",$v);
# Read default parameter from lib and add them to soc
my %param_default= $ip->get_param_default($category,$module);
125,8 → 131,7
my %new_param_value=%param_value;
#gui
my $table_size = ($param_num<10) ? 10 : $param_num;
my($width,$hight)=max_win_size();
my $window = def_popwin_size(.6*$width,.6*$hight, "Parameter setting for $module ");
my $window = def_popwin_size(60,60, "Parameter setting for $module ",'percent');
my $table = def_table($table_size, 7, FALSE);
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
136,19 → 141,30
my $ok = def_image_button('icons/select.png','OK');
my $at0= 'expand';
my $at1= 'shrink';
$table->attach (gen_label_in_center("Parameter name"),0, 3, $row, $row+1,'expand','shrink',2,2);
$table->attach (gen_label_in_center("Value"),3, 6, $row, $row+1,'expand','shrink',2,2);
$table->attach (gen_label_in_center("Description"),6, 7, $row, $row+1,'expand','shrink',2,2);
$table->attach (gen_label_in_left("Parameter name"),0, 3, $row, $row+1,$at0,$at1,2,2);
$table->attach (gen_label_in_left("Value"),3, 6, $row, $row+1,$at0,$at1,2,2);
$table->attach (gen_label_in_left("Description"),6, 7, $row, $row+1,$at0,$at1,2,2);
$row++;
foreach my $p (@parameters){
my ($default,$type,$content,$info)= $ip->ip_get_parameter($category,$module,$p);
my $value=$param_value{$p};
if ($type eq "File_Entry"){
my $entry=gen_entry($value);
my $brows=get_file_name(undef,undef,$entry,undef,undef,undef,undef,undef);
my $box=def_hbox(TRUE,0);
$box->pack_start($entry,FALSE,FALSE,3);
$box->pack_start($brows,FALSE,FALSE,3);
$table->attach ($box, 3, 6, $row, $row+1,$at0,$at1,2,2);
$entry-> signal_connect("changed" => sub{$new_param_value{$p}=$entry->get_text();});
}
if ($type eq "Entry"){
elsif ($type eq "Entry"){
my $entry=gen_entry($value);
$table->attach ($entry, 3, 6, $row, $row+1,'expand','shrink',2,2);
$table->attach ($entry, 3, 6, $row, $row+1,$at0,$at1,2,2);
$entry-> signal_connect("changed" => sub{$new_param_value{$p}=$entry->get_text();});
}
elsif ($type eq "Combo-box"){
155,7 → 171,7
my @combo_list=split(",",$content);
my $pos=get_item_pos($value, @combo_list);
my $combo=gen_combo(\@combo_list, $pos);
$table->attach ($combo, 3, 6, $row, $row+1,'expand','shrink',2,2);
$table->attach ($combo, 3, 6, $row, $row+1,$at0,$at1,2,2);
$combo-> signal_connect("changed" => sub{$new_param_value{$p}=$combo->get_active_text();});
}
168,7 → 184,7
my $spin=gen_spin($min,$max,$step);
if(defined $value) {$spin->set_value($value);}
else {$spin->set_value($min);}
$table->attach ($spin, 3, 4, $row, $row+1,'expand','shrink',2,2);
$table->attach ($spin, 3, 4, $row, $row+1,$at0,$at1,2,2);
$spin-> signal_connect("value_changed" => sub{ $new_param_value{$p}=$spin->get_value_as_int(); });
# $box=def_label_spin_help_box ($param,$info, $value,$min,$max,$step, 2);
175,7 → 191,7
}
if (defined $info && $type ne "Fixed"){
my $info_button=def_image_button('icons/help.png');
$table->attach ($info_button, 6, 7, $row, $row+1,'expand','shrink',2,2);
$table->attach ($info_button, 6, 7, $row, $row+1,$at0,$at1,2,2);
$info_button->signal_connect('clicked'=>sub{
message_dialog($info);
184,8 → 200,8
}
if ($type ne "Fixed"){
#print "$p:val:$value\n";
my $label =gen_label_in_center($p);
$table->attach ($label, 0, 3, $row, $row+1,'expand','shrink',2,2);
my $label =gen_label_in_left($p);
$table->attach ($label, 0, 3, $row, $row+1,$at0,$at1,2,2);
$row++;
}
193,14 → 209,16
}
#if ($row== 0){
#my $label =gen_label_in_left("The $module IP does not have any adjatable parameter");
# $table->attach ($label, 0, 7, $row, $row+1,'expand','shrink',2,2);
# $table->attach ($label, 0, 7, $row, $row+1,$at0,'shrink',2,2);
 
#}
my $mtable = def_table(10, 1, FALSE);
 
$mtable->attach_defaults($scrolled_win,0,1,0,9);
$mtable->attach($ok,0,1,9,10,'expand','shrink',2,2);
$mtable->attach($ok,0,1,9,10,'expand','fill',2,2);
$window->add ($mtable);
$window->show_all();
340,8 → 358,31
my $module=$soc->soc_get_module($instance_id);
my $category=$soc->soc_get_category($instance_id);
my $module_name_label=box_label(FALSE,0,$module);
$table->attach_defaults ($module_name_label,0,1,$offset+0,$offset+1);
my $box0=def_hbox(FALSE,5);
$box0->pack_start( $module_name_label, FALSE, FALSE, 3);
 
#module pdf
my $pdf=$soc->soc_get_description_pdf($instance_id);
if(defined $pdf){
my $b=def_image_button('icons/evince-icon.png');
$box0->pack_start( $b, FALSE, FALSE, 3);
$b->signal_connect ("clicked" => sub{
my $dir = Cwd::getcwd();
my $project_dir = abs_path("$dir/../../"); #mpsoc directory address
#print "path ${project_dir}$pdf\n";
if (-f "${project_dir}$pdf"){
system qq (xdg-open ${project_dir}$pdf);
}elsif (-f "$pdf"){
system qq (xdg-open $pdf);
}else{
message_dialog("Error! $pdf or ${project_dir}$pdf did not find!\n");
}
 
});
 
}
$table->attach ($box0,0,1,$offset+0,$offset+1,'expand','shrink',2,2);
 
#parameter setting button
my $param_button = def_image_button('icons/setting.png','Setting');
my $box1=def_hbox(FALSE,5);
348,7 → 389,7
my $up=def_image_button("icons/up_sim.png");
$box1->pack_start( $up, FALSE, FALSE, 3);
$box1->pack_start($param_button, FALSE, FALSE,3);
$table->attach_defaults ($box1 ,0,1,$offset+1,$offset+2);
$table->attach ($box1 ,0,1,$offset+1,$offset+2,'expand','shrink',2,2);
$param_button->signal_connect (clicked => sub{
get_module_parameter($soc,$ip,$instance_id);
367,7 → 408,7
my $dwn=def_image_button("icons/down_sim.png");
$box2->pack_start( $dwn, FALSE, FALSE, 3);
$box2->pack_start($cancel_button, FALSE, FALSE,3);
$table->attach_defaults ($box2,0,1,$offset+2,$offset+3);
$table->attach ($box2,0,1,$offset+2,$offset+3,'expand','shrink',2,2);
$cancel_button->signal_connect (clicked => sub{
remove_instance_from_soc($soc,$instance_id);
377,37 → 418,86
set_gui_status($soc,"refresh_soc",0);
});
 
#instance name
my $instance_name=$soc->soc_get_instance_name($instance_id);
my $instance_label=gen_label_in_left("Instance name");
my $instance_label=gen_label_in_left(" Instance name");
my $instance_entry = gen_entry($instance_name);
$table->attach_defaults ($instance_label,1,2,$offset+0,$offset+1);
$table->attach_defaults ($instance_entry,1,2,$offset+1,$offset+2);
$table->attach ($instance_label,1,2,$offset+0,$offset+1,'expand','shrink',2,2);
#$table->attach_defaults ($instance_entry,1,2,$offset+1,$offset+2);
 
 
my $enter= def_image_button("icons/enter.png");
$instance_entry->signal_connect (changed => sub{
my $box=def_pack_hbox(FALSE,0,$instance_entry );
$table->attach ($box,1,2,$offset+1,$offset+2,'expand','shrink',2,2);
 
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");
$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")
});
 
 
}
 
$instance_entry->signal_connect ("activate" => sub{
#print "changed\n";
$instance_name=$instance_entry->get_text();
my $new_name=$instance_entry->get_text();
#check if instance name exist in soc
set_gui_status($soc,"refresh_soc",1) if($instance_name eq $new_name );
my @instance_names= $soc->soc_get_all_instance_name();
if( grep {$_ eq $instance_name} @instance_names){
print "$instance_name exist\n";
if( grep {$_ eq $new_name} @instance_names){
print "$new_name exist\n";
}
else {
#add instance name to soc
$soc->soc_set_instance_name($instance_id,$instance_name);
$soc->soc_set_instance_name($instance_id,$new_name);
set_gui_status($soc,"refresh_soc",25);
set_gui_status($soc,"refresh_soc",1);
}
});
my $change=0;
$instance_entry->signal_connect ("changed" => sub{
if($change ==0){
$box->pack_start( $enter, FALSE, FALSE, 0);
$box->show_all;
$change=1;
}
 
});
$enter->signal_connect ("clicked" => sub{
my $new_name=$instance_entry->get_text();
#check if instance name exist in soc
set_gui_status($soc,"refresh_soc",1) if($instance_name eq $new_name );
my @instance_names= $soc->soc_get_all_instance_name();
if( grep {$_ eq $new_name} @instance_names){
print "$new_name exist\n";
}
else {
#add instance name to soc
$soc->soc_set_instance_name($instance_id,$new_name);
set_gui_status($soc,"refresh_soc",1);
}
 
 
});
 
 
#interface_pluges
my %plugs = $ip->get_module_plugs_value($category,$module);
484,11 → 574,11
#plug name
my $plug_name= $soc->soc_get_plug_name($instance_id,$plug,$k);
if(! defined $plug_name ){$plug_name=($plug_num>1)?"$plug\[$k\]":$plug}
$plug_name=" $plug_name";
$plug_name=" $plug_name ";
my($plug_box, $plug_combo)= def_h_labeled_combo_scaled($plug_name,\@connettions_name,$pos,1,2);
#if($row>2){$table->resize ($row, 2);}
$table->attach_defaults ($plug_box,2,5,$row+$offset,$row+$offset+1);$row=$row+1;
$table->attach ($plug_box,2,5,$row+$offset,$row+$offset+1,'fill','fill',2,2); $row++;
my $plug_num=$k;
my @ll=($soc,$instance_id,$plug,$info,$plug_num);
577,7 → 667,7
my $separator = Gtk2::HSeparator->new;
#$box->pack_start($separator, FALSE, FALSE, 3);
if($row<3) {$row=3;}
$table->attach_defaults ($separator,0,5,$row+$offset,$row+$offset+1);$row=$row+1;
$table->attach ($separator,0,5,$row+$offset,$row+$offset+1,'fill','fill',2,2); $row++;
return ($offset+$row);
}
 
619,8 → 709,8
}
if($row<20){for ($i=$row; $i<20; $i++){
my $temp=gen_label_in_center(" ");
$table->attach_defaults ($temp, 0, 1 , $i, $i+1);
#my $temp=gen_label_in_center(" ");
#$table->attach_defaults ($temp, 0, 1 , $i, $i+1);
}}
858,7 → 948,7
my $name=$soc->object_get_attribute('soc_name');
my ($file_v,$top_v,$readme,$prog)=soc_generate_verilog($soc);
my ($file_v,$top_v,$readme,$prog)=soc_generate_verilog($soc,$sw_path);
# Write object file
open(FILE, ">lib/soc/$name.SOC") || die "Can not open: $!";
867,13 → 957,14
close(FILE) || die "Error closing file: $!";
# Write verilog file
my $h=autogen_warning().get_license_header("${name}.v")."\n`timescale 1ns / 1ps\n";
open(FILE, ">lib/verilog/$name.v") || die "Can not open: $!";
print FILE $file_v;
print FILE $h.$file_v;
close(FILE) || die "Error closing file: $!";
# Write Top module file
if($gen_top){
my $l=autogen_warning().get_license_header("${name}_top.v");
my $l=autogen_warning().get_license_header("${name}_top.v")."\n`timescale 1ns / 1ps\n";
open(FILE, ">lib/verilog/${name}_top.v") || die "Can not open: $!";
print FILE "$l\n$top_v";
close(FILE) || die "Error closing file: $!";
1034,7 → 1125,7
my $soc=shift;
my $window = def_popwin_size(1200,500,"Wishbone slave port address setting");
my $window = def_popwin_size(80,50,"Wishbone slave port address setting",'percent');
my $table = def_table(10, 6, FALSE);
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
1335,7 → 1426,7
#############
 
sub load_soc{
my ($soc,$info)=@_;
my ($soc,$info,$ip)=@_;
my $file;
my $dialog = Gtk2::FileChooserDialog->new(
'Select a File', undef,
1363,38 → 1454,133
return;
}
clone_obj($soc,$pp);
check_instances_version($soc,$ip);
set_gui_status($soc,"load_file",0);
}
}
$dialog->destroy;
 
 
 
 
}
 
 
sub check_instances_version{
my ($soc,$ip)=@_;
 
#check if the IP's version didnt increases
my @all_instances=$soc->soc_get_all_instances();
foreach my $instance_id (@all_instances){
my ($old_v,$new_v)= get_old_new_ip_version ($soc,$ip,$instance_id);
my $differences='';
$differences="$differences \t The $instance_id version (V.$old_v) missmatches with the one exsiting in the library (V.$new_v).\n " if($old_v != $new_v);
message_dialog("Warning: The generated system may not work correctly: \n $differences Please remove and then add the aforementioned instance(s) to update them with current version(s)") if(length($differences)>1);
 
}
 
 
}
 
sub get_old_new_ip_version{
my ($soc,$ip,$instance_id)=@_;
my $old_v=$soc->object_get_attribute($instance_id,"version",undef);
$old_v=0 if(!defined $old_v);
my $module=$soc->soc_get_module($instance_id);
my $category=$soc->soc_get_category($instance_id);
my $new_v=$ip->ip_get($category,$module,"version");
$new_v=0 if(!defined $new_v);
return ($old_v,$new_v);
}
 
 
 
 
sub get_ram_init{
my $soc=shift;
my $window = def_popwin_size(80,50,"Memory initial file setting setting",'percent');
my $table = def_table(10, 6, FALSE);
my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
$scrolled_win->set_policy( "automatic", "automatic" );
$scrolled_win->add_with_viewport($table);
my $row=0;
my $col=0;
my @instances=$soc->soc_get_all_instances();
foreach my $id (@instances){
my $category = $soc->soc_get_category($id);
if ($category eq 'RAM') {
my $ram_name= $soc->soc_get_instance_name($id);
$table->attach (gen_label_in_left("$ram_name"),$col,$col+1, $row, $row+1,'fill','shrink',2,2);$col++;
my $init_type=gen_combobox_object ($soc,'RAM_INIT','type',"Dont_Care,Fill_0,Fill_1,Search_in_sw,Fixed_file","Search_in_sw",undef);
my $init_inf= "Define how the memory must be initialized :
Dont_Care: The memory wont be initialized
Fill_0: All memory bits will fill with value zero
Fill_1: All memory bits will fill with value one
Search_in_sw: Each instance of this processing core
use different initial file that is
located in its SW folder.
Fixed_file: All instance of this processing core
use the same initial file";
$row++;
}
}
$window->add($scrolled_win);
$window->show_all;
}
 
 
sub software_edit_soc {
my $soc=shift;
my $name=$soc->object_get_attribute('soc_name');
if (length($name)==0){
message_dialog("Please define the SoC name!");
return ;
}
my $target_dir = "$ENV{'PRONOC_WORK'}/SOC/$name";
my $sw = "$target_dir/sw";
my ($app,$table,$tview) = software_main($sw);
 
 
 
my $make = def_image_button('icons/gen.png','Compile');
my $regen=def_image_button('icons/refresh.png','Regenerate main.c');
$table->attach ($regen,0, 1, 1,2,'shrink','shrink',0,0);
$table->attach ($make,9, 10, 1,2,'shrink','shrink',0,0);
$regen -> signal_connect ("clicked" => sub{
my $dialog = Gtk2::MessageDialog->new (my $window,
'destroy-with-parent',
'question', # message type
'yes-no', # which set of buttons?
"Are you sure you want to regenaret the Top.v file? Note that any changes you have made will be lost");
my $response = $dialog->run;
if ($response eq 'yes') {
save_file ("$sw/main.c",main_c_template($name));
$app->load_source("$sw/main.c");
}
 
 
});
 
$make -> signal_connect("clicked" => sub{
$app->do_save();
run_make_file($sw,$tview);
 
});
 
}
 
 
 
 
############
# main
############
1429,7 → 1615,11
my $device_win=show_active_dev($soc,$ip,$infc,\$refresh_dev_win,$info);
my $generate = def_image_button('icons/gen.png','Generate');
my $generate = def_image_button('icons/gen.png','Generate RTL');
my $compile = def_image_button('icons/gate.jpg','Compile RTL');
my $software = def_image_button('icons/binary.png','Software');
my $diagram = def_image_button('icons/diagram.png','Diagram');
my $ram = def_image_button('icons/RAM.png','Memory');
 
 
1436,7 → 1626,7
 
 
my $wb = def_image_button('icons/setting.png','Wishbone address setting');
my $wb = def_image_button('icons/setting.png','Wishbone-bus addr');
1448,18 → 1638,38
#$table->attach_defaults ($event_box, $col, $col+1, $row, $row+1);
$main_table->attach_defaults ($tree_box , 0, 2, 0, 17);
$main_table->attach_defaults ($device_win , 2, 12, 0, 17);
$main_table->attach_defaults ($infobox , 0, 12, 17,19);
$main_table->attach ($open,0, 3, 19,20,'expand','shrink',2,2);
$main_table->attach_defaults ($entrybox,3, 7, 19,20);
$main_table->attach ($wb, 7, 10, 19,20,'expand','shrink',2,2);
$main_table->attach ($generate, 10, 12, 19,20,'expand','shrink',2,2);
 
 
 
 
#$main_table->attach_defaults ($tree_box , 0, 2, 0, 17);
#$main_table->attach_defaults ($device_win , 2, 12, 0, 17);
#$main_table->attach_defaults ($infobox , 0, 12, 17,19);
 
 
my $h1=gen_hpaned($tree_box,.15,$device_win);
my $v2=gen_vpaned($h1,.55,$infobox);
$main_table->attach_defaults ($v2 , 0, 12, 0,19);
 
 
 
 
$main_table->attach ($open,0, 2, 19,20,'expand','shrink',2,2);
$main_table->attach_defaults ($entrybox,2, 4, 19,20);
$main_table->attach ($wb, 4,6, 19,20,'expand','shrink',2,2);
$main_table->attach ($diagram, 6, 7, 19,20,'expand','shrink',2,2);
$main_table->attach ($generate, 7, 8, 19,20,'expand','shrink',2,2);
$main_table->attach ($software, 8, 9, 19,20,'expand','shrink',2,2);
#$main_table->attach ($ram, 9, 10, 19,20,'expand','shrink',2,2);
$main_table->attach ($compile, 10, 12, 19,20,'expand','shrink',2,2);
 
$diagram-> signal_connect("clicked" => sub{
show_tile_diagram ($soc);
});
$generate-> signal_connect("clicked" => sub{
my $name=$soc->object_get_attribute('soc_name');
1474,8 → 1684,9
message_dialog("The soc name must not end with '_number'!");
return ;
}
if ( $name =~ /\W+/ ){
message_dialog('The soc name must not contain any non-word character:("./\()\':,.;<>~!@#$%^&*|+=[]{}`~?-")!")');
my $error = check_verilog_identifier_syntax($name);
if ( defined $error ){
message_dialog("The \"$name\" is given with an unacceptable formatting. This name will be used as top level verilog module name so it must follow Verilog identifier declaration formatting:\n $error");
return ;
}
 
1485,11 → 1696,52
$soc->object_add_attribute('global_param','CORE_ID',0);
generate_soc($soc,$info,$target_dir,$hw_dir,$sw_path,1,1);
message_dialog("SoC \"$name\" has been created successfully at $target_dir/ " );
exec($^X, $0, @ARGV);# reset ProNoC to apply changes
#message_dialog("SoC \"$name\" has been created successfully at $target_dir/ " );
my $dialog = Gtk2::MessageDialog->new (my $window,
'destroy-with-parent',
'question', # message type
'yes-no', # which set of buttons?
"Processing Tile \"$name\" has been created successfully at $target_dir/. In order to see this tile in MPSoC Generator you need to restar the ProNoC. Do you ant to reset the ProNoC now?");
my $response = $dialog->run;
if ($response eq 'yes') {
exec($^X, $0, @ARGV);# reset ProNoC to apply changes
}
$dialog->destroy;
 
 
 
});
 
$software -> signal_connect("clicked" => sub{
software_edit_soc($soc);
 
});
 
$ram-> signal_connect("clicked" => sub{
get_ram_init($soc);
 
});
 
 
$compile -> signal_connect("clicked" => sub{
my $name=$soc->object_get_attribute('soc_name');
if (length($name)==0){
message_dialog("Please define the SoC name!");
return ;
}
my $target_dir = "$ENV{'PRONOC_WORK'}/SOC/$name";
my $top = "$target_dir/src_verilog/${name}_top.v";
if (-f $top){
select_compiler($soc,$name,$top,$target_dir);
} else {
message_dialog("Cannot find $top file. Please run RTL Generator first!");
return;
}
});
 
$wb-> signal_connect("clicked" => sub{
wb_address_setting($soc);
1496,7 → 1748,7
});
 
$open-> signal_connect("clicked" => sub{
load_soc($soc,$info);
load_soc($soc,$info,$ip);
});
 
1514,6 → 1766,14
$timeout--;
set_gui_status($soc,$state,$timeout);
}elsif ($state eq 'save_project'){
# Write object file
my $name=$soc->object_get_attribute('soc_name',undef);
open(FILE, ">lib/soc/$name.SOC") || die "Can not open: $!";
print FILE perl_file_header("$name.SOC");
print FILE Data::Dumper->Dump([\%$soc],['soc']);
close(FILE) || die "Error closing file: $!";
set_gui_status($soc,"ideal",0);
}
elsif( $state ne "ideal" ){
$refresh_dev_win->clicked;
1532,3 → 1792,9
 
}
 
 
 
 
 
 
/software_editor.pl
0,0 → 1,764
#!/usr/bin/perl
 
use strict;
use warnings;
 
use Glib qw(TRUE FALSE);
use Gtk2 '-init';
use Gtk2::SourceView2;
use Data::Dumper;
 
 
use base 'Class::Accessor::Fast';
require "widget.pl";
 
 
__PACKAGE__->mk_accessors(qw{
window
sourceview
buffer
filename
search_regexp
search_case
search_entry
regexp
highlighted
});
 
my $NAME = 'Otec';
 
 
exit main() unless caller;
 
 
sub software_main {
my ($sw,$file) = @_;
 
 
my $app = __PACKAGE__->new();
my ($table,$tview,$window)=$app->build_gui($sw);
my $main_c=(defined $file)? "$sw/$file" : "$sw/main.c";
$app->load_source($main_c) if (-f $main_c );
 
#Gtk2->main();
 
return ($app,$table,$tview,$window);
}
 
 
sub build_gui {
my ($self,$sw) = @_;
 
my $window = def_popwin_size (75,75,'Source Editore','percent');
my $table= def_table(2,10,FALSE);
 
 
 
my $hpaned = Gtk2::HPaned -> new;
my $vpaned = Gtk2::VPaned -> new;
$table->attach_defaults ($vpaned,0, 10, 0,1);
#my $make = def_image_button('icons/run.png','Compile');
#$table->attach ($make,9, 10, 1,2,'shrink','shrink',0,0);
#$make -> signal_connect("clicked" => sub{
#$self->do_save();
#run_make_file($sw,$tview);
 
#});
 
$window -> add ( $table);
 
my($width,$hight)=max_win_size();
my $scwin_dirs = Gtk2::ScrolledWindow -> new;
$scwin_dirs -> set_policy ('automatic', 'automatic');
$hpaned -> pack1 ($scwin_dirs, TRUE, TRUE);
$hpaned ->set_position ($width*.15);
 
my $scwin_text = Gtk2::ScrolledWindow -> new;
$scwin_text -> set_policy ('automatic', 'automatic');
$hpaned -> pack2 ($scwin_text, TRUE, TRUE);
 
my ($scwin_info,$tview)= create_text();
add_colored_tag($tview,'red');
add_colored_tag($tview,'blue');
$vpaned-> pack1 ($hpaned, TRUE, TRUE);
$vpaned ->set_position ($hight*.5);
$vpaned-> pack2 ($scwin_info, TRUE, TRUE);
 
 
 
 
# Directory name, full path
my $tree_store = Gtk2::TreeStore->new('Glib::String', 'Glib::String');
my $tree_view = Gtk2::TreeView->new($tree_store);
my $column = Gtk2::TreeViewColumn->new_with_attributes('', Gtk2::CellRendererText->new(), text => "0");
$tree_view->append_column($column);
$tree_view->set_headers_visible(FALSE);
$tree_view->signal_connect (button_release_event => sub{
my $tree_model = $tree_view->get_model();
my $selection = $tree_view->get_selection();
my $iter = $selection->get_selected();
if(defined $iter){
my $path = $tree_model->get($iter, 1) ;
$path= substr $path, 0, -1;
$self->load_source($path) if(-f $path);
}
return;
});
 
 
$tree_view->signal_connect ('row-expanded' => sub {
my ($tree_view, $iter, $tree_path) = @_;
my $tree_model = $tree_view->get_model();
my ($dir, $path) = $tree_model->get($iter);
 
# for each of $iter's children add any subdirectories
my $child = $tree_model->iter_children ($iter);
while ($child) {
my ($dir, $path) = $tree_model->get($child, 0, 1);
add_to_tree($tree_view,$tree_store, $child, $dir, $path);
$child = $tree_model->iter_next ($child);
}
return;
});
 
 
$scwin_dirs -> add($tree_view);
 
 
 
my $child = $tree_store->append(undef);
$tree_store->set($child, 0, $sw, 1, '/');
add_to_tree($tree_view,$tree_store, $child, '/', "$sw/");
#print "$sw/\n";
 
#my $window = Gtk2::Window->new();
#$window->set_size_request(480, 360);
#$window->set_title($NAME);
$self->window($window);
 
my $vbox = Gtk2::VBox->new(FALSE, 0);
$scwin_text->add_with_viewport($vbox);
 
$vbox->pack_start($self->build_menu, FALSE, FALSE, 0);
$vbox->pack_start($self->build_search_box, FALSE, FALSE, 0);
 
my $scroll = Gtk2::ScrolledWindow->new();
$scroll->set_policy('automatic', 'automatic');
$scroll->set_shadow_type('in');
$vbox->pack_start($scroll, TRUE, TRUE, 0);
 
my $buffer = $self->create_buffer();
my $sourceview = Gtk2::SourceView2::View->new_with_buffer($buffer);
$sourceview->set_show_line_numbers(TRUE);
$sourceview->set_tab_width(2);
$sourceview->set_indent_on_tab(TRUE);
$sourceview->set_highlight_current_line(TRUE);
# $sourceview->set_draw_spaces(['tab', 'newline']);
 
#
# Fix Gtk2::TextView's annoying paste behaviour when pasting with the mouse
# (middle button click). By default gtk will scroll the text view to the
# original place where the cursor is.
#
$sourceview->signal_connect(button_press_event => sub {
my ($view, $event) = @_;
 
# We're only interested on middle mouse clicks (mouse-paste)
return FALSE unless $event->button == 2;
 
# Remember the position of the paste
my (@coords) = $sourceview->window_to_buffer_coords('text', $event->x, $event->y);
my ($iter) = $sourceview->get_iter_at_position(@coords);
$self->{paste_mark} = $buffer->create_mark('paste', $iter, FALSE);
 
return FALSE;
});
 
 
#
# If a paste is done through the middle click then place the cursor at the end
# of the pasted text.
#
$buffer->signal_connect('paste-done' => sub {
my $mark = delete $self->{paste_mark} or return;
 
my $iter = $buffer->get_iter_at_mark($mark);
$buffer->place_cursor($iter);
 
$self->sourceview->scroll_to_mark(
$mark,
0.0,
FALSE,
0.0, 0.5
);
$buffer->delete_mark($mark);
});
 
 
$scroll->add($sourceview);
$self->sourceview($sourceview);
$self->buffer($sourceview->get_buffer);
 
$window->signal_connect(delete_event => sub {
Gtk2->main_quit();
return TRUE;
});
 
$window->show_all();
return ($table,$tview,$window);
}
 
 
sub build_search_box {
my $self = shift;
 
# Elements of the search box
my $hbox = Gtk2::HBox->new(FALSE, 0);
 
my $search_entry = Gtk2::Entry->new();
$search_entry->signal_connect(activate => sub {$self->do_search()});
$search_entry->signal_connect(icon_release => sub {$self->do_search()});
$self->search_entry($search_entry);
 
my $search_regexp = Gtk2::CheckButton->new('RegExp');
$search_regexp->signal_connect(toggled => sub {
$self->search_regexp($search_regexp->get_active);
});
 
my $search_case = Gtk2::CheckButton->new('Case');
$search_case->signal_connect(toggled => sub {
$self->search_case($search_case->get_active);
});
 
my $search_icon = Gtk2::Button->new_from_stock('gtk-find');
$search_entry->set_icon_from_stock(primary => 'gtk-find');
 
$hbox->pack_start($search_entry, TRUE, TRUE , 0);
$hbox->pack_start($search_regexp, FALSE, FALSE, 0);
$hbox->pack_start($search_case, FALSE, FALSE, 0);
 
return $hbox;
}
 
 
sub create_buffer {
my $self = shift;
my $tags = Gtk2::TextTagTable->new();
 
add_tag($tags, search => {
background => 'yellow',
});
add_tag($tags, goto_line => {
'paragraph-background' => 'orange',
});
 
my $buffer = Gtk2::SourceView2::Buffer->new($tags);
$buffer->signal_connect('notify::cursor-position' => sub {
$self->clear_highlighted();
});
 
return $buffer;
}
 
 
sub add_tag {
my ($tags, $name, $properties) = @_;
 
my $tag = Gtk2::TextTag->new($name);
$tag->set(%{ $properties });
$tags->add($tag);
}
 
 
sub detect_language {
my $self = shift;
my ($filename) = @_;
 
# Guess the programming language of the file
my $manager = Gtk2::SourceView2::LanguageManager->get_default;
my $language = $manager->guess_language($filename);
$self->buffer->set_language($language);
}
 
 
sub load_source {
my $self = shift;
my ($filename) = @_;
my $buffer = $self->buffer;
 
# Guess the programming language of the file
$self->detect_language($filename);
 
# Loading a file should not be undoable.
my $content;
do {
open my $handle, $filename or die "Can't read file $filename because $!";
local $/;
$content = <$handle>;
close $handle;
};
$buffer->begin_not_undoable_action();
$buffer->set_text($content);
$buffer->end_not_undoable_action();
 
$buffer->set_modified(FALSE);
$buffer->place_cursor($buffer->get_start_iter);
 
$self->filename($filename);
$self->window->set_title("$filename - $NAME");
}
 
 
sub clear_highlighted {
my $self = shift;
 
my $highlighted = delete $self->{highlighted} or return;
 
my $buffer = $self->buffer;
 
my @iters;
foreach my $mark (@{ $highlighted->{marks} }) {
my $iter = $buffer->get_iter_at_mark($mark);
push @iters, $iter;
$buffer->delete_mark($mark);
}
 
$buffer->remove_tag_by_name($highlighted->{name}, @iters);
}
 
 
sub get_text {
my $self = shift;
my $buffer = $self->buffer;
return $buffer->get_text($buffer->get_start_iter, $buffer->get_end_iter, FALSE);
}
 
 
sub do_search {
my $self = shift;
my $criteria = $self->search_entry->get_text;
if ($criteria eq '') {return;}
 
my $case = $self->search_case;
my $buffer = $self->buffer;
 
 
# Start the search at the last search result or from the current cursor's
# position. As a fall back we also add the beginning of the document. Once we
# have the start position we can erase the previous search results.
my @start;
if (my $highlighted = $self->highlighted) {
# Search from the last match
push @start, $buffer->get_iter_at_mark($highlighted->{marks}[1]);
$self->clear_highlighted();
}
else {
# Search from the cursor
push @start, $buffer->get_iter_at_offset(
$buffer->get_property('cursor-position')
);
}
push @start, $buffer->get_start_iter;
 
my @iters;
if ($self->search_regexp) {
# Gtk2::SourceView2 nor Gtk2::SourceView support regular expressions so we
# have to do the search by hand!
 
my $text = $self->get_text;
my $regexp = $case ? qr/$criteria/m : qr/$criteria/im;
 
foreach my $iter (@start) {
# Tell Perl where to start the regexp lookup
pos($text) = $iter->get_offset;
 
if ($text =~ /($regexp)/g) {
my $word = $1;
my $pos = pos($text);
@iters = (
$buffer->get_iter_at_offset($pos - length($word)),
$buffer->get_iter_at_offset($pos),
);
last;
}
}
}
else {
# Use the builtin search mechanism
my $flags = $case ? [ ] : [ 'case-insensitive' ];
foreach my $iter (@start) {
@iters = Gtk2::SourceView2::Iter->forward_search($iter, $criteria, $flags);
last if @iters;
}
}
 
$self->show_highlighted(search => @iters) if @iters;
}
 
 
sub show_highlighted {
my $self = shift;
my ($tag_name, $start, $end) = @_;
my $buffer = $self->buffer;
 
# Highlight the region, remember it and scroll to it
my $match_start = $buffer->create_mark('match-start', $start, TRUE);
my $match_end = $buffer->create_mark('match-end', $end, FALSE);
 
$buffer->apply_tag_by_name($tag_name, $start, $end);
 
# We have a callback that listens to when the cursor is placed and we don't
# want it to undo our work! So let's unhighlight the previous entry.
delete $self->{highlighted};
$buffer->place_cursor($end);
 
$self->sourceview->scroll_to_mark(
$match_start,
0.2,
FALSE,
0.0, 0.5
);
 
# Keep a reference to the markers once they have been added to the buffer.
# Using them before can be catastrophic (segmenation fault).
#
$self->highlighted({
name => $tag_name,
marks => [$match_start, $match_end],
});
}
 
 
sub do_file_new {
my $self = shift;
my $buffer = $self->buffer;
 
# Set no language
$buffer->set_language(undef);
 
# Showing a blank editor should not be undoable.
$buffer->begin_not_undoable_action();
$buffer->set_text('');
$buffer->end_not_undoable_action();
 
$buffer->set_modified(FALSE);
$buffer->place_cursor($buffer->get_start_iter);
 
$self->filename('');
$self->window->set_title("Untitled - $NAME");
}
 
 
sub do_file_open {
my $self = shift;
my ($window, $action, $menu_item) = @_;
 
my $dialog = Gtk2::FileSelection->new("Open file...");
$dialog->signal_connect(response => sub {
my ($dialog, $response) = @_;
 
if ($response eq 'ok') {
my $file = $dialog->get_filename;
return if -d $file;
$self->load_source($file);
}
 
$dialog->destroy();
});
$dialog->show();
}
 
 
sub do_show_about_dialog {
my $self = shift;
 
my $dialog = Gtk2::AboutDialog->new();
$dialog->set_authors("Emmanuel Rodriguez");
$dialog->set_comments("Gtk2::SourceView2 Demo");
$dialog->signal_connect(response => sub {
my ($dialog, $response) = @_;
$dialog->destroy();
});
$dialog->show();
}
 
 
sub do_ask_goto_line {
my $self = shift;
 
my $dialog = Gtk2::Dialog->new_with_buttons(
"Goto to line",
$self->window,
[ 'modal' ],
'gtk-cancel' => 'cancel',
'gtk-ok' => 'ok',
);
 
my $hbox = Gtk2::HBox->new(FALSE, 0);
$hbox->pack_start(
Gtk2::Label->new("Line number: "),
FALSE, FALSE, 0
);
my $entry = Gtk2::Entry->new();
$hbox->pack_start($entry, TRUE, TRUE, 0);
 
$dialog->get_content_area->add($hbox);
$dialog->show_all();
 
 
# Signal handlers
$entry->signal_connect(activate => sub {
if ($entry->get_text =~ /(\d+)/) {
$dialog->response('ok');
}
});
 
# Run the dialog
my $response = $dialog->run();
$dialog->destroy();
return unless $response eq 'ok';
 
return unless my ($line) = ($entry->get_text =~ /(\d+)/);
my $buffer = $self->buffer;
my $start = $buffer->get_iter_at_line($line - 1);
my $end = $start->copy;
$end->forward_to_line_end;
 
$self->clear_highlighted();
$self->show_highlighted(goto_line => $start, $end);
}
 
 
sub do_quit {
my $self = shift;
Gtk2->main_quit();
}
 
 
sub do_save_as {
my $self = shift;
 
# If no file is associated with the editor then ask the user for a file where
# to save the contents of the buffer.
my $dialog = Gtk2::FileChooserDialog->new(
"Save file", $self->window, 'save',
'gtk-cancel' => 'cancel',
'gtk-save' => 'ok',
);
 
my $response = $dialog->run();
if ($response eq 'ok') {
$self->filename($dialog->get_filename);
$self->do_save();
}
$dialog->destroy();
}
 
 
sub do_save {
my $self = shift;
 
my $filename = $self->filename;
 
# If there's no file then do a save as...
if (! $filename) {
$self->do_save_as();
return;
}
 
my $buffer = $self->buffer;
open my $handle, '>:encoding(UTF-8)', $filename or die "Can't write to $filename: $!";
print $handle $self->get_text;
close $handle;
 
if (! $buffer->get_language) {
$self->detect_language($filename);
}
}
 
 
sub build_menu {
my $self = shift;
 
my $entries = [
# name, stock id, label
[ "FileMenu", undef, "_File" ],
[ "SearchMenu", undef, "_Search" ],
[ "HelpMenu", undef, "_Help" ],
 
# name, stock id, label, accelerator, tooltip, method
[
"New",
'gtk-new',
"_New",
"<control>N",
"Create a new file",
sub { $self->do_file_new(@_) }
],
[
"Open",
'gtk-open',
"_Open",
"<control>O",
"Open a file",
sub { $self->do_file_open(@_) }
],
[
"Save",
'gtk-save',
"_Save",
"<control>S",
"Save current file",
sub { $self->do_save(@_) }
],
[
"SaveAs",
'gtk-save',
"Save _As...",
"<control><shift>S",
"Save to a file",
sub { $self->do_save_as(@_) }
],
[
"Quit",
'gtk-quit',
"_Quit",
"<control>Q",
"Quit",
sub { $self->do_quit() }
],
[
"About",
'gtk-about',
"_About",
undef,
"About",
sub { $self->do_show_about_dialog(@_) }
],
[
"GotoLine",
undef,
"Goto to _Line",
"<control>L",
"Go to line",
sub { $self->do_ask_goto_line(@_) }
],
];
 
my $actions = Gtk2::ActionGroup->new("Actions");
$actions->add_actions($entries, undef);
 
my $ui = Gtk2::UIManager->new();
$ui->insert_action_group($actions, 0);
$ui->add_ui_from_string(<<'__UI__');
<ui>
<menubar name='MenuBar'>
<menu action='FileMenu'>
<menuitem action='New'/>
<menuitem action='Open'/>
<separator/>
<menuitem action='Save'/>
<menuitem action='SaveAs'/>
<separator/>
<menuitem action='Quit'/>
</menu>
<menu action='SearchMenu'>
<menuitem action='GotoLine'/>
</menu>
<menu action='HelpMenu'>
<menuitem action='About'/>
</menu>
</menubar>
</ui>
__UI__
 
$self->window->add_accel_group($ui->get_accel_group);
 
return $ui->get_widget('/MenuBar');
}
 
 
 
sub add_to_tree {
my ($tree_view,$tree_store, $parent, $dir, $path) = @_;
my $tree_model = $tree_view->get_model();
 
# If $parent already has children, then remove them first
my $child = $tree_model->iter_children ($parent);
while ($child) {
$tree_store->remove ($child);
$child = $tree_model->iter_children ($parent);
}
 
# Add children from directory listing
opendir(DIRHANDLE, $path) || return ; #die "Cannot open directory:$path $!\n";
foreach my $subdir (sort readdir(DIRHANDLE)) {
if ($subdir ne '.' and $subdir ne '..'
# and -d $path.$subdir and -r $path.$subdir
) {
my $child = $tree_store->append($parent);
$tree_store->set($child, 0, $subdir, 1, "$path$subdir/");
}
}
closedir(DIRHANDLE);
}
 
 
# Directory expanded. Populate subdirectories in readiness.
 
sub populate_tree {
 
# $iter has been expanded
my ($tree_view,$tree_store, $iter, $tree_path) = @_;
my $tree_model = $tree_view->get_model();
my ($dir, $path) = $tree_model->get($iter);
 
# for each of $iter's children add any subdirectories
my $child = $tree_model->iter_children ($iter);
while ($child) {
my ($dir, $path) = $tree_model->get($child, 0, 1);
add_to_tree($tree_view,$tree_store, $child, $dir, $path);
$child = $tree_model->iter_next ($child);
}
return;
}
 
 
sub run_make_file {
my ($dir,$outtext)=@_;
my $cmd = "cd \"$dir/\" \n make ";
my $error=0;
show_info(\$outtext,"$cmd\n");
my ($stdout,$exit,$stderr)=run_cmd_in_back_ground_get_stdout( $cmd);
 
if($stderr){
$stderr=~ s/[‘,’]//g;
add_info(\$outtext,"$stdout\n");
add_colored_info(\$outtext,"$stderr\n","red");
add_colored_info(\$outtext,"Compilation failed.\n",'red');
 
}else{
 
add_info(\$outtext,"$stdout\n");
add_colored_info(\$outtext,"Compilation finished successfully.\n",'blue');
}
#add_info(\$outtext,"**********Quartus compilation is done successfully in $target_dir!*************\n") if($error==0);
 
 
 
}
 
 
 
 
1;
 
/verilog_gen.pl
19,7 → 19,7
#####################
 
sub soc_generate_verilog{
my ($soc)= @_;
my ($soc,$sw_path)= @_;
my $soc_name=$soc->object_get_attribute('soc_name');
#my $top_ip=ip_gen->ip_gen_new();
my $top_ip=ip_gen->top_gen_new();
29,12 → 29,13
my $io_sim_v;
my $core_id= $soc->object_get_attribute('global_param','CORE_ID');
$core_id= 0 if(!defined $core_id);
my $param_as_in_v="\tparameter\tCORE_ID=$core_id";
my $param_as_in_v="\tparameter\tCORE_ID=$core_id,
\tparameter\tSW_LOC=\"$sw_path\"";
 
 
 
 
my $param_pass_v="\t.CORE_ID(CORE_ID)";
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);
84,7 → 85,7
add_text_to_string(\$soc_v,"endmodule\n\n");
$soc->soc_add_top($top_ip);
$soc->object_add_attribute('top_ip',undef,$top_ip);
#print @assigned_wires;
 
#generate topmodule
91,7 → 92,7
my $top_v = (defined $param_as_in_v )? "module ${soc_name}_top #(\n $param_as_in_v\n)(\n$io_sim_v\n);\n": "module ${soc_name}_top (\n $io_sim_v\n);\n";
my $ins= gen_soc_instance_v($soc,$soc_name,$param_pass_v);
 
add_text_to_string(\$top_v,$functions_all);
add_text_to_string(\$top_v,$local_param_v_all."\n".$io_full_v_all);
add_text_to_string(\$top_v,$ins);
my ($readme,$prog)=gen_system_info($soc,$param_as_in_v);
728,12 → 729,12
$v= $soc->object_get_attribute('global_param',$JTAG_INDEX);
$JTAG_INDEX = $v if (defined $v);
my $BINFILE=$soc->soc_get_module_param_value($instance_id,'INIT_FILE_NAME');
my $BINFILE=$soc->soc_get_module_param_value($instance_id,'JTAG_MEM_FILE');
($BINFILE)=$BINFILE=~ /"([^"]*)"/ if(defined $BINFILE);
$BINFILE=(defined $BINFILE) ? $BINFILE.'.bin' : 'ram0.bin';
my $OFSSET="0x00000000";
my $end=((1<<$aw)*($dw/8))-1;
my $end=((1 << $aw)*($dw/8))-1;
my $BOUNDRY=sprintf("0x%08x", $end);
if($jtag_connect =~ /JTAG_WB/){
$prog= "$prog \$JTAG_MAIN -n $JTAG_INDEX -s \"$OFSSET\" -e \"$BOUNDRY\" -i \"$BINFILE\" -c";
/widget.pl
286,7 → 286,7
}
 
sub def_image{
sub def_icon{
my $image_file=shift;
my $font_size=get_defualt_font_size();
my $size=($font_size==10)? 25:
302,18 → 302,35
}
 
 
sub open_image{
my ($image_file,$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 = Gtk2::Gdk::Pixbuf->new_from_file_at_scale($image_file,$x,$y,TRUE);
my $image = Gtk2::Image->new_from_pixbuf($pixbuf);
return $image;
 
}
 
 
 
sub def_image_button{
my ($image_file, $label_text, $homogeneous)=@_;
# create box for image and label
$homogeneous = FALSE if(!defined $homogeneous);
my $box = def_hbox($homogeneous,0);
my $image = def_image($image_file);
my $image = def_icon($image_file) if(-f $image_file);
# now on to the image stuff
#my $image = Gtk2::Image->new_from_file($image_file);
$box->pack_start($image, FALSE, FALSE, 0);
$box->pack_start($image, FALSE, FALSE, 0) if(-f $image_file);
$box->set_border_width(0);
$box->set_spacing (0);
# Create a label for the button
337,7 → 354,7
# create box for image and label
my $box = def_hbox(FALSE,1);
# now on to the image stuff
my $image = def_image($image_file);
my $image = def_icon($image_file);
$box->pack_start($image, TRUE, FALSE, 0);
# Create a label for the button
if(defined $label_text ) {
454,13 → 471,14
############
 
sub message_dialog {
my @message=@_;
my ($message,$type)=@_;
$type = 'info' if (!defined $type);
my $window;
my $dialog = Gtk2::MessageDialog->new ($window,
[qw/modal destroy-with-parent/],
'info',
$type,
'ok',
@message);
$message);
$dialog->run;
$dialog->destroy;
500,12 → 518,18
 
 
sub def_popwin_size {
my $x=shift;
my $y=shift;
my @titel=shift;
my ($x,$y,$titel,$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 $window = Gtk2::Window->new('popup');
my $window = Gtk2::Window->new('toplevel');
$window->set_title(@titel);
$window->set_title($titel);
$window->set_position("center");
$window->set_default_size($x, $y);
$window->set_border_width(20);
549,7 → 573,7
#print "($width,$hight)\n";
my $font_size=($width>=1600)? 10:
($width>=1400)? 9:
($width>=1200)? 8:
($width>=1200)? 9:
($width>=1000)? 7:6;
#print "$font_size\n";
return $font_size;
597,8 → 621,49
 
}
 
sub def_pack_vbox{
my( $homogeneous, $spacing , @box_list)=@_;
my $box=def_vbox($homogeneous, $spacing);
foreach my $subbox (@box_list){
$box->pack_start( $subbox, FALSE, FALSE, 3);
}
return $box;
 
}
 
 
##########
# Paned
#########
 
 
sub gen_vpaned {
my ($w1,$loc,$w2) = @_;
my $vpaned = Gtk2::VPaned -> new;
my($width,$hight)=max_win_size();
 
$vpaned -> pack1($w1, TRUE, TRUE);
$vpaned -> set_position ($hight*$loc);
$vpaned -> pack2($w2, TRUE, TRUE);
return $vpaned;
}
 
 
sub gen_hpaned {
my ($w1,$loc,$w2) = @_;
my $hpaned = Gtk2::HPaned -> new;
my($width,$hight)=max_win_size();
 
$hpaned -> pack1($w1, TRUE, TRUE);
$hpaned -> set_position ($width*$loc);
$hpaned -> pack2($w2, TRUE, TRUE);
return $hpaned;
}
 
#############
# text_view
############
688,14 → 753,38
}
 
sub show_colored_info{
my ($textview_ref,$info,$color)=@_;
my $buffer = $$textview_ref->get_buffer();
#$buffer->set_text($info);
my $textiter = $buffer->get_start_iter();
$buffer->insert_with_tags_by_name ($textiter, "$info", "${color}_tag");
}
 
sub add_colored_info{
my ($textview_ref,$info,$color)=@_;
my $buffer = $$textview_ref->get_buffer();
my $textiter = $buffer->get_end_iter();
#Insert some text into the buffer
#$buffer->insert($textiter,$info);
$buffer->insert_with_tags_by_name ($textiter, "$info", "${color}_tag");
}
 
sub add_colored_tag{
my ($textview_ref,$color)=@_;
my $buffer = $textview_ref->get_buffer();
$buffer->create_tag ("${color}_tag", foreground => $color);
}
 
 
####################
# read verilog file
# file
##################
 
 
sub read_file{
sub read_verilog_file{
my @files = @_;
my %cmd_line_defines = ();
my $quiet = 1;
718,19 → 807,131
 
sub add_color_to_gd{
foreach (my $i=0;$i<32;$i++ ) {
my ($red,$green,$blue)=get_color($i);
my ($red,$green,$blue)=get_color($i);
add_colour("my_color$i"=>[$red>>8,$green>>8,$blue>>8]);
add_colour("my_color$i"=>[$red>>8,$green>>8,$blue>>8]);
}
}
 
 
 
sub append_text_to_file {
my ($file_path,$text)=@_;
open(my $fd, ">>$file_path");
print $fd $text;
close $fd;
}
 
 
 
 
sub save_file {
my ($file_path,$text)=@_;
open(my $fd, ">$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 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;
780,8 → 981,51
}
 
 
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
#############
888,6 → 1132,8
sub get_file_name {
my ($object,$title,$entry,$attribute1,$attribute2,$extension,$lable,$open_in)= @_;
my $browse= def_image_button("icons/browse.png");
my $dir = Cwd::getcwd();
my $project_dir = abs_path("$dir/../../"); #mpsoc directory address
 
$browse->signal_connect("clicked"=> sub{
my $entry_ref=$_[1];
912,12 → 1158,16
}
if ( "ok" eq $dialog->run ) {
$file = $dialog->get_filename;
$file = $dialog->get_filename;
#remove $project_dir form beginig of each file
$file =~ s/$project_dir//;
$$entry_ref->set_text($file);
$object->object_add_attribute($attribute1,$attribute2,$file);
$object->object_add_attribute($attribute1,$attribute2,$file) if(defined $object);
my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
$lable->set_markup("<span foreground= 'black' ><b>$name$suffix</b></span>");
$lable->show;
if(defined $lable){
$lable->set_markup("<span foreground= 'black' ><b>$name$suffix</b></span>");
$lable->show;
}
#check_input_file($file,$socgen,$soc_state,$info);
#print "file = $file\n";
1028,8 → 1278,10
}
 
 
sub gen_check_box_object {
my ($object,$attribute1,$attribute2,$content,$value,$default,$status,$timeout)=@_;
sub gen_check_box_object_array {
my ($object,$attribute1,$attribute2,$content,$default,$status,$timeout)=@_;
my $value=$object->object_get_attribute($attribute1,$attribute2);
$value = $default if (!defined $value);
my $widget = def_hbox(FALSE,0);
my @check;
for (my $i=0;$i<$content;$i++){
1074,6 → 1326,39
 
 
 
 
 
sub gen_check_box_object {
my ($object,$attribute1,$attribute2,$default,$status,$timeout)=@_;
my $value=$object->object_get_attribute($attribute1,$attribute2);
if (!defined $value){
#set initial value
$object->object_add_attribute($attribute1,$attribute2,$default);
$value = $default
}
my $widget = Gtk2::CheckButton->new;
if($value == 1) {$widget->set_active(TRUE);}
else {$widget->set_active(FALSE);}
#get new value
$widget-> signal_connect("toggled" => sub{
my $new_val;
if($widget->get_active()) {$new_val=1;}
else {$new_val=0;}
$object->object_add_attribute($attribute1,$attribute2,$new_val);
#print "\$new_val=$new_val\n";
set_gui_status($object,$status,$timeout) if (defined $status);
});
return $widget;
 
}
 
 
 
 
 
 
sub get_dir_in_object {
my ($object,$attribute1,$attribute2,$content,$status,$timeout)=@_;
my $widget = def_hbox(FALSE,0);
1103,7 → 1388,7
$lable=gen_label_in_center($name.$suffix);
} else {
$lable=gen_label_in_center("Selecet a $extension file");
$lable=gen_label_in_center("Selecet a file");
$lable->set_markup("<span foreground= 'red' ><b>No file has been selected yet</b></span>");
}
my $entry=gen_entry();
1269,54 → 1554,7
}
 
 
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 read_file_cntent {
my ($f,$project_dir)=@_;
my $n="$project_dir$f";
my $str;
if (-f "$n") { #copy file
$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 metric_conversion{
my $size=shift;
my $size_text= $size==0 ? 'Error':
1327,4 → 1565,38
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;
}
 
 
 
 
 
1

powered by: WebSVN 2.1.0

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