Reputation: 39
I'm trying to display an animated image on a screen, thanks to the VGA port on a FPGA board.
So, I have a entity called sonic_digit which permits to send my image :
sonic_digit0 : sonic_digit port map(
val => val2,
posX=> posXX,
posY =>conv_std_logic_vector(300,10),
rgbOut => rgb,
beamX=>beamX,
beamY=>beamY,
beamValid=>beamValid);
val is used to change the image (the sprite to display).
Firstly, I want to display in a loop the 3 first sprites and stop it when it reaches the 550th pixel in x and the show the 4th sprite. So I have to have for val : 00, 01, 10, 00, 01, 10, 00 ........ and then 11 when 550 is reached by posXX.
So, I tired to use my process which also manage the time between two images :
process (clk50) begin
if rising_edge(clk50) then
count <= count+1;
if count = conv_std_logic_vector(0,23) then
posXX <= posXX+1;
val2 <= val2+1;
if val2 = "11" then
val2 <= "00";
end if;
end if;
end if;
end process;
My image correctly moves in x but it keep increasing to 11, like if the line if val2 = "11" doesn't work... I have 00, 01, 10, 11, 00, 01, 10, 11, ...
Anyone have an idea ? Thanks for your help
Upvotes: 1
Views: 161
Reputation: 3365
The val2 comparison is synchronous and occurs only on the rising edge of your clock. So the value of val2 has to increment to "11" for the comparison to trigger, so the sequence generated is "00" "01" "10" "11" "00" ...
If you want to omit the "11" term, your conditional needs to be:
if val2 = "10" then
val2 <= "00";
end if;
Also, while not strictly required, I do not like overlapping assignments in process blocks, so I would refactor your code to be:
if val2 = "10" then
val2 <= "00";
else
val2 <= val2 + 1;
end if;
Upvotes: 2