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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 alirezamon
#!/usr/bin/perl -w -I ..
2
###############################################################################
3
#
4
# File:         emulator.pm
5
# 
6
#
7
###############################################################################
8
use warnings;
9
use strict;
10
 
11
 
12
 
13 48 alirezamon
 
14 25 alirezamon
package emulator;
15
 
16 48 alirezamon
sub uniq {
17
  my %seen;
18
  return grep { !$seen{$_}++ } @_;
19
}
20 25 alirezamon
 
21
sub emulator_new {
22
    # be backwards compatible with non-OO call
23
    my $class = ("ARRAY" eq ref $_[0]) ? "mpsoc" : shift;
24
    my $self;
25
 
26
 
27
    $self = {};
28
    $self->{file_name}        = (); # information on each file
29 38 alirezamon
    $self->{samples} = ();
30 25 alirezamon
    emulator_initial_setting($self);
31
 
32
 
33
    bless($self,$class);
34
 
35
 
36
    return $self;
37
}
38
 
39
sub emulator_initial_setting{
40
        my $self=shift;
41
        $self->{status}="ideal";
42
        $self->{setting}{show_noc_setting}=1;
43
        $self->{setting}{show_adv_setting}=0;
44
        $self->{setting}{show_tile_setting}=0;
45
        $self->{setting}{soc_path}="lib/soc";
46
 
47
}
48
 
49
 
50
 
51
 
52
 
53
 
54
 
55
 
56
sub object_add_attribute{
57
        my ($self,$attribute1,$attribute2,$value)=@_;
58
        if(!defined $attribute2){$self->{$attribute1}=$value;}
59
        else {$self->{$attribute1}{$attribute2}=$value;}
60
 
61
}
62
 
63
sub object_get_attribute{
64
        my ($self,$attribute1,$attribute2)=@_;
65
        if(!defined $attribute2) {return $self->{$attribute1};}
66
        return $self->{$attribute1}{$attribute2};
67
 
68
 
69
}
70
 
71
sub object_add_attribute_order{
72
        my ($self,$attribute,@param)=@_;
73 48 alirezamon
        my $r = $self->{'parameters_order'}{$attribute};
74
        my @a;
75
        @a = @{$r} if(defined $r);
76
        push (@a,@param);
77
        @a=uniq(@a);
78
        $self->{'parameters_order'}{$attribute} =\@a;
79 25 alirezamon
}
80
 
81
sub object_get_attribute_order{
82
        my ($self,$attribute)=@_;
83 38 alirezamon
        my @array;
84
        @array =  @{$self->{parameters_order}{$attribute}} if (defined $self->{parameters_order}{$attribute});
85 48 alirezamon
        return uniq (@array);
86 25 alirezamon
}
87
 
88
 
89 38 alirezamon
sub object_delete_attribute_order{
90
        my ($self,$attribute,@param)=@_;
91
        my @array=object_get_attribute_order($self,$attribute);
92
        foreach my $p (@param){
93
                @array=remove_scolar_from_array(\@array,$p);
94 25 alirezamon
 
95 38 alirezamon
        }
96
        $self->{'parameters_order'}{$attribute}=[];
97
        object_add_attribute_order($self,$attribute,@array);
98
}
99 25 alirezamon
 
100 38 alirezamon
sub object_remove_attribute{
101
        my ($self,$attribute1,$attribute2)=@_;
102
        if(!defined $attribute2){
103
                delete $self->{$attribute1} if ( exists( $self->{$attribute1}));
104
        }
105
        else {
106
                delete $self->{$attribute1}{$attribute2} if ( exists( $self->{$attribute1}{$attribute2})); ;
107
 
108
        }
109
 
110
}
111
 
112
sub remove_scolar_from_array{
113
        my ($array_ref,$item)=@_;
114
        my @array=@{$array_ref};
115
        my @new;
116
        foreach my $p (@array){
117
                if($p ne $item ){
118
                        push(@new,$p);
119
                }
120
        }
121
        return @new;
122
}
123
 
124
 
125
 
126 25 alirezamon
1

powered by: WebSVN 2.1.0

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