Verilog-CodeGen

 view release on metacpan or  search on metacpan

scripts/gui.pl  view on Meta::CPAN

my $i=0;
my $ok=1;
my $sock = new IO::Socket::INET (LocalHost => 'localhost',
				 LocalPort => 2507,
				 Proto => 'tcp',
				 Listen => 5,
				 ReuseAddr => 1,
				 );
die "Could not connect: $!" unless $sock;
print STDERR "Done \n";

MainLoop();

exit(0);


#-------------------------------------------------------------------
sub create_ui {
    my $top = MainWindow->new('-background'=>'white','-title'=>'Perl/Verilog Coding Environment');

    # MENU STUFF

    # Menu bar
    my $menu_bar_frame = $top->Frame('-background'=>'darkgrey','-width'=>80)->pack('-side' => 'top','-anchor'=>'w', '-fill' => 'x');
my $menu_bar=$menu_bar_frame->Frame('-background'=>'grey','-relief'=>'flat','-borderwidth'=>1,'-width'=>80)->pack('-side' => 'left','-anchor'=>'w', '-fill' => 'x','padx'=>5,'pady'=>5);
#==============================================================================

# General 
    # File menu
    my $menu_file = $menu_bar->Menubutton('-text' => 'File','-tearoff'=>0,
                                          '-relief' => 'flat',
                                          '-borderwidth' => 1,'font'=>$normal,'foreground'=>'black','background'=>'grey'
                                          )->grid('-row'=>0,'-column'=>0,'-sticky'=>'w','-pady'=>5,'-padx'=>5);

    $menu_file->command('-label' => 'XEmacs', '-state'=>'active',
			'-command' => sub {$xemacs=1;system("xemacs blank &")},
			'foreground'=>'black','background'=>'grey','font'=>$normal,
);
    $menu_file->command('-label' => 'Schematics', '-state'=>'active',
			'-command' => sub {chdir "Schematics/$design";system("tkgate &"); chdir '..'},
			'foreground'=>'black','background'=>'grey','font'=>$normal,
);
    $menu_file->command('-label' => 'Diagrams', '-state'=>'active',
			'-command' => sub {chdir "Diagrams/$design";system("dia &"); chdir '..'},
			'foreground'=>'black','background'=>'grey','font'=>$normal,
);
    $menu_file->command('-label' => 'gCVS', '-state'=>'active',
			'-command' => sub {system("/usr/local/gcvs/bin/gcvs &")},
			'foreground'=>'black','background'=>'grey','font'=>$normal,
);
    $menu_file->command('-label' => 'Exit', '-command' => sub {close $sock;if($pid ne 'WRONG'){exec("kill -9 $pid")}else{exit(0)}},'foreground'=>'black','background'=>'grey','font'=>$normal,);

#==============================================================================

 $matrix[0][3] = $menu_bar->Label ('background' =>'grey')->grid('-row'=>0,'-column'=>3,'-sticky'=>'w',);

my $image=  $matrix[0][3]->Photo('-file'=>'GUI/rectangle_power_perl.gif');
 $matrix[0][3]->configure('-image'=>$image);


my $projectframe=$menu_bar->Frame('-background'=>'grey','-relief'=>'flat','-borderwidth'=>1,'-width'=>80)->grid('-row' => 0, '-column' => 1,'-columnspan'=>2,'-sticky'=>'w');
my $project = $projectframe->Label ('-text'=>'Design:', '-font' => $normal, '-background' =>'grey')->pack('-side' => 'left','-anchor'=>'w', '-fill' => 'x','padx'=>1,'pady'=>1);
$matrix[0][1] = $projectframe->Entry ('-width'   =>  15, '-font' => $normal,'foreground' => 'black','background' =>'white', )->pack('-side' => 'left','-anchor'=>'w', '-fill' => 'x','padx'=>1,'pady'=>1);
my $projectbutton = $projectframe->Button('-font' => $bold,'background' =>'grey','-text' => 'Set', '-command' => \&set_design)->pack('-side' => 'left','-anchor'=>'w', 'padx'=>1,'pady'=>1);

#==============================================================================
    # Device Object Code
 $matrix[1][0] = $menu_bar->Label ('-text'=>'Device Object Code', '-width'=>80, '-font' => $bold,'foreground' => 'black', '-background' =>'lightgrey',)->grid(
'-row' => 1, '-column' => 0,'-columnspan'=>4,'-sticky'=>'w');

 $matrix[2][3] = $menu_bar->Button('-width'=> 10, '-font' => $bold,'foreground' => 'black','background' =>'grey','-text' => 'Edit', '-command' => \&show_obj)->grid(
'-row' => 2,'-column'=> 3,'-sticky'=>'w');
 $matrix[2][2] = $menu_bar->Entry ('-width'   =>  20, '-font' => $normal,'foreground' => 'black','background' =>'white', )->grid(
'-row' => 2, '-column' => 2);

 $matrix[3][3] = $menu_bar->Button('-width'=> 10, '-font' => $bold,'foreground' => 'black','background' =>'grey','-text' => 'Parse', '-command' => \&debug)->grid(
'-row' => 3,'-column'=> 3,'-sticky'=>'w');

 $matrix[3][1] = $menu_bar->Label ('-text'=>'Show result', '-font' => $bold,'foreground' => 'black','background' =>'grey','-width'=>20,'-relief'=>'flat','-borderwidth'=>1,'-anchor'=>'w')->grid(
'-row' => 3, '-column' =>1,'-sticky'=>'w');
 $matrix[3][0] = $menu_bar->Checkbutton ('-variable'   => \$showdefault,
 '-font' => $normal,'foreground' => 'black','background' =>'grey','-width'=>0)->grid(
'-row' => 3, '-column' =>0,'-sticky'=>'e');
#==============================================================================
    # Device Library Module
 $matrix[4][0] = $menu_bar->Label ('-text'=>'Device Library Module', '-width' => 80, '-font' => $bold,'foreground' => 'black','background' =>'lightgrey',)->grid(
'-row' => 4, '-column' => 0,'-columnspan'=>4,'-sticky'=>'w');

 $matrix[5][0] = $menu_bar->Button('-width'=> 10, '-font' => $bold,'foreground' => 'black','background' =>'grey','-text' => 'Update', '-command' => \&update)->grid(
'-row' => 5,'-column'=>3,'-sticky'=>'w');

 $matrix[5][1] = $menu_bar->Label ('-text'=>'Show module', '-font' => $bold,'foreground' => 'black','background' =>'grey','-width'=>20,'-relief'=>'flat','-borderwidth'=>1,'-anchor'=>'w')->grid(
'-row' => 5, '-column' =>1,'-sticky'=>'w');
 $matrix[5][3] = $menu_bar->Checkbutton ('-variable'   => \$update,
 '-font' => $normal,'foreground' => 'black','background' =>'grey','-width'=>0)->grid(
'-row' => 5, '-column' =>0,'-sticky'=>'e');

#==============================================================================
    # Testbench Code
 $matrix[6][0] = $menu_bar->Label ('-text'=>'Testbench Code', '-width' => 80, '-font' => $bold,'foreground' => 'black','background' =>'lightgrey',)->grid(
'-row' => 6, '-column' => 0,'-columnspan'=>4);
#------------------------------------------------------------------------------
 $matrix[7][3] = $menu_bar->Button('-width'=> 10, '-font' => $bold,'foreground' => 'black','background' =>'grey','-text' => 'Edit', '-command' => \&edit_tb)->grid(
'-row' => 7 ,'-column'=>3,'-sticky'=>'w');
 $matrix[7][2] = $menu_bar->Entry ('-width'   =>  20, '-font' => $normal,'foreground' => 'black','background' =>'white',)->grid(
'-row' => 7, '-column' =>2);
 $matrix[7][1] = $menu_bar->Label ('-text'=>'Overwrite', '-font' => $bold,'foreground' => 'black','background' =>'grey', '-width'=> 20, '-relief'=>'flat','-borderwidth'=>1,'-anchor'=>'w',)->grid(
'-row' => 7, '-column' =>1,'-sticky'=>'w');
 $matrix[7][0] = $menu_bar->Checkbutton ('-variable'   => \$overwrite, '-font' => $normal,'foreground' => 'black','background' =>'grey','-width' => 0)->grid(
'-row' => 7, '-column' =>0,'-sticky'=>'e');
#------------------------------------------------------------------------------
 $matrix[8][3] = $menu_bar->Button('-width'=> 10, '-font' => $bold,'foreground' => 'black','background' =>'grey','-text' => 'Parse', '-command' => \&parse_tb )->grid(
'-row' => 8 ,'-column'=>3,'-sticky'=>'w');

 $matrix[8][1] = $menu_bar->Label ('-text'=>'Show result', '-font' => $bold,'foreground' => 'black','background' =>'grey','-width'=>20,'-relief'=>'flat','-borderwidth'=>1,'-anchor'=>'w',)->grid(
'-row' => 8, '-column' =>1,'-sticky'=>'w');
 $matrix[8][0] = $menu_bar->Checkbutton ('-variable'   => \$showtb, '-font' => $normal,'foreground' => 'black','background' =>'grey','-width'=>0,)->grid(
'-row' => 8, '-column' =>0,'-sticky'=>'e');

 $matrix[9][1] = $menu_bar->Label ('-text'=>'Inspect Code', '-font' => $bold,'foreground' => 'black','background' =>'grey','-width'=>20,'-relief'=>'flat','-borderwidth'=>1,'-anchor'=>'w',)->grid(
'-row' => 9, '-column' =>1,'-sticky'=>'w');
 $matrix[9][0] = $menu_bar->Checkbutton ('-variable'   => \$inspectcode, '-font' => $normal,'foreground' => 'black','background' =>'grey','-width'=>0,)->grid(
'-row' => 9, '-column' =>0,'-sticky'=>'e');

 $matrix[10][1] = $menu_bar->Label ('-text'=>'Plot', '-font' => $bold,'foreground' => 'black','background' =>'grey','-width'=>20,'-relief'=>'flat','-borderwidth'=>1,'-anchor'=>'w',)->grid(
'-row' => 11, '-column' =>1,'-sticky'=>'w');
 $matrix[10][0] = $menu_bar->Checkbutton ('-variable'   => \$plot, '-font' => $normal,'foreground' => 'black','background' =>'grey','-width'=>0,)->grid(
'-row' => 11, '-column' =>0,'-sticky'=>'e');

 $matrix[11][1] = $menu_bar->Label ('-text'=>'Run','-font' => $bold,'foreground' => 'black','background' =>'grey','-width'=>20,'-relief'=>'flat','-borderwidth'=>1,'-anchor'=>'w',)->grid(
'-row' => 10, '-column' =>1,'-sticky'=>'w');
 $matrix[11][0] = $menu_bar->Checkbutton ('-variable'   => \$run,'-font' => $normal,'foreground' => 'black','background' =>'grey','-width'=>0,)->grid(
'-row' => 10, '-column' =>0,'-sticky'=>'e');

#=no_warnings
# $matrix[10][1] = $menu_bar->Label ('-text'=>'No warnings', '-font' => $bold,'foreground' => 'black','background' =>'grey','-width'=>20,'-relief'=>'flat','-borderwidth'=>1,'-anchor'=>'w',)->grid(
#'-row' => 10, '-column' =>1,'-sticky'=>'w');
# $matrix[10][0] = $menu_bar->Checkbutton ('-variable'   => \$nowarn, '-font' => $normal,'foreground' => 'black','background' =>'grey','-width'=>0,)->grid(
#'-row' => 10, '-column' =>0,'-sticky'=>'e');
#=cut
#------------------------------------------------------------------------------
 $matrix[12][0] = $menu_bar->Label ('-text'=>'Output log', '-width' => 80, '-font' => $bold,'foreground' => 'black','background' =>'lightgrey',)->grid(
'-row' => 12, '-column' => 0,'-columnspan'=>4);
#==============================================================================
# Console 
my $text_frame = $top->Frame('-background'=>'black', '-width'=>80)->pack('-side' => 'top', '-fill' => 'x');
#
 $text=$text_frame->Text('-foreground' => 'grey','-background'=>'black','-height'=>25, '-width'=>80)->pack('-side' => 'left', '-fill' => 'y');
 $text->tagConfigure('console', '-font' => $console,'foreground' => 'grey','background' =>'black',); 
my $scroll=$text_frame->Scrollbar('-background'=>'grey','-width'=>10,'-command' => ['yview', $text])->pack('-side' => 'right', '-fill' => 'y');
# Inform listbox about the scrollbar
$text->configure('-yscrollcommand' => ['set', $scroll]);

  } #end of create_ui
#-------------------------------------------------------------------
sub set_design {
$design=$matrix[0][1]->get();
system("./GUI/create_design.pl $design 2>&1 | ./GUI/send_stdout.pl &");
&listen();
}
#-------------------------------------------------------------------
sub launch_xemacs {
my $xe=shift;
if($xe) {
# we could do fork & exec, but this is more intuitive
system("xemacs blank&");
my @pid=`ps -aux | grep 'xemacs blank' | grep -v grep`;
$pid=shift @pid;
chomp $pid;
$pid=~s/^\w+\s+(\d+)/$1/;
$pid=~s/\s+.*//;
}
}
#-------------------------------------------------------------------
sub show_obj {
my $pattern= $matrix[2][2]->get();
#system("./GUI/debug.pl -s $pattern 2>&1 | ./GUI/send_stdout.pl &");
system("./GUI/debug.pl -s $pattern $design 2>&1 | ./GUI/send_stdout.pl &");
&listen();
#system("./GUI/debug.pl -s $pattern > tmp &");
#&write_output();
}
#-------------------------------------------------------------------
sub debug {
  (!$showdefault)&&($showdefault=0);
my $pattern= $matrix[2][2]->get();
my $f='';
if ($showdefault==1) {$f='-sd'}
#system("./GUI/debug.pl $f $pattern 2>&1 | ./GUI/send_stdout.pl &");
system("./GUI/debug.pl $f $pattern $design 2>&1 | ./GUI/send_stdout.pl &");
&listen();
#system("./GUI/debug.pl $f $pattern >& tmp &");
#&write_output();
}
#-------------------------------------------------------------------
sub update {
  (!$update) &&($update=0);
my $f='';
if($update==1){$f='-s'}
$text->delete('1.0','end');
#system("./GUI/update.pl $f  2>&1 | ./GUI/send_stdout.pl &");
system("./GUI/update.pl $f $design 2>&1 | ./GUI/send_stdout.pl &");
&listen();



( run in 0.894 second using v1.01-cache-2.11-cpan-39bf76dae61 )