-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.vhd
More file actions
89 lines (71 loc) · 2.54 KB
/
GUI.vhd
File metadata and controls
89 lines (71 loc) · 2.54 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 16:07:23 06/03/2025
-- Design Name:
-- Module Name: GUI - Behavioral
-- Project Name:
-- Target Devices:
-- Tool versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx primitives in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity GUI is port(
GPUClk : in std_logic;
x : integer range 0 to 1023;
y : integer range 0 to 1023;
color : out std_logic_vector(7 downto 0));
end GUI;
architecture Behavioral of GUI is
CONSTANT BORDER : STD_LOGIC_VECTOR(7 DOWNTO 0) := (OTHERS => '1');
CONSTANT ACT_LSS0 : STD_LOGIC_VECTOR(7 DOWNTO 0) := "11100000";
CONSTANT ACT_EQL0 : STD_LOGIC_VECTOR(7 DOWNTO 0) := "11111100";
CONSTANT ACT_GRT0 : STD_LOGIC_VECTOR(7 DOWNTO 0) := "00011100";
CONSTANT INACTIVE : STD_LOGIC_VECTOR(7 DOWNTO 0) := (OTHERS => '0');
CONSTANT CARTESIAN : STD_LOGIC_VECTOR(7 DOWNTO 0) := "00000011";
-- Screen Calibration
-- use this constants if you don't see plot or it's not clear
CONSTANT TOLERANCE : INTEGER := 2; -- Direct impact for line thickness
CONSTANT DIVIDER : INTEGER := 1048576; -- DIVDER of function (MUST BE POWER OF 2)
CONSTANT VERTICAL_CAL : INTEGER := 230; -- VERTICAL function CALibration
signal fx : integer range 0 to 2147483647;
--process (x) begin
-- fx <=
begin
process (GPUClk) begin
fx <= (((x-100)*(x-200)*(x-350)*(x-450))/DIVIDER)+VERTICAL_CAL;
--fx <= (((x-200)*(x-200)*(x-500))/DIVIDER)+VERTICAL_CAL;
if rising_edge(GPUClk) then
-- Visible Area
if ((x>=0) and (x<=639) and (y>=0) and (y<=479)) then
if ((x=0) or (x=639) or (y=0) or (y=479)) then color <= BORDER;
elsif (y=(479-VERTICAL_CAL)) then color <= CARTESIAN;
elsif (abs(y-(479-fx)) <= TOLERANCE) then
if ((fx-VERTICAL_CAL)>0) then color <= ACT_GRT0;
elsif ((fx-VERTICAL_CAL)=0) then color <= ACT_EQL0;
else color <= ACT_LSS0;
end if;
else color <= INACTIVE;
end if;
--Blanking Area
else color <= INACTIVE;
end if;
end if;
end process;
end Behavioral;