From 86775eb6816edde22ea2058b6716b7196d8f318c Mon Sep 17 00:00:00 2001 From: Lemonochrome <80280962+Lemonochrme@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:32:01 +0200 Subject: [PATCH 1/9] Update README.md --- README.md | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 20c5884..9c71a90 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ -# memory_file -Banc de mémoire super sympa !! +# Banc de mémoire + +Architecture contenant deux mémoires : une mémoire pour les données et une mémoire pour les instructions. Leur structure est présentée dans la figure 5. +- **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`. From d142daa38ab2af768105d10a3ac1db44303cebe7 Mon Sep 17 00:00:00 2001 From: Lemonochrome <80280962+Lemonochrme@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:33:01 +0200 Subject: [PATCH 2/9] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c71a90..f5b1c41 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # Banc de mémoire -Architecture contenant deux mémoires : une mémoire pour les données et une mémoire pour les instructions. Leur structure est présentée dans la figure 5. +![image](https://github.com/yoboujon/memory_file/assets/80280962/2ebe1960-2c3f-4cb3-9127-4cbc40e2bcab) + + +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). From 6681bebab0acaa275b7401d46b2a4782a776d1f7 Mon Sep 17 00:00:00 2001 From: Lemonochrome <80280962+Lemonochrme@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:34:03 +0200 Subject: [PATCH 3/9] Update README.md --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f5b1c41..34dbab2 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ # Banc de mémoire -![image](https://github.com/yoboujon/memory_file/assets/80280962/2ebe1960-2c3f-4cb3-9127-4cbc40e2bcab) - - Architecture contenant deux mémoires : une mémoire pour les données et une mémoire pour les instructions. - **Entrées/Sorties :** - Entrées : @@ -31,3 +28,8 @@ Architecture contenant deux mémoires : une mémoire pour les données et une m - 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`. + + + + ![image-removebg-preview](https://github.com/yoboujon/memory_file/assets/80280962/16b2cba7-9bc8-497b-a628-b5c782b92be1) + From 23649b9b469da2327b188fa59e729241079fc1e0 Mon Sep 17 00:00:00 2001 From: Lemonochrome <80280962+Lemonochrme@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:34:26 +0200 Subject: [PATCH 4/9] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 34dbab2..2463628 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,3 @@ Architecture contenant deux mémoires : une mémoire pour les données et une m - À l'exécution, toute modification du contenu de cette mémoire est empêchée. - La lecture se fait synchrone avec l'horloge `CLK`. - - - ![image-removebg-preview](https://github.com/yoboujon/memory_file/assets/80280962/16b2cba7-9bc8-497b-a628-b5c782b92be1) - From 7df7fc9a6fbc10b7c503610b91ea78308143a379 Mon Sep 17 00:00:00 2001 From: Lemonochrome <80280962+Lemonochrme@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:36:23 +0200 Subject: [PATCH 5/9] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 2463628..614de6f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Banc de mémoire + ![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 : From f7cedc281edcdf7e932f6b0976874d4b9b2bb960 Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Fri, 29 Sep 2023 16:46:33 +0200 Subject: [PATCH 6/9] Boiler plate for Instruction Memory --- src/instruction.vhd | 24 ++++++++++++++++++++++++ src/sim_instruction.vhd | 29 +++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/instruction.vhd create mode 100644 src/sim_instruction.vhd diff --git a/src/instruction.vhd b/src/instruction.vhd new file mode 100644 index 0000000..08ab29f --- /dev/null +++ b/src/instruction.vhd @@ -0,0 +1,24 @@ +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 +); +end instruction; + +architecture behavior_instr of instruction is + -- Array of STD_LOGIC_VECTOR + type code_array is array(0 to 15) of + STD_LOGIC_VECTOR(7 downto 0); + -- Memory variable + signal code_memory: code_array; +begin + process(instruction, clk) is + begin + end process; +end behavior_instr; \ No newline at end of file diff --git a/src/sim_instruction.vhd b/src/sim_instruction.vhd new file mode 100644 index 0000000..6a8c3eb --- /dev/null +++ b/src/sim_instruction.vhd @@ -0,0 +1,29 @@ +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: in 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); + + +end bench; From d823f37938586efbcfd24ae6db89a2eceb71252e Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Sun, 1 Oct 2023 23:17:50 +0200 Subject: [PATCH 7/9] Added basic behavior, Added Vivado Project file --- memory_file.xpr | 234 ++++++++++++++++++++++++++++++++++++++++ src/instruction.vhd | 34 ++++-- src/sim_instruction.vhd | 4 +- 3 files changed, 262 insertions(+), 10 deletions(-) create mode 100644 memory_file.xpr diff --git a/memory_file.xpr b/memory_file.xpr new file mode 100644 index 0000000..57f70ee --- /dev/null +++ b/memory_file.xpr @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Vivado Synthesis Defaults + + + + + + + + + + + + Default settings for Implementation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + default_dashboard + + + diff --git a/src/instruction.vhd b/src/instruction.vhd index 08ab29f..9caf15d 100644 --- a/src/instruction.vhd +++ b/src/instruction.vhd @@ -4,21 +4,37 @@ 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 -); + 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) := (others => '0'); + end loop; + return init_result; + end function init; end instruction; architecture behavior_instr of instruction is - -- Array of STD_LOGIC_VECTOR - type code_array is array(0 to 15) of - STD_LOGIC_VECTOR(7 downto 0); -- Memory variable - signal code_memory: code_array; + 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/src/sim_instruction.vhd b/src/sim_instruction.vhd index 6a8c3eb..db14e8d 100644 --- a/src/sim_instruction.vhd +++ b/src/sim_instruction.vhd @@ -11,7 +11,7 @@ architecture bench of test_instr is component instruction is port( instruction: in STD_LOGIC_VECTOR(7 downto 0); - code: in STD_LOGIC_VECTOR(31 downto 0); + code: out STD_LOGIC_VECTOR(31 downto 0); clk: in STD_LOGIC ); end component; @@ -24,6 +24,8 @@ architecture bench of test_instr is begin testeur: instruction PORT MAP(inAddress, outCode, inClock); + inClock <= not inClock after 1ns; + inAddress <= X"00", X"0a" after 10ns; end bench; From ef708bf2a4e570ba5dfdd93f9d06ff8c331e9896 Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Sun, 1 Oct 2023 23:35:17 +0200 Subject: [PATCH 8/9] Tweak to Instruction.vhd to show the index of the array when called. --- memory_file.xpr | 5 +++-- src/instruction.vhd | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/memory_file.xpr b/memory_file.xpr index 57f70ee..58bbd2f 100644 --- a/memory_file.xpr +++ b/memory_file.xpr @@ -62,7 +62,7 @@