For a project i got a screen with a resolution of 1024*600. For the project i need a squarre of 20px *20px with a red color. Im trying to get my verticale pos en horizontale pos out of the hsync en vsync pulse but this doesn't work. Have anyone a solution?
process(int_hsync, int_vsync)
begin
if Rising_Edge(int_vsync) then
vsync <= 0;
elsif Rising_Edge(in_clk) then
vsync <= vsync+1;
end if;
if Rising_Edge(int_hsync) then
hsync <= 0;
elsif Rising_Edge(in_clk) then
hsync <= hsync+1;
end if;
end process;
process(in_clk)
begin
if Rising_Edge(in_clk) then
if hsync < 20 and vsync <20 then
int_pixel <= X"0000ff";
else
int_pixel <= X"ff0000";
end if;
end if;
end process;
Without some additional details it is very difficult to tell what you are trying to do.
However, I did notice that your process is only sensitive to int_hsync
and int_vsync
, yet you are looking for a rising_edge of in_clk
. You should do an edge detect similar to this, instead (assuming that in_clk
is much faster than hsync and vsync):
process(in_clk)
begin
if rising_edge(in_clk) then
int_vsync_dly <= int_vsync;
int_hsync_dly <= int_hsync;
if int_vsync = '1' and int_vsync_dly = '0' then -- rising edge detect
vsync <= 0;
else
vsync <= vsync+1;
end if;
if int_hsync = '1' and int_hsync_dly = '0' then -- rising edge detect
hsync <= 0;
else
hsync <= hsync+1;
end if;
end if;
end process;
This increments vsync
and hsync
counters every time a rising edge of the respective trigger signals is observed. Do make sure that the inputs are properly registered before the edge detection to help avoid meta-stable cases.