Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------------------------
- -- Engineer: Pasquale Boemio
- --
- -- Create Date: 17:48:53 01/03/2012
- -- Module Name: SevenSegmentDisplay - Behavioral
- -- Project Name: ALUProject
- -- Target Devices: xc3s1200e-4fg320
- -- Description: Modulo utilizzato per rappresentare un numero sul display
- -- (viene effettuata anche la conversione bin to hex)
- --
- -- Revision 0.01 - File Created
- ----------------------------------------------------------------------------------
- library IEEE;
- use IEEE.STD_LOGIC_1164.ALL;
- -----------------------------------------------
- -- Vista esterna del blocco SevenSegmentDisplay
- -----------------------------------------------
- entity SevenSegmentDisplay is
- Port ( cifre : in STD_LOGIC_VECTOR (7 downto 0);
- clock : in STD_LOGIC;
- complement : in STD_LOGIC;
- anodi : inout STD_LOGIC_VECTOR (3 downto 0) := "1110";
- sevenSegments : out STD_LOGIC_VECTOR (6 downto 0));
- end SevenSegmentDisplay;
- -----------------------------------------------
- architecture Behavioral of SevenSegmentDisplay is
- ----------------------------------------
- -- Definizione di un blocco ClockSpeeder
- ----------------------------------------
- component clockGenerator
- Port ( slowerClock : in STD_LOGIC;
- fasterClock : out STD_LOGIC);
- end component clockGenerator;
- for innerClockGenerator : clockGenerator use entity ClockSpeeder(Behavioral);
- ----------------------------------------
- ---------------------------------------------
- -- Definizione di un segnale di clock interno
- ---------------------------------------------
- signal innerClock : STD_LOGIC;
- ---------------------------------------------
- -----------------------------------------
- -- Definizione delle codifiche dei numeri
- -----------------------------------------
- constant zero : STD_LOGIC_VECTOR(6 downto 0) := "1000000";
- constant uno : STD_LOGIC_VECTOR(6 downto 0) := "1111001";
- constant due : STD_LOGIC_VECTOR(6 downto 0) := "0100100";
- constant tre : STD_LOGIC_VECTOR(6 downto 0) := "0110000";
- constant quattro : STD_LOGIC_VECTOR(6 downto 0) := "0011001";
- constant cinque : STD_LOGIC_VECTOR(6 downto 0) := "0010010";
- constant sei : STD_LOGIC_VECTOR(6 downto 0) := "0000010";
- constant sette : STD_LOGIC_VECTOR(6 downto 0) := "1111000";
- constant otto : STD_LOGIC_VECTOR(6 downto 0) := "0000000";
- constant nove : STD_LOGIC_VECTOR(6 downto 0) := "0010000";
- constant a : STD_LOGIC_VECTOR(6 downto 0) := "0001000";
- constant b : STD_LOGIC_VECTOR(6 downto 0) := "0000011";
- constant c : STD_LOGIC_VECTOR(6 downto 0) := "1000110";
- constant d : STD_LOGIC_VECTOR(6 downto 0) := "0100001";
- constant e : STD_LOGIC_VECTOR(6 downto 0) := "0000110";
- constant f : STD_LOGIC_VECTOR(6 downto 0) := "0001110";
- constant minSimbol : STD_LOGIC_VECTOR(6 downto 0) := "0111111";
- signal firstHex : STD_LOGIC_VECTOR(6 downto 0) := zero;
- signal secondHex : STD_LOGIC_VECTOR(6 downto 0) := zero;
- signal sign : STD_LOGIC_VECTOR(6 downto 0) := "1111111";
- -----------------------------------------
- -------------------------------------------------------------------
- -- Segnali utilizzati per suddividere il numero nelle due cifre hex
- -------------------------------------------------------------------
- signal lessSignificative : STD_LOGIC_VECTOR(3 downto 0);
- signal moreSignificative : STD_LOGIC_VECTOR(3 downto 0);
- -------------------------------------------------------------------
- begin
- innerClockGenerator : clockGenerator port map(clock, innerClock); -- Cablaggio del generatore di clock
- --------------------------------------------------
- -- Processo che mostra le cifre su ciascun display
- --------------------------------------------------
- display_process : process(innerClock) begin
- if innerClock'event and innerClock = '1' then
- case anodi is
- when "1110" => sevenSegments <= firstHex; --firstHex;
- anodi <= "1101";
- when "1101" => sevenSegments <= secondHex;
- anodi <= "1011";
- when "1011" => sevenSegments <= "0001001";
- anodi <="0111";
- when "0111" => sevenSegments <= sign;
- anodi <= "1110";
- when others => null;
- end case;
- end if;
- end process display_process;
- --------------------------------------------------
- ---------------------------------------------------------
- -- Processo che codifica le cifre per essere visualizzate
- ---------------------------------------------------------
- numberDecoder_process: process(cifre)
- begin
- lessSignificative <= cifre(3 downto 0);
- moreSignificative <= cifre(7 downto 4);
- if complement = '0' then
- case lessSignificative is
- when "0000" => firstHex <= zero;
- when "0001" => firstHex <= uno;
- when "0010" => firstHex <= due;
- when "0011" => firstHex <= tre;
- when "0100" => firstHex <= quattro;
- when "0101" => firstHex <= cinque;
- when "0110" => firstHex <= sei;
- when "0111" => firstHex <= sette;
- when "1000" => firstHex <= otto;
- when "1001" => firstHex <= nove;
- when "1010" => firstHex <= a;
- when "1011" => firstHex <= b;
- when "1100" => firstHex <= c;
- when "1101" => firstHex <= d;
- when "1110" => firstHex <= e;
- when "1111" => firstHex <= f;
- when others => null;
- end case;
- case moreSignificative is
- when "0000" => secondHex <= zero;
- when "0001" => secondHex <= uno;
- when "0010" => secondHex <= due;
- when "0011" => secondHex <= tre;
- when "0100" => secondHex <= quattro;
- when "0101" => secondHex <= cinque;
- when "0110" => secondHex <= sei;
- when "0111" => secondHex <= sette;
- when "1000" => secondHex <= otto;
- when "1001" => secondHex <= nove;
- when "1010" => secondHex <= a;
- when "1011" => secondHex <= b;
- when "1100" => secondHex <= c;
- when "1101" => secondHex <= d;
- when "1110" => secondHex <= e;
- when "1111" => secondHex <= f;
- when others => null;
- end case;
- sign <= "1111111";
- else
- case lessSignificative is
- when "0000" => firstHex <= zero;
- when "0001" => firstHex <= f;
- when "0010" => firstHex <= e;
- when "0011" => firstHex <= d;
- when "0100" => firstHex <= c;
- when "0101" => firstHex <= b;
- when "0110" => firstHex <= a;
- when "0111" => firstHex <= nove;
- when "1000" => firstHex <= otto;
- when "1001" => firstHex <= sette;
- when "1010" => firstHex <= sei;
- when "1011" => firstHex <= cinque;
- when "1100" => firstHex <= quattro;
- when "1101" => firstHex <= tre;
- when "1110" => firstHex <= due;
- when "1111" => firstHex <= uno;
- when others => null;
- end case;
- case moreSignificative is
- when "0000" => secondHex <= zero;
- when "0001" => secondHex <= uno;
- when "0010" => secondHex <= due;
- when "0011" => secondHex <= tre;
- when "0100" => secondHex <= quattro;
- when "0101" => secondHex <= cinque;
- when "0110" => secondHex <= sei;
- when "0111" => secondHex <= sette;
- when "1000" => secondHex <= sette;
- when "1001" => secondHex <= sei;
- when "1010" => secondHex <= cinque;
- when "1011" => secondHex <= quattro;
- when "1100" => secondHex <= tre;
- when "1101" => secondHex <= due;
- when "1110" => secondHex <= uno;
- when "1111" => secondHex <= zero;
- when others => null;
- end case;
- if moreSignificative(3)='1' then
- sign <= minSimbol;
- else
- sign <= "0000000";
- end if;
- end if;
- end process numberDecoder_process;
- ---------------------------------------------------------
- end Behavioral;
Add Comment
Please, Sign In to add comment