ฉันกำลังทำงานกับ VGA บน Basys3 FPGA ของฉัน และตอนนี้ฉันต้องการวาดโซนเพลต ซึ่งสมการคือ (1 + cos(k*r^2)) / 2 โดยที่ r คือระยะห่างจากศูนย์กลางเพลต และ k=2*pi/lambda คือเลขคลื่นซึ่งกำหนดขนาดของเพลต ฉันเดาว่าแนวทางปฏิบัติที่ดีที่สุดคือการใช้โคไซน์ LUT แต่ฉันไม่รู้ว่าจะสร้างได้อย่างไร ฉันค่อนข้างเข้าใจแนวคิดเบื้องหลัง แต่ฉันไม่รู้ว่าจะเขียนอย่างไรและควรมีค่าใด
นี่คือรหัสที่ฉันพยายามทดสอบ:
ปัญหาเดียวในตอนนี้คือฉันไม่รู้ว่าจะต้องเติม memory_type :=()
ด้วยค่าใด เพื่อที่มันจะเท่ากับ k*r^2 จากสูตร
architecture Behavioral of VGAdraw is
signal i : integer range 0 to 29:=0;
signal r : integer :=2;
type memory_type is array (0 to 29) of integer range -128 to 127;
signal cosine : memory_type :=();
begin
process(CLK)
begin
if (CLK'EVENT and CLK = '1') then
if (cntHor >= 0) AND (cntHor <= cstHorAL - 1) then
RED <= conv_std_logic_vector ((1 - cosine (i)) / 2, 8) (7 downto 4);
GREEN <= conv_std_logic_vector ((1 - cosine (i)) / 2, 8) (7 downto 4);
BLUE <= conv_std_logic_vector ((1 - cosine (i)) / 2, 8) (7 downto 4);
i <= i + 1;
else
RED <= "0000";
GREEN <= "0000";
BLUE <= "0000";
end if;
end if;
end process;
end Behavioral;
cntHor - ตัวนับแนวนอน
cstHorAL - จำนวนพิกเซลบนบรรทัดที่ใช้งานอยู่
ฉันไม่สามารถโพสต์ภาพได้เนื่องจากขาดชื่อเสียง แต่ภาพควรมีลักษณะดังนี้: http://handforgedvideo.com/wp-content/uploads/2013/02/1920x1080p24_Luma_Zone_Plate_Main.png
ความช่วยเหลือใด ๆ ที่ชื่นชม ขอบคุณ!