From 175d0d37b778f5b8e5a7693db6b07172ef706d4d Mon Sep 17 00:00:00 2001 From: leo Date: Sun, 19 Dec 2021 23:05:28 +0100 Subject: [PATCH] l'affichage marche presque --- sources_snake/Gene_Snake.vhd | 76 +++++++++++++++++++---------------- sources_snake/VGA_top.vhd | 7 ++-- sources_snake/updateSnake.vhd | 2 +- 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/sources_snake/Gene_Snake.vhd b/sources_snake/Gene_Snake.vhd index 22697b3..e455c9c 100644 --- a/sources_snake/Gene_Snake.vhd +++ b/sources_snake/Gene_Snake.vhd @@ -59,55 +59,61 @@ signal snakeHere: std_logic; --1 si on doit afficher le pixel 0 sinon signal dx : signed(2 downto 0); signal dy : signed(2 downto 0); signal running : std_logic; +signal startUpdate : std_logic; +signal snakePresentBuffer : std_logic; begin -- Process de calcul d'affichage -process(X,Y,clk,reset,running,dx,dy,updateOrder,currentSnake,snakeHere) +process(X,Y,clk,reset,running,dx,dy,updateOrder,currentSnake,snakeHere,snakePresentBuffer) begin ---if(updateOrder'event and updateOrder = '1') then --- running <= '1'; --- snakeHere <= '0'; --- dx <= to_signed(-1,3); --- dy <= to_signed(-1,3); ---end if; +if(updateOrder'event and updateOrder = '1') then + snakePresentBuffer <= snakeHere; + startUpdate <= '1'; +end if; ---if(reset = '0') then --- dx <= to_signed(-1,3); --- dy <= to_signed(-1,3); --- running <= '0'; --- snakeHere <= '0'; ---elsif(clk'event and clk = '1') then --- if(running = '1') then --- dx <= dx + 1; +if(reset = '0') then + running <= '0'; + snakeHere <= '0'; + snakePresentBuffer <= '0'; +elsif(clk'event and clk = '1') then + if(startUpdate = '1') then + running <= '1'; + snakeHere <= '0'; + dx <= to_signed(-1,3); + dy <= to_signed(-1,3); + end if; + if(running = '1') then + dx <= dx + 1; + if(dx = 2) then + dx <= to_signed(-1,3); + dy <= dy + 1; + end if; --- if(dx = 2) then --- dx <= to_signed(-1,3); --- dy <= dy + 1; --- end if; --- end if; ---end if; -if(clk'event and clk = '1') then - if(currentSnake.isDefined = '1') then - --if(X>=currentSnake.X-8 and X<=currentSnake.X+8 and Y>=currentSnake.Y-8 and Y<=currentSnake.Y+8) then - snakeHere <= '1'; - --end if; - else - snakeHere <= '0'; + if(dy = 2) then + dy <= to_signed(-1,3); + running <= '0'; + end if; + + if(currentSnake.isDefined = '1') then + --if(X>=currentSnake.X-8 and X<=currentSnake.X+8 and Y>=currentSnake.Y-8 and Y<=currentSnake.Y+8) then + snakeHere <= '1'; + --end if; + end if; end if; end if; ---if(dy = 2) then --- dy <= to_signed(-1,3); --- running <= '0'; ---end if; +if(running = '1') then + startUpdate <= '0'; +end if; + end process; ---matAddress <= resize(shift_right(to_unsigned(to_integer(Y)+to_integer(dy),9),4)*40+shift_right(to_unsigned(to_integer(X)+to_integer(dx),10),4),SNAKE_ADDRESS_SIZE); --on resize parce qu'il as décidé que le resultat faisait 18bits au lieu des 11 attendus -matAddress <= resize(shift_right(Y,4)*40+shift_right(X,4),SNAKE_ADDRESS_SIZE); +matAddress <= resize(shift_right(to_unsigned(to_integer(Y)+to_integer(dy),9),4)*40+shift_right(to_unsigned(to_integer(X)+to_integer(dx),10),4),SNAKE_ADDRESS_SIZE); --on resize parce qu'il as décidé que le resultat faisait 18bits au lieu des 11 attendus +--matAddress <= '0' & X/16;--resize(shift_right(Y,4)*40+shift_right(X,4),SNAKE_ADDRESS_SIZE); currentAddress <= listRef; -snakePresent <= snakeHere; +snakePresent <= snakePresentBuffer; end Behavioral; diff --git a/sources_snake/VGA_top.vhd b/sources_snake/VGA_top.vhd index 8161632..a4fa3f8 100644 --- a/sources_snake/VGA_top.vhd +++ b/sources_snake/VGA_top.vhd @@ -247,7 +247,7 @@ U6 : snakeRAM --La RAM pour le snake address1 => displayRAMAddress, data1 => displayRAMdata, writeEnable1 => '0', - clk1 => pxl_clk, + clk1 => H125MHz, address2 => updateRAMAddress, data2 => updateRAMData, @@ -265,7 +265,7 @@ U7 : snakeRAM --La RAM pour la matrice de correspondance address1 => matdispRAMAddress, data1 => matdispRAMdata, writeEnable1 => '0', - clk1 => pxl_clk, + clk1 => H125MHz, address2 => matupdRAMAddress, data2 => std_logic_vector(matupdRAMData), @@ -273,5 +273,6 @@ U7 : snakeRAM --La RAM pour la matrice de correspondance clk2 => H125MHz ); -led <= std_logic_vector(displayRAMData(3 downto 0)); +led(0) <= resetGeneral; +led(1) <= updateRAMWE; end Behavioral; diff --git a/sources_snake/updateSnake.vhd b/sources_snake/updateSnake.vhd index c844f67..2874bca 100644 --- a/sources_snake/updateSnake.vhd +++ b/sources_snake/updateSnake.vhd @@ -96,7 +96,7 @@ begin currentSnake.dirY <= to_signed(0,2); currentSnake.isDefined <= '0'; - matAddress <= to_unsigned(10,SNAKE_ADDRESS_SIZE); + matAddress <= index; matData <= to_unsigned(10,SNAKE_ADDRESS_SIZE); end if; end process;