diff --git a/README.md b/README.md index 08a5133..949faa5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,34 @@ -# memory_file +# Banc de mémoire -![image](https://github.com/yoboujon/memory_file/assets/80280962/499115ef-c166-4234-a626-8e3361fb032e) + ![image](https://github.com/yoboujon/memory_file/assets/80280962/a9fc3fba-c9fc-4597-b7a3-30122237c86f) + + +Architecture contenant deux mémoires : une mémoire pour les données et une mémoire pour les instructions. +- **Entrées/Sorties :** + - Entrées : + - `@A(3:0)` : Adresse de la mémoire des données (4 bits). + - `@B(3:0)` : Adresse de la mémoire des instructions (4 bits). + - `DATA(7:0)` : Données à écrire dans la mémoire des données (8 bits). + - `CLK` : Signal d'horloge. + - `RST` : Signal de réinitialisation. + - `@W(3:0)` : Adresse d'écriture pour la mémoire des données (4 bits). + - `QA(7:0)` : Données lues depuis la mémoire des données (8 bits). + - `QB(7:0)` : Données lues depuis la mémoire des instructions (8 bits). + - `W` : Signal de sélection d'écriture dans la mémoire des données. + - Sorties : + - Aucune sortie spécifiée. + +- **Mémoire des données :** + - La mémoire des données permet un accès en lecture ou en écriture. + - L'adresse de la zone mémoire est fournie par l'entrée `@`. + - Pour réaliser une lecture, `RW` doit être positionné à 1. + - Pour réaliser une écriture, `RW` doit être positionné à 0. Dans le cas d'une écriture, le contenu de l'entrée `IN` est copié dans la mémoire à l'adresse `@`. + - Le signal de reset, `RST`, permet d'initialiser le contenu de la mémoire à 0x00. + - Les opérations de lecture, d'écriture et de reset se font synchrones avec l'horloge `CLK`. + +- **Mémoire des instructions :** + - La mémoire des instructions a une structure simplifiée et s'apparente à une ROM. + - Le programme à exécuter par le microprocesseur est stocké dans cette mémoire au préalable. + - À l'exécution, toute modification du contenu de cette mémoire est empêchée. + - La lecture se fait synchrone avec l'horloge `CLK`. diff --git a/instruction_memory/memory_file.xpr b/instruction_memory/memory_file.xpr new file mode 100644 index 0000000..58bbd2f --- /dev/null +++ b/instruction_memory/memory_file.xpr @@ -0,0 +1,235 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Vivado Synthesis Defaults + + + + + + + + + + + + Default settings for Implementation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + default_dashboard + + + diff --git a/instruction_memory/src/instruction.vhd b/instruction_memory/src/instruction.vhd new file mode 100644 index 0000000..1a0e6d8 --- /dev/null +++ b/instruction_memory/src/instruction.vhd @@ -0,0 +1,40 @@ +library IEEE; +use IEEE.STD_LOGIC_1164.ALL; +use IEEE.STD_LOGIC_ARITH.ALL; +use IEEE.STD_LOGIC_UNSIGNED.ALL; + +entity instruction is + port( + instruction: in STD_LOGIC_VECTOR(7 downto 0); + code: out STD_LOGIC_VECTOR(31 downto 0); + clk: in STD_LOGIC + ); + + -- Array of STD_LOGIC_VECTOR + type code_array is array(0 to 256) of + STD_LOGIC_VECTOR(31 downto 0); + + -- Initialize the code memory + function init return code_array is + variable init_result: code_array; + begin + --do something (e.g. read data from a file, perform some initialization calculation, ...) + -- Exemple : + for i in code_array'range loop + init_result(i) := std_logic_vector(conv_unsigned(i, 32)); + end loop; + return init_result; + end function init; +end instruction; + +architecture behavior_instr of instruction is + -- Memory variable + signal code_memory: code_array := init; +begin + process(instruction, clk) is + begin + if clk'event AND clk = '1' then + code <= code_memory(CONV_INTEGER(UNSIGNED(instruction))); + end if; + end process; +end behavior_instr; \ No newline at end of file diff --git a/instruction_memory/src/sim_instruction.vhd b/instruction_memory/src/sim_instruction.vhd new file mode 100644 index 0000000..db14e8d --- /dev/null +++ b/instruction_memory/src/sim_instruction.vhd @@ -0,0 +1,31 @@ +library IEEE; +use IEEE.STD_LOGIC_1164.ALL; +use IEEE.NUMERIC_STD.ALL; +use IEEE.STD_LOGIC_ARITH.ALL; +use IEEE.STD_LOGIC_UNSIGNED.ALL; + +entity test_instr is +end test_instr; + +architecture bench of test_instr is + component instruction is + port( + instruction: in STD_LOGIC_VECTOR(7 downto 0); + code: out STD_LOGIC_VECTOR(31 downto 0); + clk: in STD_LOGIC + ); + end component; + + for all : instruction use entity work.instruction; + + signal inAddress : STD_LOGIC_VECTOR(7 downto 0); + signal outCode : STD_LOGIC_VECTOR(31 downto 0); + signal inClock : STD_LOGIC := '0'; + +begin + testeur: instruction PORT MAP(inAddress, outCode, inClock); + inClock <= not inClock after 1ns; + + inAddress <= X"00", X"0a" after 10ns; + +end bench;