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 43

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 34 alirezamon
                my $vdb =  read_verilog_file($file);
21 16 alirezamon
                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 34 alirezamon
        my $window=def_popwin_size(60,60,"Import Ports",'percent');
181 16 alirezamon
 
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 34 alirezamon
        my $vdb=read_verilog_file($file);
187 16 alirezamon
        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 38 alirezamon
        my $combo_box=labele_widget_info(" Select soket type:",$combo,'Define the soket as multi connection if only if all interfaces ports are output oprts and they can feed more than one plug interface. E.g. clk is defined as multi connection');
333 16 alirezamon
 
334 34 alirezamon
        $table->attach ($entrybox, 0, 2 , $row, $row+1,'expand','shrink',2,2);
335
        $table->attach ($combo_box, 3, 6 , $row, $row+1,'expand','shrink',2,2);
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 34 alirezamon
                $table->attach ($sep, 0, 10 , $row, $row+1,'fill','fill',2,2);   $row++;
353 16 alirezamon
 
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 34 alirezamon
                $table->attach ($lab1, 1, 2 , $row, $row+1,'expand','shrink',2,2);
392
                $table->attach ($swap, 3, 4 , $row, $row+1,'expand','shrink',2,2);
393
                $table->attach ($lab2, 5, 6 , $row, $row+1,'expand','shrink',2,2);      $row++;
394
                $table->attach ($sep2, 0, 9 , $row, $row+1,'fill','fill',2,2);   $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 34 alirezamon
                $table->attach ($lab3, 0, 1 , $row, $row+1,'expand','shrink',2,2);
401
                $table->attach ($lab4, 1, 2 , $row, $row+1,'expand','shrink',2,2);
402
                $table->attach ($lab5, 2, 3 , $row, $row+1,'expand','shrink',2,2);
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 34 alirezamon
                $table->attach ($lab6, 4, 5 , $row, $row+1,'expand','shrink',2,2);
407
                $table->attach ($lab7, 5, 6 , $row, $row+1,'expand','shrink',2,2);
408
                $table->attach ($lab8, 6, 7 , $row, $row+1,'expand','shrink',2,2);
409 17 alirezamon
                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 34 alirezamon
                $table->attach ($lab9, 8, 9 , $row, $row+1,'expand','shrink',2,2);
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 34 alirezamon
                        $table->attach ($combo1, 0, 1 , $row, $row+1,'expand','shrink',2,2);
460
                        $table->attach ($entry2, 1, 2 , $row, $row+1,'expand','shrink',2,2);
461
                        $table->attach ($entry3, 2, 3 , $row, $row+1,'expand','shrink',2,2);
462 16 alirezamon
 
463
 
464 34 alirezamon
                        $table->attach ($connect_type_lable, 4, 5 , $row, $row+1,'expand','shrink',2,2);
465
                        $table->attach ($entry4, 5, 6 , $row, $row+1,'expand','shrink',2,2);
466
                        $table->attach ($entry5, 6, 7 , $row, $row+1,'expand','shrink',2,2);
467
                        $table->attach ($combentry, 8, 9 , $row, $row+1,'expand','shrink',2,2);
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 34 alirezamon
                #$table->attach_defaults ($temp, 0, 1 , $i, $i+1);
550 16 alirezamon
        }
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 34 alirezamon
 
599
                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?" ;
600
 
601
                my $dialog = Gtk2::MessageDialog->new (my $window,
602
                        'destroy-with-parent',
603
                        'question', # message type
604
                        'yes-no', # which set of buttons?
605
                        "$message");
606
                my $response = $dialog->run;
607
                if ($response eq 'yes') {
608
                        exec($^X, $0, @ARGV);# reset ProNoC to apply changes    
609
                }
610
                $dialog->destroy;
611
 
612
 
613 16 alirezamon
        }else{
614
                my $message="Category must be defined!";
615
                message_dialog($message);
616
 
617
        }
618
 
619
 
620
return 1;
621
}
622
 
623
 
624
 
625
###########
626
#       get description
627
#########
628
 
629
sub get_intfc_description{
630 25 alirezamon
        my ($intfc_gen,$info)=@_;
631 16 alirezamon
        my $description = $intfc_gen->intfc_get_description();
632
        my $table = Gtk2::Table->new (15, 15, TRUE);
633 34 alirezamon
        my $window=def_popwin_size(50,50,"Add description",'percent');
634 16 alirezamon
        my ($scrwin,$text_view)=create_text();
635
        #my $buffer = $textbox->get_buffer();
636
        my $ok=def_image_button("icons/select.png",' Ok ');
637
 
638
        $table->attach_defaults($scrwin,0,15,0,14);
639
        $table->attach_defaults($ok,6,9,14,15);
640
        my $text_buffer = $text_view->get_buffer;
641
        if(defined $description) {$text_buffer->set_text($description)};
642
 
643
        $ok->signal_connect("clicked"=> sub {
644
                $window->destroy;
645
 
646
                 my $text = $text_buffer->get_text($text_buffer->get_bounds, TRUE);
647
                 $intfc_gen->intfc_set_description($text);
648
                #print "$text\n";
649
 
650
        });
651
 
652
        $window->add($table);
653
        $window->show_all();
654
 
655
}
656
 
657
 
658
 
659 17 alirezamon
sub load_interface{
660 25 alirezamon
        my ($intfc_gen)=@_;
661 17 alirezamon
        my $file;
662
        my $dialog = Gtk2::FileChooserDialog->new(
663
                'Select a File', undef,
664
                'open',
665
                'gtk-cancel' => 'cancel',
666
                'gtk-ok'     => 'ok',
667
                );
668 16 alirezamon
 
669 17 alirezamon
        my $filter = Gtk2::FileFilter->new();
670
        $filter->set_name("ITC");
671
        $filter->add_pattern("*.ITC");
672
        $dialog->add_filter ($filter);
673
        my $dir = Cwd::getcwd();
674
        $dialog->set_current_folder ("$dir/lib/interface")      ;
675 16 alirezamon
 
676
 
677 17 alirezamon
        if ( "ok" eq $dialog->run ) {
678
                $file = $dialog->get_filename;
679
                my ($name,$path,$suffix) = fileparse("$file",qr"\..[^.]*$");
680
                if($suffix eq '.ITC'){
681
                        $intfc_gen->intfc_set_interface_file($file);
682 25 alirezamon
                        set_gui_status($intfc_gen,"load_file",0);
683 17 alirezamon
                }
684
     }
685
     $dialog->destroy;
686
 
687
 
688
 
689
}
690
 
691
 
692
 
693 16 alirezamon
############
694
#    main
695
############
696
sub intfc_main{
697
 
698
        my $intfc_gen= intfc_gen->interface_generator();
699 25 alirezamon
        set_gui_status($intfc_gen,"ideal",0);
700 17 alirezamon
        my $main_table = Gtk2::Table->new (15, 12, FALSE);
701 25 alirezamon
        $main_table->set_row_spacings (4);
702
        $main_table->set_col_spacings (1);
703 16 alirezamon
        # The box which holds the info, warning, error ...  mesages
704
        my ($infobox,$info)= create_text();
705
 
706
 
707
        my $refresh = Gtk2::Button->new_from_stock('ref');
708
        my $generate = def_image_button('icons/gen.png','Generate');
709
 
710
 
711
 
712 25 alirezamon
        my $fbox=file_box($intfc_gen,$info);
713
        my $sbox=module_select($intfc_gen,$info);
714 16 alirezamon
 
715
 
716 25 alirezamon
        my $devbox=dev_box_show($intfc_gen,$info);
717
 
718 34 alirezamon
        #$main_table->attach_defaults ($fbox , 0, 12, 0,1);
719
        #$main_table->attach_defaults ($sbox , 0, 12, 1,2);
720
        #$main_table->attach_defaults ($devbox , 0, 12, 2,12);
721
        #$main_table->attach_defaults ($infobox  , 0, 12, 12,14);
722
 
723
        my $v1=def_pack_vbox(TRUE,0,$fbox,$sbox);
724
        my $v2=gen_vpaned($v1,.1,$devbox);
725
        my $v3=gen_vpaned($v2,.6,$infobox);
726
        $main_table->attach_defaults ($v3  , 0, 12, 0,14);
727
 
728
 
729 25 alirezamon
        $main_table->attach ($generate  , 6, 8, 14,15,'shrink','shrink',2,2);
730 16 alirezamon
 
731 17 alirezamon
 
732
        my $open = def_image_button('icons/browse.png','Load Interface');
733
        my $openbox=def_hbox(TRUE,0);
734
        $openbox->pack_start($open,   FALSE, FALSE,0);
735 25 alirezamon
        $main_table->attach ($openbox,0, 2, 14,15,'shrink','shrink',2,2);
736 17 alirezamon
 
737 25 alirezamon
        #referesh the mpsoc generator 
738
        $refresh-> signal_connect("clicked" => sub{
739
                $devbox->destroy();
740
                $fbox->destroy();
741
                $sbox->destroy();
742 34 alirezamon
                $v1->destroy();
743 25 alirezamon
                select(undef, undef, undef, 0.1); #wait 10 ms
744
                $devbox=dev_box_show($intfc_gen,$info);
745
                $fbox=file_box($intfc_gen,$info);
746 34 alirezamon
                $sbox=module_select($intfc_gen,$info);
747
                $v1=def_pack_vbox(TRUE,0,$fbox,$sbox);
748
                $v2->pack1($v1,TRUE, TRUE);
749
                $v2->pack2($devbox,TRUE, TRUE);
750
                $v3-> pack1($v2, TRUE, TRUE);
751
                #$main_table->attach_defaults ($v3  , 0, 12, 0,14);
752
 
753
                $v3->show_all();
754 25 alirezamon
 
755
        });
756
 
757
 
758
 
759
 
760 16 alirezamon
        #check soc status every 0.5 second. referesh gui if there is any changes 
761
Glib::Timeout->add (100, sub{
762
 
763 25 alirezamon
                my ($state,$timeout)= get_gui_status($intfc_gen);
764 16 alirezamon
                if ($timeout>0){
765
                        $timeout--;
766 25 alirezamon
                        set_gui_status($intfc_gen,$state,$timeout);
767 16 alirezamon
                }
768
                elsif($state eq "load_file"){
769
                        my $file=$intfc_gen->intfc_get_interface_file();
770 43 alirezamon
                        my ($pp,$r,$err) = regen_object($file);
771
                        if ($r){
772
                                add_info(\$info,"**Error reading  $file file: $err\n");
773
                                return;
774
                        }
775
                        clone_obj($intfc_gen,$pp);
776 25 alirezamon
                        set_gui_status($intfc_gen,"ref",1);
777 16 alirezamon
 
778
 
779
                }
780
                elsif( $state ne "ideal" ){
781
                        $refresh->clicked;
782 25 alirezamon
                        set_gui_status($intfc_gen,"ideal",0);
783 16 alirezamon
 
784
                }
785
                return TRUE;
786
 
787
                } );
788 17 alirezamon
 
789
        $open-> signal_connect("clicked" => sub{
790 25 alirezamon
                load_interface($intfc_gen);
791 17 alirezamon
 
792
        });
793 16 alirezamon
 
794
        $generate-> signal_connect("clicked" => sub{
795 17 alirezamon
                if( check_intfc($intfc_gen)) {
796
                        generate_lib($intfc_gen);
797
 
798
                }
799 16 alirezamon
 
800
                $refresh->clicked;
801
 
802
});
803
 
804
        #show_selected_dev($info,\@active_dev,\$dev_list_refresh,\$dev_table);
805
 
806
 
807
 
808
#$box->show;
809
        #$window->add ($main_table);
810
        #$window->show_all;
811
        #return $main_table;
812
 
813
        my $sc_win = new Gtk2::ScrolledWindow (undef, undef);
814
                $sc_win->set_policy( "automatic", "automatic" );
815
                $sc_win->add_with_viewport($main_table);
816
 
817
        return $sc_win;
818
 
819
 
820
}
821
 
822
 
823
 
824
 
825
 
826
1
827
 

powered by: WebSVN 2.1.0

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