104 lines
3.1 KiB
VHDL
104 lines
3.1 KiB
VHDL
----------------------------------------------------------------------------------
|
|
-- Company:
|
|
-- Engineer:
|
|
--
|
|
-- Create Date: 09.07.2021 09:54:12
|
|
-- Design Name:
|
|
-- Module Name: ScreenDriver - Behavioral
|
|
-- Project Name:
|
|
-- Target Devices:
|
|
-- Tool Versions:
|
|
-- Description:
|
|
--
|
|
-- Dependencies:
|
|
--
|
|
-- Revision:
|
|
-- Revision 0.01 - File Created
|
|
-- Additional Comments:
|
|
--
|
|
----------------------------------------------------------------------------------
|
|
|
|
|
|
library IEEE;
|
|
use IEEE.STD_LOGIC_1164.ALL;
|
|
use IEEE.STD_LOGIC_UNSIGNED.ALL;
|
|
use IEEE.NUMERIC_STD.ALL;
|
|
|
|
-- Uncomment the following library declaration if using
|
|
-- arithmetic functions with Signed or Unsigned values
|
|
--use IEEE.NUMERIC_STD.ALL;
|
|
|
|
-- Uncomment the following library declaration if instantiating
|
|
-- any Xilinx leaf cells in this code.
|
|
--library UNISIM;
|
|
--use UNISIM.VComponents.all;
|
|
|
|
entity ScreenDriver is
|
|
Generic ( Nb_bits : Natural
|
|
);
|
|
Port ( CLK : in STD_LOGIC;
|
|
Value : in STD_LOGIC_VECTOR (Nb_Bits - 1 downto 0);
|
|
ValueAv : in STD_LOGIC;
|
|
IsInt : in STD_LOGIC;
|
|
OutData : out STD_LOGIC_VECTOR (0 to 6);
|
|
OutDataAv : out STD_LOGIC);
|
|
end ScreenDriver;
|
|
|
|
architecture Behavioral of ScreenDriver is
|
|
|
|
signal intern_value : STD_LOGIC_VECTOR (Nb_Bits - 1 downto 0) := (others => '0');
|
|
signal current_hexa : STD_LOGIC_VECTOR (3 downto 0) := (others => '0');
|
|
subtype compteur_T is Integer range -2 to Nb_bits/4 - 1;
|
|
signal compteur : compteur_T := -2;
|
|
signal first_detected : BOOLEAN := false;
|
|
|
|
|
|
constant Code_ASCII_Zero : STD_LOGIC_VECTOR (0 to 6) := "0110000";
|
|
|
|
|
|
begin
|
|
|
|
current_hexa <= intern_value(Nb_Bits - 1 - compteur * 4 downto Nb_Bits - compteur * 4 - 4) when compteur >= 0 and compteur < Nb_Bits else "0000";
|
|
|
|
process
|
|
begin
|
|
wait until CLK'event and CLK = '1';
|
|
if ValueAv = '1' then
|
|
if IsInt = '0' then
|
|
OutData <= Value (6 downto 0);
|
|
else
|
|
intern_value <= Value;
|
|
OutData <= Code_ASCII_Zero;
|
|
compteur <= compteur + 1;
|
|
end if;
|
|
OutDataAv <= '1';
|
|
elsif compteur = -1 then
|
|
OutData <= "1111000";
|
|
compteur <= compteur + 1;
|
|
elsif compteur >= 0 then
|
|
if (current_hexa >= "0000" and current_hexa <= "1001") then
|
|
if (not(current_hexa = "0000") or first_detected or compteur = Nb_bits/4 - 1 ) then
|
|
OutData <= "011" & current_hexa;
|
|
OutDataAv <= '1';
|
|
first_detected <= true;
|
|
else
|
|
OutDataAv <= '0';
|
|
end if;
|
|
else
|
|
OutData <= ("000" & current_hexa) + "0110111";
|
|
OutDataAv <= '1';
|
|
first_detected <= true;
|
|
end if;
|
|
|
|
if (compteur = Nb_bits/4 - 1) then
|
|
compteur <= -2;
|
|
first_detected <= false;
|
|
else
|
|
compteur <= compteur + 1;
|
|
end if;
|
|
else
|
|
OutDataAv <= '0';
|
|
end if;
|
|
end process;
|
|
|
|
end Behavioral;
|