OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [perl_gui/] [lib/] [perl/] [interface_gen.pl] - Blame information for rev 25

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 alirezamon
#! /usr/bin/perl -w
2
use Glib qw/TRUE FALSE/;
3
use strict;
4
use warnings;
5
use Data::Dumper;
6
use intfc_gen;
7
use rvp;
8
use Gtk2;
9
 
10
 
11
 
12
require "widget.pl";
13
 
14
 
15
sub read_file_modules{
16 25 alirezamon
        my ($file,$intfc_gen,$info)=@_;
17 16 alirezamon
 
18
        if (!defined $file) {return; }
19
        if (-e $file) {
20
                my $vdb =  read_file($file);
21
                my @modules=sort $vdb->get_modules($file);
22
                #foreach my $p(@module_list) {print "$p\n"}
23
                $intfc_gen->intfc_set_interface_file($file);
24
                $intfc_gen->intfc_set_module_name($modules[0]);
25
                $intfc_gen->intfc_add_module_list(@modules);
26
 
27 25 alirezamon
                set_gui_status($intfc_gen,"file_selected",1);
28 16 alirezamon
                show_info(\$info,"Select the module which contain the interface ports\n ");
29
 
30
        }
31
        else {
32
                show_info(\$info,"File $file doese not exsit!\n ");
33
 
34
        }
35
}
36
 
37
 
38
################
39
#  check_input_intfc_file
40
################
41
 
42
sub check_input_intfc_file{
43 25 alirezamon
        my ($file,$intfc_gen,$info)=@_;
44 16 alirezamon
        my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
45
        if($suffix eq '.ITC'){
46
                $intfc_gen->intfc_set_interface_file($file);
47 25 alirezamon
                set_gui_status($intfc_gen,"load_file",0);
48 16 alirezamon
 
49
 
50
        }else{
51 25 alirezamon
                read_file_modules($file,$intfc_gen,$info);
52 16 alirezamon
 
53
        }
54
 
55
 
56
}
57
 
58
sub file_box {
59 25 alirezamon
        my ($intfc_gen,$info)=@_;
60 16 alirezamon
        my $label = gen_label_in_left("Select file:");
61
        my $entry = Gtk2::Entry->new;
62
        my $open= def_image_button("icons/select.png","Open");
63
        my $browse= def_image_button("icons/browse.png","Browse");
64
        my $file= $intfc_gen->intfc_get_interface_file();
65 25 alirezamon
        my $intfc_info= def_image_button("icons/add_info.png","Description");
66
        my $table = def_table(1,10,TRUE);
67 17 alirezamon
        $intfc_info->signal_connect("clicked"=> sub{
68 25 alirezamon
                get_intfc_description($intfc_gen,$info);
69 17 alirezamon
 
70
 
71
        });
72
 
73 16 alirezamon
        if(defined $file){$entry->set_text($file);}
74
        show_info(\$info,"Please select the verilog file containig the interface\n");
75
        $browse->signal_connect("clicked"=> sub{
76
                my $entry_ref=$_[1];
77
                my $file;
78
        my $dialog = Gtk2::FileChooserDialog->new(
79
                'Select a File', undef,
80
                'open',
81
                'gtk-cancel' => 'cancel',
82
                'gtk-ok'     => 'ok',
83
                );
84
 
85
                        my $filter = Gtk2::FileFilter->new();
86
                        $filter->set_name("Verilog");
87
                        $filter->add_pattern("*.v");
88
                        my $filter2 = Gtk2::FileFilter->new();
89
                        $filter2->set_name("Interface");
90
                        $filter2->add_pattern("*.ITC");
91
                        $dialog->add_filter ($filter);
92
                        $dialog->add_filter ($filter2);
93
 
94
 
95
                if ( "ok" eq $dialog->run ) {
96
                        $file = $dialog->get_filename;
97
                                        $$entry_ref->set_text($file);
98 25 alirezamon
                                        check_input_intfc_file($file,$intfc_gen,$info);
99
                                        #read_file_modules($file,$intfc_gen,$info);
100 16 alirezamon
                        #print "file = $file\n";
101
                 }
102
                $dialog->destroy;
103
 
104
 
105
 
106
        } , \$entry);
107
 
108
        $open->signal_connect("clicked"=> sub{
109
                my $file_name=$entry->get_text();
110 25 alirezamon
                check_input_intfc_file($file,$intfc_gen,$info);
111
                #read_file_modules($file_name,$intfc_gen,$info);
112 16 alirezamon
 
113
                });
114
        $entry->signal_connect("activate"=>sub{
115
                my $file_name=$entry->get_text();
116 25 alirezamon
                read_file_modules($file_name,$intfc_gen,$info);
117 16 alirezamon
        });
118
 
119
        $entry->signal_connect("changed"=>sub{
120
                show_info(\$info,"Please select the verilog file containig the interface\n");
121
        });
122
 
123 25 alirezamon
        my $row=0;
124 17 alirezamon
        $table->attach_defaults ($label, 0, 1 , $row, $row+1);
125
        $table->attach_defaults ($entry, 1, 7 , $row, $row+1);
126 25 alirezamon
        $table->attach ($browse, 7, 8, $row, $row+1,'shrink','shrink',2,2);
127
        $table->attach ($intfc_info, 8, 9 , $row, $row+1,'shrink','shrink',2,2);
128 17 alirezamon
        #$table->attach_defaults ($open,  9, 10, $row, $row+1);
129 16 alirezamon
        #$table->attach_defaults ($entry, $col, $col+1, $row, $row+1);
130 25 alirezamon
        return $table;
131 16 alirezamon
 
132
 
133
}
134
 
135
 
136
 
137
sub get_ports_type{
138
        my ($vdb,$top_module)=@_;
139
        my %ports;
140
 
141
        foreach my $sig (sort $vdb->get_modules_signals($top_module)) {
142
        my ($line,$a_line,$i_line,$type,$file,$posedge,$negedge,
143
         $type2,$s_file,$s_line,$range,$a_file,$i_file,$dims) =
144
           $vdb->get_module_signal($top_module,$sig);
145
 
146
                if($type eq "input" or $type eq "inout" or $type eq "output" ){
147
                        $ports{$sig}=$type;
148
 
149
                }
150
        }
151
        return %ports;
152
}
153
 
154
 
155
 
156
sub get_ports_rang{
157
        my ($vdb,$top_module)=@_;
158
        my %ports;
159
 
160
        foreach my $sig (sort $vdb->get_modules_signals($top_module)) {
161
        my ($line,$a_line,$i_line,$type,$file,$posedge,$negedge,
162
         $type2,$s_file,$s_line,$range,$a_file,$i_file,$dims) =
163
           $vdb->get_module_signal($top_module,$sig);
164
 
165
                if($type eq "input" or $type eq "inout" or $type eq "output" ){
166
 
167
 
168
 
169
                        $ports{$sig}=remove_all_white_spaces($range);
170
 
171
                }
172
        }
173
        return %ports;
174
}
175
 
176
 
177
 
178
sub get_interface_ports {
179 25 alirezamon
        my ($intfc_gen,$info)=@_;
180 16 alirezamon
        my $window=def_popwin_size(800,600,"Import Ports");
181
 
182 25 alirezamon
        my $file=$intfc_gen->intfc_get_interface_file();
183 16 alirezamon
        if (!defined $file){show_info(\$info,"File name has not been defined yet!");  return;}
184 25 alirezamon
        my $module=$intfc_gen->intfc_get_module_name();
185 16 alirezamon
        if (!defined $module){  show_info(\$info,"Module name has not been selected yet!");  return;}
186
        my $vdb=read_file($file);
187
        my %port_type=get_ports_type($vdb,$module);
188
        my %port_range=get_ports_rang($vdb,$module);
189
 
190
        my $table=def_table(8,8,TRUE);
191
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
192
        $scrolled_win->set_policy( "automatic", "automatic" );
193
        $scrolled_win->add_with_viewport($table);
194
 
195
 
196
 
197
        my $title=gen_label_in_center("Select the ports included in the interface");
198
        my $title1=gen_label_in_center("Type");
199
        my $title2=gen_label_in_center("Range");
200
        my $title3=gen_label_in_center("Name");
201
        my $title4=gen_label_in_center("Select");
202
 
203
        my $row =0;
204
        $table->attach_defaults($title, 0,8, $row, $row+1);
205
        $row++;
206
        $table->attach_defaults($title1, 0,1, $row, $row+1);
207
        $table->attach_defaults($title2, 1,4, $row, $row+1);
208
        $table->attach_defaults($title3, 4,7, $row, $row+1);
209
        $table->attach_defaults($title4, 7,8, $row, $row+1);
210
 
211
        my $separator = Gtk2::HSeparator->new;
212
        $row++;
213
 
214
        $table->attach_defaults($separator, 0,8, $row, $row+1);
215
 
216
        $row++;
217 25 alirezamon
        $intfc_gen->intfc_remove_ports();
218 16 alirezamon
        foreach my $p (sort keys %port_type){
219
                my $port_id= $p;
220
                my $porttype=$port_type{$p};
221
                my $label1= gen_label_in_center("$porttype");
222
                $table->attach_defaults($label1, 0,1, $row, $row+1);
223
                my $portrange=$port_range{$p};
224
                if (  $port_range{$p} ne ''){
225
 
226
                        my $label2= gen_label_in_center("\[$portrange\]");
227
                        $table->attach_defaults($label2, 1,4, $row, $row+1);
228
                }
229
 
230
                my $label3= gen_label_in_center($p);
231
                $table->attach_defaults($label3, 4,7, $row, $row+1);
232
 
233
                my $check= Gtk2::CheckButton->new;
234
                $table->attach_defaults($check, 7,8, $row, $row+1);
235
 
236
                $row++;
237
                if($row>8){$table->resize ($row, 8);}
238
                #print "$p\:$port_type{$p}\n";
239
 
240
                $check->signal_connect("toggled"=>sub{
241
                        my $widget=shift;
242
                        my $in=$widget->get_active();
243
                        if ($in eq 1){
244
                                my $connect_type=($porttype eq "input")? "output" : ($porttype eq "output")? "input" : $porttype;
245 25 alirezamon
                                $intfc_gen->intfc_add_port($port_id,$porttype,$portrange,$p,$connect_type,$portrange,$p,"concatenate","Active low");
246 16 alirezamon
 
247
 
248
 
249
                                #print "chanhed to $in \n";
250
                        }else {
251 25 alirezamon
                                $intfc_gen->intfc_remove_port($port_id);
252 16 alirezamon
 
253
                                #print "chanhed to 0 \n";
254
 
255
                        }
256
 
257
 
258
                });
259
 
260
        }
261
 
262
 
263
        my $ok= def_image_button("icons/select.png","ok");
264 25 alirezamon
        $table->attach($ok, 3,5, $row, $row+1,'shrink','shrink',2,2);
265 16 alirezamon
 
266
        $ok->signal_connect("clicked"=>sub{
267
                $window->destroy;
268 25 alirezamon
                set_gui_status($intfc_gen,"refresh",1);
269 16 alirezamon
 
270
 
271
                });
272
 
273
        $window->add($scrolled_win);
274
 
275
        $window->show_all();
276
}
277
 
278
 
279
 
280
 
281
 
282
 
283
sub module_select{
284 25 alirezamon
        my ($intfc_gen,$info)=@_;
285
        my $file= $intfc_gen->intfc_get_interface_file();
286 16 alirezamon
 
287 25 alirezamon
        my $table = def_table(1,10,TRUE);
288
 
289
 
290
 
291
        my @modules= $intfc_gen->intfc_get_module_list();
292
        my $combo=gen_combobox_object($intfc_gen,'module_name',undef,join(',', @modules),undef,'refresh',1);
293
        my $modul_name=labele_widget_info(" Select module:",$combo);
294
 
295
 
296 16 alirezamon
        my $port= def_image_button("icons/import.png","Import Ports");
297 25 alirezamon
        my $category_entry=gen_entry_object($intfc_gen,'category',undef,undef,undef,undef);
298
        my $category=labele_widget_info(" Select Category:",$category_entry,'Define the Interface category:e.g RAM, wishbone,...');
299
 
300 16 alirezamon
 
301
 
302
 
303 25 alirezamon
        my $row=0;
304
        #$table->attach_defaults ($label, 0, 1 , $row, $row+1);
305
        $table->attach  ($modul_name, 0, 3 , $row,$row+1,'shrink','shrink',2,2);
306
        $table->attach ($port, 4, 6 , $row, $row+1,'shrink','shrink',2,2);
307
        $table->attach_defaults ($category, 7, 10 , $row, $row+1);
308 17 alirezamon
 
309
 
310 16 alirezamon
 
311 25 alirezamon
 
312 16 alirezamon
        $port->signal_connect("clicked"=> sub{
313 25 alirezamon
                get_interface_ports($intfc_gen,$info);
314 16 alirezamon
 
315
 
316
        });
317
 
318
 
319
 
320 25 alirezamon
        return $table;
321 16 alirezamon
 
322 17 alirezamon
 
323 16 alirezamon
}
324
 
325
sub interface_type_select {
326 25 alirezamon
        my ($intfc_gen,$info,$table,$row)=@_;
327
 
328
        my $entry=gen_entry_object($intfc_gen,'name',undef,undef,"refresh",50);
329
        my $entrybox=labele_widget_info(" Interface name:",$entry);
330
 
331
        my $combo=gen_combobox_object($intfc_gen,'connection_num',undef,"single connection,multi connection","single connection",'refresh',1);
332
        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');
333 16 alirezamon
 
334 25 alirezamon
        $table->attach_defaults ($entrybox, 0, 2 , $row, $row+1);
335
        $table->attach_defaults ($combo_box, 3, 5 , $row, $row+1);
336 17 alirezamon
 
337 16 alirezamon
}
338
 
339
 
340
 
341
 
342
 
343 18 alirezamon
 
344 16 alirezamon
sub port_select{
345 25 alirezamon
        my ($intfc_gen,$info,$table,$row)=@_;
346 17 alirezamon
        my(%types,%ranges,%names,%connect_types,%connect_ranges,%connect_names,%outport_types,%default_outs);
347 25 alirezamon
        $intfc_gen->intfc_get_ports(\%types,\%ranges,\%names,\%connect_types,\%connect_ranges,\%connect_names,\%outport_types,\%default_outs);
348 16 alirezamon
 
349
        my $size = keys %types;
350
        if($size >0){
351
                my $sep = Gtk2::HSeparator->new;
352
                $table->attach_defaults ($sep, 0, 10 , $row, $row+1);    $row++;
353
 
354
 
355 17 alirezamon
                my $swap= def_image_button("icons/swap.png","swap");
356
 
357 16 alirezamon
                $swap->signal_connect('clicked'=>sub{
358 25 alirezamon
                        my $type=$intfc_gen->intfc_get_interface_type();
359 16 alirezamon
                        if($type eq 'plug'){
360 25 alirezamon
                                        $intfc_gen->intfc_set_interface_type('socket');
361 16 alirezamon
                        }
362
                        else {
363 25 alirezamon
                                        $intfc_gen->intfc_set_interface_type('plug');
364 16 alirezamon
                        }
365 25 alirezamon
                        set_gui_status($intfc_gen,"refresh",1);
366 16 alirezamon
 
367
                });
368
 
369
 
370
                my @intfcs=("plug","socket");
371 25 alirezamon
                my $inttype=$intfc_gen->intfc_get_interface_type();
372 16 alirezamon
                if (!defined $inttype){
373
                        $inttype='plug';
374 25 alirezamon
                        $intfc_gen->intfc_set_interface_type($inttype);
375 16 alirezamon
                }
376
 
377
                #my $lab1= gen_label_in_center($inttype);
378
                my ($lab1,$lab2);
379
                if ($inttype eq 'plug'){
380
                        $lab1=def_image_label('icons/plug.png'  ,'plug  ');
381
                        $lab2=def_image_label('icons/socket.png','socket');
382
                }else {
383
                        $lab2=def_image_label('icons/plug.png','plug');
384
                        $lab1=def_image_label('icons/socket.png','socket');
385
 
386
                }
387
 
388 17 alirezamon
                my $sep2 = Gtk2::HSeparator->new;
389 16 alirezamon
 
390
 
391 25 alirezamon
                $table->attach ($lab1, 1, 2 , $row, $row+1,'shrink','shrink',2,2);
392
                $table->attach ($swap, 3, 4 , $row, $row+1,'shrink','shrink',2,2);
393
                $table->attach ($lab2, 5, 6 , $row, $row+1,'shrink','shrink',2,2);      $row++;
394 17 alirezamon
                $table->attach_defaults ($sep2, 0, 9 , $row, $row+1);    $row++;
395 16 alirezamon
 
396
 
397
                my $lab3= gen_label_in_center("Type");
398
                my $lab4= gen_label_in_center("Range");
399
                my $lab5= gen_label_in_center("Name");
400
                $table->attach_defaults ($lab3, 0, 1 , $row, $row+1);
401 17 alirezamon
                $table->attach_defaults ($lab4, 1, 2 , $row, $row+1);
402
                $table->attach_defaults ($lab5, 2, 3 , $row, $row+1);
403 16 alirezamon
                my $lab6= gen_label_in_center("Type");
404
                my $lab7= gen_label_in_center("Range");
405
                my $lab8= gen_label_in_center("Name");
406 17 alirezamon
                $table->attach_defaults ($lab6, 4, 5 , $row, $row+1);
407
                $table->attach_defaults ($lab7, 5, 6 , $row, $row+1);
408
                $table->attach_defaults ($lab8, 6, 7 , $row, $row+1);
409
                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 ");
410
                $table->attach_defaults ($lab9, 8, 9 , $row, $row+1);
411 16 alirezamon
                $row++;
412
 
413
                foreach my $id (sort keys %ranges){
414
                        my $type=$types{$id};
415
                        my $range=$ranges{$id};
416
                        my $name=$names{$id};
417
                        my $connect_type=$connect_types{$id};
418
                        my $connect_range=$connect_ranges{$id};
419
                        my $connect_name=$connect_names{$id};
420
                        my $outport_type=$outport_types{$id};
421 17 alirezamon
                        my $default_out=$default_outs{$id};
422
                        if(! defined $default_out){
423
                                $default_out = "Active low"; # port_width_repeat($connect_range,"1\'b0");
424 25 alirezamon
                                $intfc_gen->intfc_add_port($id,$type,$range,$name,$connect_type,$connect_range,$connect_name,$outport_type,$default_out);
425 17 alirezamon
                                print "\$default_out is set to: $default_out\n ";
426
                        }
427 16 alirezamon
 
428 17 alirezamon
                        #my $box=def_hbox(FALSE,0);
429
 
430 16 alirezamon
                        my @ports_type=("input","output","inout");
431
                        my $pos=get_scolar_pos($type,@ports_type);
432
                        my $combo1=gen_combo(\@ports_type,$pos);
433
                        my $entry2=gen_entry($range);
434
                        my $entry3=gen_entry($name);
435
                        my $separator = Gtk2::VSeparator->new;
436
                        my $connect_type_lable= gen_label_in_center($connect_type);
437
                        my $entry4=gen_entry($connect_range);
438
                        my $entry5=gen_entry($connect_name);
439
                        my @outport_types=("shared","concatenate");
440 17 alirezamon
                        my $pos2=get_scolar_pos($outport_type,@outport_types);
441 16 alirezamon
                        my $combo2=gen_combo(\@outport_types,$pos2);
442 17 alirezamon
 
443 16 alirezamon
 
444 17 alirezamon
                        #my @list=(port_width_repeat($range,"1\'b0"),port_width_repeat($range,"1\'b1"),port_width_repeat($range,"1\'bx"));
445
                        my @list=("Active low","Active high","Don't care");
446
 
447
                        my $combentry=gen_combo_entry(\@list);
448
                        $pos2=get_scolar_pos($default_out,@list);
449
                        if( defined $pos2){
450
                                $combentry->set_active($pos2);
451
                        } else {
452
                                ($combentry->child)->set_text($default_out);
453
                        }
454
 
455
 
456
                        #$box->pack_start($entry3,TRUE,FALSE,3);
457
                        #$box->pack_start($separator,TRUE,FALSE,3);
458 16 alirezamon
 
459
                        $table->attach_defaults ($combo1, 0, 1 , $row, $row+1);
460 17 alirezamon
                        $table->attach_defaults ($entry2, 1, 2 , $row, $row+1);
461
                        $table->attach_defaults ($entry3, 2, 3 , $row, $row+1);
462 16 alirezamon
 
463
 
464 17 alirezamon
                        $table->attach_defaults ($connect_type_lable, 4, 5 , $row, $row+1);
465
                        $table->attach_defaults ($entry4, 5, 6 , $row, $row+1);
466
                        $table->attach_defaults ($entry5, 6, 7 , $row, $row+1);
467
                        $table->attach_defaults ($combentry, 8, 9 , $row, $row+1);
468 16 alirezamon
 
469
                        $combo1->signal_connect("changed"=>sub{
470
                                my $new_type=$combo1->get_active_text();
471
                                my $new_connect_type=($new_type eq "input")? "output" : ($new_type eq "output")? "input" : $new_type;
472 25 alirezamon
                                $intfc_gen->intfc_add_port($id,$new_type,$range,$name,$new_connect_type,$connect_range,$connect_name,$outport_type,$default_out);
473
                                set_gui_status($intfc_gen,"refresh",1);
474 16 alirezamon
 
475
                        });
476
                        $entry2->signal_connect("changed"=>sub{
477
                                $range=$entry2->get_text();
478 25 alirezamon
                                $intfc_gen->intfc_add_port($id,$type,$range,$name,$connect_type,$connect_range,$connect_name,$outport_type,$default_out);
479
                                set_gui_status($intfc_gen,"refresh",50);
480 16 alirezamon
 
481
                        });
482
                        $entry3->signal_connect("changed"=>sub{
483
                                $name=$entry3->get_text();
484 25 alirezamon
                                $intfc_gen->intfc_add_port($id,$type,$range,$name,$connect_type,$connect_range,$connect_name,$outport_type,$default_out);
485
                                set_gui_status($intfc_gen,"refresh",50);
486 16 alirezamon
 
487
                        });
488
 
489
                        $entry4->signal_connect("changed"=>sub{
490
                                $connect_range=$entry4->get_text();
491 25 alirezamon
                                $intfc_gen->intfc_add_port($id,$type,$range,$name,$connect_type,$connect_range,$connect_name,$outport_type,$default_out);
492
                                set_gui_status($intfc_gen,"refresh",50);
493 16 alirezamon
 
494
                        });
495
                        $entry5->signal_connect("changed"=>sub{
496
                                $connect_name=$entry5->get_text();
497 25 alirezamon
                                $intfc_gen->intfc_add_port($id,$type,$range,$name,$connect_type,$connect_range,$connect_name,$outport_type,$default_out);
498
                                set_gui_status($intfc_gen,"refresh",50);
499 16 alirezamon
 
500
                        });
501
                        $combo2->signal_connect("changed"=>sub{
502
                                my $new_outport_type=$combo2->get_active_text();
503 25 alirezamon
                                $intfc_gen->intfc_add_port($id,$type,$range,$name,$connect_type,$connect_range,$connect_name,$new_outport_type,$default_out);
504
                                set_gui_status($intfc_gen,"refresh",1);
505 16 alirezamon
 
506
                        });
507 17 alirezamon
                        ($combentry->child)->signal_connect('changed' => sub {
508
                                my ($entry) = @_;
509
                                $default_out=$entry->get_text();
510 25 alirezamon
                                $intfc_gen->intfc_add_port($id,$type,$range,$name,$connect_type,$connect_range,$connect_name,$outport_type,$default_out);
511 16 alirezamon
 
512 17 alirezamon
 
513
                        });
514 16 alirezamon
 
515 17 alirezamon
 
516
 
517 16 alirezamon
                        $row++;
518
 
519
 
520
                }#foreach port  
521
 
522
 
523
        }
524
        return $row;
525
}
526
 
527
 
528
 
529
 
530
 
531
 
532
 
533
 
534
 
535
 
536 25 alirezamon
 
537
 
538
 
539
sub dev_box_show{
540
        my($intfc_gen,$info)=@_;
541
 
542 16 alirezamon
        my $table = def_table(20,10,FALSE);
543
 
544 25 alirezamon
 
545
        interface_type_select($intfc_gen,$info,$table,0);
546
        my $row=port_select($intfc_gen,$info,$table,1);
547 16 alirezamon
        for (my $i=$row; $i<20; $i++){
548 25 alirezamon
                my $temp=gen_label_in_center(" ");
549 16 alirezamon
                $table->attach_defaults ($temp, 0, 1 , $i, $i+1);
550
        }
551
        my $scrolled_win = new Gtk2::ScrolledWindow (undef, undef);
552
        $scrolled_win->set_policy( "automatic", "automatic" );
553 25 alirezamon
        $scrolled_win->add_with_viewport($table);
554 16 alirezamon
 
555
 
556
 
557 25 alirezamon
 
558
 
559 16 alirezamon
        return $scrolled_win;
560
 
561
}
562
 
563
 
564
 
565
 
566
sub check_intfc{
567
        my $intfc_gen=shift;
568
        my $result;
569
        my $message;
570
 
571
 
572
        $result=$intfc_gen->intfc_ckeck_ports_available();
573
        if(!defined $result){$message="No port connection has been selected for this interface!";}
574
        $result=$intfc_gen->intfc_get_interface_name();
575
        if(!defined $result){$message="The interface name is empty!";}
576
        $result=$intfc_gen->intfc_get_interface_file();
577
        if(!defined $result){$message="The verilog file containig the interface has not been selected!";}
578
 
579
        if(!defined $message){return 1;}
580
        else {message_dialog($message); return 0;}
581
 
582
 
583
}
584
 
585
 
586
 
587
sub generate_lib{
588
        my $intfc_gen=shift;
589
        my $name=$intfc_gen->intfc_get_interface_name();
590 25 alirezamon
        my $category=$intfc_gen->object_get_attribute('category');
591 16 alirezamon
        # Write
592
        if(defined ($category)){
593
                open(FILE,  ">lib/interface/$name.ITC") || die "Can not open: $!";
594 25 alirezamon
                print FILE perl_file_header("$name.ITC");
595 16 alirezamon
                print FILE Data::Dumper->Dump([\%$intfc_gen],["HashRef"]);
596
                close(FILE) || die "Error closing file: $!";
597
                #store \%$intfc_gen, "lib/$name.ITC";
598
                my $message="Interface $name has been generated successfully" ;
599
                message_dialog($message);
600 17 alirezamon
                exec($^X, $0, @ARGV);# reset ProNoC to apply changes
601 16 alirezamon
                #$hashref = retrieve('file');
602
        }else{
603
                my $message="Category must be defined!";
604
                message_dialog($message);
605
 
606
        }
607
 
608
 
609
return 1;
610
}
611
 
612
 
613
 
614
###########
615
#       get description
616
#########
617
 
618
sub get_intfc_description{
619 25 alirezamon
        my ($intfc_gen,$info)=@_;
620 16 alirezamon
        my $description = $intfc_gen->intfc_get_description();
621
        my $table = Gtk2::Table->new (15, 15, TRUE);
622
        my $window=def_popwin_size(500,500,"Add description");
623
        my ($scrwin,$text_view)=create_text();
624
        #my $buffer = $textbox->get_buffer();
625
        my $ok=def_image_button("icons/select.png",' Ok ');
626
 
627
        $table->attach_defaults($scrwin,0,15,0,14);
628
        $table->attach_defaults($ok,6,9,14,15);
629
        my $text_buffer = $text_view->get_buffer;
630
        if(defined $description) {$text_buffer->set_text($description)};
631
 
632
        $ok->signal_connect("clicked"=> sub {
633
                $window->destroy;
634
 
635
                 my $text = $text_buffer->get_text($text_buffer->get_bounds, TRUE);
636
                 $intfc_gen->intfc_set_description($text);
637
                #print "$text\n";
638
 
639
        });
640
 
641
        $window->add($table);
642
        $window->show_all();
643
 
644
}
645
 
646
 
647
 
648 17 alirezamon
sub load_interface{
649 25 alirezamon
        my ($intfc_gen)=@_;
650 17 alirezamon
        my $file;
651
        my $dialog = Gtk2::FileChooserDialog->new(
652
                'Select a File', undef,
653
                'open',
654
                'gtk-cancel' => 'cancel',
655
                'gtk-ok'     => 'ok',
656
                );
657 16 alirezamon
 
658 17 alirezamon
        my $filter = Gtk2::FileFilter->new();
659
        $filter->set_name("ITC");
660
        $filter->add_pattern("*.ITC");
661
        $dialog->add_filter ($filter);
662
        my $dir = Cwd::getcwd();
663
        $dialog->set_current_folder ("$dir/lib/interface")      ;
664 16 alirezamon
 
665
 
666 17 alirezamon
        if ( "ok" eq $dialog->run ) {
667
                $file = $dialog->get_filename;
668
                my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
669
                if($suffix eq '.ITC'){
670
                        $intfc_gen->intfc_set_interface_file($file);
671 25 alirezamon
                        set_gui_status($intfc_gen,"load_file",0);
672 17 alirezamon
                }
673
     }
674
     $dialog->destroy;
675
 
676
 
677
 
678
}
679
 
680
 
681
 
682 16 alirezamon
############
683
#    main
684
############
685
sub intfc_main{
686
 
687
        my $intfc_gen= intfc_gen->interface_generator();
688 25 alirezamon
        set_gui_status($intfc_gen,"ideal",0);
689 17 alirezamon
        my $main_table = Gtk2::Table->new (15, 12, FALSE);
690 25 alirezamon
        $main_table->set_row_spacings (4);
691
        $main_table->set_col_spacings (1);
692 16 alirezamon
        # The box which holds the info, warning, error ...  mesages
693
        my ($infobox,$info)= create_text();
694
 
695
 
696
        my $refresh = Gtk2::Button->new_from_stock('ref');
697
        my $generate = def_image_button('icons/gen.png','Generate');
698
 
699
 
700
 
701 25 alirezamon
        my $fbox=file_box($intfc_gen,$info);
702
        my $sbox=module_select($intfc_gen,$info);
703 16 alirezamon
 
704
 
705 25 alirezamon
        my $devbox=dev_box_show($intfc_gen,$info);
706
 
707
        $main_table->attach_defaults ($fbox , 0, 12, 0,1);
708
        $main_table->attach_defaults ($sbox , 0, 12, 1,2);
709
        $main_table->attach_defaults ($devbox , 0, 12, 2,12);
710 16 alirezamon
        $main_table->attach_defaults ($infobox  , 0, 12, 12,14);
711 25 alirezamon
        $main_table->attach ($generate  , 6, 8, 14,15,'shrink','shrink',2,2);
712 16 alirezamon
 
713 17 alirezamon
 
714
        my $open = def_image_button('icons/browse.png','Load Interface');
715
        my $openbox=def_hbox(TRUE,0);
716
        $openbox->pack_start($open,   FALSE, FALSE,0);
717 25 alirezamon
        $main_table->attach ($openbox,0, 2, 14,15,'shrink','shrink',2,2);
718 17 alirezamon
 
719 25 alirezamon
        #referesh the mpsoc generator 
720
        $refresh-> signal_connect("clicked" => sub{
721
                $devbox->destroy();
722
                $fbox->destroy();
723
                $sbox->destroy();
724
                select(undef, undef, undef, 0.1); #wait 10 ms
725
                $devbox=dev_box_show($intfc_gen,$info);
726
                $fbox=file_box($intfc_gen,$info);
727
                $sbox=module_select($intfc_gen,$info);
728
                $main_table->attach_defaults ($fbox , 0, 12, 0,1);
729
                $main_table->attach_defaults ($sbox , 0, 12, 1,2);
730
                $main_table->attach_defaults ($devbox , 0, 12, 3,12);
731
 
732
                $devbox->show_all();
733
                $sbox->show_all();
734
                $fbox->show_all();
735
        });
736
 
737
 
738
 
739
 
740 16 alirezamon
        #check soc status every 0.5 second. referesh gui if there is any changes 
741
Glib::Timeout->add (100, sub{
742
 
743 25 alirezamon
                my ($state,$timeout)= get_gui_status($intfc_gen);
744 16 alirezamon
                if ($timeout>0){
745
                        $timeout--;
746 25 alirezamon
                        set_gui_status($intfc_gen,$state,$timeout);
747 16 alirezamon
                }
748
                elsif($state eq "load_file"){
749
                        my $file=$intfc_gen->intfc_get_interface_file();
750
                        my $pp= eval { do $file };
751
                        clone_obj($intfc_gen,$pp);
752
 
753
 
754 25 alirezamon
                        set_gui_status($intfc_gen,"ref",1);
755 16 alirezamon
 
756
 
757
                }
758
                elsif( $state ne "ideal" ){
759
                        $refresh->clicked;
760 25 alirezamon
                        set_gui_status($intfc_gen,"ideal",0);
761 16 alirezamon
 
762
                }
763
                return TRUE;
764
 
765
                } );
766 17 alirezamon
 
767
        $open-> signal_connect("clicked" => sub{
768 25 alirezamon
                load_interface($intfc_gen);
769 17 alirezamon
 
770
        });
771 16 alirezamon
 
772
        $generate-> signal_connect("clicked" => sub{
773 17 alirezamon
                if( check_intfc($intfc_gen)) {
774
                        generate_lib($intfc_gen);
775
 
776
                }
777 16 alirezamon
 
778
                $refresh->clicked;
779
 
780
});
781
 
782
        #show_selected_dev($info,\@active_dev,\$dev_list_refresh,\$dev_table);
783
 
784
 
785
 
786
#$box->show;
787
        #$window->add ($main_table);
788
        #$window->show_all;
789
        #return $main_table;
790
 
791
        my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
792
                $sc_win->set_policy( "automatic", "automatic" );
793
                $sc_win->add_with_viewport($main_table);
794
 
795
        return $sc_win;
796
 
797
 
798
}
799
 
800
 
801
 
802
 
803
 
804
1
805
 

powered by: WebSVN 2.1.0

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