Browse Source

Lifting du code

Paul Faure 2 years ago
parent
commit
d57f8a5b37

+ 2
- 2
Processeur.srcs/sim_1/new/Test_Pipeline.vhd View File

@@ -63,8 +63,8 @@ architecture Behavioral of Test_Pipeline is
63 63
     
64 64
 begin
65 65
     instance : Pipeline
66
-    generic map (Addr_Memoire_Instruction_Size => 7,
67
-                 Memoire_Instruction_Size => 128)
66
+    generic map (Addr_Memoire_Instruction_Size => 8,
67
+                 Memoire_Instruction_Size => 256)
68 68
     port map (CLK => my_CLK,
69 69
               RST => my_RST,
70 70
               STD_IN => my_STD_IN,

+ 37
- 26
Processeur.srcs/sources_1/new/ALU.vhd View File

@@ -1,75 +1,69 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
3 5
 -- Create Date: 13.04.2021 10:07:41
4 6
 -- Module Name: ALU - Behavioral
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+--
11
+-- Description: ALU 
5 12
 -- 
13
+-- Dependencies: None
14
+--
15
+-- Comments : Assynchrone
6 16
 ----------------------------------------------------------------------------------
7 17
 
8 18
 
9 19
 library IEEE;
10 20
 use IEEE.STD_LOGIC_1164.ALL;
11 21
 use IEEE.STD_LOGIC_UNSIGNED.ALL;
12
-
13 22
 use IEEE.NUMERIC_STD.ALL;
14 23
 
15
---library UNISIM;
16
---use UNISIM.VComponents.all;
17
-
18 24
 entity ALU is
19
-    Generic (Nb_bits : Natural);
20
-    Port ( A : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
21
-           B : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
22
-           OP : in STD_LOGIC_VECTOR (2 downto 0);
23
-           S : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
24
-           N : out STD_LOGIC;
25
-           O : out STD_LOGIC;
26
-           Z : out STD_LOGIC;
27
-           C : out STD_LOGIC);
25
+    Generic (Nb_bits : Natural); -- Taille d'un mot binaire
26
+    Port ( A : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Entrée 1 de l'ALU
27
+           B : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Entrée 2 de l'ALU
28
+           OP : in STD_LOGIC_VECTOR (2 downto 0); -- Code d'opération de l'ALU
29
+           S : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Sortie de l'ALU
30
+           N : out STD_LOGIC; -- Flag Negative
31
+           O : out STD_LOGIC; -- Flag Overload
32
+           Z : out STD_LOGIC; -- Flag Zero
33
+           C : out STD_LOGIC);-- Flag Carry
28 34
 end ALU;
29 35
 
30 36
 architecture Behavioral of ALU is
31
-    signal A9 :  STD_LOGIC_VECTOR (Nb_bits downto 0);
32
-    signal B9 :  STD_LOGIC_VECTOR (Nb_bits downto 0);
33
-    signal ADD :  STD_LOGIC_VECTOR (Nb_bits downto 0);
34
-    signal SUB :  STD_LOGIC_VECTOR (Nb_bits downto 0);
35
-    signal MUL :  STD_LOGIC_VECTOR ((2*Nb_bits)-1 downto 0);
37
+    signal A9 :  STD_LOGIC_VECTOR (Nb_bits downto 0); -- Ajout d'un bit de poids fort supplémentaire (à 0)
38
+    signal B9 :  STD_LOGIC_VECTOR (Nb_bits downto 0); -- Ajout d'un bit de poids fort supplémentaire (à 0)
39
+    signal ADD :  STD_LOGIC_VECTOR (Nb_bits downto 0); -- A+B
40
+    signal SUB :  STD_LOGIC_VECTOR (Nb_bits downto 0); -- A-B
41
+    signal MUL :  STD_LOGIC_VECTOR ((2*Nb_bits)-1 downto 0); -- A*B
42
+    
43
+    -- Signaux interne
36 44
     signal intern_N : STD_LOGIC;
37 45
     signal intern_Z : STD_LOGIC;
46
+    
47
+    -- Constantes
38 48
     constant ZERO_N : STD_LOGIC_VECTOR (Nb_bits downto 0) := (others => '0');
39 49
     constant ZERO_N1 : STD_LOGIC_VECTOR (Nb_bits downto 0) := (others => '0');
40 50
     
41 51
     
42 52
 begin
43
-    A9 <= '0' & A;
44
-    B9 <= '0' & B;
45
-    ADD <= A9 + B9;
46
-    SUB <= A9 - B9;
47
-    MUL <= A * B;    
53
+    A9 <= '0' & A; -- Ajout d'un bit de poids fort supplémentaire (à 0)
54
+    B9 <= '0' & B; -- Ajout d'un bit de poids fort supplémentaire (à 0)
55
+    ADD <= A9 + B9; -- A+B
56
+    SUB <= A9 - B9; -- A-B
57
+    MUL <= A * B;   -- A*B 
48 58
     
59
+    -- Selection de la sortie
49 60
     S <= ADD (Nb_bits-1 downto 0) when OP = "001" else 
50 61
          SUB (Nb_bits-1 downto 0) when OP = "010" else 
51 62
          MUL (Nb_bits-1 downto 0) when OP = "011" else
52 63
          -- Add division
53
-         (0 => intern_N, others => '0') when OP = "101" else
54
-         (0 => '1', others => '0') when OP = "110" and intern_Z = '0' and intern_N = '0' else
55
-         (0 => intern_Z, others => '0') when OP = "111" else
64
+         (0 => intern_N, others => '0') when OP = "101" else                                    -- Inferieur (<)
65
+         (0 => '1', others => '0') when OP = "110" and intern_Z = '0' and intern_N = '0' else   -- Superieur (>)
66
+         (0 => intern_Z, others => '0') when OP = "111" else                                    -- Egal      (=)
56 67
          (others => '0');
57 68
          
58 69
          

+ 31
- 21
Processeur.srcs/sources_1/new/BancRegistres.vhd View File

@@ -1,70 +1,62 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
3 5
 -- Create Date: 15.04.2021 08:23:48
4 6
 -- Module Name: BancRegistres - Behavioral
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+-- Description: Banc de registre
5 11
 -- 
12
+-- Dependencies: None
13
+--
14
+-- Comments : 
15
+--    - Il est possible de lire 3 registres en simultané
16
+--    - Si on souhaite lire et ecrire dans un même registre, l'écriture est prioritaire
6 17
 ----------------------------------------------------------------------------------
7 18
 
8 19
 
9 20
 library IEEE;
10 21
 use IEEE.STD_LOGIC_1164.ALL;
11
---use IEEE.STD_LOGIC_UNSIGNED.ALL;
12
---use IEEE.STD_LOGIC_ARITH.ALL;
13
-
14 22
 use IEEE.NUMERIC_STD.ALL;
15 23
 
16
---library UNISIM;
17
---use UNISIM.VComponents.all;
18
-
19 24
 entity BancRegistres is
20
-    Generic (Nb_bits : Natural;
21
-             Addr_size : Natural;
22
-             Nb_regs : Natural);
23
-    Port ( AddrA : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
24
-           AddrB : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
25
-           AddrC : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
26
-           AddrW : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
27
-           W : in STD_LOGIC;
28
-           DATA : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
29
-           RST : in STD_LOGIC;
30
-           CLK : in STD_LOGIC;
31
-           QA : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
32
-           QB : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
33
-           QC : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0));
25
+    Generic (Nb_bits : Natural; -- Taille d'un mot dans un registre
26
+             Addr_size : Natural; -- Nombres de bits nécessaires pour adresser les registres
27
+             Nb_regs : Natural); -- Nombre de registre
28
+    Port ( AddrA : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre A à lire
29
+           AddrB : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre B à lire
30
+           AddrC : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre C à lire
31
+           AddrW : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- Adresse (numéro) du registre W où ecrire
32
+           W : in STD_LOGIC; -- Flag d'écriture ('1' -> écriture)
33
+           DATA : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Donnée a écrire
34
+           RST : in STD_LOGIC; -- Reset
35
+           CLK : in STD_LOGIC; -- Clock
36
+           QA : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Sortie : Valeur contenue dans le registre AddrA
37
+           QB : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Sortie : Valeur contenue dans le registre AddrB
38
+           QC : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0));-- Sortie : Valeur contenue dans le registre AddrC
34 39
 end BancRegistres;
35 40
 
41
+
36 42
 architecture Behavioral of BancRegistres is
37
-    signal REGISTRES : STD_LOGIC_VECTOR ((Nb_regs * Nb_bits)-1 downto 0) := (others => '0');
43
+    signal REGISTRES : STD_LOGIC_VECTOR ((Nb_regs * Nb_bits)-1 downto 0) := (others => '0'); -- Buffer (registres)
38 44
 begin
39 45
     process
40 46
     begin
47
+        -- Synchronisation
41 48
         wait until CLK'event and CLK = '1';
42 49
         if (RST = '0') then
43 50
             REGISTRES <= (others => '0');
44 51
         else 
52
+            -- Ecriture
45 53
             if (W = '1') then
46 54
                 REGISTRES (((to_integer(unsigned(AddrW)) + 1) * Nb_bits - 1) downto Nb_bits * to_integer(unsigned(AddrW))) <= DATA;
47 55
             end if;
48 56
         end if;
49 57
     end process;
58
+    
59
+    -- Lecture en Assynchrone (donc écriture prioritaire)
50 60
     QA <= REGISTRES (((to_integer(unsigned(AddrA)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(AddrA)));
51 61
     QB <= REGISTRES (((to_integer(unsigned(AddrB)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(AddrB)));
52 62
     QC <= REGISTRES (((to_integer(unsigned(AddrC)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(AddrC)));    

+ 16
- 5
Processeur.srcs/sources_1/new/Clock_Divider.vhd View File

@@ -1,50 +1,42 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
3 5
 -- Create Date: 08.05.2021 21:00:25
4 6
 -- Module Name: Clock_Divider - Behavioral
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+-- Description: Diviseur de clock (rapport de 1000)
5 11
 -- 
12
+-- Dependencies: None
6 13
 ----------------------------------------------------------------------------------
7 14
 
8 15
 
9 16
 library IEEE;
10 17
 use IEEE.STD_LOGIC_1164.ALL;
11 18
 
12
---use IEEE.NUMERIC_STD.ALL;
13
-
14
---library UNISIM;
15
---use UNISIM.VComponents.all;
16
-
17 19
 entity Clock_Divider is
18 20
     Port ( CLK_IN : in STD_LOGIC;
19 21
            CLK_OUT : out STD_LOGIC);
20 22
 end Clock_Divider;
21 23
 
22 24
 architecture Behavioral of Clock_Divider is
25
+    -- Compteur pour le diviseur
23 26
     signal N : Integer := 0;
27
+    -- Signal enregistrant l'ancienne valeur de CLK
24 28
     signal CLK : STD_LOGIC := '1';
25 29
 begin
26 30
     process
27 31
     begin
32
+        -- Synchronisation
28 33
         wait until CLK_IN'event and CLK_IN = '1';
34
+        
35
+        -- Incrementation du compteur
29 36
         N <= N + 1;
37
+       
30 38
         if (N = 1000) then
39
+            -- Remise a 0 et changement d'état de la CLK
31 40
             N <= 0;
32 41
             if (CLK = '1') then
33 42
                 CLK <= '0';
@@ -53,5 +45,7 @@ begin
53 45
             end if;
54 46
         end if;
55 47
     end process;
48
+    
49
+    -- Sortie du signal (assynchrone -> imédiat)
56 50
     CLK_OUT <= CLK;
57 51
 end Behavioral;

+ 79
- 33
Processeur.srcs/sources_1/new/Etage1_LectureInstruction.vhd View File

@@ -1,64 +1,71 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
3 5
 -- Create Date: 18.04.2021 21:19:41
4 6
 -- Module Name: Etage1_LectureInstruction - Behavioral
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+-- Description: Etage 1 du processeur
11
+--     - Gestion des instructions, lecture en mémoire
12
+--     - Gestion des aléas sur les registres
13
+--     - Gestion des sauts et appels de fonction
5 14
 -- 
6 15
 -- Dependencies: 
16
+--    - MemoireInstruction
17
+--    - MemoireAdressesRetour
7 18
 ----------------------------------------------------------------------------------
8 19
 
9 20
 
10 21
 library IEEE;
11 22
 use IEEE.STD_LOGIC_1164.ALL;
12 23
 use IEEE.STD_LOGIC_UNSIGNED.ALL;
13
-
14 24
 use IEEE.NUMERIC_STD.ALL;
15 25
 
16
---library UNISIM;
17
---use UNISIM.VComponents.all;
18 26
 
19 27
 entity Etage1_LectureInstruction is
20
-    Generic (Instruction_size_in_memory : Natural;
21
-             Addr_size_mem_instruction : Natural;
22
-             Mem_instruction_size : Natural;
23
-             Nb_bits : Natural;
24
-             Instruction_bus_size : Natural;
25
-             Nb_registres : Natural;
26
-             Mem_adresse_retour_size : Natural;
27
-             Adresse_size_mem_adresse_retour : Natural;
28
-             Instructions_critiques_lecture_A : STD_LOGIC_VECTOR;
29
-             Instructions_critiques_lecture_B : STD_LOGIC_VECTOR;
30
-             Instructions_critiques_lecture_C : STD_LOGIC_VECTOR;
31
-             Instructions_critiques_ecriture : STD_LOGIC_VECTOR;
32
-             Code_Instruction_JMP : STD_LOGIC_VECTOR;
33
-             Code_Instruction_JMZ : STD_LOGIC_VECTOR;
34
-             Code_Instruction_CALL : STD_LOGIC_VECTOR;
35
-             Code_Instruction_RET : STD_LOGIC_VECTOR;
36
-             Code_Instruction_STOP : STD_LOGIC_VECTOR);
37
-    Port ( CLK : in STD_LOGIC;
38
-           RST : in STD_LOGIC;
39
-           Z : in STD_LOGIC;
40
-           A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
41
-           B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
42
-           C : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
43
-           Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0));
28
+    Generic (Instruction_size_in_memory : Natural; -- Taille d'une instruction en mémoire (Taille d'un code instruction + 3*Taille d'un mot binaire)
29
+             Addr_size_mem_instruction : Natural; -- Nombre de bits pour adresser la mémoire d'instruction
30
+             Mem_instruction_size : Natural; -- Taille de la mémoire d'instruction (nombre d'instructions stockées)
31
+             Nb_bits : Natural; -- Taille d'un mot binaire
32
+             Instruction_bus_size : Natural; -- Nombre de bits du bus d'instruction (Taille d'un code instruction)
33
+             Nb_registres : Natural; -- Nombre de registres du processeurs
34
+             Mem_adresse_retour_size : Natural; -- Taille de la mémoire des adresses de retour (nombre d'adresse maximum) (profondeur d'appel maximale)
35
+             Adresse_size_mem_adresse_retour : Natural; -- Nombre de bits pour adresser la mémoire des adresses de retour
36
+             Instructions_critiques_lecture_A : STD_LOGIC_VECTOR; -- Vecteur de bit représentant les instruction critiques sur l'opérande A (si le bit i est a un, l'instruction i lit une valeur dans le registre n°opérandeA)
37
+             Instructions_critiques_lecture_B : STD_LOGIC_VECTOR; -- Vecteur de bit représentant les instruction critiques sur l'opérande B (si le bit i est a un, l'instruction i lit une valeur dans le registre n°opérandeB)
38
+             Instructions_critiques_lecture_C : STD_LOGIC_VECTOR; -- Vecteur de bit représentant les instruction critiques sur l'opérande C (si le bit i est a un, l'instruction i lit une valeur dans le registre n°opérandeC)
39
+             Instructions_critiques_ecriture : STD_LOGIC_VECTOR; -- Vecteur de bit représentant les instruction critiques en écriture (toujours sur l'opérande A) (si le bit i est a un, l'instruction i ecrit une valeur dans le registre n°opérandeA)
40
+             
41
+             -- Exemple 1 : Soit MUL i j k avec pour numéro d'instruction 7 avec le comportement Ri <- Rj*Rk
42
+             --                Instructions_critiques_lecture_A(7) = '0'  --> MUL ne lit pas dans le registre de l'opérande A
43
+             --                Instructions_critiques_lecture_B(7) = '1'  --> MUL lit dans le registre de l'opérande B
44
+             --                Instructions_critiques_lecture_C(7) = '1'  --> MUL lit dans le registre de l'opérande C
45
+             --                Instructions_critiques_ecriture(7) = '1'  --> MUL ecrit dans le registre de l'opérande A
46
+             
47
+             -- Exemple 2 : Soit AFC i val avec pour numéro d'instruction 5 avec le comportement Ri <- val
48
+             --                Instructions_critiques_lecture_A(5) = '0'  --> AFC ne lit pas dans le registre de l'opérande A
49
+             --                Instructions_critiques_lecture_B(5) = '0'  --> AFC ne lit pas dans le registre de l'opérande B (pour AFC, B est directement la valeur, pas un numero de registre, il n'y a donc pas de lecture)
50
+             --                Instructions_critiques_lecture_C(5) = '0'  --> AFC ne lit pas dans le registre de l'opérande C
51
+             --                Instructions_critiques_ecriture(5) = '1'  --> AFC ecrit dans le registre de l'opérande A
52
+             
53
+             Code_Instruction_JMP : STD_LOGIC_VECTOR;   -- Numéro de l'instruction JMP
54
+             Code_Instruction_JMZ : STD_LOGIC_VECTOR;   -- Numéro de l'instruction JMZ
55
+             Code_Instruction_CALL : STD_LOGIC_VECTOR;  -- Numéro de l'instruction CALL
56
+             Code_Instruction_RET : STD_LOGIC_VECTOR;   -- Numéro de l'instruction RET
57
+             Code_Instruction_STOP : STD_LOGIC_VECTOR); -- Numéro de l'instruction STOP
58
+    Port ( CLK : in STD_LOGIC; -- Clock
59
+           RST : in STD_LOGIC; -- Reset
60
+           Z : in STD_LOGIC;   -- Flag Zero de l'ALU (utile pour le JMZ)
61
+           A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande A
62
+           B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande B
63
+           C : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande C
64
+           Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0)); -- Sortie du code de l'instruction
44 65
 end Etage1_LectureInstruction;
45 66
 
67
+
68
+
46 69
 architecture Behavioral of Etage1_LectureInstruction is
47 70
     component MemoireInstructions is
48 71
     Generic (Nb_bits : Natural;
@@ -82,26 +89,35 @@ architecture Behavioral of Etage1_LectureInstruction is
82 89
                F : out STD_LOGIC);
83 90
     end component;
84 91
     
92
+    -- Signaux pour récuperer l'instruction de la mémoire
85 93
     signal Pointeur_instruction : STD_LOGIC_VECTOR (Addr_size_mem_instruction - 1 downto 0) := (others => '0');
86 94
     signal Pointeur_instruction_next : STD_LOGIC_VECTOR (Addr_size_mem_instruction - 1 downto 0) := (0 => '1', others => '0');
87 95
     signal Instruction_courante : STD_LOGIC_VECTOR (Instruction_size_in_memory - 1 downto 0) := (others => '0');
88 96
     
97
+    
98
+    -- Tableau pour gérer les aléas des registres (lecture en étage 2 avant écriture en étage 5)
89 99
     subtype Registre is integer range -1 to Nb_registres - 1;
90 100
     type Tab_registres is array (1 to 3) of Registre;
91 101
     signal Tableau : Tab_registres := (others => - 1);
92 102
     
103
+    -- Signaux de gestion pour la mémoire des adresses de retour
93 104
     signal Adresse_Retour : STD_LOGIC_VECTOR (Addr_size_mem_instruction - 1 downto 0) := (others => '0');
94 105
     signal E : STD_LOGIC;
95 106
     signal F : STD_LOGIC;
96 107
     signal R_Aux : STD_LOGIC := '0';
97 108
     signal W_Aux : STD_LOGIC := '0';
98 109
 
110
+    -- constantes pour injecter des bulles dans le pipeline
99 111
     constant Instruction_nulle : STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0) := (others => '0');
100 112
     constant Argument_nul : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
101 113
     
114
+    -- condition pour detecter si une bulle doit être injectée 
102 115
     signal bulles : boolean := false;
103 116
     
117
+    -- Compteur pour attendre lors d'un JMZ que l'instruction d'avant soit a l'ALU, ou lors d'un STOP k
104 118
     signal compteur : integer := 0;
119
+    
120
+    -- Signal d'arret (STOP 0)
105 121
     signal locked : boolean := false;
106 122
     
107 123
 begin
@@ -130,8 +146,10 @@ begin
130 146
               
131 147
     process 
132 148
     begin
149
+    -- Synchronisation
133 150
         wait until CLK'event and CLK = '1';
134 151
         if (RST = '0') then
152
+            -- Reset de l'étage
135 153
             Tableau <= (others => -1);
136 154
             Pointeur_Instruction <= (others => '0');
137 155
             compteur <= 0;
@@ -141,23 +159,28 @@ begin
141 159
             A <= Argument_nul;
142 160
             Instruction <= Instruction_nulle;
143 161
         else
162
+            -- Avancement des instructions en écritures dans le pipeline
144 163
             Tableau(3) <= Tableau(2);
145 164
             Tableau(2) <= Tableau(1);
146 165
             Tableau(1) <= -1;
147 166
             if (not bulles) then
167
+                -- S'il ne faut pas injecter de bulles ont traite l'instruction (Possible code factorisable sur ce if)
148 168
                 if ((Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_CALL) or (Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_JMP)) then
169
+                    -- CAS PARTICULIER : CALL ou JMP, on transmet et on saute
149 170
                     C <= Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits);
150 171
                     B <= Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits);
151 172
                     A <= Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits);
152 173
                     Instruction <= Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits);
153 174
                     Pointeur_Instruction <= Instruction_courante (2 * Nb_bits + Addr_size_mem_instruction - 1 downto 2 * Nb_bits);
154 175
                 elsif (Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_RET) then
176
+                    -- CAS PARTICULIER : RET, on transmet et on revient 
155 177
                     C <= Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits);
156 178
                     B <= Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits);
157 179
                     A <= Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits);
158 180
                     Instruction <= Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits);
159 181
                     Pointeur_Instruction <= Adresse_Retour;
160 182
                 elsif (Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_JMZ) then
183
+                    -- CAS PARTICULIER : JMZ, on attends que l'instruction précedente arrive sur l'ALU, si le flag Zero est a un on saute, sinon on continue normalement
161 184
                     compteur <= compteur + 1;
162 185
                     C <= Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits);
163 186
                     B <= Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits);
@@ -172,6 +195,9 @@ begin
172 195
                         compteur <= 0;
173 196
                     end if;
174 197
                 elsif (Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_STOP) then
198
+                    -- CAS PARTICULIER : STOP, si on est bloqué, on ne fait rien, programme arrété
199
+                    --                         sinon, on regarde si l'on doit se bloquer
200
+                    --                         sinon, on incremente le compteur et on attends
175 201
                     if (not locked) then
176 202
                         if (Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits) = Argument_nul) then
177 203
                             locked <= true;
@@ -187,6 +213,7 @@ begin
187 213
                     A <= Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits);
188 214
                     Instruction <= Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits);
189 215
                 else
216
+                    -- CAS GENERAL : On transmet l'instruction et les opérandes, si elle est critique en ecriture, on enregistre le registre associé dans le tableau
190 217
                     C <= Instruction_courante (1 * Nb_bits - 1 downto 0 * Nb_bits);
191 218
                     B <= Instruction_courante (2 * Nb_bits - 1 downto 1 * Nb_bits);
192 219
                     A <= Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits);
@@ -197,6 +224,7 @@ begin
197 224
                     Pointeur_Instruction <= Pointeur_Instruction + 1;
198 225
                 end if;
199 226
             else 
227
+                -- Si besoin de bulle, on l'injecte
200 228
                 C <= Argument_nul;
201 229
                 B <= Argument_nul;
202 230
                 A <= Argument_nul;
@@ -206,19 +234,19 @@ begin
206 234
     end process;
207 235
     
208 236
     
209
-    -- Condition degueu -> Instruction critique en lecture simple qui lit dans B et B dans tableau ou instruction critique en lecture double qui lit dans C et C dans tableau 
237
+    -- Condition horrible -> Instruction critique en lecture sur A qui lit dans A=i et Ri dans tableau ou instruction critique en lecture sur B qui lit dans B=j et Rj dans tableau ou instruction critique en lecture sur C qui lit dans C=k et Rk dans tableau 
210 238
     bulles <= 
211 239
     (
212 240
         (
213
-            Instructions_critiques_lecture_A(to_integer(unsigned(Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits)))) = '1'
241
+            Instructions_critiques_lecture_A(to_integer(unsigned(Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits)))) = '1' -- Intruction critique sur A
214 242
         )
215 243
         and 
216 244
         (
217
-            (to_integer(unsigned(Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits))) = Tableau(1))
245
+            (to_integer(unsigned(Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits))) = Tableau(1)) -- A est
218 246
             or 
219
-            (to_integer(unsigned(Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits))) = Tableau(2))
247
+            (to_integer(unsigned(Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits))) = Tableau(2)) --        dans le 
220 248
             or 
221
-            (to_integer(unsigned(Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits))) = Tableau(3))
249
+            (to_integer(unsigned(Instruction_courante (3 * Nb_bits - 1 downto 2 * Nb_bits))) = Tableau(3)) --                  tableau
222 250
         )
223 251
     ) 
224 252
     or 
@@ -250,10 +278,12 @@ begin
250 278
         )
251 279
     );
252 280
     
253
-    
281
+    -- Gestion de l'écriture/lecture dans la mémoire des adresses de retour
254 282
     R_Aux <= '1' when Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_Instruction_RET else
255 283
              '0';
256 284
     W_Aux <= '1' when Instruction_courante (Instruction_bus_size + 3 * Nb_bits - 1 downto 3 * Nb_bits) = Code_instruction_CALL else
257 285
              '0';
286
+             
287
+             
258 288
     Pointeur_instruction_next <= Pointeur_instruction + 1;
259 289
 end Behavioral;

+ 49
- 34
Processeur.srcs/sources_1/new/Etage2-5_Registres.vhd View File

@@ -1,61 +1,51 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
3 5
 -- Create Date: 18.04.2021 21:19:41
4 6
 -- Module Name: Etage2_5_Registres - Behavioral
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+-- Description: Etage 2 et 5 du processeur
11
+--     - Gestion des registres, lecture étage 2 et écriture étage 5
12
+--     - Lecture et Ecriture dans les entrées sorties du processeur
5 13
 -- 
6 14
 -- Dependencies: 
15
+--    - BancRegistres
16
+--    - LC
17
+--    - MUX
7 18
 ----------------------------------------------------------------------------------
8 19
 
9 20
 
10 21
 library IEEE;
11 22
 use IEEE.STD_LOGIC_1164.ALL;
12 23
 
13
---use IEEE.NUMERIC_STD.ALL;
14
-
15
---library UNISIM;
16
---use UNISIM.VComponents.all;
17
-
18 24
 entity Etage2_5_Registres is
19
-    Generic ( Nb_bits : Natural;
20
-              Nb_registres : Natural;
21
-              Addr_registres_size : Natural;
22
-              Instruction_bus_size : Natural;
23
-              Bits_Controle_LC_5 : STD_LOGIC_VECTOR;
24
-              Bits_Controle_MUX_2_A : STD_LOGIC_VECTOR;
25
-              Bits_Controle_MUX_2_B : STD_LOGIC_VECTOR;
26
-              Code_Instruction_PRI : STD_LOGIC_VECTOR;
27
-              Code_Instruction_GET : STD_LOGIC_VECTOR);
28
-    Port ( CLK : in STD_LOGIC;
29
-           RST : in STD_LOGIC;
30
-           STD_IN : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
31
-           STD_OUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
32
-           IN_2_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
33
-           IN_2_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
34
-           IN_2_C : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
35
-           IN_2_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
36
-           OUT_2_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
37
-           OUT_2_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
38
-           OUT_2_C : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
39
-           OUT_2_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
40
-           IN_5_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
41
-           IN_5_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
42
-           IN_5_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0));
25
+    Generic ( Nb_bits : Natural; -- Taille d'un mot binaire
26
+              Nb_registres : Natural; -- Nombre de registres du processeurs
27
+              Addr_registres_size : Natural; -- Nombre de bits pour adresser les registres
28
+              Instruction_bus_size : Natural; -- Nombre de bits du bus d'instruction (Taille d'un code instruction)
29
+              Bits_Controle_LC_5 : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le Link Controler de l'étage 5 (cf LC.vhd)
30
+              Bits_Controle_MUX_2_A : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexeur de l'étage 2 sur A (cf MUX.vhd)
31
+              Bits_Controle_MUX_2_B : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexeur de l'étage 2 sur B (cf MUX.vhd)
32
+              Code_Instruction_PRI : STD_LOGIC_VECTOR;  -- Numéro de l'instruction PRI
33
+              Code_Instruction_GET : STD_LOGIC_VECTOR); -- Numéro de l'instruction GET
34
+    Port ( CLK : in STD_LOGIC; -- Clock
35
+           RST : in STD_LOGIC; -- Reset
36
+           STD_IN : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de données depuis l'exterieur du processeur
37
+           STD_OUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de données vers l'exterieur du processeur
38
+           IN_2_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A de l'étage 2
39
+           IN_2_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B de l'étage 2
40
+           IN_2_C : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande C de l'étage 2
41
+           IN_2_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Entrée de l'instruction de l'étage 2
42
+           OUT_2_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande A de l'étage 2
43
+           OUT_2_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande B de l'étage 2
44
+           OUT_2_C : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande C de l'étage 2
45
+           OUT_2_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Sortie de l'instruction de l'étage 2
46
+           IN_5_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A de l'étage 5
47
+           IN_5_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B de l'étage 5
48
+           IN_5_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0)); -- Entrée de l'instruction de l'étage 5
43 49
 end Etage2_5_Registres;
44 50
 
45 51
 architecture Behavioral of Etage2_5_Registres is
@@ -94,10 +84,14 @@ architecture Behavioral of Etage2_5_Registres is
94 84
                OUTPUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0));
95 85
     end component;
96 86
     
97
-    signal Commande_BancRegistres : STD_LOGIC_VECTOR (0 downto 0) := "0";
98
-    signal Entree_BancRegistre_DATA : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
99
-    signal Sortie_BancRegistres_A : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
100
-    signal Sortie_BancRegistres_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
87
+    signal Commande_BancRegistres : STD_LOGIC_VECTOR (0 downto 0) := "0"; -- Signal de sortie du LC
88
+    
89
+    signal Entree_BancRegistre_DATA : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0'); -- Entrée DATA du banc de registre (B de l'étage 5 ou STD_IN)
90
+    
91
+    signal Sortie_BancRegistres_A : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0'); -- Sortie du banc de registre a passer par le multiplexeur sur A
92
+    signal Sortie_BancRegistres_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0'); -- Sortie du banc de registre a passer par le multiplexeur sur B
93
+    
94
+    -- Signaux internes
101 95
     signal intern_OUT_2_A : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
102 96
     signal intern_OUT_2_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
103 97
     signal intern_OUT_2_C : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
@@ -153,9 +147,11 @@ begin
153 147
                intern_OUT_2_C;
154 148
     OUT_2_Instruction <= (others => '0') when RST = '0' else
155 149
                          IN_2_Instruction;    
156
-      
150
+     
151
+    -- Gestion de STD_OU (peut être améliorée) 
157 152
     process 
158 153
     begin
154
+        -- Synchronisation sur la clock
159 155
         wait until CLK'event and CLK = '1';
160 156
         if (RST = '0') then
161 157
             intern_STD_OUT <= (others => '0');
@@ -168,6 +164,9 @@ begin
168 164
     STD_OUT <= intern_STD_OUT when RST = '1' else
169 165
                (others => '0');
170 166
     
167
+    
168
+    
169
+    -- Un multiplexeur pourrait être utilisé ici, mais cela n'a pas été jugé pertinent
171 170
     Entree_BancRegistre_DATA <= (others => '0') when RST = '0' else
172 171
                                 STD_IN when IN_2_Instruction = Code_Instruction_GET else
173 172
                                 IN_5_B;

+ 36
- 21
Processeur.srcs/sources_1/new/Etage3_Calcul.vhd View File

@@ -1,53 +1,45 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
5
+-- Create Date: 18.04.2021 21:19:41 
6
+-- Module Name: Etage3_Calcul - Structural
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+--
11
+-- Description: Etage 3 du processeur
12
+--     - Gestion de l'ALU
3 13
 -- 
4 14
 -- Dependencies: 
15
+--    - ALU
16
+--    - LC
17
+--    - MUX
18
+--
19
+-- Additional Comments: Etage assynchrone
5 20
 ----------------------------------------------------------------------------------
6 21
 
7 22
 
8 23
 library IEEE;
9 24
 use IEEE.STD_LOGIC_1164.ALL;
10 25
 
11
---use IEEE.NUMERIC_STD.ALL;
12
-
13
---library UNISIM;
14
---use UNISIM.VComponents.all;
15
-
16 26
 entity Etage3_Calcul is
17
-    Generic ( Nb_bits : Natural;
18
-              Instruction_bus_size : Natural;
19
-              Bits_Controle_LC : STD_LOGIC_VECTOR;
20
-              Bits_Controle_MUX : STD_LOGIC_VECTOR);
21
-    Port ( RST : in STD_LOGIC;
22
-           IN_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
23
-           IN_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
24
-           IN_C : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
25
-           IN_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
26
-           OUT_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
27
-           OUT_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
28
-           OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
29
-           N : out STD_LOGIC;
30
-           O : out STD_LOGIC;
31
-           Z : out STD_LOGIC;
32
-           C : out STD_LOGIC);
27
+    Generic ( Nb_bits : Natural; -- Taille d'un mot binaire
28
+              Instruction_bus_size : Natural; -- Nombre de bits du bus d'instruction (Taille d'un code instruction)
29
+              Bits_Controle_LC : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le Link Controler (cf LC.vhd)
30
+              Bits_Controle_MUX : STD_LOGIC_VECTOR); -- Vecteur de bit controlant le multiplexeur (cf MUX.vhd)
31
+    Port ( RST : in STD_LOGIC; -- Reset
32
+           IN_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A
33
+           IN_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B
34
+           IN_C : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande C
35
+           IN_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Entrée de l'instruction
36
+           OUT_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande A
37
+           OUT_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande B
38
+           OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Sortie de l'instruction
39
+           N : out STD_LOGIC; -- Flag Negative
40
+           O : out STD_LOGIC; -- Flag Overload
41
+           Z : out STD_LOGIC; -- Flag Zero
42
+           C : out STD_LOGIC);-- Flag Carry
33 43
 end Etage3_Calcul;
34 44
 
35 45
 architecture Structural of Etage3_Calcul is
@@ -81,9 +73,14 @@ architecture Structural of Etage3_Calcul is
81 73
                OUTPUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0));
82 74
     end component;
83 75
     
76
+    -- Sortie du Link Controleur commandant l'ALU
84 77
     signal OP_ALU : STD_LOGIC_VECTOR (2 downto 0) := (others => '0');
78
+    
79
+    -- Sortie de l'ALU, a passer au multiplexeur
85 80
     signal Sortie_ALU : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
86 81
     
82
+    
83
+    -- signaux internes
87 84
     signal intern_OUT_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
88 85
     signal intern_N : STD_LOGIC := '0';
89 86
     signal intern_O : STD_LOGIC := '0';

+ 54
- 37
Processeur.srcs/sources_1/new/Etage4_Memoire.vhd View File

@@ -1,21 +1,22 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
3 5
 -- Create Date: 18.04.2021 21:19:41
6
+-- Module Name: Etage4_Memoire - Structural
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+--
11
+-- Description: Etage 4 du processeur
12
+--     - Gestion de la mémoire
13
+--     - Gestion de la sauvegarde du contexte lors des appels de fonction
4 14
 -- 
5 15
 -- Dependencies: 
16
+--    - MemoireDonnees
17
+--    - MemoireAdressesRetour
18
+--    - LC
19
+--    - MUX
6 20
 ----------------------------------------------------------------------------------
7 21
 
8 22
 
@@ -23,36 +24,27 @@ library IEEE;
23 24
 use IEEE.STD_LOGIC_1164.ALL;
24 25
 use IEEE.STD_LOGIC_UNSIGNED.ALL;
25 26
 
26
-
27
---library UNISIM;
28
---use UNISIM.VComponents.all;
29
-
30 27
 entity Etage4_Memoire is
31
-    Generic ( Nb_bits : Natural;
32
-              Mem_size : Natural;
33
-              Adresse_mem_size : Natural;
34
-              Instruction_bus_size : Natural;
35
-              Mem_EBP_size : Natural;
36
-              Adresse_size_mem_EBP : Natural;
37
-              Bits_Controle_LC : STD_LOGIC_VECTOR;
38
-              Bits_Controle_MUX_IN : STD_LOGIC_VECTOR;
39
-              Bits_Controle_MUX_IN_EBP : STD_LOGIC_VECTOR;
40
-              Bits_Controle_MUX_OUT : STD_LOGIC_VECTOR;
41
-              Code_Instruction_CALL : STD_LOGIC_VECTOR;
42
-              Code_Instruction_RET : STD_LOGIC_VECTOR);
43
-    Port ( CLK : in STD_LOGIC;
44
-           RST : in STD_LOGIC;
45
-           IN_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
46
-           IN_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
47
-           IN_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
48
-           OUT_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
49
-           OUT_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
50
-           OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0));
28
+    Generic ( Nb_bits : Natural; -- Taille d'un mot binaire
29
+              Mem_size : Natural; -- Taille de la mémoire de donnees (nombre de mots binaires stockables)
30
+              Adresse_mem_size : Natural; -- Nombre de bits pour adresser la mémoire de donnees
31
+              Instruction_bus_size : Natural; -- Nombre de bits du bus d'instruction (Taille d'un code instruction)
32
+              Mem_EBP_size : Natural; -- Taille de la mémoire du contexte (profondeur d'appel maximale)
33
+              Adresse_size_mem_EBP : Natural; -- Nombre de bits pour adresser la mémoire de contexte
34
+              Bits_Controle_LC : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le Link Controler (cf LC.vhd)
35
+              Bits_Controle_MUX_IN : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexer selectionnant A ou B comme adresse (cf MUX.vhd)
36
+              Bits_Controle_MUX_IN_EBP : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexer selectionnant si on doit ajouter ou non EBP à l'adresse (cf MUX.vhd)
37
+              Bits_Controle_MUX_OUT : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexer de sortie (cf MUX.vhd)
38
+              Code_Instruction_CALL : STD_LOGIC_VECTOR; -- Numéro de l'instruction CALL
39
+              Code_Instruction_RET : STD_LOGIC_VECTOR); -- Numéro de l'instruction RET
40
+    Port ( CLK : in STD_LOGIC; -- Clock
41
+           RST : in STD_LOGIC; -- Reset
42
+           IN_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A
43
+           IN_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B
44
+           IN_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Entrée de l'instruction
45
+           OUT_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande A
46
+           OUT_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande B
47
+           OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0)); -- Sortie de l'instruction
51 48
 end Etage4_Memoire;
52 49
 
53 50
 architecture Structural of Etage4_Memoire is
@@ -100,14 +92,21 @@ architecture Structural of Etage4_Memoire is
100 92
                OUTPUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0));
101 93
     end component;
102 94
     
103
-    signal Addr_MemoireDonnees : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0');
104
-    signal IN_Addr_MemoireDonnees : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0');
105
-    signal Addr_MemoireDonnees_EBP : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0');
106
-    signal Commande_MemoireDonnees : STD_LOGIC_VECTOR (0 downto 0) := "0";
107
-    signal Sortie_MemoireDonnees : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
108
-    signal intern_OUT_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0');
109
-    signal EBP : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0');
110
-    signal New_EBP : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0');
95
+    
96
+    signal EBP : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0'); -- EBP (offset à ajouter à l'adresse)
97
+    signal New_EBP : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0'); -- Nouvelle valeur d'EBP, a stocker lors d'un CALL (Cf fonctionnement MemoireAdressesRetour.vhd)
98
+    
99
+    signal Addr_MemoireDonnees : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0'); -- Adresse entrante dans le composant de mémoire de donnees
100
+    signal IN_Addr_MemoireDonnees : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0'); -- Sortie du mux de choix d'adresse entre A et B
101
+    signal Addr_MemoireDonnees_EBP : STD_LOGIC_VECTOR (Adresse_mem_size - 1 downto 0) := (others => '0'); -- Adresse avec EBP ajouté (IN_Addr_MemoireDonnees + BP)
102
+    
103
+    signal Commande_MemoireDonnees : STD_LOGIC_VECTOR (0 downto 0) := "0"; -- Sortie du Link Controler, signal de commande de la mémoire
104
+    
105
+    signal Sortie_MemoireDonnees : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0'); -- Sortie de la mémoire (a multiplexer)
106
+    
107
+    signal intern_OUT_B : STD_LOGIC_VECTOR (Nb_bits - 1 downto 0) := (others => '0'); -- Signal interne
108
+    
109
+    -- Signaux de la memoire de contexte
111 110
     signal R_Aux : STD_LOGIC := '0';
112 111
     signal W_Aux : STD_LOGIC := '0';
113 112
     signal E : STD_LOGIC;
@@ -115,14 +114,14 @@ architecture Structural of Etage4_Memoire is
115 114
     
116 115
     
117 116
 begin
118
-    instance_LC : LC
117
+    instance_LC : LC -- Link controleur sur la mémoire de donnees
119 118
     generic map (Instruction_Vector_Size => Instruction_bus_size,
120 119
                  Command_size => 1,
121 120
                  Bits_Controle => Bits_Controle_LC)
122 121
     port map (   Instruction => IN_Instruction,
123 122
                  Commande => Commande_MemoireDonnees);
124 123
                  
125
-    instance_MUX_IN : MUX
124
+    instance_MUX_IN : MUX -- Multiplexeur selectionnant A ou B pour adresse
126 125
     generic map (Nb_bits => Adresse_mem_size,
127 126
                  Instruction_Vector_Size => Instruction_bus_size,
128 127
                  Bits_Controle => Bits_Controle_MUX_IN)
@@ -131,7 +130,7 @@ begin
131 130
                  IN2 => IN_B (Adresse_mem_size - 1 downto 0),
132 131
                  OUTPUT => IN_Addr_MemoireDonnees);
133 132
                  
134
-    instance_MUX_IN_EBP : MUX
133
+    instance_MUX_IN_EBP : MUX -- Multiplexeur selectionnant l'adresse plus EBP ou l'adresse de base
135 134
     generic map (Nb_bits => Adresse_mem_size,
136 135
                  Instruction_Vector_Size => Instruction_bus_size,
137 136
                  Bits_Controle => Bits_Controle_MUX_IN_EBP)
@@ -140,7 +139,7 @@ begin
140 139
                  IN2 => Addr_MemoireDonnees_EBP,
141 140
                  OUTPUT => Addr_MemoireDonnees);
142 141
                  
143
-    instance_MUX_OUT : MUX
142
+    instance_MUX_OUT : MUX -- Multiplexeur selectionnant la sortie de l'étage (sur B)
144 143
     generic map (Nb_bits => Nb_bits,
145 144
                  Instruction_Vector_Size => Instruction_bus_size,
146 145
                  Bits_Controle => Bits_Controle_MUX_OUT)
@@ -182,7 +181,7 @@ begin
182 181
     OUT_Instruction <= (others => '0') when RST = '0' else
183 182
              IN_Instruction;
184 183
              
185
-    
184
+    -- Controle de la mémoire de contexte (ici aussi un LC aurait été disproportionné)
186 185
     R_Aux <= '1' when IN_Instruction = Code_Instruction_RET else
187 186
              '0';
188 187
     W_Aux <= '1' when IN_Instruction = Code_Instruction_CALL else

+ 23
- 9
Processeur.srcs/sources_1/new/LC.vhd View File

@@ -1,42 +1,39 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
3 5
 -- Create Date: 17.04.2021 21:49:57
4 6
 -- Module Name: LC - Behavioral
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+-- Description: Link Controler
5 11
 -- 
12
+-- Dependencies: None
13
+--
14
+-- Comments : 
15
+--    - Associe une commande a l'instruction courante
16
+--    - A l'instruction i est renvoyé le ieme paquet de taille Command_size
17
+--
18
+-- Exemple : 
19
+--    - Soit le vecteur de bits de controle "010010100111" avec command size a 3
20
+--    - Pour l'instruction 0 sera renvoyé "111"
21
+--    - Pour l'instruction 1 sera renvoyé "100"
22
+--    - Pour l'instruction 2 sera renvoyé "010"
23
+--    - Pour l'instruction 3 sera renvoyé "010"
6 24
 ----------------------------------------------------------------------------------
7 25
 
8 26
 
9 27
 library IEEE;
10 28
 use IEEE.STD_LOGIC_1164.ALL;
11
-
12 29
 use IEEE.NUMERIC_STD.ALL;
13 30
 
14
---library UNISIM;
15
---use UNISIM.VComponents.all;
16
-
17 31
 entity LC is
18
-    Generic (Instruction_Vector_Size : Natural;
19
-            Command_size : Natural;
20
-            Bits_Controle : STD_LOGIC_VECTOR);
21
-    Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
22
-           Commande : out STD_LOGIC_VECTOR (Command_size - 1 downto 0));
32
+    Generic (Instruction_Vector_Size : Natural; -- Nombres de bits nécessaires pour coder les instructions
33
+            Command_size : Natural; -- Nombre de bits de la commande en sortie
34
+            Bits_Controle : STD_LOGIC_VECTOR); -- Vecteur de bit contenant les commandes
35
+    Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0); -- Instrcution courante
36
+           Commande : out STD_LOGIC_VECTOR (Command_size - 1 downto 0)); -- Sortie de la commande
23 37
 end LC;
24 38
 
25 39
 architecture Behavioral of LC is

+ 20
- 11
Processeur.srcs/sources_1/new/MUX.vhd View File

@@ -1,44 +1,36 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
3 5
 -- Create Date: 17.04.2021 21:49:57
4 6
 -- Module Name: MUX - Behavioral
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+-- Description: Multiplexeur
5 11
 -- 
12
+-- Dependencies: None
13
+--
14
+-- Comments : 
15
+--    - Le multiplexeur selectionne une des deux entrées qu'il repercute en sortie en fonction de l'instruction
16
+--    - Les Bits_Controle definissent cette sélection : 
17
+--          Si Bits_Controle(Instruction) = '1' alors la première entrée est selectionnée
18
+--          Sinon, la seconde
6 19
 ----------------------------------------------------------------------------------
7 20
 
8 21
 
9 22
 library IEEE;
10 23
 use IEEE.STD_LOGIC_1164.ALL;
11
-
12 24
 use IEEE.NUMERIC_STD.ALL;
13 25
 
14
---library UNISIM;
15
---use UNISIM.VComponents.all;
16
-
17 26
 entity MUX is
18
-    Generic (Nb_bits : Natural;
19
-            Instruction_Vector_Size : Natural;
20
-            Bits_Controle : STD_LOGIC_VECTOR);
21
-    Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0);
22
-           IN1 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
23
-           IN2 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
24
-           OUTPUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0));
27
+    Generic (Nb_bits : Natural; -- Taille d'un mot en entrée
28
+            Instruction_Vector_Size : Natural; -- Nombres de bits nécessaires pour coder les instructions
29
+            Bits_Controle : STD_LOGIC_VECTOR); -- Vecteur de bit controlant le multiplexeur
30
+    Port ( Instruction : in STD_LOGIC_VECTOR (Instruction_Vector_Size - 1 downto 0); -- Instrcution courante
31
+           IN1 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée 1
32
+           IN2 : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée 2
33
+           OUTPUT : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0)); -- Sortie
25 34
 end MUX;
26 35
 
27 36
 architecture Behavioral of MUX is

+ 33
- 17
Processeur.srcs/sources_1/new/MemoireAdressesRetour.vhd View File

@@ -1,67 +1,65 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
3 5
 -- Create Date: 16.04.2021 14:35:04
4 6
 -- Module Name: MemoireAdressesRetour - Behavioral
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+-- Description: Memoire des informations de controle (adresse de retour ou EBP)
5 11
 -- 
12
+-- Dependencies: None
13
+--
14
+-- Comments : Cette mémoire fonctionne comme une pile. 
15
+--               - La valeur renvoyée est toujours celle du sommet (D_OUT = sommet de la pile).
16
+--               - Lors d'une écriture, D_IN est empilé
17
+--               - Lors d'une lecture, le sommet de la pile est pop
18
+--
19
+-- Warning : 
20
+--    - On peut revoir le nom (lecture et ecriture)
21
+--    - Flags E et F non fonctionnels
6 22
 ----------------------------------------------------------------------------------
7 23
 
8 24
 
9 25
 library IEEE;
10 26
 use IEEE.STD_LOGIC_1164.ALL;
11 27
 use IEEE.STD_LOGIC_UNSIGNED.ALL;
12
-
13 28
 use IEEE.NUMERIC_STD.ALL;
14 29
 
15
---library UNISIM;
16
---use UNISIM.VComponents.all;
17
-
18 30
 entity MemoireAdressesRetour is
19
-    Generic (Nb_bits : Natural;
20
-             Addr_size : Natural;
21
-             Mem_size : Natural);
22
-    Port ( R : in STD_LOGIC;
23
-           W : in STD_LOGIC;
24
-           D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
25
-           RST : in STD_LOGIC;
26
-           CLK : in STD_LOGIC;
27
-           D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0');
28
-           E : out STD_LOGIC;
29
-           F : out STD_LOGIC);
31
+    Generic (Nb_bits : Natural; -- Taille d'un mot en memoire (taille d'une adresse de la memoire d'instruction ou d'un mot pour EBP)
32
+             Addr_size : Natural; -- Nombre de bits necessaires pour adresser la mémoire
33
+             Mem_size : Natural); -- Nombre d'éléments stockés en mémoire
34
+    Port ( R : in STD_LOGIC; -- Si R = 1 on pop le sommet
35
+           W : in STD_LOGIC; -- Si W = 1 on push D_IN
36
+           D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Data entrante
37
+           RST : in STD_LOGIC; -- Reset
38
+           CLK : in STD_LOGIC; -- Clock
39
+           D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0'); -- Sortie du composant (toujours la valeur au sommet)
40
+           E : out STD_LOGIC; -- Flag Empty
41
+           F : out STD_LOGIC);-- Flag Full
30 42
 end MemoireAdressesRetour;
31 43
 
32 44
 architecture Behavioral of MemoireAdressesRetour is
33
-    signal MEMORY : STD_LOGIC_VECTOR ((Mem_Size * Nb_bits)-1 downto 0) := (others => '0');
34
-    signal Addr : STD_LOGIC_VECTOR (Addr_size downto 0) := (others => '0');
45
+    signal MEMORY : STD_LOGIC_VECTOR ((Mem_Size * Nb_bits)-1 downto 0) := (others => '0'); -- Buffer (mémoire)
46
+    signal Addr : STD_LOGIC_VECTOR (Addr_size downto 0) := (others => '0'); -- Signal INTERNE, mémoire non adressable de l'extérieur. Pointe vers le sommet de pile
35 47
     constant EMPTY : STD_LOGIC_VECTOR (Addr_size downto 0) := (others => '0');
36 48
     constant FULL : STD_LOGIC_VECTOR (Addr_size downto 0) := (Addr_size => '1', others => '0');
37 49
 begin
38 50
     process
39 51
     begin
52
+    -- Synchronisation
40 53
         wait until CLK'event and CLK = '1';
41 54
         if (RST = '0' ) then
42 55
             MEMORY <= (others => '0');
43 56
             Addr <= (others => '0');
44 57
         else
58
+            -- Push
45 59
             if (W = '1') then
46 60
                 MEMORY (((to_integer(unsigned(Addr)) + 1) * Nb_bits - 1) downto Nb_bits * to_integer(unsigned(Addr))) <= D_IN;
47 61
                 Addr <= Addr + 1;
62
+            -- Pop
48 63
             elsif (R = '1') then 
49 64
                 Addr <= Addr - 1;
50 65
             end if;
@@ -73,6 +71,7 @@ begin
73 71
     F <= '1' when Addr = FULL else
74 72
          '0';
75 73
          
74
+    -- Sortie du sommet de pile (ou 0 si pile vide)
76 75
     D_OUT <= (others => '0') when Addr = EMPTY else
77 76
              MEMORY (to_integer(unsigned(Addr)) * Nb_bits - 1 downto Nb_bits * (to_integer(unsigned(Addr)) - 1));
78 77
 end Behavioral;

+ 18
- 15
Processeur.srcs/sources_1/new/MemoireDonnees.vhd View File

@@ -1,50 +1,35 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
3 5
 -- Create Date: 16.04.2021 14:35:04
4 6
 -- Module Name: MemoireDonnees - Behavioral
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+-- Description: Memoire des donnees utilisateur
5 11
 -- 
12
+-- Dependencies: None
6 13
 ----------------------------------------------------------------------------------
7 14
 
8
-
9 15
 library IEEE;
10 16
 use IEEE.STD_LOGIC_1164.ALL;
11
-
12 17
 use IEEE.NUMERIC_STD.ALL;
13 18
 
14
---library UNISIM;
15
---use UNISIM.VComponents.all;
16
-
17 19
 entity MemoireDonnees is
18
-    Generic (Nb_bits : Natural;
19
-             Addr_size : Natural;
20
-             Mem_size : Natural);
21
-    Port ( Addr : in STD_LOGIC_VECTOR (Addr_size-1 downto 0);
22
-           RW : in STD_LOGIC;
23
-           D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0);
24
-           RST : in STD_LOGIC;
25
-           CLK : in STD_LOGIC;
26
-           D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0'));
20
+    Generic (Nb_bits : Natural; -- Taille d'un mot en mémoire 
21
+             Addr_size : Natural; -- Nombre de bits nécessaires a l'adressage de la mémoire
22
+             Mem_size : Natural); -- Nombre de mot stockables
23
+    Port ( Addr : in STD_LOGIC_VECTOR (Addr_size-1 downto 0); -- L'adresse a laquelle il faut agir
24
+           RW : in STD_LOGIC; -- Ce qu'il faut faire ('1' -> Read, '0' -> Write)
25
+           D_IN : in STD_LOGIC_VECTOR (Nb_bits-1 downto 0); -- Data a ecrire (si RW = 0)
26
+           RST : in STD_LOGIC; -- Reset
27
+           CLK : in STD_LOGIC; -- Clock
28
+           D_OUT : out STD_LOGIC_VECTOR (Nb_bits-1 downto 0) := (others => '0')); -- Sortie de la mémoire 
27 29
 end MemoireDonnees;
28 30
 
29 31
 architecture Behavioral of MemoireDonnees is
30
-    signal MEMORY : STD_LOGIC_VECTOR ((Mem_Size * Nb_bits)-1 downto 0) := (others => '0');
32
+    signal MEMORY : STD_LOGIC_VECTOR ((Mem_Size * Nb_bits)-1 downto 0) := (others => '0'); -- Buffer pour la mémoire
31 33
 begin
32 34
     process
33 35
     begin
@@ -58,5 +43,6 @@ begin
58 43
         end if;
59 44
     end process;
60 45
     
46
+    -- Lecture assynchrone et en permanence
61 47
     D_OUT <= MEMORY (((to_integer(unsigned(Addr)) + 1) * Nb_bits) - 1 downto Nb_bits * to_integer(unsigned(Addr)));
62 48
 end Behavioral;

+ 21
- 10
Processeur.srcs/sources_1/new/MemoireInstructions.vhd
File diff suppressed because it is too large
View File


+ 20
- 7
Processeur.srcs/sources_1/new/System.vhd View File

@@ -1,36 +1,28 @@
1 1
 ----------------------------------------------------------------------------------
2
+-- Company:  INSA-Toulouse
3
+-- Engineer: Paul Faure
2 4
 -- 
3 5
 -- Create Date: 13.04.2021 10:19:15
4 6
 -- Module Name: System - Behavioral
7
+-- Project Name: Processeur sécurisé
8
+-- Target Devices: Basys 3 ARTIX7
9
+-- Tool Versions: Vivado 2016.4
10
+-- Description: Environnement du processeur, mapping entre le processeur et la carte
5 11
 -- 
6 12
 -- Dependencies: 
13
+--    - Clock_Divider
14
+--    - Pipeline
7 15
 ----------------------------------------------------------------------------------
8 16
 
9 17
 
10 18
 library IEEE;
11 19
 use IEEE.STD_LOGIC_1164.ALL;
12 20
 
13
---use IEEE.NUMERIC_STD.ALL;
14
-
15
---library UNISIM;
16
---use UNISIM.VComponents.all;
17
-
21
+-- Lien avec le fichier de contraintes 
22
+--   Récupération des leds pour STD_OUT
23
+--   Récupération des switchs pour STD_IN
24
+--   Récupération d'un bouton pour RST
25
+--   Récupération de la clock
18 26
 entity System is
19 27
     Port ( led : out STD_LOGIC_VECTOR (7 downto 0);
20 28
            sw : in STD_LOGIC_VECTOR (7 downto 0);
@@ -61,19 +53,23 @@ architecture Structural of System is
61 53
                CLK_OUT : out STD_LOGIC);
62 54
     end component;
63 55
     
56
+    -- signaux auxiliaires
64 57
     signal my_RST : STD_LOGIC;
65 58
     signal my_CLK : STD_LOGIC;
66 59
     signal buff_CLK : STD_LOGIC;
67 60
         
68 61
 begin
62
+    -- Premier diviseur de clock
69 63
     clk_div : Clock_Divider
70 64
     port map (CLK_IN => CLK,
71 65
               CLK_OUT => buff_CLK);
72 66
               
67
+    -- Second diviseur de clock
73 68
     clk_div_2 : Clock_Divider
74 69
     port map (CLK_IN => buff_CLK,
75 70
               CLK_OUT => my_CLK);
76 71
               
72
+    -- Le processeur, augmentation de la taille de la mémoire d'instruction
77 73
     instance : Pipeline
78 74
     generic map (Addr_Memoire_Instruction_Size => 8,
79 75
                  Memoire_Instruction_Size => 256)
@@ -82,7 +78,8 @@ begin
82 78
               STD_IN => sw,
83 79
               STD_OUT => led);
84 80
               
85
-    my_RST <= '0' when btnC = '1' else
86
-              '1';
81
+    -- Gestion du RST (inversion d'état)
82
+    my_RST <= '1' when btnC = '0' else
83
+              '0';
87 84
 end Structural;
88 85
 

+ 13
- 8
Processeur.xpr View File

@@ -3,7 +3,7 @@
3 3
 <!--                                                         -->
4 4
 <!-- Copyright 1986-2016 Xilinx, Inc. All Rights Reserved.   -->
5 5
 
6
-<Project Version="7" Minor="17" Path="C:/Users/Hp/Documents/TestGITProcesseur/FPGA_PIR/Processeur.xpr">
6
+<Project Version="7" Minor="17" Path="/home/paulfaure/Documents/4A/PSI/Processeur/Processeur.xpr">
7 7
   <DefaultLaunch Dir="$PRUNDIR"/>
8 8
   <Configuration>
9 9
     <Option Name="Id" Val="c2fc77f80b2a4a04afc3ac9eb7900c74"/>
@@ -18,7 +18,7 @@
18 18
     <Option Name="CompiledLibDirActivehdl" Val="$PCACHEDIR/compile_simlib/activehdl"/>
19 19
     <Option Name="TargetLanguage" Val="VHDL"/>
20 20
     <Option Name="SimulatorLanguage" Val="VHDL"/>
21
-    <Option Name="BoardPart" Val="digilentinc.com:basys3:part0:1.1"/>
21
+    <Option Name="BoardPart" Val=""/>
22 22
     <Option Name="SourceMgmtMode" Val="DisplayOnly"/>
23 23
     <Option Name="ActiveSimSet" Val="sim_1"/>
24 24
     <Option Name="DefaultLib" Val="xil_defaultlib"/>
@@ -32,7 +32,7 @@
32 32
     <Option Name="EnableBDX" Val="FALSE"/>
33 33
     <Option Name="DSABoardId" Val="basys3"/>
34 34
     <Option Name="DSANumComputeUnits" Val="16"/>
35
-    <Option Name="WTXSimLaunchSim" Val="231"/>
35
+    <Option Name="WTXSimLaunchSim" Val="234"/>
36 36
     <Option Name="WTModelSimLaunchSim" Val="0"/>
37 37
     <Option Name="WTQuestaLaunchSim" Val="0"/>
38 38
     <Option Name="WTIesLaunchSim" Val="0"/>
@@ -257,22 +257,26 @@
257 257
     <Simulator Name="Questa">
258 258
       <Option Name="Description" Val="Questa Advanced Simulator"/>
259 259
     </Simulator>
260
+    <Simulator Name="IES">
261
+      <Option Name="Description" Val="Incisive Enterprise Simulator (IES)"/>
262
+    </Simulator>
263
+    <Simulator Name="VCS">
264
+      <Option Name="Description" Val="Verilog Compiler Simulator (VCS)"/>
265
+    </Simulator>
260 266
     <Simulator Name="Riviera">
261 267
       <Option Name="Description" Val="Riviera-PRO Simulator"/>
262 268
     </Simulator>
263
-    <Simulator Name="ActiveHDL">
264
-      <Option Name="Description" Val="Active-HDL Simulator"/>
265
-    </Simulator>
266 269
   </Simulators>
267 270
   <Runs Version="1" Minor="10">
268
-    <Run Id="synth_1" Type="Ft3:Synth" SrcSet="sources_1" Part="xc7a35tcpg236-1" ConstrsSet="constrs_1" Description="Vivado Synthesis Defaults" State="current" IncludeInArchive="true">
271
+    <Run Id="synth_1" Type="Ft3:Synth" SrcSet="sources_1" Part="xc7a35tcpg236-1" ConstrsSet="constrs_1" Description="Vivado Synthesis Defaults" State="current" Dir="$PRUNDIR/synth_1" IncludeInArchive="true">
269 272
       <Strategy Version="1" Minor="2">
270 273
         <StratHandle Name="Vivado Synthesis Defaults" Flow="Vivado Synthesis 2016"/>
271 274
         <Step Id="synth_design"/>
272 275
       </Strategy>
276
+      <GeneratedRun Dir="$PRUNDIR" File="gen_run.xml"/>
273 277
       <Report Name="ROUTE_DESIGN.REPORT_METHODOLOGY" Enabled="1"/>
274 278
     </Run>
275
-    <Run Id="impl_1" Type="Ft2:EntireDesign" Part="xc7a35tcpg236-1" ConstrsSet="constrs_1" Description="Default settings for Implementation." State="current" SynthRun="synth_1" IncludeInArchive="true">
279
+    <Run Id="impl_1" Type="Ft2:EntireDesign" Part="xc7a35tcpg236-1" ConstrsSet="constrs_1" Description="Default settings for Implementation." State="current" Dir="$PRUNDIR/impl_1" SynthRun="synth_1" IncludeInArchive="true">
276 280
       <Strategy Version="1" Minor="2">
277 281
         <StratHandle Name="Vivado Implementation Defaults" Flow="Vivado Implementation 2016"/>
278 282
         <Step Id="init_design"/>
@@ -285,6 +289,7 @@
285 289
         <Step Id="post_route_phys_opt_design"/>
286 290
         <Step Id="write_bitstream"/>
287 291
       </Strategy>
292
+      <GeneratedRun Dir="$PRUNDIR" File="gen_run.xml"/>
288 293
       <Report Name="ROUTE_DESIGN.REPORT_METHODOLOGY" Enabled="1"/>
289 294
     </Run>
290 295
   </Runs>

Loading…
Cancel
Save