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 48

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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