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/] [mpsoc.pm] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 alirezamon
#! /usr/bin/perl -w
2
use strict;
3 48 alirezamon
use FindBin;
4
use lib $FindBin::Bin;
5 16 alirezamon
 
6
package mpsoc;
7
 
8
use ip_gen;
9
 
10
 
11
#use Clone 'clone';
12
 
13 48 alirezamon
sub uniq {
14
  my %seen;
15
  return grep { !$seen{$_}++ } @_;
16
}
17 16 alirezamon
 
18
 
19
sub mpsoc_new {
20
    # be backwards compatible with non-OO call
21
    my $class = ("ARRAY" eq ref $_[0]) ? "mpsoc" : shift;
22
    my $self;
23
 
24
 
25
    $self = {};
26
    $self->{file_name}        = (); # information on each file
27
    $self->{noc_param}=   {};
28
    $self->{noc_indept_param}={};
29 25 alirezamon
   # $self->{parameters_order}=[];
30
 
31 16 alirezamon
    $self->{setting}={};
32
        $self->{socs}={};
33
        mpsoc_initial_setting($self);
34
 
35
 
36
    bless($self,$class);
37
 
38
 
39
    return $self;
40
}
41
 
42
sub mpsoc_initial_setting{
43
        my $self=shift;
44
        $self->{setting}{show_noc_setting}=1;
45
        $self->{setting}{show_adv_setting}=0;
46
        $self->{setting}{show_tile_setting}=1;
47
        $self->{setting}{soc_path}="lib/soc";
48
}
49
 
50
 
51
 
52
 
53
sub mpsoc_get_instance_info{
54
        my ($self,$ip_num)=@_;
55
        return $self->{ips}{$ip_num}{name}
56
}
57
 
58
sub mpsoc_set_ip_inst_name{
59
        my ($self,$ip_num,$new_instance)=@_;
60
        $self->{ips}{$ip_num}{name}=$new_instance;
61
 
62
}
63
 
64
sub mpsoc_get_soc_list{
65
        my $self=shift;
66
        my @list;
67
        foreach my $p (sort keys %{$self->{socs}}){
68
                push(@list,$p);
69
        }
70
        return @list;
71
}
72
 
73
 
74
 
75
 
76
 
77
sub mpsoc_add_soc{
78
        my ($self,$name,$soc)=@_;
79
        $self->{socs}{$name}{top}=$soc;
80
 
81
}
82
 
83
 
84
 
85
 
86
sub mpsoc_get_soc{
87
        my ($self,$name)=@_;
88
        return $self->{socs}{$name}{top};
89
 
90
}
91
 
92
 
93
sub mpsoc_remove_soc{
94
        my ($self,$name)=@_;
95
        delete $self->{socs}{$name};
96
}
97
 
98 34 alirezamon
sub mpsoc_remove_soc_top{
99
        my ($self,$name)=@_;
100
        delete $self->{socs}{$name}{top};
101
}
102
 
103
 
104
sub mpsoc_remove_all_soc_tops{
105
        my $self=shift;
106
        foreach my $name (sort keys %{$self->{socs}}){
107
                delete $self->{socs}{$name}{top};
108
        }
109
}
110
 
111
 
112 16 alirezamon
sub mpsoc_remove_all_soc{
113
        my ($self)=@_;
114
        delete $self->{socs};
115
}
116
 
117
 
118
 
119
sub mpsoc_add_soc_tiles_num{
120
        my ($self,$name,$nums) =@_;
121
        if(defined $nums){
122
                my @f=sort { $a <=> $b } @{$nums};
123
                if( exists $self->{socs}{$name}){
124
                        $self->{socs}{$name}{tile_nums}=\@f;
125
 
126
                }
127
        }else {
128
                $self->{socs}{$name}{tile_nums}=undef;
129
 
130
        }
131
}
132
 
133
sub mpsoc_get_soc_tiles_num{
134
        my ($self,$name) =@_;
135
        my @nums;
136
        if( defined $self->{socs}{$name}{tile_nums}){
137
                @nums = @{$self->{socs}{$name}{tile_nums}};
138
 
139
        }
140 34 alirezamon
        return @nums;
141 16 alirezamon
}
142
 
143
sub mpsoc_get_scolar_pos{
144
        my ($item,@list)=@_;
145
        my $pos;
146
        my $i=0;
147
        foreach my $c (@list)
148
        {
149
                if(  $c eq $item) {$pos=$i}
150
                $i++;
151
        }
152
        return $pos;
153
}
154
 
155
sub mpsoc_get_tile_soc_name{
156
        my ($self,$tile)=@_;
157
        my @all_socs=mpsoc_get_soc_list($self);
158
        my $soc_num=0;
159
        my $p;
160
        foreach $p( @all_socs){
161
                my @tiles=mpsoc_get_soc_tiles_num ($self,$p);
162
                if ( grep( /^$tile$/, @tiles ) ){
163
                            my $num =mpsoc_get_scolar_pos($tile,@tiles);
164
 
165
                                return ($p,$soc_num,$num);
166
                }
167
                $soc_num++;
168
 
169
        }
170
        return ($p,$soc_num,undef);
171
 
172
}
173
 
174
sub mpsoc_remove_scolar_from_array{
175
        my ($array_ref,$item)=@_;
176
        my @array=@{$array_ref};
177
        my @new;
178
        foreach my $p (@array){
179
                if($p ne $item ){
180
                        push(@new,$p);
181
                }
182
        }
183
        return @new;
184
}
185
 
186
sub mpsoc_set_tile_free{
187
        my ($self,$tile)=@_;
188
        #
189
        mpsoc_set_tile_param_setting($self, $tile, 'Default');
190
        my @all_socs=mpsoc_get_soc_list($self);
191
        my $soc_num=0;
192
        my $p;
193
        foreach $p( @all_socs){
194
                my @tiles=mpsoc_get_soc_tiles_num ($self,$p);
195
                my @n=mpsoc_remove_scolar_from_array(\@tiles,$tile);
196
                mpsoc_add_soc_tiles_num($self,$p,\@n);
197
 
198
        }
199
 
200
}
201
 
202
sub mpsoc_set_tile_soc_name{
203
        my ($self,$tile,$new_soc)=@_;
204
        mpsoc_set_tile_free($self,$tile);
205
        my @tiles=mpsoc_get_soc_tiles_num ($self,$new_soc);
206
        push(@tiles,$tile);
207
        mpsoc_add_soc_tiles_num($self,$new_soc,\@tiles);
208
 
209
 
210
}
211
 
212
sub mpsoc_set_tile_param_setting{
213
        my ($self,$tile,$setting)=@_;
214
        $self->{tile}{$tile}{param_setting}=$setting;
215
 
216
}
217
 
218
sub mpsoc_get_tile_param_setting{
219
        my ($self,$tile)=@_;
220
        my $setting='Default';
221
        if(exists $self->{tile}{$tile}{param_setting}){
222
                $setting=$self->{tile}{$tile}{param_setting};
223
 
224
        }
225
        return $setting;
226
}
227
 
228
 
229 25 alirezamon
 
230
sub object_add_attribute{
231
        my ($self,$attribute1,$attribute2,$value)=@_;
232
        if(!defined $attribute2){$self->{$attribute1}=$value;}
233
        else {$self->{$attribute1}{$attribute2}=$value;}
234
 
235
}
236
 
237
 
238
 
239
sub object_get_attribute{
240
        my ($self,$attribute1,$attribute2)=@_;
241
        if(!defined $attribute2) {return $self->{$attribute1};}
242
        return $self->{$attribute1}{$attribute2};
243
 
244
 
245
}
246
 
247
 
248
sub object_add_attribute_order{
249
        my ($self,$attribute,@param)=@_;
250 48 alirezamon
        my $r = $self->{'parameters_order'}{$attribute};
251
        my @a;
252
        @a = @{$r} if(defined $r);
253
        push (@a,@param);
254
        @a=uniq(@a);
255
        $self->{'parameters_order'}{$attribute} =\@a;
256
}
257 25 alirezamon
 
258
sub object_get_attribute_order{
259
        my ($self,$attribute)=@_;
260
        return @{$self->{parameters_order}{$attribute}};
261
}
262
 
263 34 alirezamon
sub object_remove_attribute{
264
        my ($self,$attribute1,$attribute2)=@_;
265
        if(!defined $attribute2){
266
                delete $self->{$attribute1} if ( exists( $self->{$attribute1}));
267
        }
268
        else {
269
                delete $self->{$attribute1}{$attribute2} if ( exists( $self->{$attribute1}{$attribute2})); ;
270 25 alirezamon
 
271 34 alirezamon
        }
272 25 alirezamon
 
273 34 alirezamon
}
274
 
275 48 alirezamon
 
276
 
277
 
278 16 alirezamon
1
279
 

powered by: WebSVN 2.1.0

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