请问如何通过FPGA驱动VGA显示一个圆形
2个回答
展开全部
利用圆的方程X^2+Y^2<=z^2.x是行扫描计数值与圆心的差,y是列扫描与圆心的差。这是你要的圆的半径。我给你贴一段程序,我自己写的12个圆环,分了四个象限,比较蠢。不分象限的话要用无符号数。
library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity vga_block isport (clk_40mhz:in std_logic; forming:in integer range 0 to 3; coulour:in integer range 0 to 2; h_or_f:in integer range 0 to 1;vga_out:out std_logic_vector(2 downto 0);hs1,vs1:out std_logic);end;architecture behave of vga_block issignal counter_hs:integer range 0 to 1055; --屏幕中行信号 HS 使用范围signal counter_vs:integer range 0 to 627; --屏幕中场信号 VS 使用范围signal hs,vs:std_logic:='1'; --行信号 hs 和场信号 vs 高电平signal rgb1,rgb2,rgb3:std_logic_vector(2 downto 0); --水平和垂直方向上表示 3 基色的中间变量signal coulour1,coulour2: std_logic_vector(2 downto 0);beginprocess(clk_40mhz) --40MHZ 触发在每行上逐点扫描beginif rising_edge(clk_40mhz) then if counter_hs>=1055 then counter_hs<=0;else counter_hs<=counter_hs+1;end if;end if;end process;process(counter_hs) --行消隐beginif counter_hs>=0 and counter_hs<128 thenhs<='0';elsehs<='1';end if;end process;process(hs)beginif falling_edge(hs) then --VGA 中行同步负脉冲有效if counter_vs>=627 thencounter_vs<=0;else counter_vs<=counter_vs+1; --垂直扫描end if;end if;end process;process(counter_vs) --场消隐beginif counter_vs>=0 and counter_vs<=3 thenvs<='0';elsevs<='1';end if;end process;
process(counter_hs,counter_vs)
if (counter_hs >=216 and counter_hs <=616) then if (counter_vs >=27 and counter_vs <=327) then if (((327-counter_vs)**2+(616-counter_hs)**2) <=90000 and ((327-counter_vs)**2+(616-counter_hs)**2) >=75625)or(((327-counter_vs)**2+(616-counter_hs)**2) < 62500 and ((327-counter_vs)**2+(616-counter_hs)**2) >=50625)or(((327-counter_vs)**2+(616-counter_hs)**2) < 40000 and ((327-counter_vs)**2+(616-counter_hs)**2) >=30625)or(((327-counter_vs)**2+(616-counter_hs)**2) < 22500 and ((327-counter_vs)**2+(616-counter_hs)**2) >=15625)or(((327-counter_vs)**2+(616-counter_hs)**2) < 10000 and ((327-counter_vs)**2+(616-counter_hs)**2) >=5625)or(((327-counter_vs)**2+(616-counter_hs)**2) < 2500 and ((327-counter_vs)**2+(616-counter_hs)**2) >=625) then rgb1 <=coulour1; elsif (((327-counter_vs)**2+(616-counter_hs)**2) < 75625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=62500)or(((327-counter_vs)**2+(616-counter_hs)**2) < 50625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=40000)or(((327-counter_vs)**2+(616-counter_hs)**2) < 30625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=22500)or(((327-counter_vs)**2+(616-counter_hs)**2) < 15625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=10000)or(((327-counter_vs)**2+(616-counter_hs)**2) < 5625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=2500)or(((327-counter_vs)**2+(616-counter_hs)**2) < 625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=0) then rgb1 <=coulour2;else rgb1 <="000";end if; elsif (counter_vs >=327 and counter_vs <=627) then if (((counter_vs-327)**2+(616-counter_hs)**2) <=90000 and ((counter_vs-327)**2+(616-counter_hs)**2) >=75625)or(((counter_vs-327)**2+(616-counter_hs)**2) < 62500 and ((counter_vs-327)**2+(616-counter_hs)**2) >=50625)or(((counter_vs-327)**2+(616-counter_hs)**2) < 40000 and ((counter_vs-327)**2+(616-counter_hs)**2) >=30625)or(((counter_vs-327)**2+(616-counter_hs)**2) < 22500 and ((counter_vs-327)**2+(616-counter_hs)**2) >=15625)or(((counter_vs-327)**2+(616-counter_hs)**2) < 10000 and ((counter_vs-327)**2+(616-counter_hs)**2) >=5625)or(((counter_vs-327)**2+(616-counter_hs)**2) < 2500 and ((counter_vs-327)**2+(616-counter_hs)**2) >=625) then rgb1 <=coulour1; elsif (((counter_vs-327)**2+(616-counter_hs)**2) < 75625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=62500)or(((counter_vs-327)**2+(616-counter_hs)**2) < 50625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=40000)or(((counter_vs-327)**2+(616-counter_hs)**2) < 30625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=22500)or(((counter_vs-327)**2+(616-counter_hs)**2) < 15625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=10000)or(((counter_vs-327)**2+(616-counter_hs)**2) < 5625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=2500)or(((counter_vs-327)**2+(616-counter_hs)**2) < 625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=0) then rgb1 <=coulour2;else rgb1 <="000";end if; end if; elsif (counter_hs >=616 and counter_hs <=1016) then if (counter_vs >=27 and counter_vs <=327) then if (((327-counter_vs)**2+(counter_hs-616)**2) <=90000 and ((327-counter_vs)**2+(counter_hs-616)**2) >=75625)or(((327-counter_vs)**2+(counter_hs-616)**2) < 62500 and ((327-counter_vs)**2+(counter_hs-616)**2) >=50625)or(((327-counter_vs)**2+(counter_hs-616)**2) < 40000 and ((327-counter_vs)**2+(counter_hs-616)**2) >=30625)or(((327-counter_vs)**2+(counter_hs-616)**2) < 22500 and ((327-counter_vs)**2+(counter_hs-616)**2) >=15625)or(((327-counter_vs)**2+(counter_hs-616)**2) < 10000 and ((327-counter_vs)**2+(counter_hs-616)**2) >=5625)or(((327-counter_vs)**2+(counter_hs-616)**2) < 2500 and ((327-counter_vs)**2+(counter_hs-616)**2) >=625) then rgb1 <=coulour1; elsif (((327-counter_vs)**2+(counter_hs-616)**2) < 75625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=62500)or(((327-counter_vs)**2+(counter_hs-616)**2) < 50625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=40000)or(((327-counter_vs)**2+(counter_hs-616)**2) < 30625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=22500)or(((327-counter_vs)**2+(counter_hs-616)**2) < 15625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=10000)or(((327-counter_vs)**2+(counter_hs-616)**2) < 5625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=2500)or(((327-counter_vs)**2+(counter_hs-616)**2) < 625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=0) then rgb1 <=coulour2;else rgb1 <="000";end if; elsif (counter_vs >=327 and counter_vs <=627) then if (((counter_vs-327)**2+(counter_hs-616)**2) <=90000 and ((counter_vs-327)**2+(counter_hs-616)**2) >=75625)or(((counter_vs-327)**2+(counter_hs-616)**2) < 62500 and ((counter_vs-327)**2+(counter_hs-616)**2) >=50625)or(((counter_vs-327)**2+(counter_hs-616)**2) < 40000 and ((counter_vs-327)**2+(counter_hs-616)**2) >=30625)or(((counter_vs-327)**2+(counter_hs-616)**2) < 22500 and ((counter_vs-327)**2+(counter_hs-616)**2) >=15625)or(((counter_vs-327)**2+(counter_hs-616)**2) < 10000 and ((counter_vs-327)**2+(counter_hs-616)**2) >=5625)or(((counter_vs-327)**2+(counter_hs-616)**2) < 2500 and ((counter_vs-327)**2+(counter_hs-616)**2) >=625) then rgb1 <=coulour1; elsif (((counter_vs-327)**2+(counter_hs-616)**2) < 75625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=62500)or(((counter_vs-327)**2+(counter_hs-616)**2) < 50625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=40000)or(((counter_vs-327)**2+(counter_hs-616)**2) < 30625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=22500)or(((counter_vs-327)**2+(counter_hs-616)**2) < 15625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=10000)or(((counter_vs-327)**2+(counter_hs-616)**2) < 5625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=2500)or(((counter_vs-327)**2+(counter_hs-616)**2) < 625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=0) then rgb1 <=coulour2;else rgb1 <="000";end if; end if; end if;--圆环
hs1 <= hs;vs1 <= vs;Vga_out<=rgb1 end process;end;
library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity vga_block isport (clk_40mhz:in std_logic; forming:in integer range 0 to 3; coulour:in integer range 0 to 2; h_or_f:in integer range 0 to 1;vga_out:out std_logic_vector(2 downto 0);hs1,vs1:out std_logic);end;architecture behave of vga_block issignal counter_hs:integer range 0 to 1055; --屏幕中行信号 HS 使用范围signal counter_vs:integer range 0 to 627; --屏幕中场信号 VS 使用范围signal hs,vs:std_logic:='1'; --行信号 hs 和场信号 vs 高电平signal rgb1,rgb2,rgb3:std_logic_vector(2 downto 0); --水平和垂直方向上表示 3 基色的中间变量signal coulour1,coulour2: std_logic_vector(2 downto 0);beginprocess(clk_40mhz) --40MHZ 触发在每行上逐点扫描beginif rising_edge(clk_40mhz) then if counter_hs>=1055 then counter_hs<=0;else counter_hs<=counter_hs+1;end if;end if;end process;process(counter_hs) --行消隐beginif counter_hs>=0 and counter_hs<128 thenhs<='0';elsehs<='1';end if;end process;process(hs)beginif falling_edge(hs) then --VGA 中行同步负脉冲有效if counter_vs>=627 thencounter_vs<=0;else counter_vs<=counter_vs+1; --垂直扫描end if;end if;end process;process(counter_vs) --场消隐beginif counter_vs>=0 and counter_vs<=3 thenvs<='0';elsevs<='1';end if;end process;
process(counter_hs,counter_vs)
if (counter_hs >=216 and counter_hs <=616) then if (counter_vs >=27 and counter_vs <=327) then if (((327-counter_vs)**2+(616-counter_hs)**2) <=90000 and ((327-counter_vs)**2+(616-counter_hs)**2) >=75625)or(((327-counter_vs)**2+(616-counter_hs)**2) < 62500 and ((327-counter_vs)**2+(616-counter_hs)**2) >=50625)or(((327-counter_vs)**2+(616-counter_hs)**2) < 40000 and ((327-counter_vs)**2+(616-counter_hs)**2) >=30625)or(((327-counter_vs)**2+(616-counter_hs)**2) < 22500 and ((327-counter_vs)**2+(616-counter_hs)**2) >=15625)or(((327-counter_vs)**2+(616-counter_hs)**2) < 10000 and ((327-counter_vs)**2+(616-counter_hs)**2) >=5625)or(((327-counter_vs)**2+(616-counter_hs)**2) < 2500 and ((327-counter_vs)**2+(616-counter_hs)**2) >=625) then rgb1 <=coulour1; elsif (((327-counter_vs)**2+(616-counter_hs)**2) < 75625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=62500)or(((327-counter_vs)**2+(616-counter_hs)**2) < 50625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=40000)or(((327-counter_vs)**2+(616-counter_hs)**2) < 30625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=22500)or(((327-counter_vs)**2+(616-counter_hs)**2) < 15625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=10000)or(((327-counter_vs)**2+(616-counter_hs)**2) < 5625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=2500)or(((327-counter_vs)**2+(616-counter_hs)**2) < 625 and ((327-counter_vs)**2+(616-counter_hs)**2) >=0) then rgb1 <=coulour2;else rgb1 <="000";end if; elsif (counter_vs >=327 and counter_vs <=627) then if (((counter_vs-327)**2+(616-counter_hs)**2) <=90000 and ((counter_vs-327)**2+(616-counter_hs)**2) >=75625)or(((counter_vs-327)**2+(616-counter_hs)**2) < 62500 and ((counter_vs-327)**2+(616-counter_hs)**2) >=50625)or(((counter_vs-327)**2+(616-counter_hs)**2) < 40000 and ((counter_vs-327)**2+(616-counter_hs)**2) >=30625)or(((counter_vs-327)**2+(616-counter_hs)**2) < 22500 and ((counter_vs-327)**2+(616-counter_hs)**2) >=15625)or(((counter_vs-327)**2+(616-counter_hs)**2) < 10000 and ((counter_vs-327)**2+(616-counter_hs)**2) >=5625)or(((counter_vs-327)**2+(616-counter_hs)**2) < 2500 and ((counter_vs-327)**2+(616-counter_hs)**2) >=625) then rgb1 <=coulour1; elsif (((counter_vs-327)**2+(616-counter_hs)**2) < 75625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=62500)or(((counter_vs-327)**2+(616-counter_hs)**2) < 50625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=40000)or(((counter_vs-327)**2+(616-counter_hs)**2) < 30625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=22500)or(((counter_vs-327)**2+(616-counter_hs)**2) < 15625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=10000)or(((counter_vs-327)**2+(616-counter_hs)**2) < 5625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=2500)or(((counter_vs-327)**2+(616-counter_hs)**2) < 625 and ((counter_vs-327)**2+(616-counter_hs)**2) >=0) then rgb1 <=coulour2;else rgb1 <="000";end if; end if; elsif (counter_hs >=616 and counter_hs <=1016) then if (counter_vs >=27 and counter_vs <=327) then if (((327-counter_vs)**2+(counter_hs-616)**2) <=90000 and ((327-counter_vs)**2+(counter_hs-616)**2) >=75625)or(((327-counter_vs)**2+(counter_hs-616)**2) < 62500 and ((327-counter_vs)**2+(counter_hs-616)**2) >=50625)or(((327-counter_vs)**2+(counter_hs-616)**2) < 40000 and ((327-counter_vs)**2+(counter_hs-616)**2) >=30625)or(((327-counter_vs)**2+(counter_hs-616)**2) < 22500 and ((327-counter_vs)**2+(counter_hs-616)**2) >=15625)or(((327-counter_vs)**2+(counter_hs-616)**2) < 10000 and ((327-counter_vs)**2+(counter_hs-616)**2) >=5625)or(((327-counter_vs)**2+(counter_hs-616)**2) < 2500 and ((327-counter_vs)**2+(counter_hs-616)**2) >=625) then rgb1 <=coulour1; elsif (((327-counter_vs)**2+(counter_hs-616)**2) < 75625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=62500)or(((327-counter_vs)**2+(counter_hs-616)**2) < 50625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=40000)or(((327-counter_vs)**2+(counter_hs-616)**2) < 30625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=22500)or(((327-counter_vs)**2+(counter_hs-616)**2) < 15625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=10000)or(((327-counter_vs)**2+(counter_hs-616)**2) < 5625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=2500)or(((327-counter_vs)**2+(counter_hs-616)**2) < 625 and ((327-counter_vs)**2+(counter_hs-616)**2) >=0) then rgb1 <=coulour2;else rgb1 <="000";end if; elsif (counter_vs >=327 and counter_vs <=627) then if (((counter_vs-327)**2+(counter_hs-616)**2) <=90000 and ((counter_vs-327)**2+(counter_hs-616)**2) >=75625)or(((counter_vs-327)**2+(counter_hs-616)**2) < 62500 and ((counter_vs-327)**2+(counter_hs-616)**2) >=50625)or(((counter_vs-327)**2+(counter_hs-616)**2) < 40000 and ((counter_vs-327)**2+(counter_hs-616)**2) >=30625)or(((counter_vs-327)**2+(counter_hs-616)**2) < 22500 and ((counter_vs-327)**2+(counter_hs-616)**2) >=15625)or(((counter_vs-327)**2+(counter_hs-616)**2) < 10000 and ((counter_vs-327)**2+(counter_hs-616)**2) >=5625)or(((counter_vs-327)**2+(counter_hs-616)**2) < 2500 and ((counter_vs-327)**2+(counter_hs-616)**2) >=625) then rgb1 <=coulour1; elsif (((counter_vs-327)**2+(counter_hs-616)**2) < 75625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=62500)or(((counter_vs-327)**2+(counter_hs-616)**2) < 50625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=40000)or(((counter_vs-327)**2+(counter_hs-616)**2) < 30625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=22500)or(((counter_vs-327)**2+(counter_hs-616)**2) < 15625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=10000)or(((counter_vs-327)**2+(counter_hs-616)**2) < 5625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=2500)or(((counter_vs-327)**2+(counter_hs-616)**2) < 625 and ((counter_vs-327)**2+(counter_hs-616)**2) >=0) then rgb1 <=coulour2;else rgb1 <="000";end if; end if; end if;--圆环
hs1 <= hs;vs1 <= vs;Vga_out<=rgb1 end process;end;
深圳市大雅新科技有限公司
2020-03-06 广告
2020-03-06 广告
这方面更多更全面的信息其实可以找下大雅新。深圳市大雅新科技有限公司从事KVM延长器,DVI延长器,USB延长器,键盘鼠标延长器,双绞线视频传输器,VGA视频双绞线传输器,VGA延长器,VGA视频延长器,DVI KVM 切换器等,优质供应商,...
点击进入详情页
本回答由深圳市大雅新科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询