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 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. OutDataAv <= '1';
  66. x_to_send <= false;
  67. work_in_progess <= true;
  68. first_detected <= false;
  69. elsif work_in_progess then
  70. case current_hexa is
  71. when "0000" =>
  72. if first_detected or compteur = Nb_bits/4 - 1 then
  73. OutData <= "0110000";
  74. end if;
  75. when "0001" =>
  76. OutData <= "0110001";
  77. when "0010" =>
  78. OutData <= "0110010";
  79. when "0011" =>
  80. OutData <= "0110011";
  81. when "0100" =>
  82. OutData <= "0110100";
  83. when "0101" =>
  84. OutData <= "0110101";
  85. when "0110" =>
  86. OutData <= "0110110";
  87. when "0111" =>
  88. OutData <= "0110111";
  89. when "1000" =>
  90. OutData <= "0111000";
  91. when "1001" =>
  92. OutData <= "0111001";
  93. when "1010" =>
  94. OutData <= "1000001";
  95. when "1011" =>
  96. OutData <= "1000010";
  97. when "1100" =>
  98. OutData <= "1000011";
  99. when "1101" =>
  100. OutData <= "1000100";
  101. when "1110" =>
  102. OutData <= "1000101";
  103. when "1111" =>
  104. OutData <= "1000110";
  105. when others =>
  106. OutData <= "0000001";
  107. end case;
  108. if first_detected or not (current_hexa = "0000") or compteur = Nb_bits/4 - 1 then
  109. OutDataAv <= '1';
  110. first_detected <= true;
  111. else
  112. OutDataAv <= '0';
  113. first_detected <= false;
  114. end if;
  115. if (compteur = Nb_bits/4 - 1) then
  116. compteur <= 0;
  117. work_in_progess <= false;
  118. x_to_send <= false;
  119. first_detected <= false;
  120. else
  121. compteur <= compteur + 1;
  122. end if;
  123. else
  124. OutDataAv <= '0';
  125. end if;
  126. end process;
  127. end Behavioral;