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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [processor/] [VHDL/] [ext_modules/] [ext_Dis7Seg/] [ext_Dis7Seg.vhd] - Blame information for rev 7

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

Line No. Rev Author Line
1 3 jlechner
-----------------------------------------------------------------------
2
-- This file is part of SCARTS.
3
-- 
4
-- SCARTS is free software: you can redistribute it and/or modify
5
-- it under the terms of the GNU General Public License as published by
6
-- the Free Software Foundation, either version 3 of the License, or
7
-- (at your option) any later version.
8
-- 
9
-- SCARTS is distributed in the hope that it will be useful,
10
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-- GNU General Public License for more details.
13
-- 
14
-- You should have received a copy of the GNU General Public License
15
-- along with SCARTS.  If not, see <http://www.gnu.org/licenses/>.
16
-----------------------------------------------------------------------
17
 
18
 
19
-------------------------------------------------------------------------------
20
-- Title      : 7 Segment Display Architecture
21
-- Project    : SCARTS - Scalable Processor for Embedded Applications in
22
--              Realtime Environment
23
-------------------------------------------------------------------------------
24
-- File       : ext_display7seg.vhd
25
-- Author     : Dipl. Ing. Martin Delvai
26
-- Company    : TU Wien - Institut fr Technische Informatik
27
-- Created    : 2002-04-16
28
-- Last update: 2011-03-24
29
-- Platform   : SUN Solaris
30
-------------------------------------------------------------------------------
31
-- Description:
32
-- This module can be used for controlling a multi-digit sevensegment display.
33
-- The digits can be controlled in parallel or can be multipled with an
34
-- adjustable prescaler.
35
-------------------------------------------------------------------------------
36
-- Copyright (c) 2011
37
-------------------------------------------------------------------------------
38
-- Revisions  :
39
-- Date        Version  Author  Description
40
-- 2002-04-16  1.0      delvai  Created
41
-------------------------------------------------------------------------------
42
 
43
library ieee;
44
use ieee.std_logic_1164.all;
45
use ieee.numeric_std.all;
46
 
47
use work.scarts_pkg.all;
48
use work.pkg_dis7seg.all;
49
 
50
architecture behaviour of ext_Dis7Seg is
51
 
52
subtype byte is std_logic_vector(7 downto 0);
53
subtype nibble is std_logic_vector(3 downto 0);
54
type register_set is array (0 to 7) of byte;
55
type digit_data_t is array (DIGIT_COUNT-1 downto 0) of nibble;
56
 
57
constant STATUSREG_CUST : integer := 1;
58
constant CONFIGREG_CUST : integer := 3;
59
 
60
constant ZEROVALUE      : std_logic_vector(15 downto 0) := (others => '0');
61
constant PRESCALE_VALUE : std_logic_vector(15 downto 0) := (others => '1');
62
 
63
constant PRESCALER_LOW      : integer := 4;
64
constant PRESCALER_HIGH     : integer := 5;
65
constant CMD_REG            : integer := 6;
66
constant VALUE_REG          : integer := 7;
67
 
68
constant CMD_SETVALUE : std_logic_vector(1 downto 0) := "01";
69
constant CMD_SETDOT   : std_logic_vector(1 downto 0) := "10";
70
constant CMD_GETVALUE : std_logic_vector(1 downto 0) := "11";
71
 
72
type reg_type is record
73
  ifacereg   : register_set;
74
  digit_data : digit_data_t;
75
  digit_out  : digit_vector_t(DIGIT_COUNT-1 downto 0);
76
end record;
77
 
78
 
79
signal r_next : reg_type;
80
signal r : reg_type :=
81
  (
82
    ifacereg => ((PRESCALER_LOW) => (others => '1'),
83
                (PRESCALER_HIGH) => (others => '1'),
84
                others => (others => '0')),
85
    digit_data => (others => (others => '0')),
86
    digit_out  => (others => (others => '1'))
87
  );
88
 
89
signal rstint : std_ulogic;
90
 
91
begin
92
 
93
 
94
  comb : process(r, exti, extsel)
95
    variable v : reg_type;
96
    variable v_digit_index : integer range 0 to DIGIT_COUNT-1;
97
  begin
98
    v := r;
99
 
100
    -- write memory mapped addresses
101
    if ((extsel = '1') and (exti.write_en = '1')) then
102
      case exti.addr(4 downto 2) is
103
        when "000" =>
104
          if ((exti.byte_en(0) = '1') or (exti.byte_en(1) = '1')) then
105
            v.ifacereg(STATUSREG)(STA_INT) := '1';
106
            v.ifacereg(CONFIGREG)(CONF_INTA) :='0';
107
          else
108
            if ((exti.byte_en(2) = '1')) then
109
              v.ifacereg(2) := exti.data(23 downto 16);
110
            end if;
111
            if ((exti.byte_en(3) = '1')) then
112
              v.ifacereg(3) := exti.data(31 downto 24);
113
            end if;
114
          end if;
115
        when "001" =>
116
          if ((exti.byte_en(0) = '1')) then
117
            v.ifacereg(4) := exti.data(7 downto 0);
118
          end if;
119
          if ((exti.byte_en(1) = '1')) then
120
            v.ifacereg(5) := exti.data(15 downto 8);
121
          end if;
122
          if ((exti.byte_en(2) = '1')) then
123
            v.ifacereg(6) := exti.data(23 downto 16);
124
          end if;
125
          if ((exti.byte_en(3) = '1')) then
126
            v.ifacereg(7) := exti.data(31 downto 24);
127
          end if;
128
        when others =>
129
          null;
130
      end case;
131
    end if;
132
 
133
    -- read memory mapped addresses
134
    exto.data <= (others => '0');
135
    if ((extsel = '1') and (exti.write_en = '0')) then
136
      case exti.addr(4 downto 2) is
137
        when "000" =>
138
          exto.data <= r.ifacereg(3) & r.ifacereg(2) & r.ifacereg(1) & r.ifacereg(0);
139
        when "001" =>
140
          if (r.ifacereg(CONFIGREG)(CONF_ID) = '1') then
141
            exto.data <= MODULE_VER & MODULE_ID;
142
          else
143
            exto.data <= r.ifacereg(7) & r.ifacereg(6) & r.ifacereg(5) & r.ifacereg(4);
144
          end if;
145
        when others =>
146
          null;
147
      end case;
148
    end if;
149
 
150
    -- compute status flags
151
    v.ifacereg(STATUSREG)(STA_LOOR) := r.ifacereg(CONFIGREG)(CONF_LOOW);
152
    v.ifacereg(STATUSREG)(STA_FSS) := '0';
153
    v.ifacereg(STATUSREG)(STA_RESH) := '0';
154
    v.ifacereg(STATUSREG)(STA_RESL) := '0';
155
    v.ifacereg(STATUSREG)(STA_BUSY) := '0';
156
    v.ifacereg(STATUSREG)(STA_ERR) := '0';
157
    v.ifacereg(STATUSREG)(STA_RDY) := '1';
158
 
159
    -- set output enabled (default)
160
    v.ifacereg(CONFIGREG)(CONF_OUTD) := '1';
161
 
162
    -- module specific part
163
    DisEna <=  r.ifacereg(CONFIGREG)(CONF_OUTD);
164
 
165
    v_digit_index := to_integer(unsigned(r.ifacereg(CMD_REG)(5 downto 0)));
166
 
167
    if v_digit_index < DIGIT_COUNT then
168
      case r.ifacereg(CMD_REG)(7 downto 6) is
169
        when CMD_SETVALUE =>
170
          v.digit_data(v_digit_index) := r.ifacereg(VALUE_REG)(3 downto 0);
171
          v.digit_out(v_digit_index) := bin2digit(r.ifacereg(VALUE_REG)(3 downto 0));
172
        when CMD_GETVALUE =>
173
          v.ifacereg(VALUE_REG) := "0000" & v.digit_data(v_digit_index);
174
        when others => null;
175
      end case;
176
    end if;
177
 
178
    -- combine soft- and hard-reset
179
    rstint <= not RST_ACT;
180
    if exti.reset = RST_ACT or r.ifacereg(CONFIGREG)(CONF_SRES) = '1' then
181
      rstint <= RST_ACT;
182
    end if;
183
 
184
    -- reset interrupt
185
    if r.ifacereg(STATUSREG)(STA_INT) = '1' and r.ifacereg(CONFIGREG)(CONF_INTA) ='0' then
186
      v.ifacereg(STATUSREG)(STA_INT) := '0';
187
    end if;
188
    exto.intreq <= r.ifacereg(STATUSREG)(STA_INT);
189
 
190
    r_next <= v;
191
  end process;
192
 
193
 
194
  muliplexed_7seg: if MULTIPLEXED = 1 generate
195
 
196
    signal sel, sel_next               : integer range 0 to DIGIT_COUNT-1;
197
    signal count, count_next           : std_logic_vector(15 downto 0);
198
 
199
  begin
200
 
201
    process (r, count, sel)
202
    begin  -- process
203
                sel_next <= sel;
204
      if count = ZEROVALUE then
205
        count_next(7 downto 0) <= r.ifacereg(PRESCALER_LOW);
206
        count_next(15 downto 8) <= r.ifacereg(PRESCALER_HIGH);
207
        if sel = DIGIT_COUNT-1 then
208
          sel_next <= 0;
209
        else
210
          sel_next <= sel + 1;
211
        end if;
212
      else
213
        count_next <= std_logic_vector(unsigned(count) - 1);
214
      end if;
215
    end process;
216
 
217
    reg : process(clk)
218
    begin
219
      if rising_edge(clk) then
220
        if rstint = RST_ACT then
221
          count <= (others => '0');
222
          sel <= 0;
223
        else
224
          count <= count_next;
225
          sel <= sel_next;
226
        end if;
227
      end if;
228
    end process;
229
 
230
    digits(0) <= r.digit_out(sel);
231
 
232
    process (sel)
233
    begin
234
      PIN_select <= (others => '0');
235
      PIN_select(sel) <= '1';
236
    end process;
237
 
238
  end generate muliplexed_7seg;
239
 
240
 
241
  parallel_7seg: if MULTIPLEXED = 0 generate
242
    PIN_select <= (others => '0');
243
    digits <= r.digit_out;
244
  end generate parallel_7seg;
245
 
246
 
247
  reg : process(clk)
248
  begin
249
    if rising_edge(clk) then
250
      if rstint = RST_ACT then
251
        r.ifacereg <= ((PRESCALER_LOW) => (others => '1'),
252
                    (PRESCALER_HIGH) => (others => '1'),
253
                    others => (others => '0'));
254
        r.digit_data <= (others => (others => '0'));
255
        r.digit_out  <= (others => (others => '1'));
256
      else
257
        r <= r_next;
258
      end if;
259
    end if;
260
  end process;
261
 
262
 
263
end behaviour;

powered by: WebSVN 2.1.0

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