|
@@ -37,34 +37,59 @@ end Test_Etage4_Memoire;
|
37
|
37
|
|
38
|
38
|
architecture Behavioral of Test_Etage4_Memoire is
|
39
|
39
|
component Etage4_Memoire is
|
40
|
|
- Generic ( Nb_bits : Natural;
|
41
|
|
- Mem_size : Natural;
|
42
|
|
- Instruction_bus_size : Natural;
|
43
|
|
- Bits_Controle_LC : STD_LOGIC_VECTOR;
|
44
|
|
- Bits_Controle_MUX_IN : STD_LOGIC_VECTOR;
|
45
|
|
- Bits_Controle_MUX_OUT : STD_LOGIC_VECTOR);
|
46
|
|
- Port ( CLK : in STD_LOGIC;
|
47
|
|
- RST : in STD_LOGIC;
|
48
|
|
- IN_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
49
|
|
- IN_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
50
|
|
- IN_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0);
|
51
|
|
- OUT_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
52
|
|
- OUT_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0);
|
53
|
|
- OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0));
|
|
40
|
+ Generic ( Nb_bits : Natural; -- Taille d'un mot binaire
|
|
41
|
+ Mem_size : Natural; -- Taille de la mémoire de donnees (nombre de mots binaires stockables)
|
|
42
|
+ Adresse_mem_size : Natural; -- Nombre de bits pour adresser la mémoire de donnees
|
|
43
|
+ Instruction_bus_size : Natural; -- Nombre de bits du bus d'instruction (Taille d'un code instruction)
|
|
44
|
+ Bits_Controle_LC : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le Link Controler (cf LC.vhd)
|
|
45
|
+ Bits_Controle_MUX_IN : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexer selectionnant A ou B comme adresse (cf MUX.vhd)
|
|
46
|
+ 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)
|
|
47
|
+ Bits_Controle_MUX_OUT : STD_LOGIC_VECTOR; -- Vecteur de bit controlant le multiplexer de sortie (cf MUX.vhd)
|
|
48
|
+ Code_Instruction_CALL : STD_LOGIC_VECTOR; -- Numéro de l'instruction CALL
|
|
49
|
+ Code_Instruction_RET : STD_LOGIC_VECTOR); -- Numéro de l'instruction RET
|
|
50
|
+ Port ( CLK : in STD_LOGIC; -- Clock
|
|
51
|
+ RST : in STD_LOGIC; -- Reset
|
|
52
|
+ IN_A : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande A
|
|
53
|
+ IN_B : in STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Entrée de l'opérande B
|
|
54
|
+ IN_Instruction : in STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Entrée de l'instruction
|
|
55
|
+ OUT_A : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande A
|
|
56
|
+ OUT_B : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0); -- Sortie de l'opérande B
|
|
57
|
+ OUT_Instruction : out STD_LOGIC_VECTOR (Instruction_bus_size - 1 downto 0); -- Sortie de l'instruction
|
|
58
|
+ OUT_AddrRetour : out STD_LOGIC_VECTOR (Nb_bits - 1 downto 0)); -- Sortie de l'adresse de retour vers l'étage 1
|
54
|
59
|
end component;
|
55
|
60
|
|
56
|
61
|
signal my_CLK : STD_LOGIC := '0';
|
57
|
62
|
signal my_RST : STD_LOGIC := '1';
|
58
|
63
|
signal my_IN_A : STD_LOGIC_VECTOR (7 downto 0) := (others => '0');
|
59
|
64
|
signal my_IN_B : STD_LOGIC_VECTOR (7 downto 0) := (others => '0');
|
60
|
|
- signal my_IN_Instruction : STD_LOGIC_VECTOR (2 downto 0) := (others => '0');
|
|
65
|
+ signal my_IN_Instruction : STD_LOGIC_VECTOR (4 downto 0) := (others => '0');
|
61
|
66
|
signal my_OUT_A : STD_LOGIC_VECTOR (7 downto 0) := (others => '0');
|
62
|
67
|
signal my_OUT_B : STD_LOGIC_VECTOR (7 downto 0) := (others => '0');
|
63
|
|
- signal my_OUT_Instruction : STD_LOGIC_VECTOR (2 downto 0) := (others => '0');
|
|
68
|
+ signal my_OUT_Instruction : STD_LOGIC_VECTOR (4 downto 0) := (others => '0');
|
|
69
|
+ signal my_OUT_AddrRetour : STD_LOGIC_VECTOR (7 downto 0) := (others => '0');
|
64
|
70
|
|
65
|
|
- constant Bits_Controle_LC : STD_LOGIC_VECTOR (7 downto 0) := "01111111";
|
66
|
|
- constant Bits_Controle_MUX_IN : STD_LOGIC_VECTOR (7 downto 0) := "10111111";
|
67
|
|
- constant Bits_Controle_MUX_OUT : STD_LOGIC_VECTOR (7 downto 0) := "01000000";
|
|
71
|
+ constant Bits_Controle_LC : STD_LOGIC_VECTOR (31 downto 0) := "1111111111" & "1111111001011111111111";
|
|
72
|
+ constant Bits_Controle_MUX_IN : STD_LOGIC_VECTOR (31 downto 0) := "1111111111" & "1101111110101111111111";
|
|
73
|
+ constant Bits_Controle_MUX_IN_EBP : STD_LOGIC_VECTOR (31 downto 0) := "1111111111" & "1001111011001111111111";
|
|
74
|
+ constant Bits_Controle_MUX_OUT : STD_LOGIC_VECTOR (31 downto 0) := "1111111111" & "0000000001010000000000";
|
|
75
|
+ constant Code_Instruction_CALL : STD_LOGIC_VECTOR (4 downto 0) := "10011";
|
|
76
|
+ constant Code_Instruction_RET : STD_LOGIC_VECTOR (4 downto 0) := "10100";
|
|
77
|
+
|
|
78
|
+ constant CNULL : STD_LOGIC_VECTOR (4 downto 0) := "00000";
|
|
79
|
+ constant CWR : STD_LOGIC_VECTOR (4 downto 0) := "01011";
|
|
80
|
+ constant CCALL : STD_LOGIC_VECTOR (4 downto 0) := "10011";
|
|
81
|
+ constant CRET : STD_LOGIC_VECTOR (4 downto 0) := "10100";
|
|
82
|
+ constant C0 : STD_LOGIC_VECTOR (7 downto 0) := "00000000";
|
|
83
|
+ constant C1 : STD_LOGIC_VECTOR (7 downto 0) := "00000001";
|
|
84
|
+ constant C2 : STD_LOGIC_VECTOR (7 downto 0) := "00000010";
|
|
85
|
+ constant C3 : STD_LOGIC_VECTOR (7 downto 0) := "00000011";
|
|
86
|
+ constant C5 : STD_LOGIC_VECTOR (7 downto 0) := "00000101";
|
|
87
|
+ constant C7 : STD_LOGIC_VECTOR (7 downto 0) := "00000111";
|
|
88
|
+ constant C12 : STD_LOGIC_VECTOR (7 downto 0) := "00001100";
|
|
89
|
+ constant C36 : STD_LOGIC_VECTOR (7 downto 0) := "00100100";
|
|
90
|
+ constant C54 : STD_LOGIC_VECTOR (7 downto 0) := "00110110";
|
|
91
|
+ constant C77 : STD_LOGIC_VECTOR (7 downto 0) := "01001101";
|
|
92
|
+ constant C100 : STD_LOGIC_VECTOR (7 downto 0) := "01100100";
|
68
|
93
|
|
69
|
94
|
constant CLK_period : time := 10 ns;
|
70
|
95
|
|
|
@@ -72,11 +97,15 @@ begin
|
72
|
97
|
|
73
|
98
|
instance : Etage4_Memoire
|
74
|
99
|
generic map( Nb_bits => 8,
|
75
|
|
- Mem_size => 256,
|
76
|
|
- Instruction_bus_size => 3,
|
|
100
|
+ Mem_size => 16,
|
|
101
|
+ Adresse_mem_size => 4,
|
|
102
|
+ Instruction_bus_size => 5,
|
77
|
103
|
Bits_Controle_LC => Bits_Controle_LC,
|
78
|
104
|
Bits_Controle_MUX_IN => Bits_Controle_MUX_IN,
|
79
|
|
- Bits_Controle_MUX_OUT => Bits_Controle_MUX_OUT)
|
|
105
|
+ Bits_Controle_MUX_IN_EBP => Bits_Controle_MUX_IN_EBP,
|
|
106
|
+ Bits_Controle_MUX_OUT => Bits_Controle_MUX_OUT,
|
|
107
|
+ Code_Instruction_CALL => Code_Instruction_CALL,
|
|
108
|
+ Code_Instruction_RET => Code_Instruction_RET)
|
80
|
109
|
port map( CLK => my_CLK,
|
81
|
110
|
RST => my_RST,
|
82
|
111
|
IN_A => my_IN_A,
|
|
@@ -84,7 +113,8 @@ begin
|
84
|
113
|
IN_Instruction => my_IN_Instruction,
|
85
|
114
|
OUT_A => my_OUT_A,
|
86
|
115
|
OUT_B => my_OUT_B,
|
87
|
|
- OUT_Instruction => my_OUT_Instruction);
|
|
116
|
+ OUT_Instruction => my_OUT_Instruction,
|
|
117
|
+ OUT_AddrRetour => my_OUT_AddrRetour);
|
88
|
118
|
|
89
|
119
|
CLK_process :process
|
90
|
120
|
begin
|
|
@@ -96,9 +126,9 @@ begin
|
96
|
126
|
|
97
|
127
|
process
|
98
|
128
|
begin
|
99
|
|
- my_IN_A <= "01011111" after 0 ns, "11111111" after 124 ns;
|
100
|
|
- my_IN_B <= "10100110" after 0 ns, "01011111" after 124 ns;
|
101
|
|
- my_IN_Instruction <= "000" after 0 ns, "001" after 10 ns, "010" after 20 ns, "011" after 30 ns, "100" after 40 ns, "101" after 50 ns, "110" after 60 ns, "111" after 70 ns, "000" after 80 ns, "110" after 100 ns, "111" after 110 ns, "110" after 120 ns;
|
|
129
|
+ my_IN_A <= C0 after 0 ns, C0 after 5 ns, C1 after 15 ns, C2 after 25 ns, C77 after 35 ns, C0 after 45 ns, C54 after 55 ns, C0 after 65 ns, C0 after 75 ns;
|
|
130
|
+ my_IN_B <= C0 after 0 ns, C36 after 5 ns, C5 after 15 ns, C7 after 25 ns, C3 after 35 ns, C12 after 45 ns, C1 after 55 ns, C100 after 65 ns, C0 after 75 ns;
|
|
131
|
+ my_IN_Instruction <= CNULL after 0 ns, CWR after 5 ns, CWR after 15 ns, CWR after 25 ns, CCALL after 35 ns, CWR after 45 ns, CCALL after 55 ns, CWR after 65 ns, CRET after 75 ns, CRET after 85 ns, CNULL after 95 ns;
|
102
|
132
|
my_RST <= '0' after 125 ns;
|
103
|
133
|
wait;
|
104
|
134
|
end process;
|