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 34

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

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

powered by: WebSVN 2.1.0

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