Projekt z kursu Układy cyfrowe i systemy wbudowane 2 na PWr
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 21:30:49 01/03/2018
  6. -- Design Name:
  7. -- Module Name: Display4x7S - 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. -- Uncomment the following library declaration if using
  23. -- arithmetic functions with Signed or Unsigned values
  24. --use IEEE.NUMERIC_STD.ALL;
  25. -- Uncomment the following library declaration if instantiating
  26. -- any Xilinx primitives in this code.
  27. --library UNISIM;
  28. --use UNISIM.VComponents.all;
  29. entity Display4x7S is
  30. Port ( DI : in STD_LOGIC_VECTOR (15 downto 0);
  31. DP : in STD_LOGIC_VECTOR (3 downto 0);
  32. Blank : in STD_LOGIC_VECTOR (3 downto 0);
  33. Clk : in STD_LOGIC;
  34. DS_EN : out STD_LOGIC_VECTOR (3 downto 0);
  35. DS : out STD_LOGIC_VECTOR (7 downto 0));
  36. end Display4x7S;
  37. architecture Behavioral of Display4x7S is
  38. type state_type is (A, B, C, D);
  39. signal state, next_state : state_type;
  40. signal cycles : integer range 0 to 10000 := 0;
  41. signal Bits : STD_LOGIC_VECTOR (3 downto 0);
  42. signal Digit : STD_LOGIC_VECTOR (6 downto 0);
  43. signal Point : STD_LOGIC;
  44. begin
  45. process1 : process(Clk)
  46. begin
  47. if rising_edge(Clk) then
  48. -- Clock frequency divider
  49. -- 48 MHz -> 4800 Hz
  50. -- (1200 Hz digit refresh rate)
  51. if cycles = 10000 then
  52. state <= next_state;
  53. cycles <= 0;
  54. else
  55. cycles <= cycles + 1;
  56. end if;
  57. end if;
  58. end process process1;
  59. process2 : process(state)
  60. begin
  61. next_state <= state; -- by default
  62. case state is
  63. when A =>
  64. next_state <= B;
  65. when B =>
  66. next_state <= C;
  67. when C =>
  68. next_state <= D;
  69. when D =>
  70. next_state <= A;
  71. end case;
  72. end process process2;
  73. Bits <= DI(3 downto 0) when state = A else
  74. DI(7 downto 4) when state = B else
  75. DI(11 downto 8) when state = C else
  76. DI(15 downto 12) when state = D else
  77. "0000";
  78. Point <= DP(0) when state = A else
  79. DP(1) when state = B else
  80. DP(2) when state = C else
  81. DP(3) when state = D else
  82. '0';
  83. with Bits select
  84. Digit <= "0111111" when "0000",
  85. "0000110" when "0001",
  86. "1011011" when "0010",
  87. "1001111" when "0011",
  88. "1100110" when "0100",
  89. "1101101" when "0101",
  90. "1111101" when "0110",
  91. "0000111" when "0111",
  92. "1111111" when "1000",
  93. "1101111" when "1001",
  94. "1011111" when "1010",
  95. "1111100" when "1011",
  96. "0111001" when "1100",
  97. "1011110" when "1101",
  98. "1111001" when "1110",
  99. "1110001" when "1111",
  100. "0000000" when others;
  101. DS_EN <= "1110" when state = A and Blank(0) = '0' else
  102. "1101" when state = B and Blank(1) = '0' else
  103. "1011" when state = C and Blank(2) = '0' else
  104. "0111" when state = D and Blank(3) = '0' else
  105. "1111";
  106. DS <= Point & Digit;
  107. end Behavioral;