OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [s-pack10.adb] - Blame information for rev 778

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

Line No. Rev Author Line
1 706 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT RUN-TIME COMPONENTS                         --
4
--                                                                          --
5
--                       S Y S T E M . P A C K _ 1 0                        --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
10
--                                                                          --
11
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
17
--                                                                          --
18
-- As a special exception under Section 7 of GPL version 3, you are granted --
19
-- additional permissions described in the GCC Runtime Library Exception,   --
20
-- version 3.1, as published by the Free Software Foundation.               --
21
--                                                                          --
22
-- You should have received a copy of the GNU General Public License and    --
23
-- a copy of the GCC Runtime Library Exception along with this program;     --
24
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
27
-- GNAT was originally developed  by the GNAT team at  New York University. --
28
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29
--                                                                          --
30
------------------------------------------------------------------------------
31
 
32
with System.Storage_Elements;
33
with System.Unsigned_Types;
34
with Ada.Unchecked_Conversion;
35
 
36
package body System.Pack_10 is
37
 
38
   subtype Ofs is System.Storage_Elements.Storage_Offset;
39
   subtype Uns is System.Unsigned_Types.Unsigned;
40
   subtype N07 is System.Unsigned_Types.Unsigned range 0 .. 7;
41
 
42
   use type System.Storage_Elements.Storage_Offset;
43
   use type System.Unsigned_Types.Unsigned;
44
 
45
   type Cluster is record
46
      E0, E1, E2, E3, E4, E5, E6, E7 : Bits_10;
47
   end record;
48
 
49
   for Cluster use record
50
      E0 at 0 range 0 * Bits .. 0 * Bits + Bits - 1;
51
      E1 at 0 range 1 * Bits .. 1 * Bits + Bits - 1;
52
      E2 at 0 range 2 * Bits .. 2 * Bits + Bits - 1;
53
      E3 at 0 range 3 * Bits .. 3 * Bits + Bits - 1;
54
      E4 at 0 range 4 * Bits .. 4 * Bits + Bits - 1;
55
      E5 at 0 range 5 * Bits .. 5 * Bits + Bits - 1;
56
      E6 at 0 range 6 * Bits .. 6 * Bits + Bits - 1;
57
      E7 at 0 range 7 * Bits .. 7 * Bits + Bits - 1;
58
   end record;
59
 
60
   for Cluster'Size use Bits * 8;
61
 
62
   for Cluster'Alignment use Integer'Min (Standard'Maximum_Alignment,
63
     1 +
64
     1 * Boolean'Pos (Bits mod 2 = 0) +
65
     2 * Boolean'Pos (Bits mod 4 = 0));
66
   --  Use maximum possible alignment, given the bit field size, since this
67
   --  will result in the most efficient code possible for the field.
68
 
69
   type Cluster_Ref is access Cluster;
70
 
71
   function To_Ref is new
72
     Ada.Unchecked_Conversion (System.Address, Cluster_Ref);
73
 
74
   --  The following declarations are for the case where the address
75
   --  passed to GetU_10 or SetU_10 is not guaranteed to be aligned.
76
   --  These routines are used when the packed array is itself a
77
   --  component of a packed record, and therefore may not be aligned.
78
 
79
   type ClusterU is new Cluster;
80
   for ClusterU'Alignment use 1;
81
 
82
   type ClusterU_Ref is access ClusterU;
83
 
84
   function To_Ref is new
85
     Ada.Unchecked_Conversion (System.Address, ClusterU_Ref);
86
 
87
   ------------
88
   -- Get_10 --
89
   ------------
90
 
91
   function Get_10 (Arr : System.Address; N : Natural) return Bits_10 is
92
      C : constant Cluster_Ref := To_Ref (Arr + Bits * Ofs (Uns (N) / 8));
93
   begin
94
      case N07 (Uns (N) mod 8) is
95
         when 0 => return C.E0;
96
         when 1 => return C.E1;
97
         when 2 => return C.E2;
98
         when 3 => return C.E3;
99
         when 4 => return C.E4;
100
         when 5 => return C.E5;
101
         when 6 => return C.E6;
102
         when 7 => return C.E7;
103
      end case;
104
   end Get_10;
105
 
106
   -------------
107
   -- GetU_10 --
108
   -------------
109
 
110
   function GetU_10 (Arr : System.Address; N : Natural) return Bits_10 is
111
      C : constant ClusterU_Ref := To_Ref (Arr + Bits * Ofs (Uns (N) / 8));
112
   begin
113
      case N07 (Uns (N) mod 8) is
114
         when 0 => return C.E0;
115
         when 1 => return C.E1;
116
         when 2 => return C.E2;
117
         when 3 => return C.E3;
118
         when 4 => return C.E4;
119
         when 5 => return C.E5;
120
         when 6 => return C.E6;
121
         when 7 => return C.E7;
122
      end case;
123
   end GetU_10;
124
 
125
   ------------
126
   -- Set_10 --
127
   ------------
128
 
129
   procedure Set_10 (Arr : System.Address; N : Natural; E : Bits_10) is
130
      C : constant Cluster_Ref := To_Ref (Arr + Bits * Ofs (Uns (N) / 8));
131
 
132
   begin
133
      case N07 (Uns (N) mod 8) is
134
         when 0 => C.E0 := E;
135
         when 1 => C.E1 := E;
136
         when 2 => C.E2 := E;
137
         when 3 => C.E3 := E;
138
         when 4 => C.E4 := E;
139
         when 5 => C.E5 := E;
140
         when 6 => C.E6 := E;
141
         when 7 => C.E7 := E;
142
      end case;
143
   end Set_10;
144
 
145
   -------------
146
   -- SetU_10 --
147
   -------------
148
 
149
   procedure SetU_10 (Arr : System.Address; N : Natural; E : Bits_10) is
150
      C : constant ClusterU_Ref := To_Ref (Arr + Bits * Ofs (Uns (N) / 8));
151
 
152
   begin
153
      case N07 (Uns (N) mod 8) is
154
         when 0 => C.E0 := E;
155
         when 1 => C.E1 := E;
156
         when 2 => C.E2 := E;
157
         when 3 => C.E3 := E;
158
         when 4 => C.E4 := E;
159
         when 5 => C.E5 := E;
160
         when 6 => C.E6 := E;
161
         when 7 => C.E7 := E;
162
      end case;
163
   end SetU_10;
164
 
165
end System.Pack_10;

powered by: WebSVN 2.1.0

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