Processeur/Processeur.srcs/sources_1/new/Ecran.vhd
2021-07-19 18:55:23 +02:00

129 lines
5 KiB
VHDL

----------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 28.06.2021 09:20:00
-- Design Name:
-- Module Name: Ecran - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
use work.font.all;
use work.ScreenProperties.all;
entity Ecran is
Port ( CLK : in STD_LOGIC;
RST : in STD_LOGIC;
Data_Av : in STD_LOGIC;
Data_IN : in STD_LOGIC_VECTOR (0 to 6);
X : in X_T;
Y : in Y_T;
OUT_ON : out STD_LOGIC);
end Ecran;
architecture Behavioral of Ecran is
component TableASCII is
Port ( CodeASCII : STD_LOGIC_VECTOR (0 to 6);
Font : out STD_LOGIC_VECTOR (0 to (font_width * font_height) - 1));
end component;
constant Flush : STD_LOGIC_VECTOR (0 to 6) := "0000000";
constant RetourChariot : STD_LOGIC_VECTOR (0 to 6) := "0001010";
constant Delete : STD_LOGIC_VECTOR (0 to 6) := "1111111";
signal Ecran : STD_LOGIC_VECTOR (0 to Ecran_Taille - 1) := (others => '0'); --(0 => '1', 1 => '0', 2 => '0', 3 => '1', 4 => '0', 5 => '0', 6 => '0', others => '0');
signal L : STD_LOGIC_VECTOR (0 to 6) := "0000000";
signal L_inc : STD_LOGIC_VECTOR (0 to 6);
signal C : STD_LOGIC_VECTOR (0 to 6) := "0000000";
signal InitialL : STD_LOGIC_VECTOR (0 to 6) := "0000000";
signal InitialL_inc : STD_LOGIC_VECTOR (0 to 6);
signal Full : STD_LOGIC := '0';
signal L_Lecture : L_T := 0;
signal point_dereferencement : Natural := 0;
signal point_dereferencement_ecriture : Natural := 0;
signal CurrentCodeASCII : STD_LOGIC_VECTOR (0 to 6) := "0000000";
signal CurrentFont : STD_LOGIC_VECTOR (0 to (font_width * font_height) - 1) := (others => '0');
signal position_X : X_T := 0;
signal position_Y : Y_T := 0;
signal active : Boolean := false;
begin
instance_TableASCII : TableASCII
port map (CodeASCII => CurrentCodeASCII,
Font => CurrentFont);
process
begin
wait until CLK'event and CLK='1';
if (RST = '0' or (Data_Av = '1' and Data_IN = Flush)) then
Ecran <= (others => '0');
L <= "0000000";
C <= "0000000";
InitialL <= "0000000";
Full <= '0';
elsif (Data_Av = '1') then
if (Data_IN = Delete) then
if (C > 0) then
C <= C - 1;
Ecran(7 * (C_Blocks * to_integer(unsigned(L)) + to_integer(unsigned(C)) - 1) to 7 * (C_Blocks * to_integer(unsigned(L)) + to_integer(unsigned(C))) - 1) <= "0000000";
end if;
elsif (Data_In /= RetourChariot) then
Ecran(point_dereferencement_ecriture to point_dereferencement_ecriture + 6) <= Data_IN;
C <= C + 1;
end if;
if (Data_IN = RetourChariot or (C + 1 = C_Blocks and Data_IN /= Delete)) then
C <= "0000000";
L <= L_inc;
if (L_inc = "0000000" or Full = '1') then
Full <= '1';
InitialL <= InitialL_inc;
Ecran(7 * C_Blocks * to_integer(unsigned(L_inc)) to 7 * C_Blocks * (to_integer(unsigned(L_inc)) + 1) - 1) <= Zero_Line;
end if;
end if;
end if;
end process;
L_inc <= "0000000" when L + 1 = L_Blocks else L + 1;
InitialL_inc <= "0000000" when InitialL + 1 = L_Blocks else InitialL + 1;
point_dereferencement_ecriture <= 7 * (C_Blocks * to_integer(unsigned(L)) + to_integer(unsigned(C)));
position_X <= X - margin when X >= 0 + margin and X < screen_width - margin else 0;
position_Y <= Y - margin when Y >= 0 + margin and Y < screen_height - margin else 0;
active <= X >= 0 + margin and X < screen_width - margin and Y >= 0 + margin and Y < screen_height - margin;
L_Lecture <= position_Y/Display_CaracterHeight + to_integer(unsigned(InitialL)) - L_Blocks when (position_Y/Display_CaracterHeight + to_integer(unsigned(InitialL))) >= L_Blocks else position_Y/Display_CaracterHeight + to_integer(unsigned(InitialL));
point_dereferencement <= (7 * (C_Blocks * L_Lecture + (position_X/Display_CaracterWidht)));
CurrentCodeASCII <= Ecran(point_dereferencement to point_dereferencement + 6);
OUT_ON <= CurrentFont(((position_Y mod Display_CaracterHeight) / (Display_CaracterHeight / font_height)) * font_width + ((Display_CaracterWidht - 1) - (position_X mod Display_CaracterWidht)) / (Display_CaracterWidht / font_width)) when active else '0';
end Behavioral;