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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [processor/] [VHDL/] [ext_modules/] [ext_breakpoint/] [ext_breakpoint.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_breakpoint.vhd
25
-- Author     : Martin Delvai
26
-- Company    : TU Wien - Institut fr Technische Informatik
27
-- Created    : 2007/04/16
28
-- Last update: 2011-03-17
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_pkg.all;
45
use work.scarts_core_pkg.all;
46
use work.pkg_breakpoint.all;
47
 
48
 
49
architecture behaviour of ext_breakpoint is
50
 
51
subtype BYTE is std_logic_vector(7 downto 0);
52
type register_set is array (0 to 31) of BYTE;
53
 
54
--signal mul_result : std_logic_vector(63 downto 0);
55
 
56
constant CONFIGREG_CUST : integer := 3;
57
 
58
 
59
type reg_type is record
60
  ifacereg  : register_set;
61
end record;
62
 
63
 
64
signal r, r_next : reg_type;
65
signal do_trap, do_trap_next : std_ulogic;
66
signal rstint : std_ulogic;
67
 
68
 
69
begin
70
 
71
 
72
comb : process(r, exti, extsel, debugo_raddr)
73
  variable v : reg_type;
74
  variable anz: integer range 7 downto 0;
75
  variable index: integer range 7 downto 0;
76
  variable dummy_addr:std_logic_vector(31 downto 0);
77
begin
78
  -- Default Values
79
 
80
  do_trap_next <= '0';
81
 
82
  v := r;
83
  index := to_integer(unsigned(exti.addr(4 downto 2)));
84
    --schreiben
85
    if ((extsel = '1') and (exti.write_en = '1')) then
86
      case exti.addr(4 downto 2) is
87
        when "000" =>
88
          if ((exti.byte_en(0) = '1') or (exti.byte_en(1) = '1')) then
89
            v.ifacereg(STATUSREG)(STA_INT) := '1';
90
            v.ifacereg(CONFIGREG)(CONF_INTA) :='0';
91
          else
92
            if ((exti.byte_en(2) = '1')) then
93
              v.ifacereg(2) := exti.data(23 downto 16);
94
            end if;
95
            if ((exti.byte_en(3) = '1')) then
96
              v.ifacereg(3) := exti.data(31 downto 24);
97
            end if;
98
          end if;
99
        when others =>
100
          if ((exti.byte_en(0) = '1')) then
101
            v.ifacereg(index*4) := exti.data(7 downto 0);
102
          end if;
103
          if ((exti.byte_en(1) = '1')) then
104
            v.ifacereg(index*4+1) := exti.data(15 downto 8);
105
          end if;
106
          if ((exti.byte_en(2) = '1')) then
107
            v.ifacereg(index*4+2) := exti.data(23 downto 16);
108
          end if;
109
          if ((exti.byte_en(3) = '1')) then
110
            v.ifacereg(index*4+3) := exti.data(31 downto 24);
111
          end if;
112
        --when others =>
113
          --null;
114
      end case;
115
    end if;
116
 
117
    --auslesen
118
    exto.data <= (others => '0');
119
    if ((extsel = '1') and (exti.write_en = '0')) then
120
      case exti.addr(4 downto 2) is
121
        when "000" =>
122
          exto.data <= r.ifacereg(3) & r.ifacereg(2) & r.ifacereg(1) & r.ifacereg(0);
123
        when "001" =>
124
          if (r.ifacereg(CONFIGREG)(CONF_ID) = '1') then
125
            exto.data <= MODULE_VER & MODULE_ID;
126
          else
127
            exto.data <= r.ifacereg(index*4+3) & r.ifacereg(index*4+2)
128
                & r.ifacereg(index*4+1) & r.ifacereg(index*4);
129
          end if;
130
        when others =>
131
            exto.data <= r.ifacereg(index*4+3) & r.ifacereg(index*4+2)
132
                & r.ifacereg(index*4+1) & r.ifacereg(index*4);
133
      end case;
134
    end if;
135
 
136
 
137
    --berechnen der neuen status flags
138
    v.ifacereg(STATUSREG)(STA_LOOR) := r.ifacereg(CONFIGREG)(CONF_LOOW);
139
    v.ifacereg(STATUSREG)(STA_FSS) := '0';
140
    v.ifacereg(STATUSREG)(STA_RESH) := '0';
141
    v.ifacereg(STATUSREG)(STA_RESL) := '0';
142
    v.ifacereg(STATUSREG)(STA_BUSY) := '0';
143
    v.ifacereg(STATUSREG)(STA_ERR) := '0';
144
    v.ifacereg(STATUSREG)(STA_RDY) := '1';
145
 
146
    -- Output soll Defaultmassig auf eingeschalten sie 
147
    v.ifacereg(CONFIGREG)(CONF_OUTD) := '1';
148
 
149
    --soft- und hard-reset vereinen
150
    rstint <= not RST_ACT;
151
    if exti.reset = RST_ACT or r.ifacereg(CONFIGREG)(CONF_SRES) = '1' then
152
      rstint <= RST_ACT;
153
    end if;
154
 
155
    --Interrupt Behandlung 
156
    if r.ifacereg(CONFIGREG)(CONF_INTA) = '1' then
157
      v.ifacereg(STATUSREG)(STA_INT)   := '0';
158
      v.ifacereg(CONFIGREG)(CONF_INTA) := '0';
159
    end if;
160
 
161
    exto.intreq <= r.ifacereg(STATUSREG)(STA_INT);
162
 
163
 
164
  -- Module Specific part
165
  if r.ifacereg(CONFIGREG_CUST)(6 downto 3) /= "0000" then
166
    --Single Stepping. 
167
--    if pc /= s_debugo_pc then
168
      -- Decrement single-step counter whenever an instruction is executed.
169
      v.ifacereg(CONFIGREG_CUST)(6 downto 3) := std_logic_vector(UNSIGNED(r.ifacereg(CONFIGREG_CUST)(6 downto 3)) - 1);
170
      if v.ifacereg(CONFIGREG_CUST)(6 downto 3) = "0000" then
171
            --Counter reached zero. Raise interrupt.
172
            v.ifacereg(STATUSREG)(STA_INT) := '1';
173
      end if;
174
--    end if;
175
  elsif r.ifacereg(CONFIGREG_CUST)(7) = '1' -- Enabled
176
    and r.ifacereg(CONFIGREG_CUST)(2 downto 0) /= "000" then
177
--    --Compare breakpoint-addresses with current PC.
178
    anz := to_integer(UNSIGNED(r.ifacereg(CONFIGREG_CUST)(2 downto 0)));
179
    dummy_addr := (others => '0');
180
    dummy_addr(INSTR_RAM_CFG_C-1 downto 0) := debugo_raddr;
181
 
182
    for i in 7 downto 1 loop
183
      if anz >= i then
184
        if v.ifacereg(4*i + 0) = dummy_addr(7 downto 0)
185
          and v.ifacereg(4*i + 1) = dummy_addr(15 downto 8)
186
          --Add the next 2 lines for 32-Bit configurations.
187
          and (WORD_CFG_C = 1 or v.ifacereg(4*i + 2) = dummy_addr(23 downto 16))
188
          and (WORD_CFG_C = 1 or v.ifacereg(4*i + 3) = dummy_addr(31 downto 24))
189
        then
190
          --Breapoint hit. Return TRAP0 as opcode.
191
          do_trap_next <= '1';
192
        end if;
193
      end if;
194
    end loop;
195
  end if;
196
 
197
--  s_debugo_pc_next <= pc;
198
 
199
  r_next <= v;
200
end process;
201
 
202
 
203
  -- Module Specific part
204
 
205
--  mod_specific: process (r)
206
--  begin  -- process mod_specific
207
 
208
-- Multiplikation von 2 32 Bit Zahlen:
209
--   mul_result <= (r.ifacereg(4)&r.ifacereg(5)) *(r.ifacereg(6)&r.ifacereg(7));
210
 
211
--   end process mod_specific;
212
 
213
 
214
-- Synchronous process 
215
  reg : process(clk)
216
  begin
217
    if rising_edge(clk) then
218
      if rstint = RST_ACT then
219
        r.ifacereg <= (others => (others => '0'));
220
        do_trap <= '0';
221
      else
222
        r <= r_next;
223
        do_trap <= do_trap_next;
224
      end if;
225
    end if;
226
  end process;
227
 
228
 
229
  output : process(do_trap, debugo_rdata, watchpoint_act)
230
  begin
231
    if do_trap = '1'
232
        or watchpoint_act = '1' --Watchpoints can asynchronously request generation of Trap-instructions. 
233
    then
234
      debugi_rdata <= "1110101100000000"; --TRAP0
235
    else
236
      debugi_rdata <= debugo_rdata;
237
    end if;
238
  end process;
239
 
240
 
241
end behaviour;

powered by: WebSVN 2.1.0

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