| Nico Huber | 5e9b1b5 | 2016-10-08 22:09:33 +0200 | [diff] [blame] | 1 | -- |
| 2 | -- Copyright (C) 2016 secunet Security Networks AG |
| 3 | -- |
| 4 | -- This program is free software; you can redistribute it and/or modify |
| 5 | -- it under the terms of the GNU General Public License as published by |
| Nico Huber | aab715f | 2016-10-18 00:22:25 +0200 | [diff] [blame] | 6 | -- the Free Software Foundation; either version 2 of the License, or |
| 7 | -- (at your option) any later version. |
| Nico Huber | 5e9b1b5 | 2016-10-08 22:09:33 +0200 | [diff] [blame] | 8 | -- |
| 9 | -- This program is distributed in the hope that it will be useful, |
| 10 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | -- GNU General Public License for more details. |
| 13 | -- |
| 14 | |
| 15 | with HW.Sub_Regs; |
| 16 | with HW.MMIO_Range; |
| 17 | |
| 18 | use type HW.Word64; |
| 19 | |
| 20 | generic |
| 21 | with package Range_P is new MMIO_Range (<>); |
| 22 | Byte_Offset_O : Natural := 0; |
| 23 | |
| 24 | with package Subs_P is new Sub_Regs (<>); |
| 25 | Regs : Subs_P.Array_T; |
| 26 | |
| 27 | package HW.MMIO_Regs |
| 28 | is |
| 29 | |
| 30 | Byte_Offset : Natural := Byte_Offset_O; |
| 31 | |
| 32 | ---------------------------------------------------------------------------- |
| 33 | |
| 34 | procedure Read (Value : out Word8; Idx : Subs_P.Index_T) |
| 35 | with |
| 36 | Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 37 | (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and |
| 38 | ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 39 | (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and |
| 40 | Range_P.Element_T'Size <= Word64'Size and |
| 41 | Regs (Idx).MSB < Range_P.Element_T'Size and |
| 42 | Regs (Idx).MSB >= Regs (Idx).LSB and |
| 43 | Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Word8'Size; |
| 44 | |
| 45 | procedure Read (Value : out Word16; Idx : Subs_P.Index_T) |
| 46 | with |
| 47 | Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 48 | (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and |
| 49 | ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 50 | (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and |
| 51 | Range_P.Element_T'Size <= Word64'Size and |
| 52 | Regs (Idx).MSB < Range_P.Element_T'Size and |
| 53 | Regs (Idx).MSB >= Regs (Idx).LSB and |
| 54 | Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Word16'Size; |
| 55 | |
| 56 | procedure Read (Value : out Word32; Idx : Subs_P.Index_T) |
| 57 | with |
| 58 | Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 59 | (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and |
| 60 | ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 61 | (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and |
| 62 | Range_P.Element_T'Size <= Word64'Size and |
| 63 | Regs (Idx).MSB < Range_P.Element_T'Size and |
| 64 | Regs (Idx).MSB >= Regs (Idx).LSB and |
| 65 | Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Word32'Size; |
| 66 | |
| 67 | procedure Read (Value : out Word64; Idx : Subs_P.Index_T) |
| 68 | with |
| 69 | Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 70 | (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and |
| 71 | ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 72 | (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and |
| 73 | Range_P.Element_T'Size <= Word64'Size and |
| 74 | Regs (Idx).MSB < Range_P.Element_T'Size and |
| 75 | Regs (Idx).MSB >= Regs (Idx).LSB and |
| 76 | Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Word64'Size; |
| 77 | |
| 78 | ---------------------------------------------------------------------------- |
| 79 | |
| 80 | procedure Write (Idx : Subs_P.Index_T; Value : Word8) |
| 81 | with |
| 82 | Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 83 | (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and |
| 84 | ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 85 | (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and |
| 86 | Range_P.Element_T'Size <= Word64'Size and |
| 87 | Regs (Idx).MSB < Range_P.Element_T'Size and |
| 88 | Regs (Idx).MSB >= Regs (Idx).LSB and |
| 89 | Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Value'Size and |
| 90 | Word64 (Value) < Word64 (2 ** (Regs (Idx).MSB + 1 - Regs (Idx).LSB)); |
| 91 | |
| 92 | procedure Write (Idx : Subs_P.Index_T; Value : Word16) |
| 93 | with |
| 94 | Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 95 | (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and |
| 96 | ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 97 | (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and |
| 98 | Range_P.Element_T'Size <= Word64'Size and |
| 99 | Regs (Idx).MSB < Range_P.Element_T'Size and |
| 100 | Regs (Idx).MSB >= Regs (Idx).LSB and |
| 101 | Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Value'Size and |
| 102 | Word64 (Value) < Word64 (2 ** (Regs (Idx).MSB + 1 - Regs (Idx).LSB)); |
| 103 | |
| 104 | procedure Write (Idx : Subs_P.Index_T; Value : Word32) |
| 105 | with |
| 106 | Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 107 | (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and |
| 108 | ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 109 | (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and |
| 110 | Range_P.Element_T'Size <= Word64'Size and |
| 111 | Regs (Idx).MSB < Range_P.Element_T'Size and |
| 112 | Regs (Idx).MSB >= Regs (Idx).LSB and |
| 113 | Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Value'Size and |
| 114 | Word64 (Value) < Word64 (2 ** (Regs (Idx).MSB + 1 - Regs (Idx).LSB)); |
| 115 | |
| 116 | procedure Write (Idx : Subs_P.Index_T; Value : Word64) |
| 117 | with |
| 118 | Pre => ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 119 | (Range_P.Element_T'Size / 8)) >= Integer (Range_P.Index_T'First) and |
| 120 | ((Byte_Offset + Regs (Idx).Byte_Offset) / |
| 121 | (Range_P.Element_T'Size / 8)) <= Integer (Range_P.Index_T'Last) and |
| 122 | Range_P.Element_T'Size <= Word64'Size and |
| 123 | Regs (Idx).MSB < Range_P.Element_T'Size and |
| 124 | Regs (Idx).MSB >= Regs (Idx).LSB and |
| 125 | Regs (Idx).MSB - Regs (Idx).LSB + 1 <= Value'Size and |
| 126 | Word64 (Value) < Word64 (2 ** (Regs (Idx).MSB + 1 - Regs (Idx).LSB)); |
| 127 | |
| 128 | end HW.MMIO_Regs; |