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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_7seg.vhd] - Blame information for rev 243

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

Line No. Rev Author Line
1 241 jshamlet
-- Copyright (c)2020 Jeremy Seth Henry
2
-- All rights reserved.
3
--
4
-- Redistribution and use in source and binary forms, with or without
5
-- modification, are permitted provided that the following conditions are met:
6
--     * Redistributions of source code must retain the above copyright
7
--       notice, this list of conditions and the following disclaimer.
8
--     * Redistributions in binary form must reproduce the above copyright
9
--       notice, this list of conditions and the following disclaimer in the
10
--       documentation and/or other materials provided with the distribution,
11
--       where applicable (as part of a user interface, debugging port, etc.)
12
--
13
-- THIS SOFTWARE IS PROVIDED BY JEREMY SETH HENRY ``AS IS'' AND ANY
14
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
-- DISCLAIMED. IN NO EVENT SHALL JEREMY SETH HENRY BE LIABLE FOR ANY
17
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
--
24
-- VHDL Units :  o8_register
25
-- Description:  Provides a single addressible 8-bit output register
26
--
27
-- Register Map:
28
-- Offset  Bitfield Description                        Read/Write
29
--   0x00  ---AAAAA Display 1 value                       (RW)
30
--   0x01  ---AAAAA Display 2 value                       (RW)
31
--   0x02  AAAAAAAA Display 1 brightness                  (RW)
32
--   0x03  AAAAAAAA Display 2 brightness                  (RW)
33
--
34
-- Revision History
35
-- Author          Date     Change
36
------------------ -------- ---------------------------------------------------
37
-- Seth Henry      05/08/19 Design Start
38
 
39
library ieee;
40
  use ieee.std_logic_1164.all;
41
  use ieee.std_logic_unsigned.all;
42
  use ieee.std_logic_arith.all;
43
  use ieee.std_logic_misc.all;
44
 
45
library work;
46
  use work.open8_pkg.all;
47
 
48
entity o8_7seg is
49
generic(
50
  Default_LED1_Value         : std_logic_vector(4 downto 0);
51
  Default_LED1_Bright        : DATA_TYPE := x"FF";
52
  Default_LED2_Value         : std_logic_vector(4 downto 0);
53
  Default_LED2_Bright        : DATA_TYPE := x"FF";
54
  Common_Cathode             : boolean   := TRUE;
55
  Address                    : ADDRESS_TYPE
56
);
57
port(
58
  Open8_Bus                  : in  OPEN8_BUS_TYPE;
59
  Rd_Data                    : out DATA_TYPE;
60
  --
61
  SegLED1                    : out std_logic_vector(6 downto  0);
62
  SegLED2                    : out std_logic_vector(6 downto  0)
63
);
64
end entity;
65
 
66
architecture behave of o8_7seg is
67
 
68
  alias Clock                is Open8_Bus.Clock;
69
  alias Reset                is Open8_Bus.Reset;
70
 
71
  constant User_Addr         : std_logic_vector(15 downto 2)
72
                               := Address(15 downto 2);
73
  alias  Comp_Addr           is Open8_Bus.Address(15 downto 2);
74
  signal Addr_Match          : std_logic;
75
  alias  Reg_Addr            is Open8_Bus.Address(1 downto 0);
76
  signal Reg_Sel             : std_logic_vector(1 downto 0);
77
  signal Wr_En               : std_logic;
78
  signal Wr_Data_q           : DATA_TYPE;
79
  signal Rd_En               : std_logic;
80
 
81
  signal LED1_Reg            : std_logic_vector(4 downto 0);
82
  signal LED1_Brt            : DATA_TYPE;
83
  signal LED2_Reg            : std_logic_vector(4 downto 0);
84
  signal LED2_Brt            : DATA_TYPE;
85
 
86
 
87
  signal LED1_PDM            : std_logic;
88
  signal LED1_Ext            : std_logic_vector(6 downto  0);
89
 
90
  signal LED2_PDM            : std_logic;
91
  signal LED2_Ext            : std_logic_vector(6 downto  0);
92
 
93
  signal SegLED1_Full        : std_logic_vector(6 downto  0);
94
  signal SegLED2_Full        : std_logic_vector(6 downto  0);
95
 
96
-- Standard 7-Segment Numeric Display
97
--
98
--    -A-
99
--  |     |
100
--  F     B
101
--  |     |
102
--    -G-
103
--  |     |
104
--  E     C
105
--  |     |
106
--    -D-  (DP)
107
 
108
  type LED_DEFS_TYPE is array(0 to 31) of std_logic_vector(6 downto 0);
109
  constant CHAR_DEFINITIONS  : LED_DEFS_TYPE := (
110
--                                GFEDCBA
111
                                 "0111111",  -- 00 -> 0
112
                                 "0000110",  -- 01 -> 1
113
                                 "1011011",  -- 02 -> 2
114
                                 "1001111",  -- 03 -> 3
115
                                 "1100110",  -- 04 -> 4
116
                                 "1101101",  -- 05 -> 5
117
                                 "1111101",  -- 06 -> 6
118
                                 "0000111",  -- 07 -> 7
119
                                 "1111111",  -- 08 -> 8
120
                                 "1101111",  -- 09 -> 9
121
                                 "1110111",  -- 10 -> A
122
                                 "1111100",  -- 11 -> B
123
                                 "1011000",  -- 12 -> C
124
                                 "1011110",  -- 13 -> D
125
                                 "1111001",  -- 14 -> E
126
                                 "1110001",  -- 15 -> F
127
                                 "0111101",  -- 16 -> G
128
                                 "1110110",  -- 17 -> H
129
                                 "0000100",  -- 18 -> i
130
                                 "0001110",  -- 19 -> J
131
                                 "0111000",  -- 20 -> L
132
                                 "1010100",  -- 21 -> n
133
                                 "1011100",  -- 22 -> o
134
                                 "1110011",  -- 23 -> P
135
                                 "1010000",  -- 24 -> r
136
                                 "0011100",  -- 25 -> u
137
                                 "1101110",  -- 26 -> y
138
                                 "1000000",  -- 27 -> -
139
                                 "1001000",  -- 28 -> =
140
                                 "1100011",  -- 29 -> DEG
141
                                 "0000010",  -- 30 -> '
142
                                 "0000000"   -- 31 -> " "
143
                                 );
144
 
145
begin
146
 
147
  Addr_Match                 <= '1' when Comp_Addr = User_Addr else '0';
148
 
149
  io_reg: process( Clock, Reset )
150
  begin
151
    if( Reset = Reset_Level )then
152
      Reg_Sel                <= "00";
153
      Wr_En                  <= '0';
154
      Wr_Data_q              <= x"00";
155
      LED1_Reg               <= Default_LED1_Value;
156
      LED2_Reg               <= Default_LED2_Value;
157
      LED1_Brt               <= Default_LED1_Bright;
158
      LED2_Brt               <= Default_LED2_Bright;
159
      Rd_En                  <= '0';
160
      Rd_Data                <= OPEN8_NULLBUS;
161
    elsif( rising_edge( Clock ) )then
162
      Reg_Sel                <= Reg_Addr;
163
 
164
      Wr_En                  <= Addr_Match and Open8_Bus.Wr_En;
165
      Wr_Data_q              <= Open8_Bus.Wr_Data;
166
      if( Wr_En = '1' )then
167
        case( Reg_Sel )is
168
          when "00" =>
169
            LED1_Reg         <= Wr_Data_q(4 downto 0);
170
          when "01" =>
171
            LED2_Reg         <= Wr_Data_q(4 downto 0);
172
          when "10" =>
173
            LED1_Brt         <= Wr_Data_q;
174
          when "11" =>
175
            LED2_Brt         <= Wr_Data_q;
176
          when others =>
177
            null;
178
        end case;
179
      end if;
180
 
181
      Rd_Data                <= OPEN8_NULLBUS;
182
      Rd_En                  <= Addr_Match and Open8_Bus.Rd_En;
183
      if( Rd_En = '1' )then
184
        case( Reg_Sel )is
185
          when "00" =>
186
            Rd_Data          <= "000" & LED1_Reg;
187
          when "01" =>
188
            Rd_Data          <= "000" & LED2_Reg;
189
          when "10" =>
190
            Rd_Data          <= LED1_Brt;
191
          when "11" =>
192
            Rd_Data          <= LED2_Brt;
193
          when others =>
194
            null;
195
        end case;
196
      end if;
197
    end if;
198
  end process;
199
 
200
  U_LED1_PWM : entity work.vdsm8
201
  generic map(
202
    Reset_Level              => Reset_Level
203
  )
204
  port map(
205
    Clock                    => Clock,
206
    Reset                    => Reset,
207
    DACin                    => LED1_Brt,
208
    DACout                   => LED1_PDM
209
  );
210
 
211
  U_LED2_PWM : entity work.vdsm8
212
  generic map(
213
    Reset_Level              => Reset_Level
214
  )
215
  port map(
216
    Clock                    => Clock,
217
    Reset                    => Reset,
218
    DACin                    => LED2_Brt,
219
    DACout                   => LED2_PDM
220
  );
221
 
222
  LED1_Ext                   <= (others => LED1_PDM);
223
  LED2_Ext                   <= (others => LED2_PDM);
224
 
225
  SegLED1_Full               <= CHAR_DEFINITIONS(conv_integer(LED1_Reg));
226
  SegLED2_Full               <= CHAR_DEFINITIONS(conv_integer(LED2_Reg));
227
 
228
Common_Cathode_Mode : if( Common_Cathode )generate
229
 
230
  LUT_proc: process( Clock, Reset )
231
  begin
232
    if( Reset = Reset_Level )then
233
      SegLED1                <= (others => '0');
234
      SegLED2                <= (others => '0');
235
    elsif( rising_edge(Clock) )then
236
      SegLED1                <= (SegLED1_Full and LED1_Ext) xor "1111111";
237
      SegLED2                <= (SegLED2_Full and LED2_Ext) xor "1111111";
238
    end if;
239
  end process;
240
 
241
end generate;
242
 
243
Common_Anode_Mode : if( not Common_Cathode )generate
244
 
245
  LUT_proc: process( Clock, Reset )
246
  begin
247
    if( Reset = Reset_Level )then
248
      SegLED1                <= (others => '1');
249
      SegLED2                <= (others => '1');
250
    elsif( rising_edge(Clock) )then
251
      SegLED1                <= (SegLED1_Full and LED1_Ext);
252
      SegLED2                <= (SegLED2_Full and LED2_Ext);
253
    end if;
254
  end process;
255
 
256
 
257
end generate;
258
 
259
end architecture;

powered by: WebSVN 2.1.0

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