From fdf128601899dd9bae8a198deb74403681be82ee Mon Sep 17 00:00:00 2001 From: Benjamin Chausse Date: Sat, 3 May 2025 11:09:17 -0400 Subject: hihihaha --- .../sources_1/imports/src/AppCombi_top.vhd | 161 +++++++++++---------- pb_APP_log_comb.srcs/sources_1/new/Add1BitB.vhd | 65 +++++++-- pb_APP_log_comb.srcs/sources_1/new/Add4Bits.vhd | 89 +++++++++--- pb_APP_log_comb.srcs/sources_1/new/full_adder.vhd | 2 +- pb_APP_log_comb.xpr | 2 +- 5 files changed, 212 insertions(+), 107 deletions(-) diff --git a/pb_APP_log_comb.srcs/sources_1/imports/src/AppCombi_top.vhd b/pb_APP_log_comb.srcs/sources_1/imports/src/AppCombi_top.vhd index 0f939d4..79209c9 100644 --- a/pb_APP_log_comb.srcs/sources_1/imports/src/AppCombi_top.vhd +++ b/pb_APP_log_comb.srcs/sources_1/imports/src/AppCombi_top.vhd @@ -1,13 +1,13 @@ --------------------------------------------------------------------------------------------- -- Université de Sherbrooke - Département de GEGI --- Version : 3.0 --- Nomenclature : GRAMS --- Date : 21 Avril 2020 --- Auteur(s) : Réjean Fontaine, Daniel Dalle, Marc-André Tétrault --- Technologies : FPGA Zynq (carte ZYBO Z7-10 ZYBO Z7-20) --- peripheriques: Pmod8LD PmodSSD +-- Version : 3.0 +-- Nomenclature : GRAMS +-- Date : 21 Avril 2020 +-- Auteur(s) : Réjean Fontaine, Daniel Dalle, Marc-André Tétrault +-- Technologies : FPGA Zynq (carte ZYBO Z7-10 ZYBO Z7-20) +-- peripheriques: Pmod8LD PmodSSD -- --- Outils : vivado 2019.1 64 bits +-- Outils : vivado 2019.1 64 bits --------------------------------------------------------------------------------------------- -- Description: -- Circuit utilitaire pour le laboratoire et la problématique de logique combinatoire @@ -15,7 +15,7 @@ --------------------------------------------------------------------------------------------- -- À faire : -- Voir le guide de l'APP --- Insérer les modules additionneurs ("components" et "instances") +-- Insérer les modules additionneurs ("components" et "instances") -- --------------------------------------------------------------------------------------------- @@ -26,86 +26,95 @@ library UNISIM; use UNISIM.Vcomponents.ALL; entity AppCombi_top is - port ( - i_btn : in std_logic_vector (3 downto 0); -- Boutons de la carte Zybo - i_sw : in std_logic_vector (3 downto 0); -- Interrupteurs de la carte Zybo - sysclk : in std_logic; -- horloge systeme - o_SSD : out std_logic_vector (7 downto 0); -- vers cnnecteur pmod afficheur 7 segments - o_led : out std_logic_vector (3 downto 0); -- vers DELs de la carte Zybo - o_led6_r : out std_logic; -- vers DEL rouge de la carte Zybo - o_pmodled : out std_logic_vector (7 downto 0) -- vers connecteur pmod 8 DELs - ); + port ( + i_btn : in std_logic_vector (3 downto 0); -- Boutons de la carte Zybo + i_sw : in std_logic_vector (3 downto 0); -- Interrupteurs de la carte Zybo + sysclk : in std_logic; -- horloge systeme + o_SSD : out std_logic_vector (7 downto 0); -- vers cnnecteur pmod afficheur 7 segments + o_led : out std_logic_vector (3 downto 0); -- vers DELs de la carte Zybo + o_led6_r : out std_logic; -- vers DEL rouge de la carte Zybo + o_pmodled : out std_logic_vector (7 downto 0) -- vers connecteur pmod 8 DELs + ); end AppCombi_top; - + architecture BEHAVIORAL of AppCombi_top is - constant nbreboutons : integer := 4; -- Carte Zybo Z7 - constant freq_sys_MHz : integer := 125; -- 125 MHz - - signal d_s_1Hz : std_logic; - signal clk_5MHz : std_logic; + constant nbreboutons : integer := 4; -- Carte Zybo Z7 + constant freq_sys_MHz : integer := 125; -- 125 MHz + + signal d_s_1Hz : std_logic; + signal clk_5MHz : std_logic; -- - signal d_opa : std_logic_vector (3 downto 0):= "0000"; -- operande A - signal d_opb : std_logic_vector (3 downto 0):= "0000"; -- operande B - signal d_cin : std_logic := '0'; -- retenue entree - signal d_sum : std_logic_vector (3 downto 0):= "0000"; -- somme - signal d_cout : std_logic := '0'; -- retenue sortie + signal d_opa : std_logic_vector (3 downto 0):= "0000"; -- operande A + signal d_opb : std_logic_vector (3 downto 0):= "0000"; -- operande B + signal d_cin : std_logic := '0'; -- retenue entree + signal d_sum : std_logic_vector (3 downto 0):= "0000"; -- somme + signal d_cout : std_logic := '0'; -- retenue sortie -- - signal d_AFF0 : std_logic_vector (3 downto 0):= "0000"; - signal d_AFF1 : std_logic_vector (3 downto 0):= "0000"; - - + signal d_AFF0 : std_logic_vector (3 downto 0):= "0000"; + signal d_AFF1 : std_logic_vector (3 downto 0):= "0000"; + + + component Add4Bits is Port ( + A : in STD_LOGIC_VECTOR (0 to 3); + B : in STD_LOGIC_VECTOR (0 to 3); + C : in STD_LOGIC; + R : out STD_LOGIC_VECTOR (0 to 3); + Rc : out STD_LOGIC + ); + end component; + component synchro_module_v2 is generic (const_CLK_syst_MHz: integer := freq_sys_MHz); - Port ( - clkm : in STD_LOGIC; -- Entrée horloge maitre - o_CLK_5MHz : out STD_LOGIC; -- horloge divise utilise pour le circuit - o_S_1Hz : out STD_LOGIC -- Signal temoin 1 Hz - ); - end component; + Port ( + clkm : in STD_LOGIC; -- Entrée horloge maitre + o_CLK_5MHz : out STD_LOGIC; -- horloge divise utilise pour le circuit + o_S_1Hz : out STD_LOGIC -- Signal temoin 1 Hz + ); + end component; component septSegments_Top is - Port ( clk : in STD_LOGIC; -- horloge systeme, typique 100 MHz (preciser par le constante) - i_AFF0 : in STD_LOGIC_VECTOR (3 downto 0); -- donnee a afficher sur 8 bits : chiffre hexa position 1 et 0 - i_AFF1 : in STD_LOGIC_VECTOR (3 downto 0); -- donnee a afficher sur 8 bits : chiffre hexa position 1 et 0 - o_AFFSSD_Sim : out string(1 to 2); - o_AFFSSD : out STD_LOGIC_VECTOR (7 downto 0) - ); + Port ( clk : in STD_LOGIC; -- horloge systeme, typique 100 MHz (preciser par le constante) + i_AFF0 : in STD_LOGIC_VECTOR (3 downto 0); -- donnee a afficher sur 8 bits : chiffre hexa position 1 et 0 + i_AFF1 : in STD_LOGIC_VECTOR (3 downto 0); -- donnee a afficher sur 8 bits : chiffre hexa position 1 et 0 + o_AFFSSD_Sim : out string(1 to 2); + o_AFFSSD : out STD_LOGIC_VECTOR (7 downto 0) + ); end component; - + begin - - inst_synch : synchro_module_v2 - generic map (const_CLK_syst_MHz => freq_sys_MHz) - port map ( - clkm => sysclk, - o_CLK_5MHz => clk_5MHz, - o_S_1Hz => d_S_1Hz - ); - - inst_aff : septSegments_Top - port map ( - clk => clk_5MHz, - -- donnee a afficher definies sur 8 bits : chiffre hexa position 1 et 0 - i_AFF1 => d_AFF1, - i_AFF0 => d_AFF0, - o_AFFSSD_Sim => open, -- ne pas modifier le "open". Ligne pour simulations seulement. - o_AFFSSD => o_SSD -- sorties directement adaptees au connecteur PmodSSD - ); - - - d_opa <= i_sw; -- operande A sur interrupteurs - d_opb <= i_btn; -- operande B sur boutons - d_cin <= '0'; -- la retenue d'entrée alterne 0 1 a 1 Hz - - d_AFF0 <= d_sum(3 downto 0); -- Le resultat de votre additionneur affiché sur PmodSSD(0) - d_AFF1 <= '0' & '0' & '0' & d_Cout; -- La retenue de sortie affichée sur PmodSSD(1) (0 ou 1) - o_led6_r <= d_Cout; -- La led couleur représente aussi la retenue en sortie Cout - o_pmodled <= d_opa & d_opb; -- Les opérandes d'entrés reproduits combinés sur Pmod8LD - o_led (3 downto 0) <= '0' & '0' & '0' & d_S_1Hz; -- La LED0 sur la carte représente la retenue d'entrée - - + + inst_synch : synchro_module_v2 + generic map (const_CLK_syst_MHz => freq_sys_MHz) + port map ( + clkm => sysclk, + o_CLK_5MHz => clk_5MHz, + o_S_1Hz => d_S_1Hz + ); + + inst_aff : septSegments_Top + port map ( + clk => clk_5MHz, + -- donnee a afficher definies sur 8 bits : chiffre hexa position 1 et 0 + i_AFF1 => d_AFF1, + i_AFF0 => d_AFF0, + o_AFFSSD_Sim => open, -- ne pas modifier le "open". Ligne pour simulations seulement. + o_AFFSSD => o_SSD -- sorties directement adaptees au connecteur PmodSSD + ); + + + d_opa <= i_sw; -- operande A sur interrupteurs + d_opb <= i_btn; -- operande B sur boutons + d_cin <= '0'; -- la retenue d'entrée alterne 0 1 a 1 Hz + + d_AFF0 <= d_sum(3 downto 0); -- Le resultat de votre additionneur affiché sur PmodSSD(0) + d_AFF1 <= '0' & '0' & '0' & d_Cout; -- La retenue de sortie affichée sur PmodSSD(1) (0 ou 1) + o_led6_r <= d_Cout; -- La led couleur représente aussi la retenue en sortie Cout + o_pmodled <= d_opa & d_opb; -- Les opérandes d'entrés reproduits combinés sur Pmod8LD + o_led (3 downto 0) <= '0' & '0' & '0' & d_S_1Hz; -- La LED0 sur la carte représente la retenue d'entrée + + end BEHAVIORAL; diff --git a/pb_APP_log_comb.srcs/sources_1/new/Add1BitB.vhd b/pb_APP_log_comb.srcs/sources_1/new/Add1BitB.vhd index b00716e..5f99927 100644 --- a/pb_APP_log_comb.srcs/sources_1/new/Add1BitB.vhd +++ b/pb_APP_log_comb.srcs/sources_1/new/Add1BitB.vhd @@ -1,21 +1,21 @@ ---------------------------------------------------------------------------------- --- Company: --- Engineer: --- +-- Company: +-- Engineer: +-- -- Create Date: 04/30/2025 03:19:19 PM --- Design Name: +-- Design Name: -- Module Name: Add1BitB - Behavioral --- Project Name: --- Target Devices: --- Tool Versions: --- Description: --- --- Dependencies: --- +-- Project Name: +-- Target Devices: +-- Tool Versions: +-- Description: +-- +-- Dependencies: +-- -- Revision: -- Revision 0.01 - File Created -- Additional Comments: --- +-- ---------------------------------------------------------------------------------- @@ -41,7 +41,48 @@ end Add1BitB; architecture Behavioral of Add1BitB is + signal buf: STD_LOGIC_VECTOR(2 downto 0); + +begin + +Adder: process(X, Y, Ci) is begin + buf(0) <= X; + buf(1) <= Y; + buf(2) <= Ci; + + case (buf) is + when "000" => + O <= '0'; + Co <= '0'; + when "001" => + O <= '1'; + Co <= '0'; + when "010" => + O <= '1'; + Co <= '0'; + when "011" => + O <= '0'; + Co <= '1'; + when "100" => + O <= '1'; + Co <= '0'; + when "101" => + O <= '0'; + Co <= '1'; + when "110" => + O <= '0'; + Co <= '1'; + when "111" => + O <= '1'; + Co <= '1'; + when others => + O <= '0'; + Co <= '0'; + end case; + +end process Adder; + end Behavioral; diff --git a/pb_APP_log_comb.srcs/sources_1/new/Add4Bits.vhd b/pb_APP_log_comb.srcs/sources_1/new/Add4Bits.vhd index be2cf13..371d81b 100644 --- a/pb_APP_log_comb.srcs/sources_1/new/Add4Bits.vhd +++ b/pb_APP_log_comb.srcs/sources_1/new/Add4Bits.vhd @@ -1,21 +1,21 @@ ---------------------------------------------------------------------------------- --- Company: --- Engineer: --- +-- Company: +-- Engineer: +-- -- Create Date: 04/30/2025 03:19:19 PM --- Design Name: +-- Design Name: -- Module Name: Add4Bits - Behavioral --- Project Name: --- Target Devices: --- Tool Versions: --- Description: --- --- Dependencies: --- +-- Project Name: +-- Target Devices: +-- Tool Versions: +-- Description: +-- +-- Dependencies: +-- -- Revision: -- Revision 0.01 - File Created -- Additional Comments: --- +-- ---------------------------------------------------------------------------------- @@ -32,16 +32,71 @@ use IEEE.STD_LOGIC_1164.ALL; --use UNISIM.VComponents.all; entity Add4Bits is - Port ( X : in STD_LOGIC_VECTOR (0 to 3); - Y : in STD_LOGIC_VECTOR (0 to 3); - Ci : in STD_LOGIC; - O : out STD_LOGIC_VECTOR (0 to 3); - Co : out STD_LOGIC); + Port ( A : in STD_LOGIC_VECTOR (0 to 3); + B : in STD_LOGIC_VECTOR (0 to 3); + C : in STD_LOGIC; + R : out STD_LOGIC_VECTOR (0 to 3); + Rc : out STD_LOGIC); end Add4Bits; architecture Behavioral of Add4Bits is + signal bufA : STD_LOGIC; + signal bufB : STD_LOGIC; + signal bufC : STD_LOGIC; + + component Add1BitA is + Port ( + X : in STD_LOGIC; + Y : in STD_LOGIC; + Ci: in STD_LOGIC; + O : out STD_LOGIC; + Co: out STD_LOGIC + ); + end component; + + component Add1BitB is + Port ( + X : in STD_LOGIC; + Y : in STD_LOGIC; + Ci: in STD_LOGIC; + O : out STD_LOGIC; + Co: out STD_LOGIC + ); + end component; + begin + first : Add1BitA port map ( + X => A(0), + Y => B(0), + Ci => C, + O => R(0), + Co => bufA + ); + + sec : Add1BitA port map ( + X => A(1), + Y => B(1), + Ci => bufA, + O => R(1), + Co => bufB + ); + + third : Add1BitB port map ( + X => A(2), + Y => B(2), + Ci => bufB, + O => R(2), + Co => bufC + ); + + fourth : Add1BitB port map ( + X => A(3), + Y => B(3), + Ci => bufC, + O => R(3), + Co => Rc + ); end Behavioral; diff --git a/pb_APP_log_comb.srcs/sources_1/new/full_adder.vhd b/pb_APP_log_comb.srcs/sources_1/new/full_adder.vhd index 7f5148d..1ffef11 100644 --- a/pb_APP_log_comb.srcs/sources_1/new/full_adder.vhd +++ b/pb_APP_log_comb.srcs/sources_1/new/full_adder.vhd @@ -1,6 +1,6 @@ ---------------------------------------------------------------------------------- -- Company: --- Engineer: +-- Engineer: BenTheMan -- -- Create Date: 04/30/2025 01:11:03 PM -- Design Name: diff --git a/pb_APP_log_comb.xpr b/pb_APP_log_comb.xpr index fe9d7e0..bbc1529 100644 --- a/pb_APP_log_comb.xpr +++ b/pb_APP_log_comb.xpr @@ -145,7 +145,7 @@ -- cgit v1.2.3