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

Subversion Repositories c16

[/] [c16/] [trunk/] [vhdl/] [bin_to_7segment.vhd] - Blame information for rev 31

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

Line No. Rev Author Line
1 2 jsauermann
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 bin_to_7segment is
12
    Port(       CLK_I : in std_logic;
13
                        PC    : in std_logic_vector(15 downto 0);
14
                        SEG1  : out std_logic_vector(7 downto 1);
15
                        SEG2  : out std_logic_vector(7 downto 0));
16
end bin_to_7segment;
17
 
18
architecture Behavioral of bin_to_7segment is
19
 
20
                                                                --                                        +-------      middle  upper
21
                                                                --                                        |+-------     right   upper
22
                                                                --                                        ||+------     right   lower
23
                                                                --                                        |||+-----     middle  lower
24
                                                                --                                        ||||+----     left    lower
25
                                                                --                                        |||||+---     left    upper
26
                                                                --                                        ||||||+--     middle  middle
27
                                                                --                                        |||||||
28
constant LEDV_0         : std_logic_vector(6 downto 0):= "1111110";-- 0
29
constant LEDV_1         : std_logic_vector(6 downto 0):= "0110000";-- 1
30
constant LEDV_2         : std_logic_vector(6 downto 0):= "1101101";-- 2
31
constant LEDV_3         : std_logic_vector(6 downto 0):= "1111001";-- 3
32
constant LEDV_4         : std_logic_vector(6 downto 0):= "0110011";-- 4
33
constant LEDV_5         : std_logic_vector(6 downto 0):= "1011011";-- 5
34
constant LEDV_6         : std_logic_vector(6 downto 0):= "1011111";-- 6
35
constant LEDV_7         : std_logic_vector(6 downto 0):= "1110000";-- 7
36
constant LEDV_8         : std_logic_vector(6 downto 0):= "1111111";-- 8
37
constant LEDV_9         : std_logic_vector(6 downto 0):= "1111011";-- 9
38
constant LEDV_A         : std_logic_vector(6 downto 0):= "1110111";-- A
39
constant LEDV_b         : std_logic_vector(6 downto 0):= "0011111";-- b
40
constant LEDV_C         : std_logic_vector(6 downto 0):= "1001110";-- C
41
constant LEDV_d         : std_logic_vector(6 downto 0):= "0111101";-- d
42
constant LEDV_E         : std_logic_vector(6 downto 0):= "1001111";-- E
43
constant LEDV_F         : std_logic_vector(6 downto 0):= "1000111";-- F
44
 
45 9 jsauermann
        signal LED_CNT  : std_logic_vector(25 downto 0);
46 2 jsauermann
        signal LED_VAL  : std_logic_vector(15 downto 0);
47
 
48
begin
49
 
50
        process(CLK_I)
51
 
52
                variable LED4H, LED4L  : std_logic_vector(3 downto 0);
53
 
54
        begin
55
                if (rising_edge(CLK_I)) then
56 9 jsauermann
                        if (LED_CNT(25) = '0')   then
57
                                LED4H := LED_VAL( 7 downto  4);
58
                                LED4L := LED_VAL( 3 downto  0);
59
                        else
60
                                LED4H := LED_VAL(15 downto 12);
61
                                LED4L := LED_VAL(11 downto  8);
62
                        end if;
63 2 jsauermann
 
64 9 jsauermann
                        if (LED_CNT = 0) then    LED_VAL <= PC;  end if;
65
                        LED_CNT <= LED_CNT + 1;
66 2 jsauermann
 
67 9 jsauermann
                        case LED4H is
68
                                when X"0" =>     SEG1 <= LEDV_0;
69
                                when X"1" =>    SEG1 <= LEDV_1;
70
                                when X"2" =>    SEG1 <= LEDV_2;
71
                                when X"3" =>    SEG1 <= LEDV_3;
72
                                when X"4" =>    SEG1 <= LEDV_4;
73
                                when X"5" =>    SEG1 <= LEDV_5;
74
                                when X"6" =>    SEG1 <= LEDV_6;
75
                                when X"7" =>    SEG1 <= LEDV_7;
76
                                when X"8" =>    SEG1 <= LEDV_8;
77
                                when X"9" =>    SEG1 <= LEDV_9;
78
                                when X"A" =>    SEG1 <= LEDV_A;
79
                                when X"B" =>    SEG1 <= LEDV_b;
80
                                when X"C" =>    SEG1 <= LEDV_c;
81
                                when X"D" =>    SEG1 <= LEDV_d;
82
                                when X"E" =>    SEG1 <= LEDV_E;
83
                                when others =>  SEG1 <= LEDV_F;
84
                        end case;
85 2 jsauermann
 
86 9 jsauermann
                        case LED4L is
87
                                when X"0" =>     SEG2(7 downto 1) <= LEDV_0;
88
                                when X"1" =>    SEG2(7 downto 1) <= LEDV_1;
89
                                when X"2" =>    SEG2(7 downto 1) <= LEDV_2;
90
                                when X"3" =>    SEG2(7 downto 1) <= LEDV_3;
91
                                when X"4" =>    SEG2(7 downto 1) <= LEDV_4;
92
                                when X"5" =>    SEG2(7 downto 1) <= LEDV_5;
93
                                when X"6" =>    SEG2(7 downto 1) <= LEDV_6;
94
                                when X"7" =>    SEG2(7 downto 1) <= LEDV_7;
95
                                when X"8" =>    SEG2(7 downto 1) <= LEDV_8;
96
                                when X"9" =>    SEG2(7 downto 1) <= LEDV_9;
97
                                when X"A" =>    SEG2(7 downto 1) <= LEDV_A;
98
                                when X"B" =>    SEG2(7 downto 1) <= LEDV_b;
99
                                when X"C" =>    SEG2(7 downto 1) <= LEDV_c;
100
                                when X"D" =>    SEG2(7 downto 1) <= LEDV_d;
101
                                when X"E" =>    SEG2(7 downto 1) <= LEDV_E;
102
                                when others =>  SEG2(7 downto 1) <= LEDV_F;
103
                        end case;
104 2 jsauermann
 
105 9 jsauermann
                        SEG2(0) <= LED_CNT(25);
106 2 jsauermann
                end if;
107
        end process;
108
 
109
end Behavioral;

powered by: WebSVN 2.1.0

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