-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathVGA_screen_pkg.vhd
61 lines (47 loc) · 1.45 KB
/
VGA_screen_pkg.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
library ieee;
context ieee.ieee_std_context;
package VGA_screen_pkg is
generic (
G_WIDTH : natural := 640;
G_HEIGHT : natural := 480
);
type screen_t is
array ( natural range 0 to G_HEIGHT-1,
natural range 0 to G_WIDTH-1 ) of integer;
shared variable screen: screen_t;
-- TODO: pass a fat pointer, so that width and height need not to be passed explicitly
procedure save_screenshot (
variable ptr: screen_t;
width, height: natural;
id: integer := 0
);
attribute foreign of save_screenshot : procedure is "VHPIDIRECT save_screenshot";
procedure sim_cleanup;
attribute foreign of sim_cleanup : procedure is "VHPIDIRECT sim_cleanup";
---
function RGB_to_integer (rgb: std_logic_vector(2 downto 0)) return integer;
end VGA_screen_pkg;
package body VGA_screen_pkg is
procedure save_screenshot (
variable ptr: screen_t;
width, height: natural;
id: integer := 0
) is
begin report "VHPIDIRECT save_screenshot" severity failure;
end procedure;
procedure sim_cleanup is
begin report "VHPIDIRECT sim_cleanup" severity failure;
end procedure;
---
function RGB_to_integer (rgb: std_logic_vector(2 downto 0)) return integer is
variable raw24: std_logic_vector(31 downto 0);
begin
raw24 := (
7 downto 0 => rgb(2),
15 downto 8 => rgb(1),
23 downto 16 => rgb(0),
others => '1'
);
return to_integer(signed(raw24));
end function;
end VGA_screen_pkg;