Commentaires

This commit is contained in:
Paul Faure 2021-07-30 10:09:20 +02:00
parent 7230638484
commit d3d3c6da9c
18 changed files with 333 additions and 333 deletions

View file

@ -1,21 +1,16 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 05.07.2021 15:20:28
-- Design Name:
-- Module Name: Compteur_X - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
-- Description: Compteur la coordonnée X du VGA
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- - None
----------------------------------------------------------------------------------

View file

@ -1,21 +1,16 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 05.07.2021 15:20:28
-- Design Name:
-- Module Name: Compteur_Y - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
-- Description: Compteur la coordonnée Y du VGA
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- - None
----------------------------------------------------------------------------------

View file

@ -1,21 +1,18 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 28.06.2021 09:20:00
-- Design Name:
-- Module Name: Ecran - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
-- Description: Tableau des caractères à afficher à l'écran
-- - Ajoute les caractère a la suite les un des autres (comme un fichier avec un curseur)
-- - Prends des coordonnées (X,Y) et renvoi l'état du pixel associé
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- - TableASCII
----------------------------------------------------------------------------------
@ -30,12 +27,12 @@ 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);
Data_Av : in STD_LOGIC; -- Un caractère doit être ajouté au tableau
Data_IN : in STD_LOGIC_VECTOR (0 to 6); -- Caractère à ajouter
X : in X_T;
Y : in Y_T;
OUT_ON : out STD_LOGIC);
X : in X_T; -- Position X
Y : in Y_T; -- Position Y
OUT_ON : out STD_LOGIC); -- Valeur du pixel (X,Y)
end Ecran;
architecture Behavioral of Ecran is
@ -45,32 +42,33 @@ architecture Behavioral of Ecran is
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');
constant Flush : STD_LOGIC_VECTOR (0 to 6) := "0000000"; -- Code ASCII du flush
constant RetourChariot : STD_LOGIC_VECTOR (0 to 6) := "0001010"; -- Code ASCII du retour chariot
constant Delete : STD_LOGIC_VECTOR (0 to 6) := "1111111"; -- Code ASCII du Delete
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 Ecran : STD_LOGIC_VECTOR (0 to Ecran_Taille - 1) := (others => '0'); -- Tableau des caractères de l'écran
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 : STD_LOGIC_VECTOR (0 to 6) := "0000000"; -- Ligne du tableau dans laquelle il faut écrire (position Y du curseur)
signal L_inc : STD_LOGIC_VECTOR (0 to 6); -- L+1 mod Nb_Lignes
signal C : STD_LOGIC_VECTOR (0 to 6) := "0000000"; -- Colone du tableau dans laquelle il faut écrire (position X du curseur)
signal L_Lecture : L_T := 0;
signal InitialL : STD_LOGIC_VECTOR (0 to 6) := "0000000"; -- Le tableau fonctionne comme un buffer circulaire, il faut donc garder en mémoire la première ligne
signal InitialL_inc : STD_LOGIC_VECTOR (0 to 6); -- InitialL+1 mod Nb_Lignes
signal Full : STD_LOGIC := '0'; -- Si le tableau est plein
signal point_dereferencement : Natural := 0;
signal point_dereferencement_ecriture : Natural := 0;
signal L_Lecture : L_T := 0; -- Ligne pour la lecture dans le tableau
signal CurrentCodeASCII : STD_LOGIC_VECTOR (0 to 6) := "0000000";
signal CurrentFont : STD_LOGIC_VECTOR (0 to (font_width * font_height) - 1) := (others => '0');
signal point_dereferencement : Natural := 0; -- Index dans le tableau ou est stocké le code ASCII correspondant à (X,Y)
signal point_dereferencement_ecriture : Natural := 0; -- Index dans le tableau ou la valeur doit être écrite
signal position_X : X_T := 0;
signal position_Y : Y_T := 0;
signal CurrentCodeASCII : STD_LOGIC_VECTOR (0 to 6) := "0000000"; -- Le code ASCII actuellement lu
signal CurrentFont : STD_LOGIC_VECTOR (0 to (font_width * font_height) - 1) := (others => '0'); -- La font correspondante a ce Code
signal active : Boolean := false;
signal position_X : X_T := 0; -- Signal pour décaler X de manière a introduire une marge
signal position_Y : Y_T := 0; -- Signal pour décaler Y de manière a introduire une marge
signal active : Boolean := false; -- Nous sommes (ou non) dans la zone active de l'écran
begin
@ -82,22 +80,27 @@ begin
begin
wait until CLK'event and CLK='1';
if (RST = '0' or (Data_Av = '1' and Data_IN = Flush)) then
-- Reset ou FLUSH
Ecran <= (others => '0');
L <= "0000000";
C <= "0000000";
InitialL <= "0000000";
Full <= '0';
elsif (Data_Av = '1') then
-- Data disponible
if (Data_IN = Delete) then
-- Un Delete, on efface un caractère sur la ligne (Nb : on ne peut effacer que la ligne courante)
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
-- Un caractère lamda, on l'écrit
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
-- Si besoin on saute a la ligne suivant
C <= "0000000";
L <= L_inc;
if (L_inc = "0000000" or Full = '1') then
@ -109,21 +112,22 @@ begin
end if;
end process;
-- Gestion des signaux d'écriture
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)));
-- Gestion des signaux de lecture
position_X <= X - margin when X >= 0 + margin and X < screen_width - margin else 0; -- Prise en compte des marges
position_Y <= Y - margin when Y >= 0 + margin and Y < screen_height - margin else 0; -- Prise en compte des marges
active <= X >= 0 + margin and X < screen_width - margin and Y >= 0 + margin and Y < screen_height - margin; -- Fenetre active ?
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)); -- Calcul de la ligne de lecture
point_dereferencement <= (7 * (C_Blocks * L_Lecture + (position_X/Display_CaracterWidht))); -- Calcul du point de déréférencement
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); -- Recupération du code ASCII
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';
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'; -- Calcul de l'état du pixel
end Behavioral;

View file

@ -7,7 +7,7 @@
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
-- Description: Etage 1 du processeur
-- Description: Etage 1 du processeur (version non sécurisée)
-- - Gestion des instructions, lecture en mémoire
-- - Gestion des aléas sur les registres
-- - Gestion des sauts et appels de fonction

View file

@ -8,7 +8,7 @@
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
--
-- Description: Etage 4 du processeur
-- Description: Etage 4 du processeur (non sécurisé)
-- - Gestion de la mémoire
-- - Gestion de la sauvegarde du contexte et de l'adresse de retour lors des appels de fonction
--

View file

@ -1,36 +1,25 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 01.07.2021 09:09:30
-- Design Name:
-- Module Name: Keyboard - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
--
-- Description: Composant clavier, intègre le controleur du clavier pour en faire un composant bufferisé
--
-- Dependencies:
-- - KeyboardControler
-- - KeyboardToASCII
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Comments : Transforme aussi la keycode en code ASCII
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity Keyboard is
Port (CLK : in STD_LOGIC;

View file

@ -1,36 +1,24 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 01.07.2021 09:09:30
-- Design Name:
-- Module Name: KeyboardControler - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
--
-- Dependencies:
-- Description: ALU
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-- Dependencies: Fait le lien avec le BUS PS2 du clavier, récupère la touche tapée et la renvoi
--
-- Comments : Il n'y a pas de bufferisation
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity KeyboardControler is
Port (CLK : in STD_LOGIC;
@ -45,58 +33,80 @@ end KeyboardControler;
architecture Behavioral of KeyboardControler is
-- Compteur pour récupérer la trame PS2
subtype compteur_T is Natural range 0 to 10;
signal compteur : compteur_T := 0;
-- Trame en cours de lecture
signal current_data : STD_LOGIC_VECTOR (0 to 7) := (others => '0');
-- Denière trame lue
signal previous_data : STD_LOGIC_VECTOR (0 to 7) := (others => '0');
-- Signaux pour controler le bit de parité de la trame
signal parity : STD_LOGIC := '0';
signal intern_alert : STD_LOGIC := '0';
-- Signaux pour signaler qu'une touche a été préssée
signal intern_Data_av : STD_LOGIC := '0';
signal dejaSignale : boolean := false;
begin
-- process de récupération de la trame, synchronisé sur la CLK du bus PS2
-- A chaque front montant on lit ce qu'il y a a lire et on avance le compteur
process
begin
wait until PS2Clk'event and PS2Clk = '1';
case compteur is
when 0 =>
-- Bit de start : on réinitialise tout
parity <= '1';
intern_alert <= '0';
intern_Data_av <= '0';
when 1 =>
-- Lecture et MAJ de la parité
current_data(7) <= PS2Data;
parity <= parity XOR PS2Data;
when 2 =>
-- Lecture et MAJ de la parité
current_data(6) <= PS2Data;
parity <= parity XOR PS2Data;
when 3 =>
-- Lecture et MAJ de la parité
current_data(5) <= PS2Data;
parity <= parity XOR PS2Data;
when 4 =>
-- Lecture et MAJ de la parité
current_data(4) <= PS2Data;
parity <= parity XOR PS2Data;
when 5 =>
-- Lecture et MAJ de la parité
current_data(3) <= PS2Data;
parity <= parity XOR PS2Data;
when 6 =>
-- Lecture et MAJ de la parité
current_data(2) <= PS2Data;
parity <= parity XOR PS2Data;
when 7 =>
-- Lecture et MAJ de la parité
current_data(1) <= PS2Data;
parity <= parity XOR PS2Data;
when 8 =>
-- Lecture et MAJ de la parité
current_data(0) <= PS2Data;
parity <= parity XOR PS2Data;
when 9 =>
-- Check de la parité
if (parity = PS2Data) then
intern_alert <= '0';
else
intern_alert <= '1';
end if;
when 10 =>
-- Envoi de la touche
if (intern_alert = '0') then
previous_data <= current_data;
-- Elimination des touches non classiques
if (not (previous_data = "11110000" or current_data = "11110000" or previous_data = "11100000")) then
Data <= current_data;
intern_Data_av <= '1';
@ -107,6 +117,8 @@ begin
compteur <= (compteur + 1) mod 11;
end process;
-- Gestion de l'avertissement de touche
process
begin
wait until CLK'event and CLK = '1';

View file

@ -1,21 +1,16 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 13.07.2021 09:30:08
-- Design Name:
-- Module Name: KeyboardDriver - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-- Description: Driver pour interfacer le clavier avec les besoins du processeur
--
-- Dependencies: None
----------------------------------------------------------------------------------
@ -24,26 +19,21 @@ use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity KeyboardDriver is
Generic (Nb_Bits : Natural);
Port (CLK : in STD_LOGIC;
Data_read : out STD_LOGIC;
Data_av : in STD_LOGIC;
Data : in STD_LOGIC_VECTOR (0 to 6);
STD_IN : out STD_LOGIC_VECTOR (Nb_Bits - 1 downto 0);
STD_IN_Av : out STD_LOGIC;
STD_IN_Request : in STD_LOGIC;
STD_OUT : out STD_LOGIC_VECTOR (Nb_Bits - 1 downto 0);
STD_OUT_Av : out STD_LOGIC);
Data_read : out STD_LOGIC; -- ******************************
Data_av : in STD_LOGIC; -- ***** Signaux du clavier *****
Data : in STD_LOGIC_VECTOR (0 to 6); -- ******************************
STD_IN : out STD_LOGIC_VECTOR (Nb_Bits - 1 downto 0); -- ******************************
STD_IN_Av : out STD_LOGIC; -- *** Signaux du processeur ***
STD_IN_Request : in STD_LOGIC; -- ******************************
STD_OUT : out STD_LOGIC_VECTOR (Nb_Bits - 1 downto 0);-- ******************************
STD_OUT_Av : out STD_LOGIC); -- **** Signaux d'affichage ****
end KeyboardDriver;
architecture Behavioral of KeyboardDriver is
@ -64,23 +54,29 @@ begin
intern_value <= 0;
end if;
if STD_IN_Request = '1' then
-- Si on nous demande une valeur
work_in_progress <= true;
if Data_av = '1' then
-- Si une touche a été appuyée
if (Data = "1111111") then
-- Si c'est un Delete, on divide la valeur actuelle par 10
intern_value <= intern_value / 10;
STD_OUT <= Zeros & Data;
STD_OUT_Av <= '1';
elsif (Data = "0001010") then
-- Si c'est un Enter, on envoi la velaue au processeur
STD_IN <= std_logic_vector(to_unsigned(intern_value, Nb_bits));
STD_IN_Av <= '1';
work_in_progress <= false;
STD_OUT <= Zeros & Data;
STD_OUT_Av <= '1';
elsif (Data >= "0110000" and Data <= "0111001") then
-- Si c'est un nombre, on décale la valeur d'un chiffre a gauche puis un insere la touche saisie
intern_value <= intern_value * 10 + to_integer(unsigned(Data(3 to 6)));
STD_OUT <= Zeros & Data;
STD_OUT_Av <= '1';
end if;
-- Toute autre touche est ignorée
end if;
end if;
end process;

View file

@ -1,21 +1,18 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 02.07.2021 10:43:18
-- Design Name:
-- Module Name: KeyboardToASCII - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
--
-- Dependencies:
-- Description: Associe le code ASCII au keycode de la touche
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-- Dependencies: None
--
-- Comments : Assynchrone
----------------------------------------------------------------------------------

View file

@ -23,12 +23,12 @@ entity MemoireDonnees is
Port ( Addr : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- L'adresse a laquelle il faut agir
RW : in STD_LOGIC; -- Ce qu'il faut faire ('1' -> Read, '0' -> Write)
D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Data a ecrire (si RW = 0)
CALL : in STD_LOGIC; -- '1' -> CALL en cours
IN_EBP : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Valeur d'EBP à stocker en cas de CALL
IN_AddrRet : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Valeur d'@ de retour à stocker en cas de CALL
RET : in STD_LOGIC; -- '1' -> RET en cours
OUT_EBP : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0'); -- Valeur d'EBP à renvoyer en cas de RET
OUT_AddrRet : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0'); -- Valeur d'@ de retour à renvoyer en cas de RET
CALL : in STD_LOGIC; -- '1' -> CALL en cours (INUTILE POUR LA VERSION SECURISEE)
IN_EBP : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Valeur d'EBP à stocker en cas de CALL (INUTILE POUR LA VERSION SECURISEE)
IN_AddrRet : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Valeur d'@ de retour à stocker en cas de CALL (INUTILE POUR LA VERSION SECURISEE)
RET : in STD_LOGIC; -- '1' -> RET en cours (INUTILE POUR LA VERSION SECURISEE)
OUT_EBP : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0'); -- Valeur d'EBP à renvoyer en cas de RET (INUTILE POUR LA VERSION SECURISEE)
OUT_AddrRet : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0'); -- Valeur d'@ de retour à renvoyer en cas de RET (INUTILE POUR LA VERSION SECURISEE)
RST : in STD_LOGIC; -- Reset
CLK : in STD_LOGIC; -- Clock
D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0')); -- Sortie de la mémoire

View file

@ -1,36 +1,26 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 13.07.2021 09:30:08
-- Design Name:
-- Module Name: PeripheriqueClavier - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
--
-- Description: Assemble les composants du clavier pour faire un composant périphérique que l'on peut connecter au processeur
-- - Le clavier (controleur intégré)
-- - Le driver
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- - Keyboard
-- - KeyboardDriver
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity PeripheriqueClavier is
Generic (Nb_Bits : Natural);
Port ( CLK : in STD_LOGIC;

View file

@ -1,21 +1,25 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 09.07.2021 15:25:56
-- Design Name:
-- Module Name: PeripheriqueEcran - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
--
-- Description: Assemble les composants de l'écran pour faire un composant périphérique que l'on peut connecter au processeur
-- - Le controleur
-- - L'écran
-- - Le driver
--
-- Dependencies:
-- - VGAControler
-- - Ecran
-- - ScreenDriver
-- - clk_wiz_0
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Comments : la clock doit être accélérée pour atteindre 108Mhz pour le VGA
----------------------------------------------------------------------------------

View file

@ -1,49 +1,38 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 19.04.2021 16:57:41
-- Design Name:
-- Module Name: Pipeline - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
-- Description: Version sécurisée du pipeline, connecte les étages et fait avancer les signaux sur le pipeline
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- - Etage1_LectureInstruction
-- - Etage2_5_Registres
-- - Etage3_Calcul
-- - Etage4_Memoire
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity Pipeline is
Generic (Nb_bits : Natural := 8;
Instruction_En_Memoire_Size : Natural := 29;
Addr_Memoire_Instruction_Size : Natural := 3;
Memoire_Instruction_Size : Natural := 8;
Instruction_Bus_Size : Natural := 5;
Nb_Instructions : Natural := 32;
Nb_Registres : Natural := 16;
Addr_registres_size : Natural := 4;
Memoire_Size : Natural := 32;
Adresse_mem_size : Natural := 5;
Memoire_Adresses_Retour_Size : Natural := 16;
Adresse_Memoire_Adresses_Retour_Size : Natural := 4);
Generic (Nb_bits : Natural := 8; -- Taille d'un mot binaire
Instruction_En_Memoire_Size : Natural := 29; -- Taille d'une instruction en mémoire (Taille d'un code instruction + 3*Taille d'un mot binaire)
Addr_Memoire_Instruction_Size : Natural := 3; -- Nombre de bits pour adresser la mémoire d'instruction
Memoire_Instruction_Size : Natural := 8; -- Taille de la mémoire d'instruction (nombre d'instructions stockées)
Instruction_Bus_Size : Natural := 5; -- Nombre de bits du bus d'instruction (Taille d'un code instruction)
Nb_Instructions : Natural := 32; -- Nombre d'instructions dans le processeur
Nb_Registres : Natural := 16; -- Nombre de registres du processeurs
Addr_registres_size : Natural := 4; -- Nombre de bits pour adresser les registres
Memoire_Size : Natural := 32; -- Taille de la mémoire de données
Adresse_mem_size : Natural := 5; -- Nombre de bits pour adresser la mémoire
Memoire_Adresses_Retour_Size : Natural := 16; -- Profondeur d'appel maximale
Adresse_Memoire_Adresses_Retour_Size : Natural := 4); -- log2(Profondeur d'appel maximale)
Port (CLK : in STD_LOGIC;
RST : in STD_LOGIC;
STD_IN : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
@ -160,6 +149,8 @@ architecture Behavioral of Pipeline is
OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0));
end component;
-- Signaux reliant les étages
signal A_from_1 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
signal A_from_2 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
signal A_from_3 : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
@ -188,6 +179,7 @@ architecture Behavioral of Pipeline is
signal Instruction_to_3 : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := (others => '0');
signal Instruction_to_4 : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := (others => '0');
signal Instruction_to_5 : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := (others => '0');
-- Sorties de l'ALU
signal N : STD_LOGIC := '0';
signal Z : STD_LOGIC := '0';
signal O : STD_LOGIC := '0';
@ -195,7 +187,7 @@ architecture Behavioral of Pipeline is
signal intern_STD_IN_Request : STD_LOGIC := '0';
-- Constantes de contrôle des MUX et LC
constant Bits_Controle_MUX_2_A : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "111111111" & "11110011101111111111111";
constant Bits_Controle_MUX_2_B : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "111111111" & "11111111000011000000001";
constant Bits_Controle_LC_3 : STD_LOGIC_VECTOR (Nb_Instructions * 3 - 1 downto 0) := "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "000" & "111" & "110" & "101" & "100" & "010" & "011" & "001" & "000";
@ -205,6 +197,8 @@ architecture Behavioral of Pipeline is
constant Bits_Controle_MUX_4_IN_EBP : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "111111111" & "11111111011001111111111";
constant Bits_Controle_MUX_4_OUT : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "111111111" & "00000000001010000000000";
constant Bits_Controle_LC_5 : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "111111111" & "00010000001011111111110";
-- Code de certaines instructions
constant Code_Instruction_JMP : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "01111";
constant Code_Instruction_JMZ : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10000";
constant Code_Instruction_PRI : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10001";
@ -214,6 +208,7 @@ architecture Behavioral of Pipeline is
constant Code_Instruction_RET : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10101";
constant Code_Instruction_STOP : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10110";
-- Constantes de contrôle des bulles
constant Instructions_critiques_lecture_A : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "111111111" & "00001100010000000000000";
constant Instructions_critiques_lecture_B : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "111111111" & "00000000111100111111110";
constant Instructions_critiques_lecture_C : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "111111111" & "00000000000000011111110";

View file

@ -194,6 +194,8 @@ architecture Behavioral of Pipeline_NS is
constant Bits_Controle_MUX_4_IN_EBP : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "111111111" & "10011111011001111111111";
constant Bits_Controle_MUX_4_OUT : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "111111111" & "00000000001010000000000";
constant Bits_Controle_LC_5 : STD_LOGIC_VECTOR (Nb_Instructions - 1 downto 0) := "111111111" & "00010000001011111111110";
-- Code de certaines instructions
constant Code_Instruction_JMP : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "01111";
constant Code_Instruction_JMZ : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10000";
constant Code_Instruction_PRI : STD_LOGIC_VECTOR (Instruction_Bus_Size - 1 downto 0) := "10001";

View file

@ -1,21 +1,18 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 09.07.2021 09:54:12
-- Design Name:
-- Module Name: ScreenDriver - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
--
-- Dependencies:
-- Description: Fait le lien entre le processeur et l'écran
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-- Dependencies: None
--
-- Comments: Gère la conversion des entiers en hexa pour l'affichage
----------------------------------------------------------------------------------
@ -24,32 +21,31 @@ use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--use IEEE.NUMERIC_STD.ALL;
-- Uncomment the following library declaration if instantiating
-- any Xilinx leaf cells in this code.
--library UNISIM;
--use UNISIM.VComponents.all;
entity ScreenDriver is
Generic ( Nb_bits : Natural
);
Port ( CLK : in STD_LOGIC;
Value : in STD_LOGIC_VECTOR (Nb_Bits - 1 downto 0);
ValueAv : in STD_LOGIC;
IsInt : in STD_LOGIC;
OutData : out STD_LOGIC_VECTOR (0 to 6);
OutDataAv : out STD_LOGIC);
Value : in STD_LOGIC_VECTOR (Nb_Bits - 1 downto 0); -- ********************************
ValueAv : in STD_LOGIC; -- ***** Depuis le processeur *****
IsInt : in STD_LOGIC; -- ********************************
OutData : out STD_LOGIC_VECTOR (0 to 6); -- ********************************
OutDataAv : out STD_LOGIC); -- ********* Vers l'écran *********
end ScreenDriver;
architecture Behavioral of ScreenDriver is
-- Signal pour récupérer la valeur entière
signal intern_value : STD_LOGIC_VECTOR (Nb_Bits - 1 downto 0) := (others => '0');
-- 4 bits actuellement en cours de conversion
signal current_hexa : STD_LOGIC_VECTOR (3 downto 0) := (others => '0');
-- Type pour gérer l'avancement dans la conversion
subtype compteur_T is Integer range -2 to Nb_bits/4 - 1;
-- Signal comptant l'avancement dans la conversion (début a -2, affichage de "0x" puis début de la conversion avec compteur = 0)
signal compteur : compteur_T := -2;
-- Si un digit non nul a été detecté
signal first_detected : BOOLEAN := false;
@ -57,43 +53,57 @@ architecture Behavioral of ScreenDriver is
begin
-- Récupération des 4 bits en cours de conversion
current_hexa <= intern_value(Nb_Bits - 1 - compteur * 4 downto Nb_Bits - compteur * 4 - 4) when compteur >= 0 and compteur < Nb_Bits else "0000";
process
begin
wait until CLK'event and CLK = '1';
if ValueAv = '1' then
-- Si on a une donnée en entier
if IsInt = '0' then
-- Si c'est un char on la répercute juste
OutData <= Value (6 downto 0);
else
-- Si c'est un entier, on récupère la valeur et affiche le 0
intern_value <= Value;
OutData <= Code_ASCII_Zero;
compteur <= compteur + 1;
end if;
-- On signal a l'écran qu'il faut afficher
OutDataAv <= '1';
elsif compteur = -1 then
-- Si une conversion est en cours a l'étape -1, on affiche x
OutData <= "1111000";
compteur <= compteur + 1;
elsif compteur >= 0 then
-- Si on est en phase de conversion
if (current_hexa >= "0000" and current_hexa <= "1001") then
-- Si on est sur un chiffre (0-9)
if (not(current_hexa = "0000") or first_detected or compteur = Nb_bits/4 - 1 ) then
-- On l'affiche si ce n'est pas 0, ou qu'un digit a déjà été detecté, ou qu'il s'agit du dernier digit de l'entier
OutData <= "011" & current_hexa;
OutDataAv <= '1';
first_detected <= true;
else
-- Sinon, le digit est un 0 inutile, on ne l'affiche pas
OutDataAv <= '0';
end if;
else
-- Si on est sur une lettre (A-F), on l'affiche
OutData <= ("000" & current_hexa) + "0110111";
OutDataAv <= '1';
first_detected <= true;
end if;
if (compteur = Nb_bits/4 - 1) then
-- Si la conversion est finie on réinitialise
compteur <= -2;
first_detected <= false;
else
-- Sinon on avance le compteur
compteur <= compteur + 1;
end if;
else

View file

@ -1,35 +1,48 @@
----------------------------------------------------------------------------------
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 02.07.2021 10:07:41
-- Package Name: ScreenProperties
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
--
-- Description: Rassemble les propriétés de l'écran et du VGA
----------------------------------------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
package ScreenProperties is
constant margin : Natural := 64;
constant margin : Natural := 64; -- Marge laissée de tous les cotés de l'écran
constant Display_CaracterWidht : Natural := 64;
constant Display_CaracterHeight : Natural := 64;
constant Display_CaracterWidht : Natural := 64; -- Taille d'affichage d'un caractère (en pixels)
constant Display_CaracterHeight : Natural := 64; -- Taille d'affichage d'un caractère (en pixels)
constant screen_width : natural := 1280;
constant screen_height : natural := 1024;
constant screen_width : natural := 1280; -- Largeur de l'écran (en pixels)
constant screen_height : natural := 1024; -- Longueur de l'écran (en pixels)
constant X_PulseWidth : Natural := 112;
constant X_FrontPorch : Natural := 48;
constant X_BackPorch : Natural := 248;
constant Y_PulseWidth : Natural := 3;
constant Y_FrontPorch : Natural := 1;
constant Y_BackPorch : Natural := 38;
constant X_PulseWidth : Natural := 112; -- Taille de la pulsation de synchronisation horizontale (en pixels)
constant X_FrontPorch : Natural := 48; -- Taille du temps avant la pulsation (en pixels)
constant X_BackPorch : Natural := 248; -- Taille du temps après la pulsation (en pixels)
constant Y_PulseWidth : Natural := 3; -- Taille de la pulsation de synchronisation verticale (en lignes)
constant Y_FrontPorch : Natural := 1; -- Taille du temps avant la pulsation (en lignes)
constant Y_BackPorch : Natural := 38; -- Taille du temps après la pulsation (en lignes)
subtype X_T is Natural range 0 to screen_width + X_PulseWidth + X_FrontPorch + X_BackPorch - 1;
subtype Y_T is Natural range 0 to screen_height + Y_PulseWidth + Y_FrontPorch + Y_BackPorch - 1;
subtype X_T is Natural range 0 to screen_width + X_PulseWidth + X_FrontPorch + X_BackPorch - 1; -- Type pour les coordonnées
subtype Y_T is Natural range 0 to screen_height + Y_PulseWidth + Y_FrontPorch + Y_BackPorch - 1; -- Type pour les coordonnées
constant C_Blocks : Natural := (screen_width - (2 * margin))/Display_CaracterWidht;
constant L_Blocks : Natural := (screen_height - (2 * margin))/Display_CaracterHeight;
constant Ecran_Taille : Natural := C_Blocks * L_Blocks * 7;
constant C_Blocks : Natural := (screen_width - (2 * margin))/Display_CaracterWidht; -- Nombre de cases par ligne dans l'écran (Nombre de colonnes)
constant L_Blocks : Natural := (screen_height - (2 * margin))/Display_CaracterHeight; -- Nombre de cases par colonne dans l'écran (Nombre de lignes)
constant Ecran_Taille : Natural := C_Blocks * L_Blocks * 7; -- Nombre de bits dans l'écran (Nombre cases dans l'écran * 7)
constant L_Size : Natural := C_Blocks * 7;
constant L_Size : Natural := C_Blocks * 7; -- Taille en bits d'une ligne
constant Zero_Line : STD_LOGIC_VECTOR (0 to L_Size - 1) := (others => '0');
constant Zero_Line : STD_LOGIC_VECTOR (0 to L_Size - 1) := (others => '0'); -- Constante, ligne de '0'
subtype L_T is Natural range 0 to L_Blocks - 1;
subtype C_T is Natural range 0 to C_Blocks - 1;
subtype L_T is Natural range 0 to L_Blocks - 1; -- Type pour les coordonnées
subtype C_T is Natural range 0 to C_Blocks - 1; -- Type pour les coordonnées
end package;

View file

@ -1,21 +1,18 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-----------------------------------------------------------------------------------
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 28.06.2021 09:20:00
-- Design Name:
-- Module Name: TableASCII - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
--
-- Dependencies:
-- Description: Table indexée sur le code ascii contenant la font de chaque caractère
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-- Dependencies: None
--
-- Comments : Assynchrone
----------------------------------------------------------------------------------

View file

@ -1,21 +1,18 @@
----------------------------------------------------------------------------------
-- Company:
-- Engineer:
-- Company: INSA-Toulouse
-- Engineer: Paul Faure
--
-- Create Date: 28.06.2021 09:20:00
-- Design Name:
-- Module Name: VGAControler - Behavioral
-- Project Name:
-- Target Devices:
-- Tool Versions:
-- Description:
-- Project Name: Processeur sécurisé
-- Target Devices: Basys 3 ARTIX7
-- Tool Versions: Vivado 2016.4
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
-- Description: Controleur du VGA
-- - Crée les signaux VGA
-- - Demande si le pixel (X,Y) doit être allumé
--
-- Dependencies: Compteur_X et Compteur_Y
----------------------------------------------------------------------------------
@ -73,8 +70,11 @@ begin
RST => RST,
Value => Y_pos);
-- Test si on est dans l'écran et non dans les zones de FP, BP, SP
active <= ((X_pos < screen_width) and (Y_pos < screen_height));
-- Affectation des couleurs et fonction du pixel (0 hors champs, gris si inactif, blanc si actif)
VGA_RED <= "0000" when ((RST = '0') or (not active)) else
"1000" when (PIXEL_ON = '0') else
"1111";
@ -85,6 +85,7 @@ begin
"1000" when (PIXEL_ON = '0') else
"1111";
-- Création des signaux de synchronisation
VGA_HS <= '0' when ((RST = '0') or (X_pos < screen_width + X_FrontPorch) or (X_pos >= screen_width + X_FrontPorch + X_PulseWidth)) else
'1';
VGA_VS <= '0' when ((RST = '0') or (Y_pos < screen_height + Y_FrontPorch) or (Y_pos >= screen_height + Y_FrontPorch + Y_PulseWidth)) else