--- Du code de debutante, pour les debutant(e)s. --- --- Je ne garantis ni un parfait respect des --- normes, ni une parfaite elegance, et encore --- moins le plein fonctionnement en toutes --- situations, critiques ou pas, d'ailleurs. --- --- (C) 2010 Laura Becognee, paru dans GNU/Linux magazine France. library IEEE; use ieee.std_logic_1164.all; entity conv_BCD_7seg is port ( -- signaux externes conv_in : in std_logic_vector (3 downto 0); SEG : out std_ulogic_vector (6 downto 0); OE : in std_logic ); end conv_BCD_7seg; architecture plup of conv_BCD_7seg is -- declaration des signaux (fils) internes signal NOR_out : std_logic_vector (3 downto 0); signal NAND_out : std_logic_vector (7 downto 0); signal OE_out : std_logic; begin -- cablage des portes nor : NOR_out(0) <= not (conv_in(2) and conv_in(1) ); NOR_out(1) <= conv_in(1) or not conv_in(2); NOR_out(2) <= not (nor_out(3) and conv_in(3)); NOR_out(3) <= conv_in(2) or conv_in(1); -- cablage de la porte nor de OE : OE_out <= not (not NOR_out(2) or OE ); -- cablage des premieres portes nand : NAND_out(0) <= not conv_in(3) and not NOR_out(3) and conv_in(0); NAND_out(1) <= not (NOR_out(1) or conv_in(0)); NAND_out(2) <= not NOR_out(1) and conv_in(0); NAND_out(3) <= not conv_in(0) and not conv_in(2) and conv_in(1); NAND_out(4) <= not (conv_in(0) or NOR_out(0) ); NAND_out(5) <= not NOR_out(0) and conv_in(0); NAND_out(6) <= conv_in(0) and conv_in(1); NAND_out(7) <= not (conv_in(3) or NOR_out(3) ); -- cablage des secondes portes nand : SEG(0) <= not (OE_out or NAND_out(0) or NAND_out(1) ); SEG(1) <= not (OE_out or NAND_out(2) or NAND_out(4) ); SEG(2) <= not (OE_out or NAND_out(3) ); SEG(3) <= not (OE_out or NAND_out(0) or NAND_out(1) or NAND_out(5) ); SEG(4) <= not (OE_out or NAND_out(1) or conv_in(0) ); SEG(5) <= not (OE_out or NAND_out(0) or NAND_out(3) or NAND_out(6) ); SEG(6) <= not (OE_out or NAND_out(5) or NAND_out(7) ); end plup; architecture plop of conv_BCD_7seg is begin process (conv_in, OE) begin if OE = '1' then case conv_in is when "0000" => SEG <= "0111111"; when "0001" => SEG <= "0000110"; when "0010" => SEG <= "1011011"; when "0011" => SEG <= "0001111"; when "0100" => SEG <= "1100110"; when "0101" => SEG <= "1101101"; when "0110" => SEG <= "1111101"; when "0111" => SEG <= "0000111"; when "1000" => SEG <= "1111111"; when "1001" => SEG <= "1101111"; when others => SEG <= "0000000"; end case; else SEG <= "0000000"; end if; end process; end plop;