OpenCores
URL https://opencores.org/ocsvn/fat_32_file_parser/fat_32_file_parser/trunk

Subversion Repositories fat_32_file_parser

[/] [fat_32_file_parser/] [trunk/] [sseg.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 craighaywo
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.STD_LOGIC_ARITH.ALL;
4
use IEEE.STD_LOGIC_UNSIGNED.ALL;
5
 
6
entity sseg is
7
 Port (
8
                        CLK     : in STD_LOGIC;
9
 
10
                        VAL_IN          : in STD_LOGIC_VECTOR (15 downto 0);
11
 
12
                        SSEG_OUT        : out STD_LOGIC_VECTOR(7 downto 0);
13
                        AN_OUT   : out STD_LOGIC_VECTOR(3 downto 0));
14
 
15
end sseg;
16
 
17
architecture Behavioral of sseg is
18
 
19
constant C_clk_div_400hz : std_logic_vector(19 downto 0) := X"1E847";
20
 
21
signal clk_div_counter          : std_logic_vector(19 downto 0) := (others => '0');
22
signal clk_400hz                                : std_logic := '0';
23
signal digit_pattern_array : std_logic_vector(7 downto 0) := "00000000";
24
signal current_segment          : std_logic_vector(1 downto 0) := "00";
25
signal cathode_select           : std_logic_vector(3 downto 0) := "0000";
26
signal current_digit                    : std_logic_vector(3 downto 0) := "0000";
27
 
28
begin
29
 
30
        SSEG_OUT <= digit_pattern_array;
31
        AN_OUT <= cathode_select;
32
 
33
  -- Slows up CLK from 50MHz to MUX_CLK 400Hz.
34
        process(CLK)
35
        begin
36
                if rising_edge(CLK) then
37
                        if clk_div_counter = C_clk_div_400hz then
38
                                clk_div_counter <= (others => '0');
39
                                clk_400hz <= '1';
40
                        else
41
                                clk_div_counter <= clk_div_counter + 1;
42
                                clk_400hz <= '0';
43
                        end if;
44
                end if;
45
        end process;
46
 
47
        process(CLK)
48
        begin
49
                if rising_edge(CLK) then
50
                        case current_digit is
51
                                when "0000" => digit_pattern_array <= "00000011";
52
                                when "0001" => digit_pattern_array <= "10011111";
53
                                when "0010" => digit_pattern_array <= "00100101";
54
                                when "0011" => digit_pattern_array <= "00001101";
55
                                when "0100" => digit_pattern_array <= "10011001";
56
                                when "0101" => digit_pattern_array <= "01001001";
57
                                when "0110" => digit_pattern_array <= "01000001";
58
                                when "0111" => digit_pattern_array <= "00011111";
59
                                when "1000" => digit_pattern_array <= "00000001";
60
                                when "1001" => digit_pattern_array <= "00011001";
61
                                when "1010" => digit_pattern_array <= "00010001";
62
                                when "1011" => digit_pattern_array <= "11000001";
63
                                when "1100" => digit_pattern_array <= "01100011";
64
                                when "1101" => digit_pattern_array <= "10000101";
65
                                when "1110" => digit_pattern_array <= "01100001";
66
                                when "1111" => digit_pattern_array <= "01110001";
67
                                when others => null;
68
                        end case;
69
                end if;
70
        end process;
71
 
72
        process(CLK)
73
        begin
74
                if rising_edge(CLK) then
75
                        if clk_400hz = '1' then
76
                                current_segment <= current_segment + 1;
77
 
78
                                case current_segment is
79
                                        when "00" =>
80
                                                cathode_select <= "1110";
81
                                                current_digit <= VAL_IN(3 downto 0);
82
                                        when "01" =>
83
                                                cathode_select <= "1101";
84
                                                current_digit <= VAL_IN(7 downto 4);
85
                                        when "10" =>
86
                                                cathode_select <= "1011";
87
                                                current_digit <= VAL_IN(11 downto 8);
88
                                        when "11" =>
89
                                                cathode_select <= "0111";
90
                                                current_digit <= VAL_IN(15 downto 12);
91
                                        when others => null;
92
                                end case;
93
                        end if;
94
                end if;
95
        end process;
96
 
97
end Behavioral;
98
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.