我使用的是Basys3 FPGA,我有一个在显示器上显示一组图像的测试图形生成器。基本上,它看起来像是整个第一个垂直列向下移动了一个像素。
根据我的教授告诉我的,这个问题是由于信号( h_sync,v_sync,RGB)不同步,h_sync和v_sync提前1位造成的,这是由于我选择图像时RGB信号的延迟。通过选择,我的意思是,我有4个活动的开关(基于它们的开/关状态)以“二进制方式”选择图像。(示例:4个开关处于0101状态,则显示第5个图像。0011状态、第三图像显示等。)
以下是选择的代码:
type Colors is array (0 to 15) of STD_LOGIC_VECTOR (7 downto 0);
signal redArr : Colors;
signal greenArr : Colors;
signal blueArr : Colors;
process (CLK)
begin
if (CLK'EVENT and CLK = '1') then
if flagAV = '1' then
RED <= redArr (conv_integer (SW));
GREEN <= greenArr (conv_integer (SW));
BLUE <= blueArr (conv_integer (SW));
else
RED <= "00000000";
GREEN <= "00000000";
BLUE <= "00000000";
end if;
LED <= SW;
end if;
end process;数组(颜色)有16个元素,因为我有16个图像,因此4个开关(SW)足以显示所有这些元素。我使用8位每种颜色。flagAV只是检查我是否是活动区域。
然后,使用来自VGADrive的H/V消隐信号将计数器内置在图像选择模块中。
VGADrive中定义的H/V同步和消隐信号:
HorizontalSync: process (CLK)
begin
if (CLK'EVENT and CLK = '1') then
if (inCntHor = RES.cstHorFP + RES.cstHorAL - 1) then
inHS <= '0';
elsif (inCntHor = RES.cstHorFP + RES.cstHorAL + RES.cstHorPW - 1) then
inHS <= '1';
end if;
end if;
end process;
HorizontalBlanking: process (CLK)
begin
if (CLK'EVENT and CLK = '1') then
if (inCntHor = RES.cstHorAL - 1) then
inHBL <= '1';
elsif (inCntHor = RES.cstHorTotSize - 1) then
inHBL <= '0';
end if;
end if;
end process;
VerticalSync: process (CLK)
begin
if (CLK'EVENT and CLK = '1') then
if (inCntVer = RES.cstVerFP + RES.cstVerAL - 1) then
inVS <= '0';
elsif (inCntVer < RES.cstVerFP + RES.cstVerAL + RES.cstVerPW - 1) then
inVS <= '1';
end if;
end if;
end process;
VerticalBlanking: process (CLK)
begin
if (CLK'EVENT and CLK = '1') then
if (inCntVer = RES.cstVerAL - 1) then
inVBL <= '1';
elsif (inCntVer = RES.cstVerTotSize - 1) then
inVBL <= '0';
end if;
end if;
end process;使用消隐信号的图像选择模块(VGADraw)中内置的计数器:
VerticalCounter: process (CLK)
begin
if (CLK'EVENT and CLK = '1') then
HBLold <= HBL;
if HBL = '0' and HBLold = '1' then
if VBL = '1' then
incntVer <= 0;
else
incntVer <= incntVer + 1;
end if;
end if;
end if;
end process;
HorizontalCounter: process (CLK)
begin
if (CLK'EVENT and CLK = '1') then
if HBL = '1' then
incntHor <= 0;
else
incntHor <= incntHor + 1;
end if;
end if;
end process;cstHorAL -像素/活动线条
cstHorFP -像素/前廊
cstHorPW -像素/脉冲宽度
cstHorBP -像素/后门廊
cstHorTotSize -像素/总行
cstVerAL -线路/活动线路
cstVerFP -线路/前廊
cstVerPW -线路/脉冲宽度
cstVerBP -线路/后门廊
cstVerTotSize -行/总帧数
HBLold -用于下降沿检测
我的问题是,如何将h_sync和v_sync信号延迟1位,以便在不移位第一个像素的情况下正确显示图像,以及在哪个模块中执行此操作?
发布于 2016-06-17 00:43:13
既然你说你实现了一个周期延迟,那么尝试更多的周期延迟,比如:
process(CLK) is
begin
if rising_edge(CLK) then
a_q <= a;
a_q_q <= a_q;
a_q_q_q <= a_q_q;
-- etc
end if;
end process;如果你想要更整洁的代码,你可以使用FOR循环来延迟任何你想要的信号周期,比如
-- In Architecture
constant num_cycles : INTEGER := 3;
signal a_v : std_logic_vector(num_cycles downto 0);
begin
a_v(0) <= a;
process(CLK) is
begin
if rising_edge(CLK) then
for i in 0 to num_cycles loop
a_v(i+1) <= a_v(i);
end loop;
end if;
end process;
end architecture;在这种情况下,a可以是h_sync或v_sync。num_cycles是您想要延迟的周期数。a_v是一个向量。要使用延迟信号,只需使用a_v(num_cycles)
https://stackoverflow.com/questions/37857777
复制相似问题