Processeur/Processeur.srcs/sources_1/new/Ecran.vhd
2021-06-30 16:36:19 +02:00

118 lines
3.8 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 work.font.all;
entity Ecran is
Generic ( HEIGHT : Natural;
WIDTH : Natural
);
Port ( CLK : in STD_LOGIC;
RST : in STD_LOGIC;
Data_Av : in STD_LOGIC;
Data_IN : in Natural;
X : in Natural;
Y : in Natural;
OUT_ON : out STD_LOGIC);
end Ecran;
architecture Behavioral of Ecran is
component TableASCII is
Port ( CodeASCII : Natural;
Font : out font_T);
end component;
constant Flush : Natural := 0;
constant RetourChariot : Natural := 13;
constant CaracterHeight : Natural := 16;
constant CaracterWidht : Natural := 16;
constant HeightSize : Natural := HEIGHT/CaracterHeight;
constant WidthSize : Natural := WIDTH/CaracterWidht;
type T_Ligne is array (0 to WidthSize - 1) of Natural;
type T_Ecran is array (0 to HeightSize - 1) of T_Ligne;
signal Ecran : T_Ecran := (others => (0 => 72, 1 => 101, 2 => 108, 3 => 108, 4 => 111, 5 => 32, 6 => 87, 7 => 111, 8 => 114, 9 => 108, 10 => 100, others => 0));
signal L : Natural := 0;
signal C : Natural := 0;
signal InitialL : Natural := 0;
signal Full : BOOLEAN := false;
signal CurrentCodeASCII : Natural := 0;
signal CurrentFont : font_T;
begin
instance_TableASCII : TableASCII
port map (CodeASCII => CurrentCodeASCII,
Font => CurrentFont);
process
begin
wait until CLK'event and CLK='1';
if (RST = '0') then
Ecran <= (others => (others => 0));
L <= 0;
C <= 0;
InitialL <= 0;
Full <= false;
elsif (Data_Av = '1') then
if (Data_IN = Flush) then
Ecran <= (others => (others => 0));
L <= 0;
C <= 0;
InitialL <= 0;
Full <= false;
elsif (Data_IN = RetourChariot) then
C <= 0;
L <= (L + 1) mod HeightSize;
if ((L + 1) mod HeightSize = 0 or Full) then
Full <= true;
InitialL <= (InitialL + 1) mod HeightSize;
Ecran((L + 1) mod HeightSize) <= (others => 0);
end if;
else
Ecran(L)(C) <= Data_IN;
C <= C + 1;
if (C + 1 = WidthSize) then
C <= 0;
L <= (L + 1) mod HeightSize;
if ((L + 1) mod HeightSize = 0 or Full) then
Full <= true;
InitialL <= (InitialL + 1) mod HeightSize;
Ecran((L + 1) mod HeightSize) <= (others => 0);
end if;
end if;
end if;
end if;
end process;
CurrentCodeASCII <= Ecran((Y/CaracterHeight + InitialL) mod HeightSize)(X/CaracterWidht) when (Y/CaracterHeight < HeightSize and X/CaracterWidht < WidthSize and RST='1') else
0;
OUT_ON <= CurrentFont((Y mod CaracterHeight) / (CaracterHeight / font_height), (X mod CaracterWidht) / (CaracterWidht / font_width));
end Behavioral;