Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / Midas / MMU / Niagara2.pm
CommitLineData
86530b38
AT
1# -*- perl -*-
2
3package Midas::MMU::Niagara2;
4use strict;
5
6use Midas::Command;
7use Midas::Error;
8use Midas::Configure;
9use Midas::Globals;
10use Midas::Segment;
11
12use TRELoad 'BitFieldTie';
13
14use base qw(Midas::MMU);
15use fields qw(
16 rasize
17 );
18
19##############################################################################
20
21sub new {
22 my $class = shift;
23 my %args = @_;
24 my $this = fields::new($class);
25 $this->SUPER::new();
26
27 foreach my $key (keys %args) {
28 $this->{$key} = $args{$key};
29 }
30
31 $this->set_defaults();
32
33 $this->{mapattr_type} = 'Midas::MMU::Niagara2::SectionAttrs';
34 $this->{tsb_type} = 'Midas::MMU::Niagara2::TSB';
35
36 return $this;
37}
38
39##############################################################################
40
41sub set_defaults {
42 my $this = shift;
43
44 $this->{vasize} = 64 unless defined $this->{vasize};
45 $this->{pasize} = 40 unless defined $this->{pasize};
46 $this->{rasize} = 40 unless defined $this->{rasize};
47 $this->{type} = 'niagara2' unless defined $this->{type};
48
49
50 $this->SUPER::set_defaults();
51}
52
53##############################################################################
54
55sub mmu_cpp_args {
56 my $this = shift;
57 my $list = ['-DNIAGARA2'];
58 push @$list, '-DALLOW_TSB_COL' if $CONFIG{allow_tsb_conflicts};
59 return $list;
60}
61
62##############################################################################
63
64##############################################################################
65##############################################################################
66
67{
68 package Midas::MMU::Niagara2::SectionAttrs;
69 use strict;
70
71 use Carp;
72 use Midas::Command;
73 use Midas::Globals;
74 use Midas::Error;
75 use Midas::MMU::SunSectionAttrs;
76 use Midas::MMU::TTEFormat;
77 use BitFieldTie;
78
79
80 use base qw(Midas::MMU::SunHyperAttrs);
81 use fields (qw(),
82 (
83 # Hard-code MMU type because 'use fields' directive needs
84 # to happen at compile-time
85 keys %{ get_union_tte_field_hash('niagara2') }
86 )
87 );
88
89 our @Settable = qw();
90
91 our %Settable = map { $_ => 1} Midas::MMU::Niagara2::SectionAttrs->settable();
92 our %FieldSizes =( );
93
94 ############################################################################
95
96 sub new {
97 my $this = shift;
98 my %args = @_;
99
100 unless (ref $this) {
101 $this = fields::new($this);
102 }
103
104 $this->{settable} = \%Settable;
105 foreach my $key (keys %args) {
106 $this->{$key} = $args{$key};
107 }
108
109 return $this;
110 }
111
112 ############################################################################
113
114 sub set_defaults {
115 my $this = shift;
116
117 $this->SUPER::set_defaults();
118
119 foreach my $field (keys %FieldSizes) {
120 $this->{$field} = 0 unless defined $this->{$field};
121 }
122 }
123
124 #############################################################################
125
126 sub settable {
127 my $this = shift;
128 my @settable = $this->SUPER::settable();
129 push @settable, @Settable;
130 return @settable;
131 }
132
133 #############################################################################
134
135 sub get_field_size_hash {
136 my $this = shift;
137 my $sizes = $this->SUPER::get_field_size_hash();
138
139 foreach my $field (keys %FieldSizes) {
140 $sizes->{$field} = $FieldSizes{$field};
141 }
142
143 return $sizes;
144 }
145
146 ############################################################################
147
148 sub legal_page_bits {
149 my $this = shift;
150 return (0, 1, 3, 5);
151 }
152
153 ###########################################################################
154
155}
156
157##############################################################################
158##############################################################################
159
160{
161 package Midas::MMU::Niagara2::TSB;
162
163 use Midas::Globals;
164 use Midas::Command;
165 use Midas::Error;
166 use BitFieldTie;
167
168 use base 'Midas::TSB';
169 use fields qw();
170
171
172
173 ############################################################################
174
175 sub new {
176 my $this = shift;
177 my %args = @_;
178
179 unless (ref $this) {
180 $this = fields::new($this);
181 }
182
183 $this->{touched} = 0;
184 $this->{force_ctx_zero} = undef;
185 $this->{page_size} = undef;
186
187 foreach my $key (keys %args) {
188 $this->{$key} = $args{$key};
189 }
190
191 return $this;
192 }
193
194 ############################################################################
195
196 sub config_from_register {
197 my $this = shift;
198 my $mmu = shift;
199
200 my $config = BitFieldTie->new(64, $this->{config_register});
201 my $base = BitFieldTie->new($PASIZE, 0);
202
203 tie my %config, 'BitFieldTie', $config;
204 tie my %base, 'BitFieldTie', $base;
205
206 $base{'39:13'} = $config{'39:13'};
207
208 $this->{base} = $base;
209 $this->{page_size} = $config{'6:4'};
210 $this->{ttefmt} = $config{7} ? 'sun4v' : 'sun4u';
211 $this->{sizebits} = $config{'3:0'};
212 $this->{is_split} = 0;
213 $this->{numentries} = 512 * (1 << $this->{sizebits});
214
215 my $base_lo = 13 + $this->{sizebits};
216 if($base_lo > 13) {
217 my $overlap = $base->extract($base_lo, 13);
218
219 if($overlap) {
220 if($CONFIG{allow_misaligned_tsb_base}) {
221 $base->store($base_lo, 13, 0);
222 } else {
223 fatal "TSB '$this->{name}' has base $base, which\n".
224 " is misaligned for size=$this->{sizebits}\n" .
225 " Illegal unless -allow_misalgined_tsb_base is defined.\n" .
226 " line=$this->{srcline}, file=$this->{srcfile}\n",
227 M_TSBSYNTAX;
228 }
229 }
230
231 }
232 }
233
234 ############################################################################
235
236}
237
238##############################################################################
239##############################################################################
240
2411;