library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
use ieee.std_logic_arith.all;
entity sync is
port(
clk:in std_logic; --VGA鏃堕挓淇″彿杈撳叆
data_in:in std_logic_vector(7 downto 0);--ADC閲囬泦鏁版嵁杈撳叆
ok:in std_logic;
ar:in std_logic;
br:in std_logic;
hsync,vsync:out std_logic; --杈撳嚭琛屽満淇″彿
r,g,b:out std_logic_vector(3 downto 0)--杈撳嚭RGB淇″彿
);
end;
architecture main of sync is
--琛屽満淇″彿璁℃暟
signal hpos:integer range 0 to 1688:=0;
signal vpos:integer range 0 to 1066:=0;
--娉㈠舰璁$畻鍙傛暟
signal V_max:integer range 0 to 5000000:=0;
signal V_min:integer range 0 to 5000000:=0;
signal Vpp:integer range 0 to 5000000:=0;
signal Vrms:integer:=0;
signal Hz:integer:=0;
--娉㈠舰鏄剧ず鍖哄煙闃靛垪
type data_arr is array(0 to 1024)of integer range 0 to 800;--鏄剧ず灞忔樉绀烘渶澶ч珮搴?
signal i:integer range 0 to 1024:=0;
signal pic_data:data_arr;--800 X 1024
signal xu:std_logic;
signal xu1:std_logic;
type picture is array(15 downto 0)of std_logic_vector(7 downto 0);
constant num_0 :picture:=(x"00",x"00",x"00",x"38",x"6c",x"c6",x"c6",x"c6",x"c6",x"c6",x"c6",x"c6",x"6c",x"38",x"00",x"00");
constant num_1 :picture:=(x"00",x"00",x"00",x"0c",x"3c",x"0c",x"0c",x"0c",x"0c",x"0c",x"0c",x"0c",x"0c",x"3f",x"00",x"00");
constant num_2 :picture:=(x"00",x"00",x"00",x"3e",x"63",x"63",x"63",x"03",x"06",x"0c",x"18",x"30",x"63",x"7f",x"00",x"00");
constant num_3 :picture:=(x"00",x"00",x"00",x"3e",x"63",x"63",x"03",x"06",x"1c",x"06",x"03",x"63",x"63",x"3e",x"00",x"00");
constant num_4 :picture:=(x"00",x"00",x"00",x"04",x"0c",x"14",x"24",x"24",x"44",x"44",x"7e",x"04",x"04",x"1e",x"00",x"00");
constant num_5 :picture:=(x"00",x"00",x"00",x"7e",x"40",x"40",x"40",x"58",x"64",x"02",x"02",x"42",x"44",x"38",x"00",x"00");
constant num_6 :picture:=(x"00",x"00",x"00",x"1c",x"24",x"40",x"40",x"58",x"64",x"42",x"42",x"42",x"24",x"18",x"00",x"00");
constant num_7 :picture:=(x"00",x"00",x"00",x"7e",x"44",x"44",x"08",x"08",x"10",x"10",x"10",x"10",x"10",x"10",x"00",x"00");
constant num_8 :picture:=(x"00",x"00",x"00",x"3c",x"42",x"42",x"42",x"24",x"18",x"24",x"42",x"42",x"42",x"3c",x"00",x"00");
constant num_9 :picture:=(x"00",x"00",x"00",x"18",x"24",x"42",x"42",x"42",x"26",x"1a",x"02",x"02",x"24",x"38",x"00",x"00");
constant char_dot :picture:=(x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"00",x"60",x"60",x"00",x"00");--灏忔暟鐐?
constant char_V :picture:=(x"00",x"00",x"00",x"e7",x"42",x"42",x"44",x"24",x"24",x"28",x"28",x"18",x"10",x"10",x"00",x"00");
constant char_t :picture:=(x"00",x"00",x"00",x"00",x"00",x"18",x"18",x"7e",x"18",x"18",x"18",x"1b",x"0e",x"00",x"00",x"00");
constant char_u :picture:=(x"00",x"00",x"00",x"00",x"00",x"00",x"63",x"21",x"21",x"21",x"21",x"21",x"23",x"1d",x"00",x"00");
constant char_0 :picture:=(x"00",x"00",x"00",x"18",x"24",x"42",x"42",x"42",x"42",x"42",x"42",x"42",x"24",x"18",x"00",x"00");
constant char_1 :picture:=(x"00",x"00",x"00",x"00",x"C0",x"38",x"04",x"00",x"00",x"60",x"18",x"07",x"00",x"00",x"00",x"00");
constant char_vsou :picture:=(x"80",x"c0",x"e0",x"f0",x"f8",x"fc",x"fe",x"ff",x"fe",x"fc",x"f8",x"f0",x"e0",x"c0",x"80",x"00");
constant char_hsou1 :picture:=(x"00",x"80",x"80",x"c0",x"c0",x"e0",x"e0",x"f0",x"f0",x"f8",x"f8",x"fc",x"fc",x"fe",x"fe",x"ff");
constant char_hsou2 :picture:=(x"00",x"01",x"01",x"03",x"03",x"07",x"07",x"0f",x"0f",x"1f",x"1f",x"3f",x"3f",x"7f",x"7f",x"ff");
type picture2 is array(31 downto 0)of std_logic_vector(15 downto 0);
constant char_M :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"f00f",x"381c",x"381c",x"381c",x"381c",x"382c",x"2c2c",x"2c2c",x"2c2c",
x"2c4c",x"2c4c",x"264c",x"264c",x"264c",x"268c",x"228c",x"238c",x"238c",x"230c",x"230c",x"210c",x"f13f",x"0000",x"0000",x"0000",x"0000");
constant char_a :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"07e0",x"1830",
x"3018",x"3018",x"3018",x"0038",x"07d8",x"1c18",x"3018",x"6018",x"6018",x"6018",x"6019",x"3079",x"1f8e",x"0000",x"0000",x"0000",x"0000");
constant char_x :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"3e7c",x"0c10",
x"0e10",x"0620",x"0340",x"0340",x"0180",x"0180",x"01c0",x"0260",x"0460",x"0430",x"0818",x"1818",x"7c7e",x"0000",x"0000",x"0000",x"0000");
constant char_dV :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"7c1e",x"180c",x"1808",x"1808",x"1808",x"0c10",x"0c10",x"0c10",x"0c10",
x"0c20",x"0620",x"0620",x"0620",x"0640",x"0340",x"0340",x"0340",x"0380",x"0180",x"0180",x"0100",x"0100",x"0000",x"0000",x"0000",x"0000");
constant char_r :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"061c",x"7e66",
x"0686",x"0780",x"0700",x"0600",x"0600",x"0600",x"0600",x"0600",x"0600",x"0600",x"0600",x"0600",x"7fe0",x"0000",x"0000",x"0000",x"0000");
constant char_xm :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"2000",x"ef3c",x"71c6",
x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"6186",x"f3cf",x"0000",x"0000",x"0000",x"0000");
constant char_s :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03e4",x"061c",
x"0c0c",x"0c04",x"0c04",x"0e00",x"07c0",x"01f0",x"0078",x"001c",x"100c",x"100c",x"180c",x"1c18",x"13f0",x"0000",x"0000",x"0000",x"0000");
constant char_q :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03c8",x"0c78",
x"1838",x"1818",x"3018",x"3018",x"3018",x"3018",x"3018",x"3018",x"3018",x"1018",x"1838",x"0c78",x"0798",x"0018",x"0018",x"0018",x"007e");
constant char_i :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0180",x"03c0",x"0180",x"0000",x"0000",x"0000",x"0080",x"1f80",x"0180",
x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"1ff8",x"0000",x"0000",x"0000",x"0000");
constant char_n :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"09e0",x"7a30",
x"1c18",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"7e7e",x"0000",x"0000",x"0000",x"0000");
constant char_p :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"09e0",x"7a30",
x"1c18",x"1808",x"180c",x"180c",x"180c",x"180c",x"180c",x"180c",x"180c",x"1818",x"1c18",x"1e30",x"19e0",x"1800",x"1800",x"1800",x"7e00");
constant char_e :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03C0",x"0C30",
x"0818",x"1808",x"300C",x"300C",x"300C",x"3FFC",x"3000",x"3000",x"3000",x"1804",x"1808",x"0E18",x"03E0",x"0000",x"0000",x"0000",x"0000");
constant char_F :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"7ffc",x"181c",x"1804",x"1802",x"1802",x"1800",x"1800",x"1810",x"1810",
x"1830",x"1ff0",x"1830",x"1810",x"1810",x"1810",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"7e00",x"0000",x"0000",x"0000",x"0000");
constant num_d0 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03c0",x"0620",x"0c30",x"1818",x"1818",x"1808",x"300c",x"300c",x"300c",
x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"1808",x"1818",x"1818",x"0c30",x"0620",x"03c0",x"0000",x"0000",x"0000",x"0000");
constant num_d1 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0080",x"0180",x"1f80",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",
x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"0180",x"03c0",x"1ff8",x"0000",x"0000",x"0000",x"0000");
constant num_d2 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"07e0",x"0838",x"1018",x"200c",x"200c",x"300c",x"300c",x"000c",x"0018",
x"0018",x"0030",x"0060",x"00c0",x"0180",x"0300",x"0200",x"0404",x"0804",x"1004",x"200c",x"3ff8",x"3ff8",x"0000",x"0000",x"0000",x"0000");
constant num_d3 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"07c0",x"1860",x"3030",x"3018",x"3018",x"3018",x"0018",x"0018",x"0030",
x"0060",x"03c0",x"0070",x"0018",x"0008",x"000c",x"000c",x"300c",x"300c",x"3008",x"3018",x"1830",x"07c0",x"0000",x"0000",x"0000",x"0000");
constant num_d4 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0060",x"0060",x"00e0",x"00e0",x"0160",x"0160",x"0260",x"0460",x"0460",
x"0860",x"0860",x"1060",x"3060",x"2060",x"4060",x"7ffc",x"0060",x"0060",x"0060",x"0060",x"0060",x"03fc",x"0000",x"0000",x"0000",x"0000");
constant num_d5 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0ffc",x"0ffc",x"1000",x"1000",x"1000",x"1000",x"1000",x"1000",x"13e0",
x"1430",x"1818",x"1008",x"000c",x"000c",x"000c",x"000c",x"300c",x"300c",x"2018",x"2018",x"1830",x"07c0",x"0000",x"0000",x"0000",x"0000");
constant num_d6 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"01e0",x"0618",x"0c18",x"0818",x"1800",x"1000",x"1000",x"3000",x"33e0",
x"3630",x"3818",x"3808",x"300c",x"300c",x"300c",x"300c",x"300c",x"180c",x"1808",x"0c18",x"0e30",x"03e0",x"0000",x"0000",x"0000",x"0000");
constant num_d7 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"1ffc",x"1ffc",x"1008",x"3010",x"2010",x"2020",x"0020",x"0040",x"0040",
x"0040",x"0080",x"0080",x"0100",x"0100",x"0100",x"0100",x"0300",x"0300",x"0300",x"0300",x"0300",x"0300",x"0000",x"0000",x"0000",x"0000");
constant num_d8 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"07e0",x"0c30",x"1818",x"300c",x"300c",x"300c",x"380c",x"3808",x"1e18",
x"0f20",x"07c0",x"18f0",x"3078",x"3038",x"601c",x"600c",x"600c",x"600c",x"600c",x"3018",x"1830",x"07c0",x"0000",x"0000",x"0000",x"0000");
constant num_d9 :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"07c0",x"1820",x"3010",x"3018",x"6008",x"600c",x"600c",x"600c",x"600c",
x"600c",x"701c",x"302c",x"186c",x"0f8c",x"000c",x"0018",x"0018",x"0010",x"3030",x"3060",x"30c0",x"0f80",x"0000",x"0000",x"0000",x"0000");
constant char_H :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"fc3f",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",
x"300c",x"3ffc",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"300c",x"fc3f",x"0000",x"0000",x"0000",x"0000");
constant char_z :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"3ff8",x"3038",
x"3030",x"2060",x"20e0",x"00c0",x"0180",x"0380",x"0300",x"0600",x"0e04",x"0c04",x"180c",x"3018",x"3ff8",x"0000",x"0000",x"0000",x"0000");
constant char_G :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03C0",x"0C30",x"0810",x"1818",x"3008",x"3008",x"2000",x"6000",x"6000",
x"6000",x"6000",x"6000",x"607E",x"6018",x"6018",x"2018",x"3018",x"3018",x"1018",x"1818",x"0C20",x"07C0",x"0000",x"0000",x"0000",x"0000");
constant char_do :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"03C0",x"0C30",
x"0818",x"1818",x"100C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"1818",x"1818",x"0C30",x"03C0",x"0000",x"0000",x"0000",x"0000");
constant char_du :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"0808",x"7878",x"1818",
x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1818",x"1838",x"0C5E",x"0790",x"0000",x"0000",x"0000",x"0000");
constant char_dL :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"7E00",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",
x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"1800",x"1802",x"1802",x"1804",x"180C",x"7FFC",x"0000",x"0000",x"0000",x"0000");
constant char_dX :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"7C3E",x"1808",x"1810",x"0C10",x"0C20",x"0620",x"0640",x"0340",x"0380",
x"0180",x"0180",x"0180",x"01C0",x"02C0",x"0260",x"0460",x"0470",x"0830",x"0830",x"1818",x"101C",x"7C3E",x"0000",x"0000",x"0000",x"0000");
constant char_dH :picture2:=(x"0000",x"0000",x"0000",x"0000",x"0000",x"0000",x"FC3F",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",
x"300C",x"3FFC",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"300C",x"FC3F",x"0000",x"0000",x"0000",x"0000");
-----------------------------------------
type picture3 is array(254 downto 0)of std_logic_vector(255 downto 0);
begin
--oooooooooooooooooooooooooooooo1鏃堕挓
process(clk,vpos,hpos)
variable hp:integer range 0 to 16:=0;
variable vp:integer range 0 to 16:=0;
begin
if(clk'event and clk='1')then
-----
if(hpos<1688)then
hpos<=hpos+1;
else
hpos<=0;
if(vpos<1066)then
vpos<=vpos+1;
else
vpos<=0;
end if;
---
vp:=vp+1;
if(vp<=8)then
xu1<='0';
else
xu1<='1';
end if;
if(vp=16)then
vp:=0;
end if;
---
end if;
----
hp:=hp+1;
if(hp<=8)then
xu<='0';
else
xu<='1';
end if;
if(hp=16)then
hp:=0;
end if;
-----
-----
if(hpos>48 and hpos<160)then
hsync<='0';
else
hsync<='1';
end if;
-----
if(vpos>0 and vpos<4)then
vsync<='0';
else
vsync<='1';
end if;
-----
end if;
end process;
------------------------------------------鏁版嵁澶勭悊涓庤绠?
process(ok)
variable data:integer range 0 to 500000:=0;--杈撳叆鏁版嵁
variable h:integer:=0;--棰戠巼
variable flag:integer:=0;
variable count:integer:=0;--ok鏃堕挓璁℃暟
variable V:integer range 0 to 255:=0;--鏈€澶у€?
variable Vi:integer range 0 to 255:=255;--鏈€灏忓€?
variable first:integer range 0 to 1:=0;
variable last_data:integer range 0 to 500000:=0;
variable j:integer range 0 to 5:=0;
begin
if(ok'event and ok='1')then
data:=conv_integer(data_in);
if(data = V_max/129/2)and (data>last_data) then
first:=1;
end if;
j:=j+1;
if(j=5)then
last_data:=data;
j:=0;
end if;
if (first=1)then
pic_data(i)<=data*2;
i<=i+1;
end if;
if(i=1024)then
i<=0;
first:=0;
end if;
if(count=49999)then
V_max<=V*129;--V*3.3/255*10000
V_min<=Vi*129;
Vpp<=V_max-V_min;
Vrms<=Vpp*85355/100000;--/2*1.707...
Hz<=h;
h:=0;
V:=0;
Vi:=255;
count:=0;
else
count:=count+1;
if(V<data)then
V:=data;
end if;
if(data<Vi)then
Vi:=data;
end if;
if(data*129<(V_max+V_min)/2)then
flag:=1;
elsif(flag=1)then
h:=h+1;
flag:=0;
end if;
end if;
end if;
end process;
--缁樺埗
process(clk,ar)
variable do:std_logic:='0';--鍍忕礌鐐规樉绀烘爣蹇椾俊鍙?
variable data_x:integer range 0 to 2000;--娉㈠舰鏄剧ず鍖哄煙X杞村潗鏍?
variable an:integer range 0 to 20000:=1;
begin
--------------------------------缁樺埗鍧愭爣绯?------------------------------------
--妯珫鍧愭爣杞?
--绔栫嚎瀹? --绔栫嚎闀? --妯嚎瀹? --妯嚎闀?
if(((hpos>506 and hpos<510) and(vpos>205+250 and vpos<750+250)) or ((vpos>748+250 and vpos<752+250) and (hpos>508 and hpos<1579)))then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
--妯埢搴︾偣
--涓婄偣 --涓偣 --涓嬬偣 --鐐归暱
elsif((((vpos>283+250 and vpos<287+250) or (vpos>438+250 and vpos<442+250) or (vpos>593+250 and vpos<597+250))and(hpos>=508 and hpos<=516)))then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
--妯埢搴︾嚎
--涓婄嚎 --涓嚎 --涓嬬嚎 --妯嚎闀?
elsif(((vpos=285+250) or (vpos=440+250) or (vpos=595+250)) and (hpos>=508 and hpos<=1579))then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
--绔栧埢搴︾嚎
--宸︾嚎 --鍙崇嚎 --绔栫嚎闀?
elsif((((hpos=615) or (hpos=722) or (hpos=829)or(hpos=936) or (hpos=1043) or (hpos=1150)or(hpos=1257) or (hpos=1364) or (hpos=1471)or (hpos=1578))and(vpos>205+250 and vpos<750+250)))then --鍒诲害绾?
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
--鍏朵綑娑傞粦
else
r<=(others=>'0');
g<=(others=>'0');
b<=(others=>'0');
end if;
----------------------------------------------------------------------------------
------------------------------鍒诲害鏁?---------------------------------
if(hpos>484 and hpos<492)then---------------0
if(vpos>740+250 and vpos<758+250)then
do:=num_0(758+250-vpos)(492-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(vpos>586+250 and vpos<604+250)then---1
do:=num_1(604+250-vpos)(492-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(vpos>431+250 and vpos<449+250)then---2
do:=num_2(449+250-vpos)(492-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(vpos>276+250 and vpos<294+250)then---3
do:=num_3(294+250-vpos)(492-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
end if;
--------------鏍囩---------------------
--鏍囩max
if(vpos>832-600 and vpos<865-600)then
if(hpos>767-240 and hpos<783-240)then
do:=char_M(865-600-vpos)(783-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(hpos>790-240 and hpos<806-240)then
do:=char_a(865-600-vpos)(806-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(hpos>813-240 and hpos<829-240)then
do:=char_x(865-600-vpos)(829-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
--鏍囩min
if(hpos>867-240 and hpos<883-240)then
do:=char_M(865-600-vpos)(883-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(hpos>890-240 and hpos<906-240)then
do:=char_i(865-600-vpos)(906-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(hpos>913-240 and hpos<929-240)then
do:=char_n(865-600-vpos)(929-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
--鏍囩vrms
if(hpos>1558-240 and hpos<1574-240)then
do:=char_dV(865-600-vpos)(1574-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(hpos>1583-240 and hpos<1599-240)then
do:=char_r(865-600-vpos)(1599-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(hpos>1608-240 and hpos<1624-240)then
do:=char_xm(865-600-vpos)(1624-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(hpos>1633-240 and hpos<1649-240)then
do:=char_s(865-600-vpos)(1649-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
--鏍囩freq
if(hpos>1662-240 and hpos<1678-240)then
do:=char_F(865-600-vpos)(1678-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(hpos>1687-240 and hpos<1703-240)then
do:=char_r(865-600-vpos)(1703-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(hpos>1712-240 and hpos<1728-240)then
do:=char_e(865-600-vpos)(1728-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
if(hpos>1737-240 and hpos<1753-240)then
do:=char_q(865-600-vpos)(1753-240-hpos);
if(do='1')then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'1');
end if;
end if;
end if;
------------------------------------鏁版嵁--------------------------------
---------Vmax
if(vpos>932-600and vpos<965-600)then
if(hpos>760-240 and hpos<776-240)then
case (V_max/10000) is
when 0=> do:=num_d0(965-600-vpos)(776-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(776-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(776-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(776-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(776-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(776-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(776-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(776-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(776-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(776-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>776-240 and hpos<784-240 and vpos>949-600) then
do:=char_dot(965-600-vpos)(784-240-hpos);
if(do='1') then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>784-240 and hpos<800-240)then
case ((V_max/1000)REM 10) is
when 0=> do:=num_d0(965-600-vpos)(800-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(800-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(800-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(800-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(800-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(800-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(800-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(800-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(800-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(800-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>800-240 and hpos<816-240)then
case ((V_max/100)REM 10) is
when 0=> do:=num_d0(965-600-vpos)(816-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(816-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(816-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(816-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(816-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(816-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(816-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(816-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(816-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(816-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
--鍗曚綅
if(hpos>816-240 and hpos<832-240)then
do:=char_dV(965-600-vpos)(832-240-hpos);
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
---------V_min
if(hpos>860-240 and hpos<876-240)then
case (V_min/10000) is
when 0=> do:=num_d0(965-600-vpos)(876-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(876-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(876-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(876-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(876-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(876-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(876-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(876-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(876-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(876-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>876-240 and hpos<884-240 and vpos>949-600) then
do:=char_dot(965-600-vpos)(884-240-hpos);
if(do='1') then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>884-240 and hpos<900-240)then
case ((V_min/1000)REM 10) is
when 0=> do:=num_d0(965-600-vpos)(900-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(900-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(900-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(900-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(900-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(900-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(900-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(900-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(900-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(900-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>900-240 and hpos<916-240)then
case ((V_min/100)REM 10) is
when 0=> do:=num_d0(965-600-vpos)(916-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(916-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(916-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(916-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(916-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(916-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(916-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(916-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(916-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(916-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
--鍗曚綅
if(hpos>916-240 and hpos<932-240)then
do:=char_dV(965-600-vpos)(932-240-hpos);
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
---------Vrms
if(hpos>1557-240 and hpos<1573-240)then
case (Vrms/10000) is
when 0=> do:=num_d0(965-600-vpos)(1573-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(1573-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(1573-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(1573-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(1573-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(1573-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(1573-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(1573-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(1573-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(1573-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>1573-240 and hpos<1589-240 and vpos>949-600) then
do:=char_dot(965-600-vpos)(1589-240-hpos);
if(do='1') then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>1589-240 and hpos<1605-240)then
case ((Vrms/1000)REM 10) is
when 0=> do:=num_d0(965-600-vpos)(1605-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(1605-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(1605-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(1605-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(1605-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(1605-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(1605-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(1605-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(1605-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(1605-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>1605-240 and hpos<1621-240)then
case ((Vrms/100)REM 10) is
when 0=> do:=num_d0(965-600-vpos)(1621-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(1621-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(1621-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(1621-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(1621-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(1621-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(1621-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(1621-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(1621-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(1621-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
--鍗曚綅
if(hpos>1621-240 and hpos<1637-240)then
do:=char_dV(965-600-vpos)(1637-240-hpos);
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
---------Freq
if(hpos>1657-240 and hpos<1673-240)then
case (Hz/1000) is
when 0=> do:=num_d0(965-600-vpos)(1673-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(1673-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(1673-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(1673-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(1673-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(1673-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(1673-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(1673-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(1673-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(1673-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>1673-240 and hpos<1689-240)then
case ((Hz/100)REM 10) is
when 0=> do:=num_d0(965-600-vpos)(1689-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(1689-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(1689-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(1689-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(1689-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(1689-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(1689-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(1689-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(1689-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(1689-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>1689-240 and hpos<1705-240)then
case ((Hz/10)REM 10) is
when 0=> do:=num_d0(965-600-vpos)(1705-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(1705-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(1705-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(1705-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(1705-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(1705-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(1705-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(1705-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(1705-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(1705-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>1705-240 and hpos<1721-240)then
case (Hz REM 10) is
when 0=> do:=num_d0(965-600-vpos)(1721-240-hpos);
when 1=> do:=num_d1(965-600-vpos)(1721-240-hpos);
when 2=> do:=num_d2(965-600-vpos)(1721-240-hpos);
when 3=> do:=num_d3(965-600-vpos)(1721-240-hpos);
when 4=> do:=num_d4(965-600-vpos)(1721-240-hpos);
when 5=> do:=num_d5(965-600-vpos)(1721-240-hpos);
when 6=> do:=num_d6(965-600-vpos)(1721-240-hpos);
when 7=> do:=num_d7(965-600-vpos)(1721-240-hpos);
when 8=> do:=num_d8(965-600-vpos)(1721-240-hpos);
when 9=> do:=num_d9(965-600-vpos)(1721-240-hpos);
when others => do:='0';
end case;
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
--鍗曚綅
if(hpos>1721-240 and hpos<1737-240)then
do:=char_H(965-600-vpos)(1737-240-hpos);
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
if(hpos>1737-240 and hpos<1753-240)then
do:=char_z(965-600-vpos)(1753-240-hpos);
if(do='1')then
r<="0001";
g<="0001";
b<="0001";
end if;
end if;
end if;
if(falling_edge(ar))then
if(br='1' and an < 20000)then
an:=an+1;
elsif(br='0' and an > 0)then
an:=an-1;
end if;
end if;
----------------------------娉㈠舰缁樺埗-----------------------------
if(hpos>=508 and hpos<1532)then--鏄剧ず闀垮害鍒掑畾
data_x := hpos-508;--X鍧愭爣
if(vpos<750+250-pic_data(data_x)-an/100+3 and vpos>750+250-pic_data(data_x)-an/100-3) then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'0');
elsif (data_x < 1024) and
(
vpos=((750+250-pic_data(data_x)) + (750+250-pic_data(data_x+1)))/2 -an/100 or
vpos=((750+250-pic_data(data_x)) + 2 * (750+250-pic_data(data_x+1)))/3 -an/100 or
vpos=(2 * (750+250-pic_data(data_x)) + (750+250-pic_data(data_x+1)))/3 -an/100
)
then
r<=(others=>'1');
g<=(others=>'1');
b<=(others=>'0');
end if;
end if;
end process;
end;
帮我分析这个VGA显示器的工作原理
最新发布