-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.vhd
70 lines (52 loc) · 2.38 KB
/
types.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package types is
type PIXGEN_SOURCE_T is (
TRACE_PIXGEN_T,
TIME_BASE_PIXGEN_T,
SETTINGS_PIXGEN_T,
BLANK_PIXGEN_T
);
type TRIGGER_EVENT_T is (
RED_TRIGGER_T,
GREEN_TRIGGER_T,
BLUE_TRIGGER_T,
BUTTON_TRIGGER_T
);
-- This stupid thing is workaround a bug in ISE 13.1 XST synthesis tool
-- It does not understand character'val(...) statements.
type character_array_128 is array (0 to 127) of character;
constant character_conv_table : character_array_128 :=
(
NUL, SOH, STX, ETX, EOT, ENQ, ACK, BEL, BS, HT, LF, VT, FF, CR, SO,
SI, DLE, DC1, DC2, DC3, DC4, NAK, SYN, ETB, CAN, EM, SUB, ESC, FSP, GSP,
RSP, USP, ' ', '!', '"', '#', '$', '%', '&', ''', '(', ')', '*', '+', ',',
'-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';',
'<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y',
'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', '{', '|', '}', '~', DEL
);
-- short_character differs from character only by its range.
-- It has 128 first characters.
subtype short_character is character range character_conv_table (0) to character_conv_table (127);
-- short_string differs from string by:
-- o it's built of short_character's
-- o it's indexed from 0
type short_string is array (natural range <>) of short_character;
function to_short_character ( c : character ) return short_character;
function to_short_string ( s : string ) return short_string;
end types;
package body types is
function to_short_character ( c : character ) return short_character is
begin
return character_conv_table (character'pos (c) mod 128);
end function to_short_character;
function to_short_string ( s: string ) return short_string is
variable out_s : short_string (s'length - 1 downto 0);
begin
for i in s'length downto 1 loop
out_s (i - 1) := to_short_character (s (i));
end loop;
return out_s;
end function to_short_string;
end types;