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.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 Natural range 0 to Nb_bits/4 - 1;
  45. signal compteur : compteur_T := 0;
  46. signal work_in_progess : BOOLEAN := false;
  47. signal x_to_send : BOOLEAN := false;
  48. signal first_detected : BOOLEAN := false;
  49. begin
  50. current_hexa <= intern_value(Nb_Bits - 1 - compteur * 4 downto Nb_Bits - compteur * 4 - 4);
  51. process
  52. begin
  53. wait until CLK'event and CLK = '1';
  54. if ValueAv = '1' then
  55. if IsInt = '0' then
  56. OutData <= Value (6 downto 0);
  57. else
  58. intern_value <= Value;
  59. OutData <= "0110000";
  60. x_to_send <= true;
  61. end if;
  62. OutDataAv <= '1';
  63. elsif x_to_send then
  64. OutData <= "1111000";
  65. x_to_send <= false;
  66. work_in_progess <= true;
  67. elsif work_in_progess then
  68. if (current_hexa >= "0000" and current_hexa <= "1001") then
  69. if (not(current_hexa = "0000") or first_detected or compteur = Nb_bits/4 - 1 ) then
  70. OutData <= "011" & current_hexa;
  71. OutDataAv <= '1';
  72. first_detected <= true;
  73. else
  74. OutDataAv <= '0';
  75. end if;
  76. else
  77. OutData <= ("000" & current_hexa) + "0110111";
  78. OutDataAv <= '1';
  79. first_detected <= true;
  80. end if;
  81. if (compteur = Nb_bits/4 - 1) then
  82. compteur <= 0;
  83. work_in_progess <= false;
  84. x_to_send <= false;
  85. first_detected <= false;
  86. else
  87. compteur <= compteur + 1;
  88. end if;
  89. else
  90. OutDataAv <= '0';
  91. end if;
  92. end process;
  93. end Behavioral;