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

Subversion Repositories tcp_ip_core_w_dhcp

[/] [tcp_ip_core_w_dhcp/] [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 sseg_dr                          : std_logic := '0';
27
signal current_digit                    : std_logic_vector(3 downto 0) := "0000";
28
 
29
begin
30
 
31
        SSEG_OUT <= digit_pattern_array;
32
        AN_OUT <= cathode_select;
33
 
34
  -- Slows up CLK from 50MHz to MUX_CLK 400Hz.
35
        process(CLK)
36
        begin
37
                if rising_edge(CLK) then
38
                        if clk_div_counter = C_clk_div_400hz then
39
                                clk_div_counter <= (others => '0');
40
                                clk_400hz <= '1';
41
                        else
42
                                clk_div_counter <= clk_div_counter + 1;
43
                                clk_400hz <= '0';
44
                        end if;
45
                end if;
46
        end process;
47
 
48
        process(CLK)
49
        begin
50
                if rising_edge(CLK) then
51
                        case current_digit is
52
                                when "0000" => digit_pattern_array <= "00000011";
53
                                when "0001" => digit_pattern_array <= "10011111";
54
                                when "0010" => digit_pattern_array <= "00100101";
55
                                when "0011" => digit_pattern_array <= "00001101";
56
                                when "0100" => digit_pattern_array <= "10011001";
57
                                when "0101" => digit_pattern_array <= "01001001";
58
                                when "0110" => digit_pattern_array <= "01000001";
59
                                when "0111" => digit_pattern_array <= "00011111";
60
                                when "1000" => digit_pattern_array <= "00000001";
61
                                when "1001" => digit_pattern_array <= "00011001";
62
                                when "1010" => digit_pattern_array <= "00010001";
63
                                when "1011" => digit_pattern_array <= "11000001";
64
                                when "1100" => digit_pattern_array <= "01100011";
65
                                when "1101" => digit_pattern_array <= "10000101";
66
                                when "1110" => digit_pattern_array <= "01100001";
67
                                when "1111" => digit_pattern_array <= "01110001";
68
                                when others => null;
69
                        end case;
70
                end if;
71
        end process;
72
 
73
        process(CLK)
74
        begin
75
                if rising_edge(CLK) then
76
                        if clk_400hz = '1' then
77
                                current_segment <= current_segment + 1;
78
 
79
                                case current_segment is
80
                                        when "00" =>
81
                                                cathode_select <= "1110";
82
                                                current_digit <= VAL_IN(3 downto 0);
83
                                        when "01" =>
84
                                                cathode_select <= "1101";
85
                                                current_digit <= VAL_IN(7 downto 4);
86
                                        when "10" =>
87
                                                cathode_select <= "1011";
88
                                                current_digit <= VAL_IN(11 downto 8);
89
                                        when "11" =>
90
                                                cathode_select <= "0111";
91
                                                current_digit <= VAL_IN(15 downto 12);
92
                                        when others => null;
93
                                end case;
94
                        end if;
95
                end if;
96
        end process;
97
 
98
end Behavioral;
99
 

powered by: WebSVN 2.1.0

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