|
| 1 | +// Note: This file is temporarily copied here from the Sail compiler. It can |
| 2 | +// be removed when Sail 0.18 is released. |
| 3 | + |
| 4 | +/*==========================================================================*/ |
| 5 | +/* Sail */ |
| 6 | +/* */ |
| 7 | +/* Sail and the Sail architecture models here, comprising all files and */ |
| 8 | +/* directories except the ASL-derived Sail code in the aarch64 directory, */ |
| 9 | +/* are subject to the BSD two-clause licence below. */ |
| 10 | +/* */ |
| 11 | +/* The ASL derived parts of the ARMv8.3 specification in */ |
| 12 | +/* aarch64/no_vector and aarch64/full are copyright ARM Ltd. */ |
| 13 | +/* */ |
| 14 | +/* Copyright (c) 2013-2021 */ |
| 15 | +/* Kathyrn Gray */ |
| 16 | +/* Shaked Flur */ |
| 17 | +/* Stephen Kell */ |
| 18 | +/* Gabriel Kerneis */ |
| 19 | +/* Robert Norton-Wright */ |
| 20 | +/* Christopher Pulte */ |
| 21 | +/* Peter Sewell */ |
| 22 | +/* Alasdair Armstrong */ |
| 23 | +/* Brian Campbell */ |
| 24 | +/* Thomas Bauereiss */ |
| 25 | +/* Anthony Fox */ |
| 26 | +/* Jon French */ |
| 27 | +/* Dominic Mulligan */ |
| 28 | +/* Stephen Kell */ |
| 29 | +/* Mark Wassell */ |
| 30 | +/* Alastair Reid (Arm Ltd) */ |
| 31 | +/* */ |
| 32 | +/* All rights reserved. */ |
| 33 | +/* */ |
| 34 | +/* This work was partially supported by EPSRC grant EP/K008528/1 <a */ |
| 35 | +/* href="http://www.cl.cam.ac.uk/users/pes20/rems">REMS: Rigorous */ |
| 36 | +/* Engineering for Mainstream Systems</a>, an ARM iCASE award, EPSRC IAA */ |
| 37 | +/* KTF funding, and donations from Arm. This project has received */ |
| 38 | +/* funding from the European Research Council (ERC) under the European */ |
| 39 | +/* Union’s Horizon 2020 research and innovation programme (grant */ |
| 40 | +/* agreement No 789108, ELVER). */ |
| 41 | +/* */ |
| 42 | +/* This software was developed by SRI International and the University of */ |
| 43 | +/* Cambridge Computer Laboratory (Department of Computer Science and */ |
| 44 | +/* Technology) under DARPA/AFRL contracts FA8650-18-C-7809 ("CIFV") */ |
| 45 | +/* and FA8750-10-C-0237 ("CTSRD"). */ |
| 46 | +/* */ |
| 47 | +/* Redistribution and use in source and binary forms, with or without */ |
| 48 | +/* modification, are permitted provided that the following conditions */ |
| 49 | +/* are met: */ |
| 50 | +/* 1. Redistributions of source code must retain the above copyright */ |
| 51 | +/* notice, this list of conditions and the following disclaimer. */ |
| 52 | +/* 2. Redistributions in binary form must reproduce the above copyright */ |
| 53 | +/* notice, this list of conditions and the following disclaimer in */ |
| 54 | +/* the documentation and/or other materials provided with the */ |
| 55 | +/* distribution. */ |
| 56 | +/* */ |
| 57 | +/* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' */ |
| 58 | +/* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */ |
| 59 | +/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */ |
| 60 | +/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR */ |
| 61 | +/* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */ |
| 62 | +/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ |
| 63 | +/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF */ |
| 64 | +/* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND */ |
| 65 | +/* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */ |
| 66 | +/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */ |
| 67 | +/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF */ |
| 68 | +/* SUCH DAMAGE. */ |
| 69 | +/*==========================================================================*/ |
| 70 | + |
| 71 | +$ifndef _HEX_BITS |
| 72 | +$define _HEX_BITS |
| 73 | + |
| 74 | +$include <vector.sail> |
| 75 | +$include <string.sail> |
| 76 | + |
| 77 | +val "parse_hex_bits" : forall 'n, 'n > 0. (int('n), string) -> bits('n) |
| 78 | +val "valid_hex_bits" : forall 'n, 'n > 0. (int('n), string) -> bool |
| 79 | + |
| 80 | +val hex_bits : forall 'n, 'n > 0. bits('n) <-> (int('n), string) |
| 81 | + |
| 82 | +function hex_bits_forwards(bv) = (length(bv), hex_str(unsigned(bv))) |
| 83 | +function hex_bits_forwards_matches(bv) = true |
| 84 | + |
| 85 | +function hex_bits_backwards(n, str) = parse_hex_bits(n, str) |
| 86 | +function hex_bits_backwards_matches(n, str) = valid_hex_bits(n, str) |
| 87 | + |
| 88 | +mapping hex_bits_1 : bits(1) <-> string = { hex_bits(1, s) <-> s } |
| 89 | +mapping hex_bits_2 : bits(2) <-> string = { hex_bits(2, s) <-> s } |
| 90 | +mapping hex_bits_3 : bits(3) <-> string = { hex_bits(3, s) <-> s } |
| 91 | +mapping hex_bits_4 : bits(4) <-> string = { hex_bits(4, s) <-> s } |
| 92 | +mapping hex_bits_5 : bits(5) <-> string = { hex_bits(5, s) <-> s } |
| 93 | +mapping hex_bits_6 : bits(6) <-> string = { hex_bits(6, s) <-> s } |
| 94 | +mapping hex_bits_7 : bits(7) <-> string = { hex_bits(7, s) <-> s } |
| 95 | +mapping hex_bits_8 : bits(8) <-> string = { hex_bits(8, s) <-> s } |
| 96 | +mapping hex_bits_9 : bits(9) <-> string = { hex_bits(9, s) <-> s } |
| 97 | + |
| 98 | +mapping hex_bits_10 : bits(10) <-> string = { hex_bits(10, s) <-> s } |
| 99 | +mapping hex_bits_11 : bits(11) <-> string = { hex_bits(11, s) <-> s } |
| 100 | +mapping hex_bits_12 : bits(12) <-> string = { hex_bits(12, s) <-> s } |
| 101 | +mapping hex_bits_13 : bits(13) <-> string = { hex_bits(13, s) <-> s } |
| 102 | +mapping hex_bits_14 : bits(14) <-> string = { hex_bits(14, s) <-> s } |
| 103 | +mapping hex_bits_15 : bits(15) <-> string = { hex_bits(15, s) <-> s } |
| 104 | +mapping hex_bits_16 : bits(16) <-> string = { hex_bits(16, s) <-> s } |
| 105 | +mapping hex_bits_17 : bits(17) <-> string = { hex_bits(17, s) <-> s } |
| 106 | +mapping hex_bits_18 : bits(18) <-> string = { hex_bits(18, s) <-> s } |
| 107 | +mapping hex_bits_19 : bits(19) <-> string = { hex_bits(19, s) <-> s } |
| 108 | + |
| 109 | +mapping hex_bits_20 : bits(20) <-> string = { hex_bits(20, s) <-> s } |
| 110 | +mapping hex_bits_21 : bits(21) <-> string = { hex_bits(21, s) <-> s } |
| 111 | +mapping hex_bits_22 : bits(22) <-> string = { hex_bits(22, s) <-> s } |
| 112 | +mapping hex_bits_23 : bits(23) <-> string = { hex_bits(23, s) <-> s } |
| 113 | +mapping hex_bits_24 : bits(24) <-> string = { hex_bits(24, s) <-> s } |
| 114 | +mapping hex_bits_25 : bits(25) <-> string = { hex_bits(25, s) <-> s } |
| 115 | +mapping hex_bits_26 : bits(26) <-> string = { hex_bits(26, s) <-> s } |
| 116 | +mapping hex_bits_27 : bits(27) <-> string = { hex_bits(27, s) <-> s } |
| 117 | +mapping hex_bits_28 : bits(28) <-> string = { hex_bits(28, s) <-> s } |
| 118 | +mapping hex_bits_29 : bits(29) <-> string = { hex_bits(29, s) <-> s } |
| 119 | + |
| 120 | +mapping hex_bits_30 : bits(30) <-> string = { hex_bits(30, s) <-> s } |
| 121 | +mapping hex_bits_31 : bits(31) <-> string = { hex_bits(31, s) <-> s } |
| 122 | +mapping hex_bits_32 : bits(32) <-> string = { hex_bits(32, s) <-> s } |
| 123 | + |
| 124 | +$endif _HEX_BITS |
0 commit comments