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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [gaisler/] [jtag/] [jtagcom.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
------------------------------------------------------------------------------
2
--  This file is a part of the GRLIB VHDL IP LIBRARY
3
--  Copyright (C) 2003, Gaisler Research
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  This program is distributed in the hope that it will be useful,
11
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--  GNU General Public License for more details.
14
--
15
--  You should have received a copy of the GNU General Public License
16
--  along with this program; if not, write to the Free Software
17
--  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
18
-----------------------------------------------------------------------------   
19
-- Entity:      jtagcom
20
-- File:        jtagcom.vhd
21
-- Author:      Edvin Catovic - Gaisler Research
22
-- Description: JTAG Debug Interface with AHB master interface 
23
------------------------------------------------------------------------------
24
 
25
 
26
library ieee;
27
use ieee.std_logic_1164.all;
28
library grlib;
29
use grlib.amba.all;
30
use grlib.stdlib.all;
31
library techmap;
32
use techmap.gencomp.all;
33
library gaisler;
34
use gaisler.libjtagcom.all;
35
use gaisler.misc.all;
36
 
37
entity jtagcom is
38
  generic (
39
    isel   : integer range 0 to 1 := 0;
40
    nsync  : integer range 1 to 2 := 2;
41
    ainst  : integer range 0 to 255 := 2;
42
    dinst  : integer range 0 to 255 := 3);
43
  port (
44
    rst  : in std_ulogic;
45
    clk  : in std_ulogic;
46
    tapo : in tap_out_type;
47
    tapi : out tap_in_type;
48
    dmao : in  ahb_dma_out_type;
49
    dmai : out ahb_dma_in_type
50
    );
51
end;
52
 
53
 
54
architecture rtl of jtagcom is
55
 
56
  constant ADDBITS : integer := 10;
57
  constant NOCMP : boolean := (isel /= 0);
58
 
59
 
60
  type state_type is (shft, ahb);
61
 
62
  type reg_type is record
63
    addr  : std_logic_vector(34 downto 0);
64
    data  : std_logic_vector(32 downto 0);
65
    state : state_type;
66
    tck   : std_logic_vector(nsync-1 downto 0);
67
    tck2  : std_ulogic;
68
    trst  : std_logic_vector(nsync-1 downto 0);
69
    tdi   : std_logic_vector(nsync-1 downto 0);
70
    shift : std_logic_vector(nsync-1 downto 0);
71
    shift2: std_ulogic;
72
    shift3: std_ulogic;
73
    asel  : std_logic_vector(nsync-1 downto 0);
74
    dsel  : std_logic_vector(nsync-1 downto 0);
75
    tdi2  : std_ulogic;
76
  end record;
77
 
78
  signal r, rin : reg_type;
79
 
80
begin
81
 
82
  comb : process (rst, r, tapo, dmao)
83
    variable v : reg_type;
84
    variable redge  : std_ulogic;
85
    variable vdmai : ahb_dma_in_type;
86
    variable asel, dsel : std_ulogic;
87
    variable vtapi : tap_in_type;
88
    variable write, seq : std_ulogic;
89
  begin
90
 
91
    v := r;
92
 
93
    if NOCMP then
94
      asel := tapo.asel; dsel := tapo.dsel;
95
    else
96
      if tapo.inst = conv_std_logic_vector(ainst, 8) then asel := '1'; else asel := '0'; end if;
97
      if tapo.inst = conv_std_logic_vector(dinst, 8) then dsel := '1'; else dsel := '0'; end if;
98
    end if;
99
    write := r.addr(34); seq := r.data(32);
100
 
101
    v.tck(0) := r.tck(nsync-1); v.tck(nsync-1) := tapo.tck; v.tck2 := r.tck(0); v.shift2 := r.shift(0); v.shift3 := r.shift2;
102
    v.trst(0) := r.trst(nsync-1); v.trst(nsync-1) := tapo.reset;
103
    v.tdi(0) := r.tdi(nsync-1); v.tdi(nsync-1) := tapo.tdi;
104
    v.shift(0) := r.shift(nsync-1); v.shift(nsync-1) := tapo.shift;
105
    v.asel(0) := r.asel(nsync-1); v.asel(nsync-1) := asel;
106
    v.dsel(0) := r.dsel(nsync-1); v.dsel(nsync-1) := dsel;
107
    v.tdi2 := r.tdi(0);
108
    redge := not r.tck2 and r.tck(0);
109
    vdmai.address := r.addr(31 downto 0); vdmai.wdata := r.data(31 downto 0);
110
    vdmai.start := '0'; vdmai.burst := '0'; vdmai.write := write;
111
    vdmai.busy := '0'; vdmai.irq := '0'; vdmai.size := r.addr(33 downto 32);
112
 
113
    vtapi.en := r.asel(0) or r.dsel(0);
114
    if r.asel(0) = '1' then vtapi.tdo := r.addr(0); else vtapi.tdo := r.data(0); end if;
115
 
116
    case r.state is
117
      when shft =>
118
        if (r.asel(0) or r.dsel(0)) = '1' then
119
        if r.shift2 = '1' then
120
          if redge = '1' then
121
            if r.asel(0) = '1' then v.addr := r.tdi2 & r.addr(34 downto 1); end if;
122
            if r.dsel(0) = '1' then v.data := r.tdi2 & r.data(32 downto 1); end if;
123
          end if;
124
        elsif r.shift3 = '1' then
125
          if (r.asel(0) and not write) = '1' then v.state := ahb; end if;
126
          if (r.dsel(0) and (write or (not write and seq))) = '1' then -- data register
127
            v.state := ahb;
128
            if (seq and not write) = '1' then
129
              v.addr(ADDBITS-1 downto 2) := r.addr(ADDBITS-1 downto 2) + 1;
130
            end if;
131
          end if;
132
          end if;
133
        end if;
134
        vdmai.size := "00";
135
      when ahb =>
136
        if dmao.active = '1' then
137
          if dmao.ready = '1' then
138
            v.data(31 downto 0) := dmao.rdata;
139
            v.state := shft;
140
            if (write and seq) = '1' then
141
              v.addr(ADDBITS-1 downto 2) := r.addr(ADDBITS-1 downto 2) + 1;
142
            end if;
143
          end if;
144
        else
145
          vdmai.start := '1';
146
        end if;
147
    end case;
148
 
149
    if (rst = '0') or (r.trst(0) = '1') then
150
      v.state := shft; v.addr(34) := '0'; v.data(32) := '0';
151
    end if;
152
 
153
    rin <= v; dmai <= vdmai; tapi <= vtapi;
154
 
155
 
156
  end process;
157
 
158
  reg : process (clk)
159
  begin
160
    if rising_edge(clk) then r <= rin; end if;
161
  end process;
162
 
163
 
164
end;

powered by: WebSVN 2.1.0

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