画圈vhdl

画圈vhdl,vhdl,fpga,Vhdl,Fpga,如何用VHDL绘制圆? 有 Sow,我需要画一个半径为100像素的红色圆圈。我想我应该用一些向量,但是怎么用呢 entity VGAFrameTest is port( yrow, xcolumn : in unsigned(9 downto 0); -- row and column number of VGA video VGA_CLK : in std_logic; -- pixel clock VGA_R, VGA_G,

如何用VHDL绘制圆? 有

Sow,我需要画一个半径为100像素的红色圆圈。我想我应该用一些向量,但是怎么用呢

entity VGAFrameTest is
port(   yrow, xcolumn : in unsigned(9 downto 0); -- row and  column number of VGA video
        VGA_CLK : in std_logic;                -- pixel clock
        VGA_R, VGA_G, VGA_B: out std_logic_vector(9 downto 0)); --  color information
end;

architecture rtl of VGAFrameTest is
constant COLOR_ON : std_logic_vector(9 downto 0) := (others=>'1'); 
constant COLOR_OFF : std_logic_vector(9 downto 0) := (others=>'0');
constant ROW_HEIGHT : integer := 480; -- number of visible rows
恒定列宽:整数:=640-1;--可见列数-更正
开始
帧:进程(VGA_CLK)
开始
如果是上升沿(VGA时钟),则

一种方法是在
X**2+Y**2=R**2上的一些变体
例如
Y=Sqrt(R**2-X**2)

高效实现的诀窍是避免像sqrt这样昂贵的操作,并最小化(稍微)昂贵的乘法

你可以对Y进行猜测(从你知道Y为0的某个地方开始),将其平方,并将每一个新的X与R*2-X*2进行比较,在猜错得太多时修改你的猜测。 马丁的搜索词在这里会很有用


在屏幕上的正确位置设置原点(0,0)的坐标变换相对容易。

您可以通过将157696更改为(160000-r^2)来设置任何半径

480和640是圆心乘以2

  begin
      frame:process(VGA_CLK)
      begin
      if rising_edge(VGA_CLK) then 
      VGA_R<=COLOR_OFF;VGA_G<=COLOR_OFF;VGA_B<=COLOR_OFF;
            if yrow>159 and yrow <320 and xcolumn < 440  and xcolumn > 199  then 
              VGA_B<=COLOR_ON; VGA_G<=COLOR_ON;VGA_R<=COLOR_ON;   

               if  (480*yrow-yrow*yrow+640*xcolumn-xcolumn*xcolumn )> 157696   then
              VGA_B<="0001001100"; VGA_G<=COLOR_OFF; VGA_R <= "1011111000";  
             end if;
            end if;  


 end if;    
 end process;
开始
帧:进程(VGA_CLK)
开始
如果是上升沿(VGA时钟),则

VGA\u r潜在有用的搜索词:bresenham,Scanline抱歉,这里没有更多信息。如果您知道足够的VHDL来编写您最初发布的代码,那么您可以从我的答案中的提示中了解足够的内容来完成项目。
constant COLUMN_WIDTH : integer := 640 -1 ; -- number of visible columns - correction

begin
  frame:process(VGA_CLK)
  begin
  if rising_edge(VGA_CLK) then
        VGA_R<=COLOR_ON;VGA_G<=COLOR_ON;VGA_B<=COLOR_ON; --initilize  color to white  
        if (yrow = 240 and xcolumn = 320) then
          VGA_B<=COLOR_OFF; VGA_G<=COLOR_OFF; 
        elsif yrow = 1 or yrow = ROW_HEIGHT-2 or xcolumn=1 or xcolumn = COLUMN_WIDTH-2 then
          VGA_R<=COLOR_OFF; VGA_G<=COLOR_OFF; VGA_B<=COLOR_OFF; -- black frame
        elsif yrow = ROW_HEIGHT-1 then        
          VGA_B<=COLOR_OFF; VGA_G<=COLOR_OFF; --last  column is red
        end if;  
 end if;    
 end process;

end;
  begin
      frame:process(VGA_CLK)
      begin
      if rising_edge(VGA_CLK) then 
      VGA_R<=COLOR_OFF;VGA_G<=COLOR_OFF;VGA_B<=COLOR_OFF;
            if yrow>159 and yrow <320 and xcolumn < 440  and xcolumn > 199  then 
              VGA_B<=COLOR_ON; VGA_G<=COLOR_ON;VGA_R<=COLOR_ON;   

               if  (480*yrow-yrow*yrow+640*xcolumn-xcolumn*xcolumn )> 157696   then
              VGA_B<="0001001100"; VGA_G<=COLOR_OFF; VGA_R <= "1011111000";  
             end if;
            end if;  


 end if;    
 end process;