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

Subversion Repositories System09

[/] [System09/] [trunk/] [rtl/] [VHDL/] [SevenSegmentDisplay.vhd] - Blame information for rev 159

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 dilbert57
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
--  Uncomment the following lines to use the declarations that are
7
--  provided for instantiating Xilinx primitive components.
8
--library UNISIM;
9
--use UNISIM.VComponents.all;
10
 
11
entity SevenSegmentDisplay is
12
    Port ( Clk : in std_logic;
13
           Reset : in std_logic;
14
           Value0 : in std_logic_vector(3 downto 0);
15
           Value1 : in std_logic_vector(3 downto 0);
16
           Value2 : in std_logic_vector(3 downto 0);
17
           Value3 : in std_logic_vector(3 downto 0);
18
                          DPs    : in std_logic_vector(3 downto 0);
19
                          Blanks        : in std_logic_vector(3 downto 0);
20
           DigitSelect : out std_logic_vector(3 downto 0);
21
           Segments : out std_logic_vector(7 downto 0));
22
end SevenSegmentDisplay;
23
 
24
architecture Behavioral of SevenSegmentDisplay is
25
 
26
        signal ClockDivider             : std_logic_vector(13 downto 0);
27
        signal WhichDigit                       : std_logic_vector(1 downto 0);
28
        signal Result                           : std_logic_vector(7 downto 0);
29
        signal DigitValue                       : std_logic_vector(3 downto 0);
30
        signal DP                                       : std_logic;
31
        signal Blank                            : std_logic;
32
 
33
        component DecoderDriver
34
        port(
35
                DigitValue      : in std_logic_vector(3 downto 0);
36
                DP                              : in std_logic;
37
                Blank                   : in std_logic;
38
                Segments                : out std_logic_vector(7 downto 0));
39
        end component;
40
 
41
begin
42
 
43
        process(Reset,Clk) is
44
        begin
45
                if Reset = '1' then
46
                        ClockDivider <= (others => '0');
47
                        WhichDigit   <= "00";
48
                        DigitSelect     <= "1111";
49
                elsif Clk = '1' and Clk'Event then
50
                        if ClockDivider = "11000011010011" then
51
                                ClockDivider <= (others => '0');
52
                                Segments <= Result;
53
                                case WhichDigit is      -- note that everything is pipelined
54
                                        when "00" =>
55
                                                DigitSelect <= "1110";
56
                                                DigitValue <= Value1;
57
                                                DP <= DPs(1);
58
                                                Blank <= Blanks(1);
59
                                        when "01" =>
60
                                                DigitSelect <= "1101";
61
                                                DigitValue <= Value2;
62
                                                DP <= DPs(2);
63
                                                Blank <= Blanks(2);
64
                                        when "10" =>
65
                                                DigitSelect <= "1011";
66
                                                DigitValue <= Value3;
67
                                                DP <= DPs(3);
68
                                                Blank <= Blanks(3);
69
                                        when "11" =>
70
                                                DigitSelect <= "0111";
71
                                                DigitValue <= Value0;
72
                                                DP <= DPs(0);
73
                                                Blank <= Blanks(0);
74
                                        when others => null;
75
                                end case;
76
                                WhichDigit <= WhichDigit + 1;
77
                        else
78
                                ClockDivider <= ClockDivider + 1;
79
                        end if;
80
                end if;
81
        end process;
82
 
83
        Inst_DecoderDriver: DecoderDriver PORT MAP (
84
                DigitValue => DigitValue,
85
                DP => DP,
86
                Blank => Blank,
87
                Segments => Result
88
        );
89
 
90
end Behavioral;

powered by: WebSVN 2.1.0

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