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 283

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 244 jshamlet
-- Seth Henry      05/18/20 Added write qualification input
39 241 jshamlet
 
40
library ieee;
41
  use ieee.std_logic_1164.all;
42
  use ieee.std_logic_unsigned.all;
43
  use ieee.std_logic_arith.all;
44
  use ieee.std_logic_misc.all;
45
 
46
library work;
47
  use work.open8_pkg.all;
48
 
49
entity o8_7seg is
50
generic(
51
  Default_LED1_Value         : std_logic_vector(4 downto 0);
52
  Default_LED1_Bright        : DATA_TYPE := x"FF";
53
  Default_LED2_Value         : std_logic_vector(4 downto 0);
54
  Default_LED2_Bright        : DATA_TYPE := x"FF";
55
  Common_Cathode             : boolean   := TRUE;
56
  Address                    : ADDRESS_TYPE
57
);
58
port(
59
  Open8_Bus                  : in  OPEN8_BUS_TYPE;
60 244 jshamlet
  Write_Qual                 : in  std_logic := '1';
61 241 jshamlet
  Rd_Data                    : out DATA_TYPE;
62
  --
63
  SegLED1                    : out std_logic_vector(6 downto  0);
64
  SegLED2                    : out std_logic_vector(6 downto  0)
65
);
66
end entity;
67
 
68
architecture behave of o8_7seg is
69
 
70
  alias Clock                is Open8_Bus.Clock;
71
  alias Reset                is Open8_Bus.Reset;
72
 
73
  constant User_Addr         : std_logic_vector(15 downto 2)
74
                               := Address(15 downto 2);
75
  alias  Comp_Addr           is Open8_Bus.Address(15 downto 2);
76
  signal Addr_Match          : std_logic;
77
 
78 244 jshamlet
  alias  Reg_Sel_d           is Open8_Bus.Address(1 downto 0);
79
  signal Reg_Sel_q           : std_logic_vector(1 downto 0) := "00";
80
  signal Wr_En_d             : std_logic := '0';
81
  signal Wr_En_q             : std_logic := '0';
82
  alias  Wr_Data_d           is Open8_Bus.Wr_Data;
83
  signal Wr_Data_q           : DATA_TYPE := x"00";
84
  signal Rd_En_d             : std_logic := '0';
85
  signal Rd_En_q             : std_logic := '0';
86
 
87 241 jshamlet
  signal LED1_Reg            : std_logic_vector(4 downto 0);
88
  signal LED1_Brt            : DATA_TYPE;
89
  signal LED2_Reg            : std_logic_vector(4 downto 0);
90
  signal LED2_Brt            : DATA_TYPE;
91
 
92
 
93
  signal LED1_PDM            : std_logic;
94
  signal LED1_Ext            : std_logic_vector(6 downto  0);
95
 
96
  signal LED2_PDM            : std_logic;
97
  signal LED2_Ext            : std_logic_vector(6 downto  0);
98
 
99
  signal SegLED1_Full        : std_logic_vector(6 downto  0);
100
  signal SegLED2_Full        : std_logic_vector(6 downto  0);
101
 
102
-- Standard 7-Segment Numeric Display
103
--
104
--    -A-
105
--  |     |
106
--  F     B
107
--  |     |
108
--    -G-
109
--  |     |
110
--  E     C
111
--  |     |
112
--    -D-  (DP)
113
 
114
  type LED_DEFS_TYPE is array(0 to 31) of std_logic_vector(6 downto 0);
115
  constant CHAR_DEFINITIONS  : LED_DEFS_TYPE := (
116
--                                GFEDCBA
117
                                 "0111111",  -- 00 -> 0
118
                                 "0000110",  -- 01 -> 1
119
                                 "1011011",  -- 02 -> 2
120
                                 "1001111",  -- 03 -> 3
121
                                 "1100110",  -- 04 -> 4
122
                                 "1101101",  -- 05 -> 5
123
                                 "1111101",  -- 06 -> 6
124
                                 "0000111",  -- 07 -> 7
125
                                 "1111111",  -- 08 -> 8
126
                                 "1101111",  -- 09 -> 9
127
                                 "1110111",  -- 10 -> A
128
                                 "1111100",  -- 11 -> B
129
                                 "1011000",  -- 12 -> C
130
                                 "1011110",  -- 13 -> D
131
                                 "1111001",  -- 14 -> E
132
                                 "1110001",  -- 15 -> F
133
                                 "0111101",  -- 16 -> G
134
                                 "1110110",  -- 17 -> H
135
                                 "0000100",  -- 18 -> i
136
                                 "0001110",  -- 19 -> J
137
                                 "0111000",  -- 20 -> L
138
                                 "1010100",  -- 21 -> n
139
                                 "1011100",  -- 22 -> o
140
                                 "1110011",  -- 23 -> P
141
                                 "1010000",  -- 24 -> r
142
                                 "0011100",  -- 25 -> u
143
                                 "1101110",  -- 26 -> y
144
                                 "1000000",  -- 27 -> -
145
                                 "1001000",  -- 28 -> =
146
                                 "1100011",  -- 29 -> DEG
147
                                 "0000010",  -- 30 -> '
148
                                 "0000000"   -- 31 -> " "
149
                                 );
150
 
151
begin
152
 
153
  Addr_Match                 <= '1' when Comp_Addr = User_Addr else '0';
154 244 jshamlet
  Wr_En_d                    <= Addr_Match and Open8_Bus.Wr_En and Write_Qual;
155
  Rd_En_d                    <= Addr_Match and Open8_Bus.Rd_En;
156 241 jshamlet
 
157
  io_reg: process( Clock, Reset )
158
  begin
159
    if( Reset = Reset_Level )then
160 244 jshamlet
      Reg_Sel_q              <= "00";
161
      Wr_En_q                <= '0';
162 241 jshamlet
      Wr_Data_q              <= x"00";
163 244 jshamlet
      Rd_En_q                <= '0';
164
      Rd_Data                <= OPEN8_NULLBUS;
165
 
166 241 jshamlet
      LED1_Reg               <= Default_LED1_Value;
167
      LED2_Reg               <= Default_LED2_Value;
168
      LED1_Brt               <= Default_LED1_Bright;
169
      LED2_Brt               <= Default_LED2_Bright;
170
    elsif( rising_edge( Clock ) )then
171 244 jshamlet
      Reg_Sel_q              <= Reg_Sel_d;
172 241 jshamlet
 
173 244 jshamlet
      Wr_En_q                <= Wr_En_d;
174
      Wr_Data_q              <= Wr_Data_d;
175
      if( Wr_En_q = '1' )then
176
        case( Reg_Sel_q )is
177 241 jshamlet
          when "00" =>
178
            LED1_Reg         <= Wr_Data_q(4 downto 0);
179
          when "01" =>
180
            LED2_Reg         <= Wr_Data_q(4 downto 0);
181
          when "10" =>
182
            LED1_Brt         <= Wr_Data_q;
183
          when "11" =>
184
            LED2_Brt         <= Wr_Data_q;
185
          when others =>
186
            null;
187
        end case;
188
      end if;
189
 
190 244 jshamlet
      Rd_En_q                <= Rd_En_d;
191 241 jshamlet
      Rd_Data                <= OPEN8_NULLBUS;
192 257 jshamlet
      if( Rd_En_q = '1' )then
193 244 jshamlet
        case( Reg_Sel_q )is
194 241 jshamlet
          when "00" =>
195
            Rd_Data          <= "000" & LED1_Reg;
196
          when "01" =>
197
            Rd_Data          <= "000" & LED2_Reg;
198
          when "10" =>
199
            Rd_Data          <= LED1_Brt;
200
          when "11" =>
201
            Rd_Data          <= LED2_Brt;
202
          when others =>
203
            null;
204
        end case;
205
      end if;
206
    end if;
207
  end process;
208
 
209
  U_LED1_PWM : entity work.vdsm8
210
  generic map(
211
    Reset_Level              => Reset_Level
212
  )
213
  port map(
214
    Clock                    => Clock,
215
    Reset                    => Reset,
216
    DACin                    => LED1_Brt,
217
    DACout                   => LED1_PDM
218
  );
219
 
220
  U_LED2_PWM : entity work.vdsm8
221
  generic map(
222
    Reset_Level              => Reset_Level
223
  )
224
  port map(
225
    Clock                    => Clock,
226
    Reset                    => Reset,
227
    DACin                    => LED2_Brt,
228
    DACout                   => LED2_PDM
229
  );
230
 
231
  LED1_Ext                   <= (others => LED1_PDM);
232
  LED2_Ext                   <= (others => LED2_PDM);
233
 
234
  SegLED1_Full               <= CHAR_DEFINITIONS(conv_integer(LED1_Reg));
235
  SegLED2_Full               <= CHAR_DEFINITIONS(conv_integer(LED2_Reg));
236
 
237
Common_Cathode_Mode : if( Common_Cathode )generate
238
 
239
  LUT_proc: process( Clock, Reset )
240
  begin
241
    if( Reset = Reset_Level )then
242
      SegLED1                <= (others => '0');
243
      SegLED2                <= (others => '0');
244
    elsif( rising_edge(Clock) )then
245
      SegLED1                <= (SegLED1_Full and LED1_Ext) xor "1111111";
246
      SegLED2                <= (SegLED2_Full and LED2_Ext) xor "1111111";
247
    end if;
248
  end process;
249
 
250
end generate;
251
 
252
Common_Anode_Mode : if( not Common_Cathode )generate
253
 
254
  LUT_proc: process( Clock, Reset )
255
  begin
256
    if( Reset = Reset_Level )then
257
      SegLED1                <= (others => '1');
258
      SegLED2                <= (others => '1');
259
    elsif( rising_edge(Clock) )then
260
      SegLED1                <= (SegLED1_Full and LED1_Ext);
261
      SegLED2                <= (SegLED2_Full and LED2_Ext);
262
    end if;
263
  end process;
264
 
265
 
266
end generate;
267
 
268
end architecture;

powered by: WebSVN 2.1.0

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