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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [processor/] [VHDL/] [scarts_core/] [wpt.vhd] - Blame information for rev 3

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      : Template for Extension Module
21
-- Project    : SCARTS - Scalable Processor for Embedded Applications in
22
--              Realtime Environment
23
-------------------------------------------------------------------------------
24
-- File       : ext_watchpoint.vhd
25
-- Author     : Martin Delvai
26
-- Company    : TU Wien - Institut fr Technische Informatik
27
-- Created    : 2007/04/16
28
-- Last update: 2011-03-20
29
-- Platform   : Linux
30
-------------------------------------------------------------------------------
31
-- Description:
32
-------------------------------------------------------------------------------
33
-- Copyright (c) 2007 
34
-------------------------------------------------------------------------------
35
-- Revisions  :
36
-- Date        Version  Author  Description
37
-- 2007-04-16  1.0      delvai  Created
38
-------------------------------------------------------------------------------
39
 
40
library ieee;
41
use ieee.std_logic_1164.all;
42
use ieee.numeric_std.all;
43
 
44
use work.scarts_core_pkg.all;
45
use work.scarts_pkg.all;
46
 
47
entity ext_watchpoint is
48
  generic (
49
    CONF : scarts_conf_type);
50
  port(
51
    -- SCARTS Interface
52
    clk                     : IN  std_logic;
53
    extsel                  : in std_ulogic;
54
    exti                    : in  module_in_type;
55
    exto                    : out module_out_type;
56
    -- Modul specific interface (= Pins) 
57
    read_en : in std_ulogic;
58
    --    write_en : in std_ulogic;
59
    hi_addr : in std_logic_vector(CONF.word_size-1 downto 15) --lower 15 bits in exti.addr
60
        );
61
end ext_watchpoint;
62
 
63
 
64
architecture behaviour of ext_watchpoint is
65
 
66
subtype BYTE is std_logic_vector(7 downto 0);
67
type register_set is array (0 to 31) of BYTE;
68
 
69
 
70
constant CONFIGREG_CUST : integer := 3;
71
constant REG_ACCESS_ADDR : integer := 4; -- to 7
72
constant REG_ADDR0 : integer := 8;
73
constant REG_MASK0 : integer := 12;
74
 
75
 
76
constant C_CONF_R0     : integer := 0;
77
constant C_CONF_W0     : integer := 1;
78
constant C_CONF_R1     : integer := 2;
79
constant C_CONF_W1     : integer := 3;
80
constant C_CONF_R2     : integer := 4;
81
constant C_CONF_W2     : integer := 5;
82
 
83
 
84
 
85
type reg_type is record
86
  ifacereg  : register_set;
87
end record;
88
 
89
 
90
signal r, r_next : reg_type;
91
signal rstint : std_ulogic;
92
 
93
 
94
begin
95
 
96
 
97
comb : process(r, exti, extsel, hi_addr, read_en)
98
  variable v : reg_type;
99
  variable index: integer range 7 downto 0;
100
  variable dummy_addr:std_logic_vector(31 downto 0);
101
  variable access_addr, addr, mask: std_logic_vector(CONF.word_size-1 downto 0);
102
begin
103
  -- Default Values
104
  v := r;
105
  index := to_integer(unsigned(exti.addr(4 downto 2)));
106
    --schreiben
107
    if ((extsel = '1') and (exti.write_en = '1')) then
108
      case exti.addr(4 downto 2) is
109
        when "000" =>
110
          if ((exti.byte_en(0) = '1') or (exti.byte_en(1) = '1')) then
111
            v.ifacereg(STATUSREG)(STA_INT) := '1';
112
            v.ifacereg(CONFIGREG)(CONF_INTA) :='0';
113
          else
114
            if ((exti.byte_en(2) = '1')) then
115
              v.ifacereg(2) := exti.data(23 downto 16);
116
            end if;
117
            if ((exti.byte_en(3) = '1')) then
118
              v.ifacereg(3) := exti.data(31 downto 24);
119
            end if;
120
          end if;
121
        when others =>
122
          if ((exti.byte_en(0) = '1')) then
123
            v.ifacereg(index*4) := exti.data(7 downto 0);
124
          end if;
125
          if ((exti.byte_en(1) = '1')) then
126
            v.ifacereg(index*4+1) := exti.data(15 downto 8);
127
          end if;
128
          if ((exti.byte_en(2) = '1')) then
129
            v.ifacereg(index*4+2) := exti.data(23 downto 16);
130
          end if;
131
          if ((exti.byte_en(3) = '1')) then
132
            v.ifacereg(index*4+3) := exti.data(31 downto 24);
133
          end if;
134
        --when others =>
135
          --null;
136
      end case;
137
    end if;
138
 
139
    --auslesen
140
    exto.data <= (others => '0');
141
    if ((extsel = '1') and (exti.write_en = '0')) then
142
      case exti.addr(4 downto 2) is
143
        when "000" =>
144
          exto.data <= r.ifacereg(3) & r.ifacereg(2) & r.ifacereg(1) & r.ifacereg(0);
145
        when "001" =>
146
          if (r.ifacereg(CONFIGREG)(CONF_ID) = '1') then
147
            exto.data <= MODULE_VER & MODULE_ID;
148
          else
149
            exto.data <= r.ifacereg(index*4+3) & r.ifacereg(index*4+2)
150
                & r.ifacereg(index*4+1) & r.ifacereg(index*4);
151
          end if;
152
        when others =>
153
            exto.data <= r.ifacereg(index*4+3) & r.ifacereg(index*4+2)
154
                & r.ifacereg(index*4+1) & r.ifacereg(index*4);
155
      end case;
156
    end if;
157
 
158
 
159
    --berechnen der neuen status flags
160
    v.ifacereg(STATUSREG)(STA_LOOR) := r.ifacereg(CONFIGREG)(CONF_LOOW);
161
    v.ifacereg(STATUSREG)(STA_FSS) := '0';
162
    v.ifacereg(STATUSREG)(STA_RESH) := '0';
163
    v.ifacereg(STATUSREG)(STA_RESL) := '0';
164
    v.ifacereg(STATUSREG)(STA_BUSY) := '0';
165
    v.ifacereg(STATUSREG)(STA_ERR) := '0';
166
    v.ifacereg(STATUSREG)(STA_RDY) := '1';
167
 
168
    -- Output soll Defaultmassig auf eingeschalten sie 
169
    v.ifacereg(CONFIGREG)(CONF_OUTD) := '1';
170
 
171
    --soft- und hard-reset vereinen
172
    rstint <= not RST_ACT;
173
    if exti.reset = RST_ACT or r.ifacereg(CONFIGREG)(CONF_SRES) = '1' then
174
      rstint <= RST_ACT;
175
    end if;
176
 
177
    --Interrupt Behandlung 
178
    if r.ifacereg(CONFIGREG)(CONF_INTA) = '1' then
179
      v.ifacereg(STATUSREG)(STA_INT)   := '0';
180
      v.ifacereg(CONFIGREG)(CONF_INTA) := '0';
181
    end if;
182
 
183
    exto.intreq <= r.ifacereg(STATUSREG)(STA_INT);
184
 
185
  -- Module Specific part
186
        access_addr := hi_addr & exti.addr;
187
 
188
    for i in 2 downto 0 loop
189
            if CONF.word_size = 16 then
190
                        addr := r.ifacereg(REG_ADDR0+i*8+1) & r.ifacereg(REG_ADDR0+i*8);
191
                        mask := r.ifacereg(REG_MASK0+i*8+1) & r.ifacereg(REG_MASK0+i*8);
192
                else
193
                        addr := r.ifacereg(REG_ADDR0+i*8+3) & r.ifacereg(REG_ADDR0+i*8+2)
194
                                        & r.ifacereg(REG_ADDR0+i*8+1) & r.ifacereg(REG_ADDR0+i*8);
195
                        mask := r.ifacereg(REG_MASK0+i*8+3) & r.ifacereg(REG_MASK0+i*8+2)
196
                                        & r.ifacereg(REG_MASK0+i*8+1) & r.ifacereg(REG_MASK0+i*8);
197
                end if;
198
 
199
                if ((access_addr or mask) = (addr or mask)) then
200
                        if (read_en = '1' and r.ifacereg(CONFIGREG_CUST)(C_CONF_R0 + i*2) = '1')
201
                                or (exti.write_en = '1' and r.ifacereg(CONFIGREG_CUST)(C_CONF_W0 + i*2) = '1')
202
                        then
203
                                v.ifacereg(STATUSREG)(STA_INT) := '1';
204
                                v.ifacereg(REG_ACCESS_ADDR) := access_addr(7 downto 0);
205
                                v.ifacereg(REG_ACCESS_ADDR+1) := access_addr(15 downto 8);
206
                                v.ifacereg(REG_ACCESS_ADDR+2) := access_addr(23 downto 16);
207
                                v.ifacereg(REG_ACCESS_ADDR+3) := access_addr(31 downto 24);
208
                        end if;
209
        end if;
210
        end loop;
211
--   end process mod_specific;
212
 
213
  r_next <= v;
214
end process;
215
 
216
 
217
 
218
-- Synchronous process 
219
  reg : process(clk)
220
  begin
221
    if rising_edge(clk) then
222
      if rstint = RST_ACT then
223
        r.ifacereg <= (others => (others => '0'));
224
      else
225
        r <= r_next;
226
      end if;
227
    end if;
228
  end process;
229
 
230
 
231
 
232
 
233
end behaviour;

powered by: WebSVN 2.1.0

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