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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_status_led.vhd] - Blame information for rev 200

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

Line No. Rev Author Line
1 194 jshamlet
-- Copyright (c)2006, 2016, 2019, 2020 Jeremy Seth Henry
2 180 jshamlet
-- 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 194 jshamlet
-- (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 180 jshamlet
--
24
-- VHDL Units :  o8_status_led
25
-- Description:  Provides a multi-state status LED controller
26
--
27
-- Register Map:
28
-- Offset  Bitfield Description                        Read/Write
29
--   0x00  -----AAA LED Mode (2:0)                     (RW)
30
--
31
-- LED Modes:
32
-- 0x00 - LED is fully off
33
-- 0x01 - LED is fully on
34
-- 0x02 - LED is dimmed to 50%
35
-- 0x03 - LED Toggles at 1Hz
36
-- 0x04 - LED fades in and out
37
--
38
-- Revision History
39
-- Author          Date     Change
40
------------------ -------- ---------------------------------------------------
41
-- Seth Henry      12/20/19 Design Start
42
 
43
library ieee;
44
  use ieee.std_logic_1164.all;
45
  use ieee.std_logic_unsigned.all;
46
  use ieee.std_logic_arith.all;
47 191 jshamlet
  use ieee.std_logic_misc.all;
48 180 jshamlet
 
49
library work;
50
  use work.open8_pkg.all;
51
 
52
entity o8_status_led is
53
generic(
54
  Reset_Level           : std_logic;
55
  Address               : ADDRESS_TYPE
56
);
57
port(
58
  Clock                 : in  std_logic;
59
  Reset                 : in  std_logic;
60
  --
61
  Bus_Address           : in  ADDRESS_TYPE;
62
  Wr_Enable             : in  std_logic;
63
  Wr_Data               : in  DATA_TYPE;
64
  Rd_Enable             : in  std_logic;
65
  Rd_Data               : out DATA_TYPE;
66
  --
67
  LED_Out               : out std_logic
68
);
69
end entity;
70
 
71
architecture behave of o8_status_led is
72
 
73
  constant User_Addr    : std_logic_vector(15 downto 0)
74
                          := Address(15 downto 0);
75
  alias  Comp_Addr      is Bus_Address(15 downto 0);
76
  signal Addr_Match     : std_logic;
77
  signal Wr_En          : std_logic;
78
  signal Wr_Data_q      : std_logic_vector(2 downto 0);
79
  signal LED_Mode       : std_logic_vector(2 downto 0);
80
  signal Rd_En          : std_logic;
81
 
82
  signal Dim50Pct_Out   : std_logic;
83
 
84
  signal Half_Hz_Timer  : std_logic_vector(15 downto 0);
85
  constant HALF_HZ_PRD  : std_logic_vector(15 downto 0) :=
86
                           conv_std_logic_vector(500000,16);
87
  signal One_Hz_Out     : std_logic;
88
 
89
  constant TIMER_MSB    : integer range 9 to 20 := 18;
90
 
91
  signal Fade_Timer1    : std_logic_vector(TIMER_MSB downto 0);
92
  signal Fade_Timer2    : std_logic_vector(TIMER_MSB downto 0);
93
  signal Fade_Out       : std_logic;
94
 
95
begin
96
 
97
  Addr_Match            <= '1' when Comp_Addr = User_Addr else '0';
98
 
99
  io_reg: process( Clock, Reset )
100
  begin
101
    if( Reset = Reset_Level )then
102
      Wr_En             <= '0';
103
      Wr_Data_q         <= (others => '0');
104
      LED_Mode          <= (others => '0');
105
      Rd_En             <= '0';
106 191 jshamlet
      Rd_Data           <= OPEN8_NULLBUS;
107 180 jshamlet
    elsif( rising_edge( Clock ) )then
108
      Wr_En             <= Addr_Match and Wr_Enable;
109
      Wr_Data_q         <= Wr_Data(2 downto 0);
110
      if( Wr_En = '1' )then
111
        LED_Mode        <= Wr_Data_q;
112
      end if;
113
 
114 191 jshamlet
      Rd_Data           <= OPEN8_NULLBUS;
115 180 jshamlet
      Rd_En             <= Addr_Match and Rd_Enable;
116
      if( Rd_En = '1' )then
117
        Rd_Data         <= "00000" & LED_Mode;
118
      end if;
119
 
120
    end if;
121
  end process;
122 191 jshamlet
 
123 180 jshamlet
  Output_FF: process( Clock, Reset )
124
  begin
125
    if( Reset = Reset_Level )then
126
      LED_Out           <= '0';
127
    elsif( rising_edge(Clock) )then
128
      LED_Out           <= '0';
129
      case( LED_Mode )is
130
        when "001" =>
131
          LED_Out       <= '1';
132
        when "010" =>
133
          LED_Out       <= Dim50Pct_Out;
134
        when "011" =>
135
          LED_Out       <= One_Hz_Out;
136
        when "100" =>
137
          LED_Out       <= Fade_out;
138
        when others => null;
139
      end case;
140
    end if;
141
  end process;
142
 
143
  Timer_proc: process( Clock, Reset )
144
  begin
145
    if( Reset = Reset_Level )then
146
      Dim50Pct_Out      <= '0';
147
      Half_Hz_Timer     <= (others => '0');
148
      One_Hz_Out        <= '0';
149
      Fade_Timer1       <= (others => '0');
150
      Fade_Timer2       <= (others => '0');
151
      Fade_out          <= '0';
152
    elsif( rising_edge(Clock) )then
153
      Dim50Pct_Out      <= not Dim50Pct_Out;
154
 
155
      Half_Hz_Timer     <= Half_Hz_Timer - 1;
156
      if( Half_Hz_Timer = 0 )then
157
        Half_Hz_Timer   <= HALF_HZ_PRD;
158
        One_Hz_Out      <= not One_Hz_Out;
159
      end if;
160
 
161
      Fade_Timer1       <= Fade_Timer1 - 1;
162
      Fade_Timer2       <= Fade_Timer2 - 1;
163
      if( or_reduce(Fade_Timer2) = '0' )then
164
        Fade_Timer2(TIMER_MSB downto TIMER_MSB - 8) <= (others => '1');
165
        Fade_Timer2(TIMER_MSB - 9 downto 0 )        <= (others => '0');
166
      end if;
167
      Fade_out          <= Fade_Timer1(TIMER_MSB) xor Fade_Timer2(TIMER_MSB);
168
    end if;
169
  end process;
170
 
171
end architecture;

powered by: WebSVN 2.1.0

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