-- CD90001.A
|
-- CD90001.A
|
--
|
--
|
-- Grant of Unlimited Rights
|
-- Grant of Unlimited Rights
|
--
|
--
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
|
-- unlimited rights in the software and documentation contained herein.
|
-- unlimited rights in the software and documentation contained herein.
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- this public release, the Government intends to confer upon all
|
-- this public release, the Government intends to confer upon all
|
-- recipients unlimited rights equal to those held by the Government.
|
-- recipients unlimited rights equal to those held by the Government.
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- released technical data and computer software in whole or in part, in
|
-- released technical data and computer software in whole or in part, in
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- to do so.
|
-- to do so.
|
--
|
--
|
-- DISCLAIMER
|
-- DISCLAIMER
|
--
|
--
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
--*
|
--*
|
--
|
--
|
-- OBJECTIVE:
|
-- OBJECTIVE:
|
-- Check that Unchecked_Conversion is supported and is reversible in
|
-- Check that Unchecked_Conversion is supported and is reversible in
|
-- the cases where:
|
-- the cases where:
|
-- Source'Size = Target'Size
|
-- Source'Size = Target'Size
|
-- Source'Alignment = Target'Alignment
|
-- Source'Alignment = Target'Alignment
|
-- Source and Target are both represented contiguously
|
-- Source and Target are both represented contiguously
|
-- Bit pattern in Source is a meaningful value of Target type
|
-- Bit pattern in Source is a meaningful value of Target type
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- This test declares an enumeration type with a representation
|
-- This test declares an enumeration type with a representation
|
-- specification that should fit neatly into an 8 bit object; and a
|
-- specification that should fit neatly into an 8 bit object; and a
|
-- modular type that should also be able to fit easily into 8 bits;
|
-- modular type that should also be able to fit easily into 8 bits;
|
-- uses size representation clauses on both of them for 8 bit
|
-- uses size representation clauses on both of them for 8 bit
|
-- representations. It then defines two instances of
|
-- representations. It then defines two instances of
|
-- Unchecked_Conversion; to convert both ways between the types.
|
-- Unchecked_Conversion; to convert both ways between the types.
|
-- Using several distinctive values, it checks that the conversions
|
-- Using several distinctive values, it checks that the conversions
|
-- are performed, and reversible.
|
-- are performed, and reversible.
|
-- As a second case, the above is performed with an integer type and
|
-- As a second case, the above is performed with an integer type and
|
-- a packed array of booleans.
|
-- a packed array of booleans.
|
--
|
--
|
-- APPLICABILITY CRITERIA:
|
-- APPLICABILITY CRITERIA:
|
-- All implementations must attempt to compile this test.
|
-- All implementations must attempt to compile this test.
|
--
|
--
|
-- For implementations validating against Systems Programming Annex (C):
|
-- For implementations validating against Systems Programming Annex (C):
|
-- this test must execute and report PASSED.
|
-- this test must execute and report PASSED.
|
--
|
--
|
-- For implementations not validating against Annex C:
|
-- For implementations not validating against Annex C:
|
-- this test may report compile time errors at one or more points
|
-- this test may report compile time errors at one or more points
|
-- indicated by "-- ANX-C RQMT", in which case it may be graded as inapplicable.
|
-- indicated by "-- ANX-C RQMT", in which case it may be graded as inapplicable.
|
-- Otherwise, the test must execute and report PASSED.
|
-- Otherwise, the test must execute and report PASSED.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 22 JUL 95 SAIC Initial version
|
-- 22 JUL 95 SAIC Initial version
|
-- 07 MAY 96 SAIC Changed Boolean to Character for 2.1
|
-- 07 MAY 96 SAIC Changed Boolean to Character for 2.1
|
-- 27 JUL 96 SAIC Allowed for partial N/A to be PASS
|
-- 27 JUL 96 SAIC Allowed for partial N/A to be PASS
|
-- 14 FEB 97 PWB.CTA Corrected "=" to "/=" in alignment check.
|
-- 14 FEB 97 PWB.CTA Corrected "=" to "/=" in alignment check.
|
-- 16 FEB 98 EDS Modified documentation.
|
-- 16 FEB 98 EDS Modified documentation.
|
--!
|
--!
|
|
|
----------------------------------------------------------------- CD90001_0
|
----------------------------------------------------------------- CD90001_0
|
|
|
with Report;
|
with Report;
|
with Unchecked_Conversion;
|
with Unchecked_Conversion;
|
package CD90001_0 is
|
package CD90001_0 is
|
|
|
-- Case 1 : Modular <=> Enumeration
|
-- Case 1 : Modular <=> Enumeration
|
|
|
type Eight_Bits is mod 2**8;
|
type Eight_Bits is mod 2**8;
|
for Eight_Bits'Size use 8;
|
for Eight_Bits'Size use 8;
|
|
|
type User_Enums is ( One, Two, Four, Eight,
|
type User_Enums is ( One, Two, Four, Eight,
|
Sixteen, Thirty_Two, Sixty_Four, One_Twenty_Eight );
|
Sixteen, Thirty_Two, Sixty_Four, One_Twenty_Eight );
|
for User_Enums'Size use 8;
|
for User_Enums'Size use 8;
|
|
|
for User_Enums use
|
for User_Enums use
|
( One => 1, -- ANX-C RQMT.
|
( One => 1, -- ANX-C RQMT.
|
Two => 2, -- ANX-C RQMT.
|
Two => 2, -- ANX-C RQMT.
|
Four => 4, -- ANX-C RQMT.
|
Four => 4, -- ANX-C RQMT.
|
Eight => 8, -- ANX-C RQMT.
|
Eight => 8, -- ANX-C RQMT.
|
Sixteen => 16, -- ANX-C RQMT.
|
Sixteen => 16, -- ANX-C RQMT.
|
Thirty_Two => 32, -- ANX-C RQMT.
|
Thirty_Two => 32, -- ANX-C RQMT.
|
Sixty_Four => 64, -- ANX-C RQMT.
|
Sixty_Four => 64, -- ANX-C RQMT.
|
One_Twenty_Eight => 128 ); -- ANX-C RQMT.
|
One_Twenty_Eight => 128 ); -- ANX-C RQMT.
|
|
|
function EB_2_UE is new Unchecked_Conversion( Eight_Bits, User_Enums );
|
function EB_2_UE is new Unchecked_Conversion( Eight_Bits, User_Enums );
|
|
|
function UE_2_EB is new Unchecked_Conversion( User_Enums, Eight_Bits );
|
function UE_2_EB is new Unchecked_Conversion( User_Enums, Eight_Bits );
|
|
|
procedure TC_Check_Case_1;
|
procedure TC_Check_Case_1;
|
|
|
-- Case 2 : Integer <=> Packed Character array
|
-- Case 2 : Integer <=> Packed Character array
|
|
|
type Signed_16 is range -2**15+1 .. 2**15-1;
|
type Signed_16 is range -2**15+1 .. 2**15-1;
|
-- +1, -1 allows for both 1's and 2's comp
|
-- +1, -1 allows for both 1's and 2's comp
|
|
|
type Bits_16 is array(0..1) of Character;
|
type Bits_16 is array(0..1) of Character;
|
pragma Pack(Bits_16); -- ANX-C RQMT.
|
pragma Pack(Bits_16); -- ANX-C RQMT.
|
|
|
function S16_2_B16 is new Unchecked_Conversion( Signed_16, Bits_16 );
|
function S16_2_B16 is new Unchecked_Conversion( Signed_16, Bits_16 );
|
|
|
function B16_2_S16 is new Unchecked_Conversion( Bits_16, Signed_16 );
|
function B16_2_S16 is new Unchecked_Conversion( Bits_16, Signed_16 );
|
|
|
procedure TC_Check_Case_2;
|
procedure TC_Check_Case_2;
|
|
|
end CD90001_0;
|
end CD90001_0;
|
|
|
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
|
|
with Report;
|
with Report;
|
package body CD90001_0 is
|
package body CD90001_0 is
|
|
|
Check_List : constant array(1..8) of Eight_Bits
|
Check_List : constant array(1..8) of Eight_Bits
|
:= ( 1, 2, 4, 8, 16, 32, 64, 128 );
|
:= ( 1, 2, 4, 8, 16, 32, 64, 128 );
|
|
|
Check_Enum : constant array(1..8) of User_Enums
|
Check_Enum : constant array(1..8) of User_Enums
|
:= ( One, Two, Four, Eight,
|
:= ( One, Two, Four, Eight,
|
Sixteen, Thirty_Two, Sixty_Four, One_Twenty_Eight );
|
Sixteen, Thirty_Two, Sixty_Four, One_Twenty_Eight );
|
|
|
procedure TC_Check_Case_1 is
|
procedure TC_Check_Case_1 is
|
Mod_Value : Eight_Bits;
|
Mod_Value : Eight_Bits;
|
Enum_Val : User_Enums;
|
Enum_Val : User_Enums;
|
begin
|
begin
|
for I in Check_List'Range loop
|
for I in Check_List'Range loop
|
|
|
if EB_2_UE(Check_List(I)) /= Check_Enum(I) then
|
if EB_2_UE(Check_List(I)) /= Check_Enum(I) then
|
Report.Failed("EB => UE conversion failed");
|
Report.Failed("EB => UE conversion failed");
|
end if;
|
end if;
|
|
|
if Check_List(I) /= UE_2_EB(Check_Enum(I)) then
|
if Check_List(I) /= UE_2_EB(Check_Enum(I)) then
|
Report.Failed ("EU => EB conversion failed");
|
Report.Failed ("EU => EB conversion failed");
|
end if;
|
end if;
|
|
|
end loop;
|
end loop;
|
end TC_Check_Case_1;
|
end TC_Check_Case_1;
|
|
|
procedure TC_Check_Case_2 is
|
procedure TC_Check_Case_2 is
|
S: Signed_16;
|
S: Signed_16;
|
T,U: Signed_16;
|
T,U: Signed_16;
|
B: Bits_16;
|
B: Bits_16;
|
C,D: Bits_16; -- allow for byte swapping
|
C,D: Bits_16; -- allow for byte swapping
|
begin
|
begin
|
--FDEC_BA98_7654_3210
|
--FDEC_BA98_7654_3210
|
S := 2#0011_0000_0111_0111#;
|
S := 2#0011_0000_0111_0111#;
|
B := S16_2_B16( S );
|
B := S16_2_B16( S );
|
C := ( Character'Val(2#0011_0000#), Character'Val(2#0111_0111#) );
|
C := ( Character'Val(2#0011_0000#), Character'Val(2#0111_0111#) );
|
D := ( Character'Val(2#0111_0111#), Character'Val(2#0011_0000#) );
|
D := ( Character'Val(2#0111_0111#), Character'Val(2#0011_0000#) );
|
|
|
if (B /= C) and (B /= D) then
|
if (B /= C) and (B /= D) then
|
Report.Failed("Int => Chararray conversion failed");
|
Report.Failed("Int => Chararray conversion failed");
|
end if;
|
end if;
|
|
|
B := ( Character'Val(2#0011_1100#), Character'Val(2#0101_0101#) );
|
B := ( Character'Val(2#0011_1100#), Character'Val(2#0101_0101#) );
|
S := B16_2_S16( B );
|
S := B16_2_S16( B );
|
T := 2#0011_1100_0101_0101#;
|
T := 2#0011_1100_0101_0101#;
|
U := 2#0101_0101_0011_1100#;
|
U := 2#0101_0101_0011_1100#;
|
|
|
if (S /= T) and (S /= U) then
|
if (S /= T) and (S /= U) then
|
Report.Failed("Chararray => Int conversion failed");
|
Report.Failed("Chararray => Int conversion failed");
|
end if;
|
end if;
|
|
|
end TC_Check_Case_2;
|
end TC_Check_Case_2;
|
|
|
end CD90001_0;
|
end CD90001_0;
|
|
|
------------------------------------------------------------------- CD90001
|
------------------------------------------------------------------- CD90001
|
|
|
with Report;
|
with Report;
|
with CD90001_0;
|
with CD90001_0;
|
|
|
procedure CD90001 is
|
procedure CD90001 is
|
|
|
Eight_NA : Boolean := False;
|
Eight_NA : Boolean := False;
|
Sixteen_NA : Boolean := False;
|
Sixteen_NA : Boolean := False;
|
|
|
begin -- Main test procedure.
|
begin -- Main test procedure.
|
|
|
Report.Test ("CD90001", "Check that Unchecked_Conversion is supported " &
|
Report.Test ("CD90001", "Check that Unchecked_Conversion is supported " &
|
"and is reversible in appropriate cases" );
|
"and is reversible in appropriate cases" );
|
Eight_Bit_Case:
|
Eight_Bit_Case:
|
begin
|
begin
|
if CD90001_0.User_Enums'Size /= CD90001_0.Eight_Bits'Size then
|
if CD90001_0.User_Enums'Size /= CD90001_0.Eight_Bits'Size then
|
Report.Comment("The sizes of the 8 bit types used in this test "
|
Report.Comment("The sizes of the 8 bit types used in this test "
|
& "do not match" );
|
& "do not match" );
|
Eight_NA := True;
|
Eight_NA := True;
|
elsif CD90001_0.User_Enums'Alignment /= CD90001_0.Eight_Bits'Alignment then
|
elsif CD90001_0.User_Enums'Alignment /= CD90001_0.Eight_Bits'Alignment then
|
Report.Comment("The alignments of the 8 bit types used in this "
|
Report.Comment("The alignments of the 8 bit types used in this "
|
& "test do not match" );
|
& "test do not match" );
|
Eight_NA := True;
|
Eight_NA := True;
|
else
|
else
|
CD90001_0.TC_Check_Case_1;
|
CD90001_0.TC_Check_Case_1;
|
end if;
|
end if;
|
|
|
exception
|
exception
|
when Constraint_Error =>
|
when Constraint_Error =>
|
Report.Failed("Constraint_Error raised in 8 bit case");
|
Report.Failed("Constraint_Error raised in 8 bit case");
|
when others =>
|
when others =>
|
Report.Failed("Unexpected exception raised in 8 bit case");
|
Report.Failed("Unexpected exception raised in 8 bit case");
|
end Eight_Bit_Case;
|
end Eight_Bit_Case;
|
|
|
Sixteen_Bit_Case:
|
Sixteen_Bit_Case:
|
begin
|
begin
|
if CD90001_0.Signed_16'Size /= CD90001_0.Bits_16'Size then
|
if CD90001_0.Signed_16'Size /= CD90001_0.Bits_16'Size then
|
Report.Comment("The sizes of the 16 bit types used in this test "
|
Report.Comment("The sizes of the 16 bit types used in this test "
|
& "do not match" );
|
& "do not match" );
|
Sixteen_NA := True;
|
Sixteen_NA := True;
|
elsif CD90001_0.Signed_16'Alignment = CD90001_0.Bits_16'Alignment then
|
elsif CD90001_0.Signed_16'Alignment = CD90001_0.Bits_16'Alignment then
|
Report.Comment("The alignments of the 16 bit types used in this "
|
Report.Comment("The alignments of the 16 bit types used in this "
|
& "test do not match" );
|
& "test do not match" );
|
Sixteen_NA := True;
|
Sixteen_NA := True;
|
else
|
else
|
CD90001_0.TC_Check_Case_2;
|
CD90001_0.TC_Check_Case_2;
|
end if;
|
end if;
|
|
|
exception
|
exception
|
when Constraint_Error =>
|
when Constraint_Error =>
|
Report.Failed("Constraint_Error raised in 16 bit case");
|
Report.Failed("Constraint_Error raised in 16 bit case");
|
when others =>
|
when others =>
|
Report.Failed("Unexpected exception raised in 16 bit case");
|
Report.Failed("Unexpected exception raised in 16 bit case");
|
end Sixteen_Bit_Case;
|
end Sixteen_Bit_Case;
|
|
|
if Eight_NA and Sixteen_NA then
|
if Eight_NA and Sixteen_NA then
|
Report.Not_Applicable("No cases in this test apply");
|
Report.Not_Applicable("No cases in this test apply");
|
end if;
|
end if;
|
|
|
Report.Result;
|
Report.Result;
|
|
|
end CD90001;
|
end CD90001;
|
|
|