| 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: 2009-04-29
|
| 29 |
|
|
-- Platform : SUN Solaris
|
| 30 |
|
|
-------------------------------------------------------------------------------
|
| 31 |
|
|
-- Description:
|
| 32 |
|
|
-- Dieses Module kann zum Ansteuern eines vierstelligen 7 Segment Modules verwendet
|
| 33 |
|
|
-- werden. Die vier Anzeigen werden gemultiplext angesteuer.
|
| 34 |
|
|
-- Durch einen Prescaler kann man die Frequenz des weiterschaltens einsetellen.
|
| 35 |
|
|
-- Zus?zlich besitzt es noch einen 8 Bit Ausgang zum Ansteuern von z.B. LEDs
|
| 36 |
|
|
-------------------------------------------------------------------------------
|
| 37 |
|
|
-- Copyright (c) 2002
|
| 38 |
|
|
-------------------------------------------------------------------------------
|
| 39 |
|
|
-- Revisions :
|
| 40 |
|
|
-- Date Version Author Description
|
| 41 |
|
|
-- 2002-04-16 1.0 delvai Created
|
| 42 |
|
|
-------------------------------------------------------------------------------
|
| 43 |
|
|
|
| 44 |
|
|
library ieee;
|
| 45 |
|
|
use ieee.std_logic_1164.all;
|
| 46 |
|
|
use ieee.numeric_std.all;
|
| 47 |
|
|
|
| 48 |
|
|
use work.pkg_basic.all;
|
| 49 |
|
|
use work.pkg_scarts.all;
|
| 50 |
|
|
use work.pkg_counter.all;
|
| 51 |
|
|
|
| 52 |
|
|
architecture behaviour of ext_counter is
|
| 53 |
|
|
|
| 54 |
|
|
subtype BYTE is std_logic_vector(7 downto 0);
|
| 55 |
|
|
type register_set is array (0 to 3) of BYTE;
|
| 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 |
|
|
|
| 62 |
|
|
constant COUNTER_BYTE0 : integer := 4;
|
| 63 |
|
|
constant COUNTER_BYTE1 : integer := 5;
|
| 64 |
|
|
constant COUNTER_BYTE2 : integer := 6;
|
| 65 |
|
|
constant COUNTER_BYTE3 : integer := 7;
|
| 66 |
|
|
|
| 67 |
|
|
type reg_type is record
|
| 68 |
|
|
ifacereg : register_set;
|
| 69 |
|
|
counter : std_logic_vector(31 downto 0);
|
| 70 |
|
|
end record;
|
| 71 |
|
|
|
| 72 |
|
|
|
| 73 |
|
|
signal r_next : reg_type;
|
| 74 |
|
|
signal r : reg_type :=
|
| 75 |
|
|
(
|
| 76 |
|
|
ifacereg => (others => (others => '0')),
|
| 77 |
|
|
counter => (others => '0')
|
| 78 |
|
|
);
|
| 79 |
|
|
|
| 80 |
|
|
signal rstint : std_ulogic;
|
| 81 |
|
|
|
| 82 |
|
|
begin
|
| 83 |
|
|
|
| 84 |
|
|
|
| 85 |
|
|
comb : process(r, exti, extsel)
|
| 86 |
|
|
variable v : reg_type;
|
| 87 |
|
|
begin
|
| 88 |
|
|
v := r;
|
| 89 |
|
|
|
| 90 |
|
|
--schreiben
|
| 91 |
|
|
if ((extsel = '1') and (exti.write_en = '1')) then
|
| 92 |
|
|
case exti.addr(4 downto 2) is
|
| 93 |
|
|
when "000" =>
|
| 94 |
|
|
if ((exti.byte_en(0) = '1') or (exti.byte_en(1) = '1')) then
|
| 95 |
|
|
v.ifacereg(STATUSREG)(STA_INT) := '1';
|
| 96 |
|
|
v.ifacereg(CONFIGREG)(CONF_INTA) :='0';
|
| 97 |
|
|
else
|
| 98 |
|
|
if ((exti.byte_en(2) = '1')) then
|
| 99 |
|
|
v.ifacereg(2) := exti.data(23 downto 16);
|
| 100 |
|
|
end if;
|
| 101 |
|
|
if ((exti.byte_en(3) = '1')) then
|
| 102 |
|
|
v.ifacereg(3) := exti.data(31 downto 24);
|
| 103 |
|
|
end if;
|
| 104 |
|
|
end if;
|
| 105 |
|
|
when "001" =>
|
| 106 |
|
|
if ((exti.byte_en(0) = '1')) then
|
| 107 |
|
|
v.counter(7 downto 0) := exti.data(7 downto 0);
|
| 108 |
|
|
end if;
|
| 109 |
|
|
if ((exti.byte_en(1) = '1')) then
|
| 110 |
|
|
v.counter(15 downto 8) := exti.data(15 downto 8);
|
| 111 |
|
|
end if;
|
| 112 |
|
|
if ((exti.byte_en(2) = '1')) then
|
| 113 |
|
|
v.counter(23 downto 16) := exti.data(23 downto 16);
|
| 114 |
|
|
end if;
|
| 115 |
|
|
if ((exti.byte_en(3) = '1')) then
|
| 116 |
|
|
v.counter(31 downto 24) := exti.data(31 downto 24);
|
| 117 |
|
|
end if;
|
| 118 |
|
|
when others =>
|
| 119 |
|
|
null;
|
| 120 |
|
|
end case;
|
| 121 |
|
|
end if;
|
| 122 |
|
|
|
| 123 |
|
|
--auslesen
|
| 124 |
|
|
exto.data <= (others => '0');
|
| 125 |
|
|
if ((extsel = '1') and (exti.write_en = '0')) then
|
| 126 |
|
|
case exti.addr(4 downto 2) is
|
| 127 |
|
|
when "000" =>
|
| 128 |
|
|
exto.data <= r.ifacereg(3) & r.ifacereg(2) & r.ifacereg(1) & r.ifacereg(0);
|
| 129 |
|
|
when "001" =>
|
| 130 |
|
|
if (r.ifacereg(CONFIGREG)(CONF_ID) = '1') then
|
| 131 |
|
|
exto.data <= MODULE_VER & MODULE_ID;
|
| 132 |
|
|
else
|
| 133 |
|
|
exto.data <= r.counter;
|
| 134 |
|
|
end if;
|
| 135 |
|
|
when others =>
|
| 136 |
|
|
null;
|
| 137 |
|
|
end case;
|
| 138 |
|
|
end if;
|
| 139 |
|
|
|
| 140 |
|
|
|
| 141 |
|
|
--berechnen der neuen status flags
|
| 142 |
|
|
v.ifacereg(STATUSREG)(STA_LOOR) := r.ifacereg(CONFIGREG)(CONF_LOOW);
|
| 143 |
|
|
v.ifacereg(STATUSREG)(STA_FSS) := '0';
|
| 144 |
|
|
v.ifacereg(STATUSREG)(STA_RESH) := '0';
|
| 145 |
|
|
v.ifacereg(STATUSREG)(STA_RESL) := '0';
|
| 146 |
|
|
v.ifacereg(STATUSREG)(STA_BUSY) := '0';
|
| 147 |
|
|
v.ifacereg(STATUSREG)(STA_ERR) := '0';
|
| 148 |
|
|
v.ifacereg(STATUSREG)(STA_RDY) := '1';
|
| 149 |
|
|
|
| 150 |
|
|
-- Output soll Defaultmassig auf eingeschalten sie
|
| 151 |
|
|
v.ifacereg(CONFIGREG)(CONF_OUTD) := '1';
|
| 152 |
|
|
|
| 153 |
|
|
|
| 154 |
|
|
--soft- und hard-reset vereinen
|
| 155 |
|
|
rstint <= not RST_ACT;
|
| 156 |
|
|
if exti.reset = RST_ACT or r.ifacereg(CONFIGREG)(CONF_SRES) = '1' then
|
| 157 |
|
|
rstint <= RST_ACT;
|
| 158 |
|
|
end if;
|
| 159 |
|
|
|
| 160 |
|
|
-- Interrupt
|
| 161 |
|
|
if r.ifacereg(STATUSREG)(STA_INT) = '1' and r.ifacereg(CONFIGREG)(CONF_INTA) ='0' then
|
| 162 |
|
|
v.ifacereg(STATUSREG)(STA_INT) := '0';
|
| 163 |
|
|
end if;
|
| 164 |
|
|
exto.intreq <= r.ifacereg(STATUSREG)(STA_INT);
|
| 165 |
|
|
|
| 166 |
|
|
--module specific part
|
| 167 |
|
|
v.counter := r.counter;
|
| 168 |
|
|
|
| 169 |
|
|
if r.ifacereg(MY_CONFIGREG)(CMD_COUNT) = '1' then
|
| 170 |
|
|
v.counter := STD_LOGIC_VECTOR(UNSIGNED(r.counter) + 1);
|
| 171 |
|
|
elsif r.ifacereg(MY_CONFIGREG)(CMD_CLEAR) = '1' then
|
| 172 |
|
|
v.counter := (others => '0');
|
| 173 |
|
|
end if;
|
| 174 |
|
|
|
| 175 |
|
|
r_next <= v;
|
| 176 |
|
|
end process;
|
| 177 |
|
|
|
| 178 |
|
|
reg : process(clk)
|
| 179 |
|
|
begin
|
| 180 |
|
|
if rising_edge(clk) then
|
| 181 |
|
|
if rstint = RST_ACT then
|
| 182 |
|
|
r.ifacereg <= (others => (others => '0'));
|
| 183 |
|
|
r.counter <= (others => '0');
|
| 184 |
|
|
else
|
| 185 |
|
|
r <= r_next;
|
| 186 |
|
|
end if;
|
| 187 |
|
|
end if;
|
| 188 |
|
|
end process;
|
| 189 |
|
|
|
| 190 |
|
|
end behaviour;
|