No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ScreenDriver.vhd 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 09.07.2021 09:54:12
  6. -- Design Name:
  7. -- Module Name: ScreenDriver - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool Versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.STD_LOGIC_UNSIGNED.ALL;
  23. use IEEE.NUMERIC_STD.ALL;
  24. -- Uncomment the following library declaration if using
  25. -- arithmetic functions with Signed or Unsigned values
  26. --use IEEE.NUMERIC_STD.ALL;
  27. -- Uncomment the following library declaration if instantiating
  28. -- any Xilinx leaf cells in this code.
  29. --library UNISIM;
  30. --use UNISIM.VComponents.all;
  31. entity ScreenDriver is
  32. Generic ( Nb_bits : Natural
  33. );
  34. Port ( CLK : in STD_LOGIC;
  35. Value : in STD_LOGIC_VECTOR (Nb_Bits - 1 downto 0);
  36. ValueAv : in STD_LOGIC;
  37. IsInt : in STD_LOGIC;
  38. OutData : out STD_LOGIC_VECTOR (0 to 6);
  39. OutDataAv : out STD_LOGIC);
  40. end ScreenDriver;
  41. architecture Behavioral of ScreenDriver is
  42. signal intern_value : STD_LOGIC_VECTOR (Nb_Bits - 1 downto 0) := (others => '0');
  43. signal current_hexa : STD_LOGIC_VECTOR (3 downto 0) := (others => '0');
  44. subtype compteur_T is Integer range -2 to Nb_bits/4 - 1;
  45. signal compteur : compteur_T := -2;
  46. signal first_detected : BOOLEAN := false;
  47. constant Code_ASCII_Zero : STD_LOGIC_VECTOR (0 to 6) := "0110000";
  48. begin
  49. current_hexa <= intern_value(Nb_Bits - 1 - compteur * 4 downto Nb_Bits - compteur * 4 - 4) when compteur >= 0 and compteur < Nb_Bits else "0000";
  50. process
  51. begin
  52. wait until CLK'event and CLK = '1';
  53. if ValueAv = '1' then
  54. if IsInt = '0' then
  55. OutData <= Value (6 downto 0);
  56. else
  57. intern_value <= Value;
  58. OutData <= Code_ASCII_Zero;
  59. compteur <= compteur + 1;
  60. end if;
  61. OutDataAv <= '1';
  62. elsif compteur = -1 then
  63. OutData <= "1111000";
  64. compteur <= compteur + 1;
  65. elsif compteur >= 0 then
  66. if (current_hexa >= "0000" and current_hexa <= "1001") then
  67. if (not(current_hexa = "0000") or first_detected or compteur = Nb_bits/4 - 1 ) then
  68. OutData <= "011" & current_hexa;
  69. OutDataAv <= '1';
  70. first_detected <= true;
  71. else
  72. OutDataAv <= '0';
  73. end if;
  74. else
  75. OutData <= ("000" & current_hexa) + "0110111";
  76. OutDataAv <= '1';
  77. first_detected <= true;
  78. end if;
  79. if (compteur = Nb_bits/4 - 1) then
  80. compteur <= -2;
  81. first_detected <= false;
  82. else
  83. compteur <= compteur + 1;
  84. end if;
  85. else
  86. OutDataAv <= '0';
  87. end if;
  88. end process;
  89. end Behavioral;