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

Subversion Repositories scarts

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

powered by: WebSVN 2.1.0

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