1 |
48 |
alirezamon |
#!/usr/bin/perl -w
|
2 |
|
|
use constant::boolean;
|
3 |
|
|
use strict;
|
4 |
|
|
use warnings;
|
5 |
|
|
|
6 |
|
|
use FindBin;
|
7 |
|
|
use lib $FindBin::Bin;
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
use String::Scanf; # imports sscanf()
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
sub select_orcc_generated_srcs {
|
14 |
|
|
my ($self)=@_;
|
15 |
|
|
#my $window = def_popwin_size(80,80,"Generate software using ORCC compiler",'percent');
|
16 |
|
|
#my $table = def_table(10, 10, FALSE);
|
17 |
|
|
#$table->attach_defaults($infobox,0,20,$row,$row+1);
|
18 |
|
|
|
19 |
|
|
#pass noc parameter to trace generator
|
20 |
|
|
my %p;
|
21 |
|
|
my $params_ref=$self->object_get_attribute('noc_param');
|
22 |
|
|
if(defined $params_ref ){
|
23 |
|
|
|
24 |
|
|
$p{'noc_param'}=$params_ref;
|
25 |
|
|
}
|
26 |
|
|
#pass mpsoc name to trace genrator
|
27 |
|
|
my $mpsoc_name=$self->object_get_attribute('mpsoc_name');
|
28 |
|
|
$p{'mpsoc_name'}=$mpsoc_name;
|
29 |
|
|
|
30 |
|
|
#pass soc names to trace genrator
|
31 |
|
|
my ($NE, $NR, $RAw, $EAw, $Fw)=get_topology_info($self);
|
32 |
|
|
for (my $tile_num=0;$tile_num<$NE;$tile_num++){
|
33 |
|
|
my ($soc_name,$num)= $self->mpsoc_get_tile_soc_name($tile_num);
|
34 |
|
|
my $top=$self->mpsoc_get_soc($soc_name);
|
35 |
|
|
if(defined $top){
|
36 |
|
|
my @nis=get_NI_instance_list($top);
|
37 |
|
|
my $inst_name=$top->top_get_def_of_instance($nis[0],'instance');
|
38 |
|
|
$p{'ni_name'}{$tile_num}=$inst_name;
|
39 |
|
|
$p{'soc_name'}{$tile_num}=$soc_name;
|
40 |
|
|
}
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
my $trace_gen= trace_gen_main('orcc',\%p);#,$window);
|
49 |
|
|
|
50 |
|
|
#$window->add ($trace_gen);
|
51 |
|
|
#$window->show_all();
|
52 |
|
|
|
53 |
|
|
return $trace_gen;
|
54 |
|
|
my $table;
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
$self->object_add_attribute("file_id",undef,0);
|
60 |
|
|
$self->object_add_attribute("trace_id",undef,0);
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
my $col=0;
|
67 |
|
|
my $row=0;
|
68 |
|
|
my $add = def_image_button('icons/import.png',"Load");
|
69 |
|
|
set_tip($add,'Select ORCC generated CSV file');
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
$table->attach($add,$col,$col+1,$row,$row+1,'shrink','shrink',2,2);$col++;
|
73 |
|
|
my ($infobox,$info)= create_txview();
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
my $draw = def_image_button('icons/diagram.png');
|
78 |
|
|
set_tip($draw,'View Actor Connection Graph');
|
79 |
|
|
$table->attach($draw,$col,$col+1,$row,$row+1,'shrink','shrink',2,2);$col++;
|
80 |
|
|
$draw->signal_connect ( 'clicked'=> sub{
|
81 |
|
|
show_trace_diagram($self,'trace');
|
82 |
|
|
});
|
83 |
|
|
$row++;
|
84 |
|
|
$col=0;
|
85 |
|
|
my $map=actor_map($self,$info);
|
86 |
|
|
$table->attach_defaults($map,0,5,$row,$row+1);
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
my $i;
|
90 |
|
|
for ($i=$row; $i<5; $i++){
|
91 |
|
|
|
92 |
|
|
my $temp=gen_label_in_center(" ");
|
93 |
|
|
$table->attach_defaults ($temp, 0, 6 , $i, $i+1);
|
94 |
|
|
}
|
95 |
|
|
$row=$i;
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
$col=5;
|
99 |
|
|
my $next=def_image_button('icons/right.png','Next');
|
100 |
|
|
$table->attach($next,$col,$col+1,$row,$row+1,'shrink','shrink',2,2);$col++;
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
$add->signal_connect ( 'clicked'=> sub{
|
105 |
|
|
|
106 |
|
|
my $file;
|
107 |
|
|
my $dialog = gen_file_dialog('Select the ORCC generated CSV File','csv');
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
if ( "ok" eq $dialog->run ) {
|
115 |
|
|
$file = $dialog->get_filename;
|
116 |
|
|
load_orcc_csv($self,$file,$info);
|
117 |
|
|
}
|
118 |
|
|
$dialog->destroy;
|
119 |
|
|
});
|
120 |
|
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
sub load_orcc_file{
|
131 |
|
|
my($self,$tview)=@_;
|
132 |
|
|
my $file;
|
133 |
|
|
my $dialog = gen_file_dialog( undef,"csv");
|
134 |
|
|
|
135 |
|
|
if ( "ok" eq $dialog->run ) {
|
136 |
|
|
$file = $dialog->get_filename;
|
137 |
|
|
load_orcc_csv($self,$file,$tview);
|
138 |
|
|
}
|
139 |
|
|
$dialog->destroy;
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
sub load_orcc_csv{
|
147 |
|
|
my ($self,$file,$info)=@_;
|
148 |
|
|
|
149 |
|
|
add_info($info,"Use $file for generating actors network\n");
|
150 |
|
|
unless (-e $file){
|
151 |
|
|
add_colored_info($info,"Cannot find $file\n",'red');
|
152 |
|
|
return;
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
my $f_id=$self->object_get_attribute("file_id",undef);
|
156 |
|
|
my $t_id=$self->object_get_attribute("trace_id",undef);
|
157 |
|
|
|
158 |
|
|
open my $in, "<:encoding(utf8)", $file or die "$file: $!";
|
159 |
|
|
my $sect=0;
|
160 |
|
|
my $net;
|
161 |
|
|
my @actors;
|
162 |
|
|
|
163 |
|
|
my %chanels;
|
164 |
|
|
|
165 |
|
|
while (my $line = <$in>) {
|
166 |
|
|
chomp $line;
|
167 |
|
|
$line =~ s/[^\S\n]+//g; #remove space
|
168 |
|
|
|
169 |
|
|
if ($line =~ /Name,Package,Actors,Connections/){
|
170 |
|
|
$sect=1;
|
171 |
|
|
next;
|
172 |
|
|
}
|
173 |
|
|
if ($line =~ /Name,Incoming,Outgoing,Inputs,Outputs/){
|
174 |
|
|
$sect=2;
|
175 |
|
|
next;
|
176 |
|
|
}
|
177 |
|
|
if ($line =~ /Source,SrcPort,Target,TgtPort/){
|
178 |
|
|
$sect=3;
|
179 |
|
|
next;
|
180 |
|
|
}
|
181 |
|
|
if($sect==1){
|
182 |
|
|
my @fileds=split(/\s*,\s*/,$line);
|
183 |
|
|
if(defined $fileds[0]){$net=$fileds[0] if($fileds[0]=~/^\w/);}
|
184 |
|
|
}
|
185 |
|
|
if($sect==2){
|
186 |
|
|
my @fileds=split(/\s*,\s*/,$line);
|
187 |
|
|
if(defined $fileds[0]){ push(@actors,$fileds[0]) if($fileds[0]=~/^\w/);}
|
188 |
|
|
}
|
189 |
|
|
if($sect==3){
|
190 |
|
|
my @fileds=split(/\s*,\s*/,$line);
|
191 |
|
|
if(defined $fileds[0]){
|
192 |
|
|
my $src=$fileds[0];
|
193 |
|
|
my $src_port=$fileds[1];
|
194 |
|
|
my $dest=$fileds[2];
|
195 |
|
|
my $dst_port=$fileds[3];
|
196 |
|
|
my $buff_Size=$fileds[4];
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
$chanels{"${src}:$src_port"}= (defined $chanels{"${src}:$src_port"})? $chanels{"${src}:$src_port"}+1 : 0;
|
200 |
|
|
my $cc=$chanels{"${src}:$src_port"};
|
201 |
|
|
#print "find chanel for ** ${src}_$src_port -> ${dest}_$dst_port**: $cc\n";
|
202 |
|
|
|
203 |
|
|
add_trace($self, "${net}:${f_id}:","raw",$t_id, $src,$dest, 1,$file, $src_port,$dst_port,$buff_Size,$chanels{"${src}:$src_port"},0);
|
204 |
|
|
#print "add_trace($self, \"${net}:${f_id}:\",\"raw\",$t_id, $src,$dest, 1,$file, $src_port,$dst_port,$buff_Size,$chanels{\"${src}:$src_port\"});\n";
|
205 |
|
|
$t_id++;
|
206 |
|
|
}
|
207 |
|
|
|
208 |
|
|
}
|
209 |
|
|
$self->set_gui_status('ref',0);
|
210 |
|
|
|
211 |
|
|
}
|
212 |
|
|
|
213 |
|
|
my $num=scalar @actors;
|
214 |
|
|
if($num==0){
|
215 |
|
|
add_colored_info($info,"Could not find any actor in $file\n",'red');
|
216 |
|
|
return;
|
217 |
|
|
}
|
218 |
|
|
add_info($info,"total of $num actors have found:\n\t");
|
219 |
|
|
my $n=1;
|
220 |
|
|
foreach my $act (@actors){
|
221 |
|
|
add_colored_info($info,"$n-$act ",'blue');
|
222 |
|
|
$n++;
|
223 |
|
|
}
|
224 |
|
|
add_info($info,"\n");
|
225 |
|
|
|
226 |
|
|
$f_id++;
|
227 |
|
|
$self->object_add_attribute("trace_id",undef,$t_id);
|
228 |
|
|
$self->object_add_attribute("file_id",undef,$f_id);
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
}
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
sub update_merge_actor_list{
|
236 |
|
|
my ($self,$tview)=@_;
|
237 |
|
|
|
238 |
|
|
#delete old merge objects
|
239 |
|
|
remove_all_traces ($self,'merge');
|
240 |
|
|
|
241 |
|
|
#add not mereged traces
|
242 |
|
|
my $t_id=0;
|
243 |
|
|
my $ungrouped_ref= $self->object_get_attribute("grouping",'ungrouped');
|
244 |
|
|
my @ungrouped = (defined $ungrouped_ref)? @{$ungrouped_ref}:[];
|
245 |
|
|
foreach my $actor (@ungrouped){
|
246 |
|
|
my @injectors= get_all_source_traces_of_actr($self,$actor,'raw');
|
247 |
|
|
foreach my $inject (@injectors) {
|
248 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var,$src_port,$dst_port,$buff_size,$chanel,$vc,$class
|
249 |
|
|
)=get_trace($self,'raw',$inject);
|
250 |
|
|
my $tdst=$self->get_item_group_name('grouping',$dst);
|
251 |
|
|
$dst_port=0 if (!defined $dst_port);
|
252 |
|
|
if($tdst ne $dst){
|
253 |
|
|
$dst_port="${dst}_$dst_port";
|
254 |
|
|
}
|
255 |
|
|
|
256 |
|
|
add_trace($self, "$file_id",'merge',$t_id, $src,$tdst,$Mbytes,$file_name, $src_port,$dst_port,$buff_size,$chanel,$vc,$class);
|
257 |
|
|
if(defined $min_pck){
|
258 |
|
|
add_trace_extra($self, "$file_id",'merge',$t_id,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var );
|
259 |
|
|
}
|
260 |
|
|
$t_id++;
|
261 |
|
|
}
|
262 |
|
|
|
263 |
|
|
}
|
264 |
|
|
|
265 |
|
|
#update group list
|
266 |
|
|
my $group_num=$self->object_get_attribute("grouping",'group_num');
|
267 |
|
|
my $gname=$self->object_get_attribute("grouping",'group_name_root');
|
268 |
|
|
for(my $i=0;$i<$group_num;$i=$i+1){
|
269 |
|
|
my $gref = $self->object_get_attribute("grouping","$gname($i)");
|
270 |
|
|
next if(! defined $gref);
|
271 |
|
|
my @grouped = @{$gref};
|
272 |
|
|
next if (scalar @grouped == 0);
|
273 |
|
|
|
274 |
|
|
|
275 |
|
|
my $merged_actor = $self->object_get_attribute('grouping',"group($i)"."_name");
|
276 |
|
|
$merged_actor = "group($i)" if(!defined $merged_actor);
|
277 |
|
|
#my $tile =get_task_give_tile($self,$merged_actor);
|
278 |
|
|
# print "my $tile =get_task_give_tile($self,$merged_actor);\n";
|
279 |
|
|
#my $tile_id=get_tile_id($self,$merged_actor);
|
280 |
|
|
#my $tile_id = tile_id_number($tile);
|
281 |
|
|
|
282 |
|
|
#add_info($tview,"Generating $merged_actor.c grouped actor file from: @grouped actors\n");
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
my $mpsoc_name=$self->object_get_attribute('mpsoc_name');
|
286 |
|
|
$mpsoc_name = 'tmp' if (!defined $mpsoc_name);
|
287 |
|
|
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
|
288 |
|
|
|
289 |
|
|
#setp 1 : find local communication ports in merged actor
|
290 |
|
|
foreach my $actor (@grouped) {
|
291 |
|
|
my @injectors= get_all_source_traces_of_actr($self,$actor,'raw');
|
292 |
|
|
#Where does it transfer?
|
293 |
|
|
foreach my $inject (@injectors) {
|
294 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var,$src_port,$dst_port,$buff_size,$chanel,$vc,$class
|
295 |
|
|
)=get_trace($self,'raw',$inject);
|
296 |
|
|
$dst_port=0 if (!defined $dst_port);
|
297 |
|
|
$src_port=0 if (!defined $src_port);
|
298 |
|
|
my $dst_actor=$dst;
|
299 |
|
|
if (check_scolar_exist_in_array($dst,\@grouped)){
|
300 |
|
|
#print "$src $src_port is locally connected to $dst $dst_port\n";
|
301 |
|
|
$self->object_add_attribute("locally_connected","${dst}_${dst_port}","${src}_${src_port}");
|
302 |
|
|
}
|
303 |
|
|
else
|
304 |
|
|
{
|
305 |
|
|
#my ($net,$num,$name)=split(':',$src);
|
306 |
|
|
my $merge_src="$merged_actor";
|
307 |
|
|
$src_port="${src}_$src_port";
|
308 |
|
|
|
309 |
|
|
my $file="$target_dir/sw/$actor.c";
|
310 |
|
|
|
311 |
|
|
my $tdst=$self->get_item_group_name('grouping',$dst);
|
312 |
|
|
# ($dnet,$dnum,$dname)=split(':',$tdst);
|
313 |
|
|
if($tdst ne $dst){
|
314 |
|
|
#my ($dnet,$dnum,$dname)=split(':',$dst);
|
315 |
|
|
$dst_port="${dst}_$dst_port";
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
add_trace($self, "$file_id",'merge',$t_id, $merge_src,$tdst, $Mbytes,$file, $src_port,$dst_port,$buff_size,$chanel,$vc,$class);
|
319 |
|
|
if(defined $min_pck){
|
320 |
|
|
add_trace_extra($self, "$file_id",'merge',$t_id,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var );
|
321 |
|
|
}
|
322 |
|
|
$t_id++;
|
323 |
|
|
}#else
|
324 |
|
|
}#$ink=ject
|
325 |
|
|
}#actor
|
326 |
|
|
}
|
327 |
|
|
}
|
328 |
|
|
|
329 |
|
|
|
330 |
|
|
|
331 |
|
|
sub get_port_num{
|
332 |
|
|
my ($self,$hash_ref,$actor,$port_name,$chanel) =@_;
|
333 |
|
|
return undef if(!defined $hash_ref);
|
334 |
|
|
my %hash = %{$hash_ref};
|
335 |
|
|
|
336 |
|
|
my $port_num =(defined $chanel)? $hash{$actor}{$port_name}{$chanel} : $hash{$actor}{$port_name};
|
337 |
|
|
if(!defined $port_num){
|
338 |
|
|
#its a merged actor
|
339 |
|
|
my $merge_actor=$self->get_item_group_name('grouping',$actor);
|
340 |
|
|
#my($net,$num,$name)=split(':',$merge_actor);
|
341 |
|
|
my $merge_port="${actor}_$port_name";
|
342 |
|
|
return $hash{$merge_actor}{$merge_port}{$chanel} if(defined $chanel);
|
343 |
|
|
return $hash{$merge_actor}{$merge_port};
|
344 |
|
|
}
|
345 |
|
|
return $port_num;
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
|
349 |
|
|
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
|
353 |
|
|
|
354 |
|
|
sub get_fifo_list{
|
355 |
|
|
my ($self)=@_;
|
356 |
|
|
my %fifos;
|
357 |
|
|
|
358 |
|
|
my ($NE, $NR, $RAw, $EAw, $Fw)=get_topology_info($self);
|
359 |
|
|
for (my $tile_num=0;$tile_num<$NE;$tile_num++){
|
360 |
|
|
my $actor=get_task_assigned_to_tile($self,$tile_num);
|
361 |
|
|
next if(!defined $actor);
|
362 |
|
|
my $fifo_num=0;
|
363 |
|
|
my $ref = $self->get_items_in_a_group("grouping",$actor);
|
364 |
|
|
my @merge_actors = (defined $ref)? @{$ref} : ($actor);
|
365 |
|
|
foreach my $actor (@merge_actors){
|
366 |
|
|
my @injectors= get_all_source_traces_of_actr($self,$actor,'raw');
|
367 |
|
|
foreach my $inject (@injectors) {
|
368 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var,$src_port,$dst_port,$buff_size,$chanel,$vc,$class
|
369 |
|
|
)=get_trace($self,'raw',$inject);
|
370 |
|
|
|
371 |
|
|
$fifos{"${actor}_${src_port}"}{'size'}=$buff_size;
|
372 |
|
|
$fifos{"$actor"}{'file'}="$file_name";
|
373 |
|
|
$fifos{"${actor}_${src_port}"}{'fifo_num'}=$fifo_num;
|
374 |
|
|
$fifos{"${actor}_${src_port}"}{'chanel_num'}= 0 if(!defined $fifos{"${actor}_${src_port}"}{'chanel_num'});
|
375 |
|
|
$fifos{"${actor}_${src_port}"}{'chanel_num'}++;
|
376 |
|
|
$fifo_num++;
|
377 |
|
|
$fifos{"tile_$tile_num"}{'fifo_num'}=$fifo_num;
|
378 |
|
|
}
|
379 |
|
|
}
|
380 |
|
|
}
|
381 |
|
|
|
382 |
|
|
for (my $tile_num=0;$tile_num<$NE;$tile_num++){
|
383 |
|
|
my $actor=get_task_assigned_to_tile($self,$tile_num);
|
384 |
|
|
next if(!defined $actor);
|
385 |
|
|
my $fifo_num=$fifos{"tile_$tile_num"}{'fifo_num'};
|
386 |
|
|
$fifo_num= 0 if(!defined $fifo_num);
|
387 |
|
|
my $ref = $self->get_items_in_a_group("grouping",$actor);
|
388 |
|
|
my @merge_actors = (defined $ref)? @{$ref} : ($actor);
|
389 |
|
|
foreach my $actor (@merge_actors){
|
390 |
|
|
my @sinkers = get_all_dest_traces_of_actr ($self,$actor,'raw');
|
391 |
|
|
foreach my $sink (@sinkers){
|
392 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var,$src_port,$dst_port,$buff_size,$chanel,$vc,$class
|
393 |
|
|
)=get_trace($self,'raw',$sink);
|
394 |
|
|
|
395 |
|
|
$fifos{"${actor}_${dst_port}"}{'size'}=$buff_size;
|
396 |
|
|
$fifos{"$actor"}{'file'}="$file_name";
|
397 |
|
|
$fifos{"${actor}_${dst_port}"}{'chanel_num'}=$fifos{"${src}_${src_port}"}{'chanel_num'};
|
398 |
|
|
|
399 |
|
|
my $src_fifo_name= $self->object_get_attribute("locally_connected","${actor}_${dst_port}");
|
400 |
|
|
if (defined $src_fifo_name){
|
401 |
|
|
#its localy connected. src fifo num and dst fifo num are identical
|
402 |
|
|
$fifos{"${actor}_${dst_port}"}{'fifo_num'}=$fifos{"$src_fifo_name"}{'fifo_num'};
|
403 |
|
|
#print "\$fifos{\"${actor}_${dst_port}\"}{'fifo_num'}=\$fifos{\"$src_fifo_name\"}{'fifo_num'}=$fifos{$src_fifo_name}{'fifo_num'};\n";
|
404 |
|
|
}else{
|
405 |
|
|
$fifos{"${actor}_${dst_port}"}{'fifo_num'}=$fifo_num;
|
406 |
|
|
$fifo_num++;
|
407 |
|
|
$fifos{"tile_$tile_num"}{'fifo_num'}=$fifo_num;
|
408 |
|
|
}
|
409 |
|
|
|
410 |
|
|
}
|
411 |
|
|
}
|
412 |
|
|
}
|
413 |
|
|
|
414 |
|
|
# print Dumper (\%fifos);
|
415 |
|
|
|
416 |
|
|
|
417 |
|
|
return %fifos;
|
418 |
|
|
}
|
419 |
|
|
|
420 |
|
|
|
421 |
|
|
sub get_dest_chanel_from_orcc_file{
|
422 |
|
|
my ($actor_file,$actor,$dst_port)=@_;
|
423 |
|
|
#print ("-------------------\n");
|
424 |
|
|
my $str = "${actor}_${dst_port}->read_inds\\s*\\[";
|
425 |
|
|
my $txt = load_file($actor_file);
|
426 |
|
|
my $n = capture_number_after($str,$txt);
|
427 |
|
|
return $n;
|
428 |
|
|
}
|
429 |
|
|
|
430 |
|
|
|
431 |
|
|
sub genereate_output_orcc{
|
432 |
|
|
my ($self,$tview,$window)=@_;
|
433 |
|
|
|
434 |
|
|
# Code each actor destination port
|
435 |
|
|
|
436 |
|
|
|
437 |
|
|
my %soc_names=%{$self->object_get_attribute('soc_name')};
|
438 |
|
|
my %ni_names =%{$self->object_get_attribute('ni_name')};
|
439 |
|
|
|
440 |
|
|
add_info($tview,"Generating grouped actor files\n");
|
441 |
|
|
my $group_num=$self->object_get_attribute("grouping",'group_num');
|
442 |
|
|
my $gname=$self->object_get_attribute("grouping",'group_name_root');
|
443 |
|
|
|
444 |
|
|
|
445 |
|
|
my $mpsoc_name=$self->object_get_attribute('mpsoc_name');
|
446 |
|
|
my $target_dir = "$ENV{'PRONOC_WORK'}/MPSOC/$mpsoc_name";
|
447 |
|
|
|
448 |
|
|
update_merge_actor_list ($self,$tview);
|
449 |
|
|
my %srcp_number=get_srcport_constant_list($self,'merge');
|
450 |
|
|
my %dstp_number=get_destport_constant_list($self,'merge');
|
451 |
|
|
|
452 |
|
|
#print "srcport:\n". Dumper(%srcp_number);
|
453 |
|
|
#print "dstport:\n". Dumper(%dstp_number);
|
454 |
|
|
|
455 |
|
|
add_info($tview,"Generating source files\n");
|
456 |
|
|
|
457 |
|
|
my $ungrouped_ref= $self->object_get_attribute("grouping",'ungrouped');
|
458 |
|
|
my @ungrouped = (defined $ungrouped_ref)? @{$ungrouped_ref}:[];
|
459 |
|
|
|
460 |
|
|
my %fifos=get_fifo_list($self);
|
461 |
|
|
|
462 |
|
|
|
463 |
|
|
my ($NE, $NR, $RAw, $EAw, $Fw)=get_topology_info($self);
|
464 |
|
|
for (my $tile_num=0;$tile_num<$NE;$tile_num++){
|
465 |
|
|
my $target_orccdir= "$target_dir/sw/tile${tile_num}/orcc";
|
466 |
|
|
my $actor_tile ="tile($tile_num)";
|
467 |
|
|
my $actor_tile_id=$tile_num;
|
468 |
|
|
my $src_lib_file="$target_dir/sw/tile${actor_tile_id}/SOURCE_LIB";
|
469 |
|
|
my $actor=get_task_assigned_to_tile($self,$tile_num);
|
470 |
|
|
my $soc_name=$soc_names{$actor_tile_id};
|
471 |
|
|
my $ni_name=$ni_names{$actor_tile_id};
|
472 |
|
|
my $max_dst_port_num=0;
|
473 |
|
|
|
474 |
|
|
|
475 |
|
|
|
476 |
|
|
#remove old orcc lib folder
|
477 |
|
|
rmtree("$target_orccdir");
|
478 |
|
|
|
479 |
|
|
#generate main.c
|
480 |
|
|
my $r;
|
481 |
|
|
my @actors_file_names;
|
482 |
|
|
my $main_c = "$target_dir/sw/tile${actor_tile_id}/main.c";
|
483 |
|
|
unlink $main_c; #delete old main.c file
|
484 |
|
|
open my $fd, ">$main_c" or $r = "$!\n";
|
485 |
|
|
if(defined $r) {
|
486 |
|
|
add_colored_info($tview,"Could not open $main_c to write: $r",'red');
|
487 |
|
|
return;
|
488 |
|
|
}
|
489 |
|
|
|
490 |
|
|
#generate source_lib file
|
491 |
|
|
my $src_lib="SOURCE_LIB += $soc_name.c ";
|
492 |
|
|
|
493 |
|
|
|
494 |
|
|
if (!defined $actor){
|
495 |
|
|
print $fd main_c_template($soc_name);
|
496 |
|
|
close($fd);
|
497 |
|
|
#write makefile source lib list file
|
498 |
|
|
save_file($src_lib_file,$src_lib);
|
499 |
|
|
next;
|
500 |
|
|
}
|
501 |
|
|
|
502 |
|
|
|
503 |
|
|
|
504 |
|
|
mkpath("$target_orccdir",1,0755);
|
505 |
|
|
|
506 |
|
|
print $fd autogen_warning();
|
507 |
|
|
print $fd get_license_header($main_c);
|
508 |
|
|
|
509 |
|
|
my $ref = $self->get_items_in_a_group("grouping",$actor);
|
510 |
|
|
my @merge_actors = (defined $ref)? @{$ref} : ($actor);
|
511 |
|
|
|
512 |
|
|
my $main_include = "#include <stddef.h>
|
513 |
|
|
#include \"$soc_name.h\"
|
514 |
|
|
#include \"orcc/orcc_lib.h\"
|
515 |
|
|
";
|
516 |
|
|
|
517 |
|
|
|
518 |
|
|
|
519 |
|
|
my $main_def="";
|
520 |
|
|
my $main_fifo_def="";
|
521 |
|
|
my $main_fifo_assign="";
|
522 |
|
|
my $main_fifo_rst_ptr="
|
523 |
|
|
volatile unsigned char iport_array[${ni_name}_NUM_VCs];
|
524 |
|
|
volatile unsigned char oport_array[${ni_name}_NUM_VCs];
|
525 |
|
|
unsigned int credit_buff[${ni_name}_NUM_VCs];
|
526 |
|
|
|
527 |
|
|
void reset_all_fifo_ptr(void){\n";
|
528 |
|
|
|
529 |
|
|
my $all_got_packet_function="";
|
530 |
|
|
my $all_sent_packet_done_function="";
|
531 |
|
|
my $all_check_packet_function="";
|
532 |
|
|
my $all_update_credit="";
|
533 |
|
|
my $all_init_actor="";
|
534 |
|
|
my $all_run_actor="";
|
535 |
|
|
my $actors_str='';
|
536 |
|
|
|
537 |
|
|
|
538 |
|
|
|
539 |
|
|
#start generation
|
540 |
|
|
|
541 |
|
|
|
542 |
|
|
foreach my $actor (@merge_actors){
|
543 |
|
|
my $actor_file= get_actr_file_name($self,$actor,'raw');
|
544 |
|
|
my ($fname,$fpath,$fsuffix) = fileparse("$actor_file",qr"\..[^.]*$");
|
545 |
|
|
my $target_actor_file="$target_orccdir/$fname.c";
|
546 |
|
|
my $target_actor_header="$target_orccdir/$fname.h";
|
547 |
|
|
open my $fc, ">$target_actor_file" or $r = "$!\n";
|
548 |
|
|
if(defined $r) {
|
549 |
|
|
add_colored_info($tview,"Could not open $target_actor_file to write: $r",'red');
|
550 |
|
|
return;
|
551 |
|
|
}
|
552 |
|
|
|
553 |
|
|
my $LH=uc "${fname}";
|
554 |
|
|
my $actor_h="#ifndef\t ${LH}_H\n\t#define\t${LH}_H\n\n";
|
555 |
|
|
my $schedul='';
|
556 |
|
|
my $Hw_fifo_define='' ;
|
557 |
|
|
my $transfer_str='';
|
558 |
|
|
my $sink_str='';
|
559 |
|
|
my $crdit_update='';
|
560 |
|
|
|
561 |
|
|
|
562 |
|
|
|
563 |
|
|
|
564 |
|
|
|
565 |
|
|
my $actor_got_pck_func= "
|
566 |
|
|
char ${actor}_got_packet_function( unsigned char iport, unsigned int v){
|
567 |
|
|
";
|
568 |
|
|
my $actor_update_credit= "
|
569 |
|
|
char ${actor}_update_credit (unsigned int credit_port,unsigned int credit_value){
|
570 |
|
|
";
|
571 |
|
|
|
572 |
|
|
my $actor_check_pck_func= "
|
573 |
|
|
char ${actor}_check_packet_function (unsigned char iport,unsigned int size){
|
574 |
|
|
";
|
575 |
|
|
|
576 |
|
|
my $actor_sent_pck_done_func= "
|
577 |
|
|
char ${actor}_sent_packet_done_function (unsigned char oport){
|
578 |
|
|
";
|
579 |
|
|
|
580 |
|
|
my $actor_init="
|
581 |
|
|
void ${actor}_init_actor (schedinfo_t * si) {
|
582 |
|
|
";
|
583 |
|
|
|
584 |
|
|
my $actor_local_connect;
|
585 |
|
|
|
586 |
|
|
#schedular function
|
587 |
|
|
|
588 |
|
|
$schedul ="
|
589 |
|
|
${actor}_scheduler(si);";
|
590 |
|
|
|
591 |
|
|
#For each actor which is mapped to this tile, we need to find all the traces going in and out to this tile
|
592 |
|
|
#1- get the actor generated C file name:
|
593 |
|
|
|
594 |
|
|
#push(@actors_file_names, $actor_file);
|
595 |
|
|
#2- where it mapped?
|
596 |
|
|
# my $actor_tile = $self->object_get_attribute("MAP_TILE",$actor);
|
597 |
|
|
# my $actor_tile_id=get_tile_id($self,$actor);
|
598 |
|
|
#3- How many traces it transfers?
|
599 |
|
|
|
600 |
|
|
my @injectors= get_all_source_traces_of_actr($self,$actor,'raw');
|
601 |
|
|
|
602 |
|
|
#4- Where does it transffer?
|
603 |
|
|
foreach my $inject (@injectors) {
|
604 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var,$src_port,$dst_port,$buff_size,$chanel,$vc,$class
|
605 |
|
|
)=get_trace($self,'raw',$inject);
|
606 |
|
|
|
607 |
|
|
$vc= 0 if(!defined $vc);
|
608 |
|
|
$class= 0 if(!defined $class);
|
609 |
|
|
|
610 |
|
|
#my $dst_tile = $self->object_get_attribute("MAP_TILE",$dst_actor);
|
611 |
|
|
my $dst_actor=$self->get_item_group_name('grouping',$dst);
|
612 |
|
|
my $dst_tile = get_task_give_tile($self,$dst_actor);
|
613 |
|
|
#my $dst_tile_id=get_tile_id($self,$dst_actor);
|
614 |
|
|
my $dst_tile_id=tile_id_number($dst_tile);
|
615 |
|
|
|
616 |
|
|
|
617 |
|
|
if($dst_tile eq $actor_tile){
|
618 |
|
|
# this trace is connected locally in one tile
|
619 |
|
|
#my $rr="\t\t${dst}_$dst_port->read_inds[$chanel]= ${src}_${src_port}->write_ind;\n";
|
620 |
|
|
#$actor_local_connect=(defined $actor_local_connect)? $actor_local_connect.$rr:$rr;
|
621 |
|
|
next;
|
622 |
|
|
}
|
623 |
|
|
|
624 |
|
|
#5-Now generate all transfer functions (add inject ports)
|
625 |
|
|
#my ($net,$num,$name)=split(':',$actor);
|
626 |
|
|
#print "dstp_number{$dst}{$dst_port}= $dstp_number{$dst}{$dst_port};\n";
|
627 |
|
|
|
628 |
|
|
my $srcportnum = get_port_num($self,\%srcp_number,$src,$src_port,$chanel);
|
629 |
|
|
my $dstportnum = get_port_num($self,\%dstp_number,$dst,$dst_port);
|
630 |
|
|
|
631 |
|
|
|
632 |
|
|
if(!defined $dstportnum){
|
633 |
|
|
print Dumper (\$self);
|
634 |
|
|
print Dumper (\%dstp_number);
|
635 |
|
|
print "my $dstportnum = get_port_num($self,\%dstp_number,$dst,$dst_port);\n";
|
636 |
|
|
print "***********************fix me**********\n";
|
637 |
|
|
exit();
|
638 |
|
|
}
|
639 |
|
|
|
640 |
|
|
|
641 |
|
|
|
642 |
|
|
if($chanel==0){
|
643 |
|
|
$Hw_fifo_define=$Hw_fifo_define."
|
644 |
|
|
// transfer ${src_port} port definitions:
|
645 |
|
|
#define ${src_port}_w $init_weight
|
646 |
|
|
#define ${src_port}_v $vc
|
647 |
|
|
#define ${src_port}_class_num $class
|
648 |
|
|
#define ${src_port}_queue_pointer (unsigned int)&tokens_${src_port}[0]
|
649 |
|
|
#define ${src_port}_queue_size_in_byte (SIZE_${src_port} << ${actor}_${src_port}_size_shift)
|
650 |
|
|
#define ${src_port}_end_index index_${src_port}
|
651 |
|
|
|
652 |
|
|
";
|
653 |
|
|
|
654 |
|
|
#$actor_init.="\t${actor}_${src_port}->write_ind=0;\n";
|
655 |
|
|
|
656 |
|
|
}
|
657 |
|
|
|
658 |
|
|
$Hw_fifo_define=$Hw_fifo_define."
|
659 |
|
|
// ${src_port} read chanel ${chanel} definition
|
660 |
|
|
#define ${src_port}_ch${chanel}_dest_port_num $dstportnum
|
661 |
|
|
#define ${src_port}_ch${chanel}_dest_phy_addr PHY_ADDR_ENDP_${dst_tile_id}
|
662 |
|
|
#define ${src_port}_ch${chanel}_src_port_num $srcportnum
|
663 |
|
|
#define ${src_port}_ch${chanel}_start_index ${actor}_${src_port}->read_inds[$chanel]
|
664 |
|
|
#define ${src_port}_ch${chanel}_start_index_in_byte ((${src_port}_ch${chanel}_start_index % SIZE_${src_port}) << ${actor}_${src_port}_size_shift)
|
665 |
|
|
#define ${src_port}_ch${chanel}_has_data_to_send (${src_port}_end_index > ${src_port}_ch${chanel}_start_index)
|
666 |
|
|
#define ${src_port}_ch${chanel}_data_to_send_size (${src_port}_end_index - ${src_port}_ch${chanel}_start_index)
|
667 |
|
|
#define ${src_port}_ch${chanel}_send_data_size_in_byte (${src_port}_ch${chanel}_data_to_send_size << ${actor}_${src_port}_size_shift)
|
668 |
|
|
|
669 |
|
|
|
670 |
|
|
static unsigned int ${src_port}_ch${chanel}_credit = ${src_port}_queue_size_in_byte;
|
671 |
|
|
static unsigned int ${src_port}_ch${chanel}_send_data;
|
672 |
|
|
";
|
673 |
|
|
#$actor_init.="\t${src_port}_ch${chanel}_credit = ${src_port}_queue_size_in_byte;\n";
|
674 |
|
|
|
675 |
|
|
#$actor_init.="\t${actor}_${src_port}->read_inds[$chanel]=0;\n";
|
676 |
|
|
|
677 |
|
|
$transfer_str=$transfer_str."
|
678 |
|
|
if(${src_port}_ch${chanel}_has_data_to_send){
|
679 |
|
|
// if the sent vc is not busy and the sent_done_isr is not asserted sent a new packet
|
680 |
|
|
if(${ni_name}_send_is_free(${src_port}_v) && (oport_array[${src_port}_v]==255) ){ //(${ni_name}_packet_is_sent(${src_port}_v)==0)) {
|
681 |
|
|
|
682 |
|
|
//ask NI to transfer the data
|
683 |
|
|
if(transfer_manage (${src_port}_w, ${src_port}_v, ${src_port}_class_num,${src_port}_ch${chanel}_dest_port_num , ${src_port}_queue_pointer , ${src_port}_queue_size_in_byte,
|
684 |
|
|
${src_port}_ch${chanel}_start_index_in_byte, ${src_port}_ch${chanel}_send_data_size_in_byte, ${src_port}_ch${chanel}_dest_phy_addr, ${src_port}_ch${chanel}_credit,${src_port}_ch${chanel}_src_port_num, & ${src_port}_ch${chanel}_send_data, & ${src_port}_ch${chanel}_credit )){
|
685 |
|
|
|
686 |
|
|
}
|
687 |
|
|
}//has data
|
688 |
|
|
}//not busy
|
689 |
|
|
";
|
690 |
|
|
|
691 |
|
|
$actor_sent_pck_done_func=$actor_sent_pck_done_func."
|
692 |
|
|
|
693 |
|
|
if(oport == ${src_port}_ch${chanel}_src_port_num){
|
694 |
|
|
${src_port}_ch${chanel}_start_index= ${src_port}_ch${chanel}_start_index+ (${src_port}_ch${chanel}_send_data>>${actor}_${src_port}_size_shift);
|
695 |
|
|
#ifdef ORCC_DEBUG_EN
|
696 |
|
|
if (${src_port}_ch${chanel}_data_to_send_size > SIZE_${src_port}){
|
697 |
|
|
printf (\"Error the waiting data in ${actor} ${src_port} quque (\%u) is larger than the queue size (\%u)\\n\",${src_port}_ch${chanel}_data_to_send_size,SIZE_${src_port} );
|
698 |
|
|
}
|
699 |
|
|
#endif
|
700 |
|
|
return 1;
|
701 |
|
|
}
|
702 |
|
|
|
703 |
|
|
";
|
704 |
|
|
|
705 |
|
|
$actor_update_credit =$actor_update_credit."
|
706 |
|
|
if( credit_port == ${src_port}_ch${chanel}_src_port_num){
|
707 |
|
|
${src_port}_ch${chanel}_credit += (credit_value << ${actor}_${src_port}_size_shift); //credit value in byte
|
708 |
|
|
#ifdef ORCC_DEBUG_EN
|
709 |
|
|
if (${src_port}_ch${chanel}_credit > (SIZE_${src_port} << ${actor}_${src_port}_size_shift )){
|
710 |
|
|
printf (\"Error the credit counter in ${actor} ${src_port}_ch${chanel} (\%u) is larger than the queue size (\%u)\\n\",${src_port}_ch${chanel}_credit,SIZE_${src_port} );
|
711 |
|
|
}
|
712 |
|
|
#endif
|
713 |
|
|
return 1;
|
714 |
|
|
}
|
715 |
|
|
";
|
716 |
|
|
|
717 |
|
|
}# end inject
|
718 |
|
|
|
719 |
|
|
|
720 |
|
|
|
721 |
|
|
|
722 |
|
|
#6-Where the packet comes from? we need to update the sender with the remaining credit
|
723 |
|
|
my @sinkers = get_all_dest_traces_of_actr ($self,$actor,'raw');
|
724 |
|
|
foreach my $sink (@sinkers){
|
725 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var,$src_port,$dst_port,$buff_size,$chanel,$vc,$class
|
726 |
|
|
)=get_trace($self,'raw',$sink);
|
727 |
|
|
|
728 |
|
|
my $dst_chnl =get_dest_chanel_from_orcc_file($actor_file,$actor,$dst_port);
|
729 |
|
|
|
730 |
|
|
my $srcportnum = get_port_num($self,\%srcp_number,$src,$src_port,$chanel);
|
731 |
|
|
my $src_actor=$self->get_item_group_name('grouping',$src);
|
732 |
|
|
my $src_tile = get_task_give_tile($self,$src_actor);
|
733 |
|
|
#my $src_tile_id=get_tile_id($self,$src);
|
734 |
|
|
my $src_tile_id=tile_id_number($src_tile);
|
735 |
|
|
|
736 |
|
|
#print "my $srcportnum = get_port_num($self,\%srcp_number,$src,$src_port,$chanel);\n";
|
737 |
|
|
|
738 |
|
|
if($src_tile eq $actor_tile){
|
739 |
|
|
|
740 |
|
|
next;
|
741 |
|
|
}
|
742 |
|
|
|
743 |
|
|
if(!defined $srcportnum){
|
744 |
|
|
print Dumper (\$self);
|
745 |
|
|
print Dumper (\%srcp_number);
|
746 |
|
|
print "my $srcportnum = get_port_num($self,\%srcp_number,$src,$src_port,$chanel);\n";
|
747 |
|
|
print "***********************fix me**********\n";
|
748 |
|
|
exit();
|
749 |
|
|
}
|
750 |
|
|
|
751 |
|
|
#7 We need to add sink ports
|
752 |
|
|
#save the input port index before running the credit
|
753 |
|
|
#$actor_init.=\t${actor}_${dst_port}->read_inds[0]=0;
|
754 |
|
|
#$actor_init.=\t${actor}_${dst_port}->write_ind=0;
|
755 |
|
|
|
756 |
|
|
$actor_init =$actor_init."
|
757 |
|
|
\tread_${dst_port}();
|
758 |
|
|
\tindex_${dst_port}_sender=index_$dst_port;
|
759 |
|
|
";
|
760 |
|
|
|
761 |
|
|
my $dstportnum = get_port_num($self,\%dstp_number,$dst,$dst_port);
|
762 |
|
|
$max_dst_port_num=$dstportnum if($dstportnum > $max_dst_port_num );
|
763 |
|
|
|
764 |
|
|
$Hw_fifo_define=$Hw_fifo_define."
|
765 |
|
|
// Receiver port ${dst_port} port definitions:
|
766 |
|
|
static unsigned int index_${dst_port}_sender;
|
767 |
|
|
|
768 |
|
|
#define ${dst_port}_credit_w 1
|
769 |
|
|
#define ${dst_port}_credit_v 0 //Alternatively it can be another VC
|
770 |
|
|
#define ${dst_port}_credit_class_num 0 //Alternatively it can be another class
|
771 |
|
|
#define ${dst_port}_credit_dest_port 0 //0 is reserved for credit
|
772 |
|
|
#define ${dst_port}_credit_pointer (unsigned int)&credit_send_buff
|
773 |
|
|
#define ${dst_port}_credit_size_in_byte 4
|
774 |
|
|
#define ${dst_port}_credit_start_index 0
|
775 |
|
|
#define ${dst_port}_credit_send_data_size_in_byte 4
|
776 |
|
|
#define ${dst_port}_credit_dest_phy_addr PHY_ADDR_ENDP_${src_tile_id}
|
777 |
|
|
#define ${dst_port}_has_credit_to_send (index_$dst_port > index_${dst_port}_sender)
|
778 |
|
|
#define ${dst_port}_src_port_num $srcportnum
|
779 |
|
|
#define ${dst_port}_dst_port_num $dstportnum
|
780 |
|
|
#define ${dst_port}_queu_pointer (unsigned int)&tokens_${dst_port}[0]
|
781 |
|
|
#define ${dst_port}_queue_size_in_byte (SIZE_${dst_port} << ${actor}_${dst_port}_size_shift)
|
782 |
|
|
#define ${dst_port}_start_index_in_byte ((${actor}_${dst_port}->write_ind % SIZE_${dst_port})<< ${actor}_${dst_port}_size_shift)
|
783 |
|
|
#define ${dst_port}_read_indx ${actor}_${dst_port}->read_inds[$dst_chnl]
|
784 |
|
|
#define ${dst_port}_data_num_to_process (${actor}_${dst_port}->write_ind -${dst_port}_read_indx)
|
785 |
|
|
";
|
786 |
|
|
|
787 |
|
|
|
788 |
|
|
$crdit_update=$crdit_update."
|
789 |
|
|
if( ${dst_port}_has_credit_to_send){
|
790 |
|
|
if(${ni_name}_send_is_free(${dst_port}_credit_v) && (oport_array[${dst_port}_credit_v]==255) ){ // (${ni_name}_packet_is_sent(${dst_port}_credit_v)==0)){
|
791 |
|
|
//credit_num = (SIZE_${dst_port} - ${dst_port}_data_num_to_process)& 0xFFFF;
|
792 |
|
|
credit_num = (index_$dst_port - index_${dst_port}_sender)& 0xFFFF;
|
793 |
|
|
credit_send_buff= ( (${dst_port}_src_port_num <<16) | credit_num ); // most significant 16 bits indicates the port, list significant 16 bits are credit in word
|
794 |
|
|
#ifdef ORCC_DEBUG_EN
|
795 |
|
|
if(${dst_port}_data_num_to_process > SIZE_${dst_port}){
|
796 |
|
|
printf(\"Error ${dst_port}_data_num_to_process (\%u) is larger than SIZE_${dst_port} (\%u)\\n\",${dst_port}_data_num_to_process,SIZE_${dst_port});
|
797 |
|
|
}
|
798 |
|
|
#endif
|
799 |
|
|
if( transfer_manage (${dst_port}_credit_w, ${dst_port}_credit_v, ${dst_port}_credit_class_num, ${dst_port}_credit_dest_port, ${dst_port}_credit_pointer, ${dst_port}_credit_size_in_byte, ${dst_port}_credit_start_index, ${dst_port}_credit_send_data_size_in_byte, ${dst_port}_credit_dest_phy_addr, 5,${dst_port}_credit_dest_port, &tmp1,&tmp2 ) ){
|
800 |
|
|
index_${dst_port}_sender=index_${dst_port};
|
801 |
|
|
}
|
802 |
|
|
}
|
803 |
|
|
}
|
804 |
|
|
";
|
805 |
|
|
|
806 |
|
|
$actor_got_pck_func=$actor_got_pck_func."
|
807 |
|
|
if (iport == ${dst_port}_dst_port_num){
|
808 |
|
|
${ni_name}_receive (v, ${dst_port}_queu_pointer , ${dst_port}_queue_size_in_byte, ${dst_port}_start_index_in_byte);
|
809 |
|
|
return 1;
|
810 |
|
|
}
|
811 |
|
|
";
|
812 |
|
|
|
813 |
|
|
$actor_check_pck_func =$actor_check_pck_func."
|
814 |
|
|
if(iport==${dst_port}_dst_port_num){
|
815 |
|
|
${actor}_${dst_port}->write_ind = ${actor}_${dst_port}->write_ind + (size >> ${actor}_${dst_port}_size_shift);
|
816 |
|
|
#ifdef ORCC_DEBUG_EN
|
817 |
|
|
unsigned int diff = ${actor}_${dst_port}->write_ind - ${dst_port}_read_indx;
|
818 |
|
|
if(diff > SIZE_${dst_port})\{
|
819 |
|
|
printf (\"Error in ${actor}_${dst_port}: Write_index(\%u) - Read_index(\%u) is larger than queue size (\%u)\\n\",${actor}_${dst_port}->write_ind , ${dst_port}_read_indx,SIZE_${dst_port});
|
820 |
|
|
}
|
821 |
|
|
#endif
|
822 |
|
|
return 1;
|
823 |
|
|
}
|
824 |
|
|
";
|
825 |
|
|
|
826 |
|
|
|
827 |
|
|
|
828 |
|
|
|
829 |
|
|
|
830 |
|
|
|
831 |
|
|
#print "\$fifos{\"$name\"}{'file'}=$file_name\n";
|
832 |
|
|
#print "\$fifos ${name}_${dst_port}'size'=$buff_size;\n";
|
833 |
|
|
|
834 |
|
|
|
835 |
|
|
|
836 |
|
|
} #sink
|
837 |
|
|
|
838 |
|
|
|
839 |
|
|
|
840 |
|
|
|
841 |
|
|
$actor_h=$actor_h."void ${actor}_initialize(schedinfo_t *);\n";
|
842 |
|
|
$actor_h=$actor_h."void ${actor}_scheduler(schedinfo_t *);\n";
|
843 |
|
|
|
844 |
|
|
$actor_h=$actor_h."char ${actor}_got_packet_function(unsigned char , unsigned int);\n";
|
845 |
|
|
$all_got_packet_function=$all_got_packet_function."\t\t\t\t${actor}_got_packet_function(iport,i);\n";
|
846 |
|
|
$actor_got_pck_func=$actor_got_pck_func."
|
847 |
|
|
#ifdef ORCC_DEBUG_EN
|
848 |
|
|
printf(\"Wrong got pck port \%u\\n\",iport);
|
849 |
|
|
#endif
|
850 |
|
|
return 0;
|
851 |
|
|
}
|
852 |
|
|
";
|
853 |
|
|
|
854 |
|
|
$actor_h=$actor_h."char ${actor}_check_packet_function(unsigned char,unsigned int);\n";
|
855 |
|
|
$all_check_packet_function = $all_check_packet_function."\t\t\t\t${actor}_check_packet_function(iport,size);\n";
|
856 |
|
|
$actor_check_pck_func=$actor_check_pck_func."
|
857 |
|
|
#ifdef ORCC_DEBUG_EN
|
858 |
|
|
printf(\"Wrong check pck port \%u\\n\",iport);
|
859 |
|
|
#endif
|
860 |
|
|
return 0;
|
861 |
|
|
}
|
862 |
|
|
";
|
863 |
|
|
$actor_h=$actor_h."char ${actor}_sent_packet_done_function(unsigned char);\n";
|
864 |
|
|
$all_sent_packet_done_function = $all_sent_packet_done_function."\t\t\t\t${actor}_sent_packet_done_function(oport);\n";
|
865 |
|
|
$actor_sent_pck_done_func=$actor_sent_pck_done_func."
|
866 |
|
|
#ifdef ORCC_DEBUG_EN
|
867 |
|
|
printf(\"Wrong sent done port \%u\\n\",oport);
|
868 |
|
|
#endif
|
869 |
|
|
return 0;
|
870 |
|
|
}
|
871 |
|
|
";
|
872 |
|
|
$actor_h=$actor_h."char ${actor}_update_credit(unsigned int, unsigned int);\n";
|
873 |
|
|
$all_update_credit=$all_update_credit."\t\t\t\t${actor}_update_credit(credit_port,credit_value);\n";
|
874 |
|
|
$actor_update_credit =$actor_update_credit."
|
875 |
|
|
#ifdef ORCC_DEBUG_EN
|
876 |
|
|
printf(\"Wrong ${actor} Credit port \%u\\n\",credit_port);
|
877 |
|
|
#endif
|
878 |
|
|
return 0;
|
879 |
|
|
}
|
880 |
|
|
";
|
881 |
|
|
$actor_h=$actor_h."void ${actor}_init_actor(schedinfo_t *);\n";
|
882 |
|
|
$all_init_actor=$all_init_actor."\t${actor}_init_actor(&si);\n";
|
883 |
|
|
$actor_init=$actor_init."
|
884 |
|
|
|
885 |
|
|
${actor}_initialize(si);
|
886 |
|
|
|
887 |
|
|
}
|
888 |
|
|
";
|
889 |
|
|
|
890 |
|
|
$actor_h=$actor_h."void ${actor}_run_actor(schedinfo_t *);\n";
|
891 |
|
|
$all_run_actor=$all_run_actor."\t\t${actor}_run_actor(&si);\n";
|
892 |
|
|
#$all_run_actor=$all_run_actor.$actor_local_connect if(defined $actor_local_connect);
|
893 |
|
|
|
894 |
|
|
my $t = (length $crdit_update > 10 )? "unsigned int tmp1,tmp2,credit_num,credit_send_buff;" : "";
|
895 |
|
|
|
896 |
|
|
my $actor_run="
|
897 |
|
|
void ${actor}_run_actor (schedinfo_t * si) {
|
898 |
|
|
|
899 |
|
|
//unsigned int credit_send_buff;
|
900 |
|
|
|
901 |
|
|
//run schedular
|
902 |
|
|
|
903 |
|
|
|
904 |
|
|
$schedul
|
905 |
|
|
|
906 |
|
|
//check if input ports have credit update to send
|
907 |
|
|
$t
|
908 |
|
|
$crdit_update
|
909 |
|
|
|
910 |
|
|
//check if output port has data to send
|
911 |
|
|
$transfer_str
|
912 |
|
|
|
913 |
|
|
#if (ORCC_SENT_DONT_INT_EN == 0)
|
914 |
|
|
if(${ni_name}_any_sent_done_isr_is_asserted()) sent_packet_done_function();
|
915 |
|
|
#endif
|
916 |
|
|
|
917 |
|
|
#if (ORCC_SAVE_DONT_INT_EN == 0)
|
918 |
|
|
if(${ni_name}_any_save_done_isr_is_asserted()) check_packet_function();
|
919 |
|
|
#endif
|
920 |
|
|
|
921 |
|
|
#if (ORCC_GOT_PCK_INT_EN == 0)
|
922 |
|
|
if(${ni_name}_any_got_pck_isr_is_asserted()) got_packet_function();
|
923 |
|
|
#endif
|
924 |
|
|
|
925 |
|
|
#if (ORCC_GOT_ERR_INT_EN == 0)
|
926 |
|
|
if(${ni_name}_any_err_isr_is_asserted()) error_handling_function();
|
927 |
|
|
#endif
|
928 |
|
|
|
929 |
|
|
}
|
930 |
|
|
";
|
931 |
|
|
|
932 |
|
|
|
933 |
|
|
|
934 |
|
|
|
935 |
|
|
|
936 |
|
|
my $r;
|
937 |
|
|
|
938 |
|
|
add_colored_info($tview,"actor name: $actor\n",'green');
|
939 |
|
|
|
940 |
|
|
|
941 |
|
|
|
942 |
|
|
#copy orcc lib files
|
943 |
|
|
|
944 |
|
|
my $orcc_lib_dir = get_project_dir()."/mpsoc/src_c/orcc/lib";
|
945 |
|
|
opendir(DIR,"$orcc_lib_dir") or $r= "$!\n";
|
946 |
|
|
if(defined $r) {
|
947 |
|
|
add_colored_info($tview,"cannot open directory: $r",'red');
|
948 |
|
|
return;
|
949 |
|
|
}
|
950 |
|
|
foreach my $name (readdir(DIR))
|
951 |
|
|
{
|
952 |
|
|
# add_colored_info($tview,"copy ($orcc_lib_dir/$name,$target_dir/sw/tile${actor_tile_id}/);\n ",'red');
|
953 |
|
|
copy ("$orcc_lib_dir/$name","$target_orccdir/");
|
954 |
|
|
}
|
955 |
|
|
|
956 |
|
|
|
957 |
|
|
|
958 |
|
|
|
959 |
|
|
|
960 |
|
|
|
961 |
|
|
|
962 |
|
|
#print $fe "orcc/$fname.c ";
|
963 |
|
|
#$main_include=$main_include."#include \"orcc/$fname.c\"\n";
|
964 |
|
|
$main_include=$main_include."#include \"orcc/$fname.h\"\n";
|
965 |
|
|
|
966 |
|
|
$src_lib="$src_lib orcc/$fname.c";
|
967 |
|
|
|
968 |
|
|
print $fc " // Generated from $actor_file\n";
|
969 |
|
|
my $defines="";
|
970 |
|
|
my $pval = $self->object_get_attribute("map_param","add_debug");
|
971 |
|
|
$defines .= ($pval eq '1\'b1')? "#define ORCC_DEBUG_EN\n" : "";
|
972 |
|
|
$pval = $self->object_get_attribute("map_param","sent_int");
|
973 |
|
|
$defines .= ($pval eq '1\'b1')? "#define ORCC_SENT_DONT_INT_EN 1\n" : "#define ORCC_SENT_DONT_INT_EN 0\n";
|
974 |
|
|
$pval = $self->object_get_attribute("map_param","receive_int");
|
975 |
|
|
$defines .= ($pval eq '1\'b1')? "#define ORCC_SAVE_DONT_INT_EN 1\n" : "#define ORCC_SAVE_DONT_INT_EN 0\n";
|
976 |
|
|
$pval = $self->object_get_attribute("map_param","receive_int");
|
977 |
|
|
$defines .= ($pval eq '1\'b1')? "#define ORCC_GOT_PCK_INT_EN 1\n" : "#define ORCC_GOT_PCK_INT_EN 0\n";
|
978 |
|
|
$pval = $self->object_get_attribute("map_param","got_err_int");
|
979 |
|
|
$defines .= ($pval eq '1\'b1')? "#define ORCC_GOT_ERR_INT_EN 1\n" : "#define ORCC_GOT_ERR_INT_EN 0\n";
|
980 |
|
|
|
981 |
|
|
|
982 |
|
|
|
983 |
|
|
print $fc "
|
984 |
|
|
#include <stddef.h>
|
985 |
|
|
#include \"../$soc_name.h\"
|
986 |
|
|
#include \"orcc_lib.h\"
|
987 |
|
|
#include \"../../phy_addr.h\"
|
988 |
|
|
#include \"$fname.h\"
|
989 |
|
|
|
990 |
|
|
|
991 |
|
|
extern volatile unsigned char oport_array [${ni_name}_NUM_VCs];
|
992 |
|
|
|
993 |
|
|
";
|
994 |
|
|
|
995 |
|
|
|
996 |
|
|
|
997 |
|
|
my $origen_def="";
|
998 |
|
|
my $origen_fuctions="";
|
999 |
|
|
|
1000 |
|
|
|
1001 |
|
|
#read actor file name and remove unnecessarily codes. comment every files start with #include and extern
|
1002 |
|
|
open my $fh, "<", $actor_file or $r = "$!\n";
|
1003 |
|
|
if(defined $r) {
|
1004 |
|
|
add_colored_info($tview,"Could not open $actor_file: $r",'red');
|
1005 |
|
|
return;
|
1006 |
|
|
}
|
1007 |
|
|
while (my $line = <$fh>) {
|
1008 |
|
|
chomp $line;
|
1009 |
|
|
#search for fifo size inside the file
|
1010 |
|
|
if( $line =~ /^\s*#define\s+SIZE_\w+/){
|
1011 |
|
|
#example: #define SIZE_operand_1 32
|
1012 |
|
|
my $text = $line;
|
1013 |
|
|
$text =~ s/\s+/ /g; # remove extra spaces
|
1014 |
|
|
$text =~ s/^\s+//; #ltrim
|
1015 |
|
|
my ($fifo_name,$size) = sscanf("#define SIZE_%s %u",$text);
|
1016 |
|
|
$actor_h = $actor_h."#define SIZE_${actor}_$fifo_name $size\n";
|
1017 |
|
|
$fifos{"${actor}_$fifo_name"}{'size'}=$size;
|
1018 |
|
|
}
|
1019 |
|
|
|
1020 |
|
|
|
1021 |
|
|
$line = '//'.$line if( $line =~ /^\s*#include/); # comment every line start with #include
|
1022 |
|
|
if( $line =~ /^\s*extern\s+/){
|
1023 |
|
|
my $extern=0;
|
1024 |
|
|
$line =~ s/\s+/ /g; # remove extra spaces
|
1025 |
|
|
$line =~ s/^\s+//; #ltrim
|
1026 |
|
|
|
1027 |
|
|
#fifo
|
1028 |
|
|
my ($type,$fifo_name) = sscanf("extern fifo_%s_t *%s;",$line);
|
1029 |
|
|
if(defined $type){
|
1030 |
|
|
$extern=1;
|
1031 |
|
|
if (defined $fifos{$fifo_name}){
|
1032 |
|
|
#add fifo definition:
|
1033 |
|
|
my $size = $fifos{$fifo_name}{'size'};
|
1034 |
|
|
#if(!defined $size ){
|
1035 |
|
|
$size = "$fifo_name";
|
1036 |
|
|
#$size=~ s/^\s*${actor}_//g;
|
1037 |
|
|
$size = "SIZE_$size";
|
1038 |
|
|
#}
|
1039 |
|
|
|
1040 |
|
|
my $fnum = $fifos{"$fifo_name"}{'fifo_num'};
|
1041 |
|
|
my $ch_num= $fifos{"$fifo_name"}{'chanel_num'};
|
1042 |
|
|
$ch_num =1 if(!defined $ch_num);
|
1043 |
|
|
|
1044 |
|
|
my $src_fifo_name= $self->object_get_attribute("locally_connected","$fifo_name");
|
1045 |
|
|
#printf "$src_fifo_name locally connected $fifo_name\n";
|
1046 |
|
|
|
1047 |
|
|
unless (defined $src_fifo_name){#check if destintion port is not localy connected
|
1048 |
|
|
|
1049 |
|
|
$main_fifo_def=$main_fifo_def . "DECLARE_FIFO(${type}, $size, $fnum, $ch_num);\n";
|
1050 |
|
|
}
|
1051 |
|
|
$main_fifo_assign=$main_fifo_assign . "fifo_${type}_t *$fifo_name = &fifo_$fnum;\n";
|
1052 |
|
|
$main_fifo_rst_ptr.="\t${fifo_name}->write_ind=0;\n";
|
1053 |
|
|
for (my $c=0; $c<$ch_num; $c++){
|
1054 |
|
|
$main_fifo_rst_ptr.="\t${fifo_name}->read_inds[$c]=0;\n"
|
1055 |
|
|
}
|
1056 |
|
|
|
1057 |
|
|
$origen_fuctions= $origen_fuctions . "$line \n";
|
1058 |
|
|
|
1059 |
|
|
#$main_fifo_rst_ptr.="\t printf(\"${fifo_name}_addr=%u\\n\", &${fifo_name}->contents[0]);\n";
|
1060 |
|
|
|
1061 |
|
|
my $shift =
|
1062 |
|
|
($type eq "i8" || $type eq "u8") ? 0 :
|
1063 |
|
|
($type eq "i16" || $type eq "u16") ? 1 :
|
1064 |
|
|
($type eq "i32" || $type eq "u32") ? 2 :
|
1065 |
|
|
($type eq "i64" || $type eq "u64") ? 3 : "undef_type check orcc.pl";
|
1066 |
|
|
|
1067 |
|
|
$origen_def=$origen_def. "#define ${fifo_name}_size_shift $shift \n";
|
1068 |
|
|
|
1069 |
|
|
|
1070 |
|
|
|
1071 |
|
|
}else{
|
1072 |
|
|
print Dumper(\%fifos);
|
1073 |
|
|
add_colored_info($tview,"Could not find $fifo_name in csv file\n",'red');
|
1074 |
|
|
return;
|
1075 |
|
|
}
|
1076 |
|
|
}
|
1077 |
|
|
|
1078 |
|
|
#connection_t
|
1079 |
|
|
my ($connect_name) = sscanf("extern connection_t %s;",$line);
|
1080 |
|
|
if(defined $connect_name ){
|
1081 |
|
|
$extern=1;
|
1082 |
|
|
$main_def=$main_def . " connection_t $connect_name = {0, 0, 0, 0};// We dont need connection as they are done in hardware. just define to prevent error\n";
|
1083 |
|
|
$origen_fuctions= $origen_fuctions . "$line \n";
|
1084 |
|
|
}
|
1085 |
|
|
|
1086 |
|
|
|
1087 |
|
|
#actor_t
|
1088 |
|
|
my ($actor_name) = sscanf("extern actor_t %s;",$line);
|
1089 |
|
|
if(defined $actor_name ){
|
1090 |
|
|
$extern=1;
|
1091 |
|
|
if (defined $fifos{"$actor_name"}{'file'}){
|
1092 |
|
|
# print "===============================================================\n";
|
1093 |
|
|
#add actor definition
|
1094 |
|
|
#search in network.c file for actor definition
|
1095 |
|
|
my $csv=$fifos{"$actor_name"}{'file'};
|
1096 |
|
|
my ($fname,$path,$suffix) = fileparse("$csv",qr"\..[^.]*$");
|
1097 |
|
|
my $net= "$path/${fname}.c";
|
1098 |
|
|
|
1099 |
|
|
my @lines = get_line_have_string($net,"actor_t $actor_name",$tview);
|
1100 |
|
|
if(defined $lines[0]){
|
1101 |
|
|
|
1102 |
|
|
#print $fd "void ${actor_name}_initialize(schedinfo_t *);\n";
|
1103 |
|
|
#print $fd "void ${actor_name}_scheduler (schedinfo_t *);\n";
|
1104 |
|
|
#print $fd "$lines[0]\n";
|
1105 |
|
|
$origen_fuctions= $origen_fuctions . "$line \n";
|
1106 |
|
|
$actors_str=$actors_str."$lines[0]\n" if($actor_name eq $actor);
|
1107 |
|
|
}
|
1108 |
|
|
|
1109 |
|
|
}
|
1110 |
|
|
|
1111 |
|
|
|
1112 |
|
|
}
|
1113 |
|
|
|
1114 |
|
|
$line= "//$line\n" ; # comment every files start with extern
|
1115 |
|
|
add_colored_info($tview,"The Auto generator does not know how to define this extern definition:\n $line \n",'red') if($extern == 0);
|
1116 |
|
|
$origen_fuctions = $origen_fuctions. "$line\n";
|
1117 |
|
|
}#extern
|
1118 |
|
|
elsif( $line =~ /^\s?#define\s+/){
|
1119 |
|
|
$origen_def=$origen_def. "$line\n";
|
1120 |
|
|
}else{
|
1121 |
|
|
$origen_fuctions = $origen_fuctions. "$line\n";
|
1122 |
|
|
}
|
1123 |
|
|
|
1124 |
|
|
}
|
1125 |
|
|
|
1126 |
|
|
|
1127 |
|
|
|
1128 |
|
|
print $fc "
|
1129 |
|
|
$origen_def
|
1130 |
|
|
|
1131 |
|
|
$Hw_fifo_define
|
1132 |
|
|
|
1133 |
|
|
|
1134 |
|
|
$origen_fuctions
|
1135 |
|
|
|
1136 |
|
|
$actor_got_pck_func
|
1137 |
|
|
|
1138 |
|
|
$actor_update_credit
|
1139 |
|
|
|
1140 |
|
|
$actor_check_pck_func
|
1141 |
|
|
|
1142 |
|
|
$actor_sent_pck_done_func
|
1143 |
|
|
|
1144 |
|
|
|
1145 |
|
|
|
1146 |
|
|
$actor_run
|
1147 |
|
|
|
1148 |
|
|
|
1149 |
|
|
|
1150 |
|
|
$actor_init
|
1151 |
|
|
|
1152 |
|
|
";
|
1153 |
|
|
|
1154 |
|
|
|
1155 |
|
|
close($fc);
|
1156 |
|
|
|
1157 |
|
|
$actor_h.="$defines
|
1158 |
|
|
unsigned int transfer_manage (unsigned int, unsigned int, unsigned int, unsigned char, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned char, unsigned int *, unsigned int *);
|
1159 |
|
|
void got_packet_function(void);
|
1160 |
|
|
void check_packet_function (void);
|
1161 |
|
|
void sent_packet_done_function (void);
|
1162 |
|
|
void error_handling_function (void);
|
1163 |
|
|
#endif
|
1164 |
|
|
";
|
1165 |
|
|
open my $fp, ">$target_actor_header" or $r = "$!\n";
|
1166 |
|
|
if(defined $r) {
|
1167 |
|
|
add_colored_info($tview,"Could not open $target_actor_header to write: $r",'red');
|
1168 |
|
|
return;
|
1169 |
|
|
}
|
1170 |
|
|
print $fp $actor_h;
|
1171 |
|
|
close($fp);
|
1172 |
|
|
|
1173 |
|
|
|
1174 |
|
|
|
1175 |
|
|
}
|
1176 |
|
|
|
1177 |
|
|
|
1178 |
|
|
|
1179 |
|
|
|
1180 |
|
|
|
1181 |
|
|
my $got_pck_func= "
|
1182 |
|
|
void got_packet_function(void){
|
1183 |
|
|
unsigned int i ;
|
1184 |
|
|
unsigned char iport;
|
1185 |
|
|
for (i=0;i<${ni_name}_NUM_VCs;i++){
|
1186 |
|
|
if((${ni_name}_got_packet(i)) && (iport_array[i]==255) && ni_receive_is_free(i) ) {
|
1187 |
|
|
|
1188 |
|
|
iport =${ni_name}_RECEIVE_PRECAP_DATA_REG(i);
|
1189 |
|
|
iport_array[i]=iport;
|
1190 |
|
|
if(iport==0){ //a credit update packet is recived;
|
1191 |
|
|
${ni_name}_receive (i, (unsigned int)& credit_buff[i] , 4, 0);
|
1192 |
|
|
}else{
|
1193 |
|
|
$all_got_packet_function
|
1194 |
|
|
}
|
1195 |
|
|
${ni_name}_ack_got_pck_isr(i);
|
1196 |
|
|
}//If ${ni_name} got packet
|
1197 |
|
|
}//for
|
1198 |
|
|
}// got_packet_function
|
1199 |
|
|
|
1200 |
|
|
";
|
1201 |
|
|
|
1202 |
|
|
|
1203 |
|
|
|
1204 |
|
|
|
1205 |
|
|
my $sent_packet_done_function = "
|
1206 |
|
|
|
1207 |
|
|
void sent_packet_done_function (void){
|
1208 |
|
|
unsigned char oport;
|
1209 |
|
|
unsigned int i;
|
1210 |
|
|
for (i=0;i<${ni_name}_NUM_VCs;i++){
|
1211 |
|
|
if(${ni_name}_packet_is_sent(i)) {
|
1212 |
|
|
oport= oport_array[i];
|
1213 |
|
|
if(oport==0){ // a credit update packet has sent out
|
1214 |
|
|
|
1215 |
|
|
}else{
|
1216 |
|
|
$all_sent_packet_done_function
|
1217 |
|
|
}
|
1218 |
|
|
oport_array[i]=255;
|
1219 |
|
|
${ni_name}_ack_send_done_isr(i);
|
1220 |
|
|
}//If ${ni_name}_packet_is_sent
|
1221 |
|
|
}//for
|
1222 |
|
|
}//sent_packet_done_function
|
1223 |
|
|
|
1224 |
|
|
";
|
1225 |
|
|
|
1226 |
|
|
|
1227 |
|
|
|
1228 |
|
|
my $check_pck_func ="
|
1229 |
|
|
|
1230 |
|
|
void check_packet_function (void){
|
1231 |
|
|
unsigned char iport;
|
1232 |
|
|
unsigned int i ,size ;
|
1233 |
|
|
unsigned int credit_value,credit_port;
|
1234 |
|
|
#ifdef ORCC_DEBUG_EN
|
1235 |
|
|
struct SRC_INFOS src_info;
|
1236 |
|
|
#endif
|
1237 |
|
|
for (i=0;i<${ni_name}_NUM_VCs;i++){
|
1238 |
|
|
if(${ni_name}_packet_is_saved(i)) {
|
1239 |
|
|
|
1240 |
|
|
size=${ni_name}_RECEIVE_DATA_SIZE_REG(i); //size in byte
|
1241 |
|
|
iport= iport_array[i];
|
1242 |
|
|
|
1243 |
|
|
#ifdef ORCC_DEBUG_EN
|
1244 |
|
|
src_info=get_src_info(i);
|
1245 |
|
|
if(iport != src_info.r) printf (\"Error: iport missmatch \%u != \%u \\n\",iport, src_info.r );
|
1246 |
|
|
#endif
|
1247 |
|
|
|
1248 |
|
|
iport_array[i]=255;
|
1249 |
|
|
|
1250 |
|
|
if(iport==0){ // a credit update packet has been received
|
1251 |
|
|
credit_port = credit_buff[i] >> 16; //output port num
|
1252 |
|
|
credit_value = (credit_buff[i] & 0xFFFF); // credit value in word
|
1253 |
|
|
$all_update_credit
|
1254 |
|
|
}else{
|
1255 |
|
|
$all_check_packet_function
|
1256 |
|
|
}
|
1257 |
|
|
${ni_name}_ack_save_done_isr(i);
|
1258 |
|
|
}//If ${ni_name}_packet_is_saved
|
1259 |
|
|
}//for
|
1260 |
|
|
}// check_packet_function
|
1261 |
|
|
|
1262 |
|
|
";
|
1263 |
|
|
|
1264 |
|
|
my $ni_isr='
|
1265 |
|
|
|
1266 |
|
|
/*
|
1267 |
|
|
transfer_manage
|
1268 |
|
|
w: initial weight
|
1269 |
|
|
v: Virtual chanel number
|
1270 |
|
|
class_num: message class number
|
1271 |
|
|
dest_port: destination queue number
|
1272 |
|
|
queue_pointer: address in byte
|
1273 |
|
|
queue_size: queue size in byte
|
1274 |
|
|
start_index: start index byte number
|
1275 |
|
|
end_index: end index byte number
|
1276 |
|
|
dest_phy_addr
|
1277 |
|
|
credit: Number of byte available in destination queue
|
1278 |
|
|
*/
|
1279 |
|
|
|
1280 |
|
|
|
1281 |
|
|
|
1282 |
|
|
unsigned int transfer_manage (unsigned int w, unsigned int v, unsigned int class_num, unsigned char dest_port, unsigned int queue_pointer,unsigned int queue_size,
|
1283 |
|
|
unsigned int start_index, unsigned int send_data_size_in_byte, unsigned int dest_phy_addr,unsigned int credit, unsigned char port_num, unsigned int * sent_dat_size, unsigned int * dest_credit_size){
|
1284 |
|
|
|
1285 |
|
|
|
1286 |
|
|
unsigned int start_addr_pointer;
|
1287 |
|
|
unsigned int data_size=send_data_size_in_byte;
|
1288 |
|
|
';
|
1289 |
|
|
|
1290 |
|
|
$ni_isr=$ni_isr."
|
1291 |
|
|
if (${ni_name}_send_is_busy(v)) return 0 ; // if VC is busy sending previous packet do nothing
|
1292 |
|
|
|
1293 |
|
|
";
|
1294 |
|
|
|
1295 |
|
|
$ni_isr=$ni_isr.'
|
1296 |
|
|
if(credit==0) return 0;
|
1297 |
|
|
if(data_size==0) return 0;
|
1298 |
|
|
start_addr_pointer = queue_pointer + start_index;
|
1299 |
|
|
if(data_size > credit) data_size = credit; // we dont want to send more data than the receiver credit
|
1300 |
|
|
if((start_index + data_size) > queue_size) data_size = queue_size-start_index; // we only send data until end of the queue. The rest will be sent in next round starting from beginning of the queue
|
1301 |
|
|
if(data_size==0) return 0;
|
1302 |
|
|
';
|
1303 |
|
|
|
1304 |
|
|
$ni_isr=$ni_isr."
|
1305 |
|
|
oport_array[v]= port_num; // port_num and data size should be saved before calling transfer function.
|
1306 |
|
|
* sent_dat_size = data_size;
|
1307 |
|
|
* dest_credit_size -= data_size;
|
1308 |
|
|
${ni_name}_transfer (w, v, class_num, dest_port , start_addr_pointer, data_size, dest_phy_addr);
|
1309 |
|
|
return 1;
|
1310 |
|
|
}
|
1311 |
|
|
|
1312 |
|
|
|
1313 |
|
|
|
1314 |
|
|
|
1315 |
|
|
|
1316 |
|
|
|
1317 |
|
|
|
1318 |
|
|
void error_handling_function(){
|
1319 |
|
|
unsigned int i;
|
1320 |
|
|
for (i=0;i<${ni_name}_NUM_VCs;i++){
|
1321 |
|
|
if(${ni_name}_got_buff_ovf(i)) {
|
1322 |
|
|
printf (\"VC%u:The receiver allocated buffer size is smaller than the received packet size in core\%u\\n\",i,COREID);
|
1323 |
|
|
${ni_name}_ack_buff_ovf_isr(i);
|
1324 |
|
|
}
|
1325 |
|
|
if(${ni_name}_got_send_dsize_err(i)) {
|
1326 |
|
|
printf (\"VC%u:The send data size is not set in core\%u\\n\",i,COREID);
|
1327 |
|
|
${ni_name}_ack_send_dsize_err_isr(i);
|
1328 |
|
|
}
|
1329 |
|
|
if(${ni_name}_got_burst_size_err(i)){
|
1330 |
|
|
printf (\"VC%u:The burst size is not set in core\%u\\n\",i,COREID);
|
1331 |
|
|
${ni_name}_ack_burst_size_err_isr(i);
|
1332 |
|
|
}
|
1333 |
|
|
if(${ni_name}_got_invalid_send_req(i)){
|
1334 |
|
|
printf( \"VC%u:A new send request is received while the DMA is still busy sending previous packet in core\%u\\n\",i,COREID);
|
1335 |
|
|
${ni_name}_ack_invalid_send_req_isr(i);
|
1336 |
|
|
}
|
1337 |
|
|
if(${ni_name}_got_crc_mismatch(i)){
|
1338 |
|
|
printf( \"VC%u:CRC miss-matched in core\%u\\n\",i,COREID);
|
1339 |
|
|
${ni_name}_ack_crc_mismatch_isr(i);
|
1340 |
|
|
}
|
1341 |
|
|
}//for
|
1342 |
|
|
}//error_handle
|
1343 |
|
|
|
1344 |
|
|
|
1345 |
|
|
|
1346 |
|
|
|
1347 |
|
|
|
1348 |
|
|
void ${ni_name}_isr(void){
|
1349 |
|
|
//place your interrupt code here
|
1350 |
|
|
#if (ORCC_GOT_ERR_INT_EN == 1)
|
1351 |
|
|
if(${ni_name}_any_err_isr_is_asserted() ){
|
1352 |
|
|
// An error ocure
|
1353 |
|
|
error_handling_function();
|
1354 |
|
|
}
|
1355 |
|
|
#endif
|
1356 |
|
|
|
1357 |
|
|
#if (ORCC_SENT_DONT_INT_EN == 1)
|
1358 |
|
|
if( ${ni_name}_any_sent_done_isr_is_asserted() ){
|
1359 |
|
|
//check which VC has finished sending the packet.
|
1360 |
|
|
sent_packet_done_function();
|
1361 |
|
|
}
|
1362 |
|
|
#endif
|
1363 |
|
|
|
1364 |
|
|
#if (ORCC_GOT_PCK_INT_EN == 1 || ORCC_SAVE_DONT_INT_EN ==1)
|
1365 |
|
|
// regardless of ORCC_SAVE_DONT_INT_EN we need to check if the fifo pointer has been updated with last packet data size before sending save command for new packet to NI.
|
1366 |
|
|
if( ${ni_name}_any_save_done_isr_is_asserted()){
|
1367 |
|
|
//check which VC has finished saving the packet. This function must be called before got_packet_function
|
1368 |
|
|
check_packet_function();
|
1369 |
|
|
}
|
1370 |
|
|
#endif
|
1371 |
|
|
|
1372 |
|
|
#if (ORCC_GOT_PCK_INT_EN == 1)
|
1373 |
|
|
if(${ni_name}_any_got_pck_isr_is_asserted() ){
|
1374 |
|
|
//check which VC got packet
|
1375 |
|
|
got_packet_function();
|
1376 |
|
|
}
|
1377 |
|
|
#endif
|
1378 |
|
|
|
1379 |
|
|
|
1380 |
|
|
|
1381 |
|
|
return;
|
1382 |
|
|
}
|
1383 |
|
|
|
1384 |
|
|
";
|
1385 |
|
|
|
1386 |
|
|
|
1387 |
|
|
my $v_val= $self->object_get_attribute('noc_param','V');
|
1388 |
|
|
my $opr ='';
|
1389 |
|
|
for (my $i=0;$i<$v_val; $i++){
|
1390 |
|
|
$opr = $opr."\toport_array[$i]=255;\n";
|
1391 |
|
|
$opr = $opr."\tiport_array[$i]=255;\n";
|
1392 |
|
|
}
|
1393 |
|
|
|
1394 |
|
|
$main_fifo_rst_ptr.=
|
1395 |
|
|
"$opr
|
1396 |
|
|
}\n";
|
1397 |
|
|
|
1398 |
|
|
|
1399 |
|
|
my $main="
|
1400 |
|
|
int main(){
|
1401 |
|
|
schedinfo_t si;
|
1402 |
|
|
reset_all_fifo_ptr();
|
1403 |
|
|
$all_init_actor
|
1404 |
|
|
general_int_init();
|
1405 |
|
|
general_int_add(${ni_name}_INT_PIN, ${ni_name}_isr, 0); //${ni_name}_INT_PIN
|
1406 |
|
|
// Enable ${ni_name} interrupt (its connected to interrupt pin 0)
|
1407 |
|
|
general_int_enable(${ni_name}_INT_PIN);
|
1408 |
|
|
general_cpu_int_en();
|
1409 |
|
|
// hw interrupt enable function:
|
1410 |
|
|
// ${ni_name}_initial (burst_size, errors_int_en, send_int_en, save_int_en, got_pck_int_en)
|
1411 |
|
|
${ni_name}_initial (16,ORCC_GOT_ERR_INT_EN,ORCC_SENT_DONT_INT_EN,ORCC_SAVE_DONT_INT_EN,ORCC_GOT_PCK_INT_EN);
|
1412 |
|
|
|
1413 |
|
|
delay(100);
|
1414 |
|
|
while(1){
|
1415 |
|
|
$all_run_actor
|
1416 |
|
|
}
|
1417 |
|
|
return 0;
|
1418 |
|
|
}
|
1419 |
|
|
|
1420 |
|
|
";
|
1421 |
|
|
|
1422 |
|
|
my $log2=log2($max_dst_port_num +1);
|
1423 |
|
|
|
1424 |
|
|
print $fd "
|
1425 |
|
|
$main_include
|
1426 |
|
|
|
1427 |
|
|
#define MAX_DST_PORT_NUM $max_dst_port_num
|
1428 |
|
|
|
1429 |
|
|
// make sure that the HDATA_PRECAPw widh is >= log2(MAX_DST_PORT_NUM)
|
1430 |
|
|
#if ( $log2 > ${ni_name}_HDATA_PRECAPw )
|
1431 |
|
|
#error \" The value of HDATA_PRECAPw should be defined at least $log2. Open the processing tile generator and increase the NI HDATA_PRECAPw value >= $log2\"
|
1432 |
|
|
#endif
|
1433 |
|
|
|
1434 |
|
|
//make dure Byte_En is asserted in NI
|
1435 |
|
|
#if (${ni_name}_BYTE_EN == 0)
|
1436 |
|
|
#error \" The NI NI BYTE_EN parameter should be set as one for correct data comminication between cores. \"
|
1437 |
|
|
#endif
|
1438 |
|
|
|
1439 |
|
|
|
1440 |
|
|
// a simple delay function
|
1441 |
|
|
|
1442 |
|
|
void delay ( unsigned int num ){
|
1443 |
|
|
|
1444 |
|
|
while (num>0){
|
1445 |
|
|
num--;
|
1446 |
|
|
nop(); // asm volatile (\"nop\");
|
1447 |
|
|
}
|
1448 |
|
|
return;
|
1449 |
|
|
|
1450 |
|
|
}
|
1451 |
|
|
|
1452 |
|
|
|
1453 |
|
|
$actors_str
|
1454 |
|
|
|
1455 |
|
|
$main_fifo_def
|
1456 |
|
|
|
1457 |
|
|
$main_fifo_assign
|
1458 |
|
|
|
1459 |
|
|
$main_fifo_rst_ptr
|
1460 |
|
|
|
1461 |
|
|
$main_def
|
1462 |
|
|
|
1463 |
|
|
|
1464 |
|
|
|
1465 |
|
|
|
1466 |
|
|
$got_pck_func
|
1467 |
|
|
|
1468 |
|
|
$check_pck_func
|
1469 |
|
|
|
1470 |
|
|
$sent_packet_done_function
|
1471 |
|
|
|
1472 |
|
|
$ni_isr
|
1473 |
|
|
|
1474 |
|
|
$main
|
1475 |
|
|
|
1476 |
|
|
";
|
1477 |
|
|
|
1478 |
|
|
|
1479 |
|
|
|
1480 |
|
|
|
1481 |
|
|
close($fd);
|
1482 |
|
|
|
1483 |
|
|
|
1484 |
|
|
|
1485 |
|
|
save_file($src_lib_file,$src_lib);
|
1486 |
|
|
|
1487 |
|
|
|
1488 |
|
|
|
1489 |
|
|
|
1490 |
|
|
add_colored_info($tview,"$main_c file has been created successfully from @actors_file_names file \n",'blue');
|
1491 |
|
|
|
1492 |
|
|
} #actor
|
1493 |
|
|
|
1494 |
|
|
|
1495 |
|
|
#done
|
1496 |
|
|
message_dialog("The source files have been generated successfully");
|
1497 |
|
|
#print Dumper (\$self);
|
1498 |
|
|
} #end sub
|
1499 |
|
|
|
1500 |
|
|
|
1501 |
|
|
|
1502 |
|
|
sub get_line_have_string{
|
1503 |
|
|
my ($file,$str,$tview)=@_;
|
1504 |
|
|
my $r;
|
1505 |
|
|
my @matches;
|
1506 |
|
|
open my $fh, "<", $file or $r = "$!\n";
|
1507 |
|
|
if(defined $r) {
|
1508 |
|
|
add_colored_info($tview,"Could not open $file: $r",'red');
|
1509 |
|
|
return;
|
1510 |
|
|
}
|
1511 |
|
|
while (my $line = <$fh>) {
|
1512 |
|
|
chomp $line;
|
1513 |
|
|
$line =~ s/\s+/ /g; # remove extra spaces
|
1514 |
|
|
$line =~ s/^\s+//; #ltrim
|
1515 |
|
|
if ($line =~ /$str/){
|
1516 |
|
|
push(@matches,$line);
|
1517 |
|
|
}
|
1518 |
|
|
|
1519 |
|
|
}
|
1520 |
|
|
return @matches;
|
1521 |
|
|
}
|
1522 |
|
|
|
1523 |
|
|
sub get_destport_constant_list{
|
1524 |
|
|
my ($self,$category)=@_;
|
1525 |
|
|
my %destport_const;
|
1526 |
|
|
#1- Get list of all actors
|
1527 |
|
|
my @actors= get_all_tasks($self,$category);
|
1528 |
|
|
foreach my $actor (@actors){
|
1529 |
|
|
|
1530 |
|
|
my $i=1;
|
1531 |
|
|
#2- for each actor get the list of all input ports
|
1532 |
|
|
my @sinkers= get_all_dest_traces_of_actr($self,$actor,$category);
|
1533 |
|
|
#3- number each source port of this actor
|
1534 |
|
|
foreach my $sink (@sinkers){
|
1535 |
|
|
|
1536 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var,$src_port,$dst_port,$buff_size,$chanel,$vc,$class
|
1537 |
|
|
)=get_trace($self,$category,$sink);
|
1538 |
|
|
|
1539 |
|
|
$destport_const{$actor}{$dst_port}= $i;
|
1540 |
|
|
#print "destport_const{$actor}{$dst_port}= $i;\n";
|
1541 |
|
|
$i++;
|
1542 |
|
|
}
|
1543 |
|
|
}
|
1544 |
|
|
return %destport_const;
|
1545 |
|
|
}
|
1546 |
|
|
|
1547 |
|
|
|
1548 |
|
|
|
1549 |
|
|
|
1550 |
|
|
sub get_srcport_constant_list{
|
1551 |
|
|
my ($self,$category)=@_;
|
1552 |
|
|
my %srcport_const;
|
1553 |
|
|
#1- Get list of all actors
|
1554 |
|
|
my @actors= get_all_tasks($self,$category);
|
1555 |
|
|
#print "@actors\n**************************************************";
|
1556 |
|
|
foreach my $actor (@actors){
|
1557 |
|
|
|
1558 |
|
|
my $i=1;
|
1559 |
|
|
#2- for each actor get the list of all output ports
|
1560 |
|
|
my @injectors= get_all_source_traces_of_actr($self,$actor,$category);
|
1561 |
|
|
#3- number each source port of this actor
|
1562 |
|
|
foreach my $inject (@injectors){
|
1563 |
|
|
|
1564 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var,$src_port,$dst_port,$buff_size,$chanel,$vc,$class
|
1565 |
|
|
)=get_trace($self,$category,$inject);
|
1566 |
|
|
|
1567 |
|
|
$srcport_const{$actor}{$src_port}{$chanel}= $i;
|
1568 |
|
|
$i++;
|
1569 |
|
|
}
|
1570 |
|
|
}
|
1571 |
|
|
return %srcport_const;
|
1572 |
|
|
}
|
1573 |
|
|
|
1574 |
|
|
|
1575 |
|
|
|
1576 |
|
|
|
1577 |
|
|
|
1578 |
|
|
sub get_all_dest_traces_of_actr{
|
1579 |
|
|
my ($self,$actor,$category)=@_;
|
1580 |
|
|
my @traces =get_trace_list($self,$category);
|
1581 |
|
|
my @sources;
|
1582 |
|
|
foreach my $p (@traces){
|
1583 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var)=get_trace($self,$category,$p);
|
1584 |
|
|
push (@sources,$p) if($dst eq $actor);
|
1585 |
|
|
}
|
1586 |
|
|
return @sources;
|
1587 |
|
|
}
|
1588 |
|
|
|
1589 |
|
|
sub get_all_source_traces_of_actr{
|
1590 |
|
|
my ($self,$actor,$category)=@_;
|
1591 |
|
|
my @traces =get_trace_list($self,$category);
|
1592 |
|
|
my @dests;
|
1593 |
|
|
foreach my $p (@traces){
|
1594 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var)=get_trace($self,$category,$p);
|
1595 |
|
|
push (@dests,$p) if($src eq $actor);
|
1596 |
|
|
}
|
1597 |
|
|
return @dests;
|
1598 |
|
|
}
|
1599 |
|
|
|
1600 |
|
|
sub get_actr_file_name {
|
1601 |
|
|
my ($self,$actor,$category)=@_;
|
1602 |
|
|
my @traces =get_trace_list($self,$category);
|
1603 |
|
|
foreach my $p (@traces){
|
1604 |
|
|
my ($src,$dst, $Mbytes, $file_id, $file_name,$init_weight,$min_pck, $max_pck, $burst, $injct_rate, $injct_rate_var)=get_trace($self,$category,$p);
|
1605 |
|
|
if($src eq $actor || $dst eq $actor){
|
1606 |
|
|
#the actor supposed to be located next to CSV file and have the same file name as actor name
|
1607 |
|
|
my ($fname,$path,$suffix) = fileparse("$file_name",qr"\..[^.]*$");
|
1608 |
|
|
#my ($net,$num,$name)=split(':',$actor);
|
1609 |
|
|
return "$path/${actor}.c";
|
1610 |
|
|
}
|
1611 |
|
|
}
|
1612 |
|
|
return undef;
|
1613 |
|
|
}
|
1614 |
|
|
|
1615 |
|
|
|
1616 |
|
|
|
1617 |
|
|
|
1618 |
|
|
|
1619 |
|
|
|
1620 |
|
|
|
1621 |
|
|
|
1622 |
|
|
|
1623 |
|
|
|
1624 |
|
|
|
1625 |
|
|
|
1626 |
|
|
|
1627 |
|
|
|
1628 |
|
|
|
1629 |
|
|
|
1630 |
|
|
|
1631 |
|
|
1;
|