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

Subversion Repositories core_arm

[/] [core_arm/] [trunk/] [vhdl/] [sparc/] [dcom.vhd] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tarookumic
 
2
 
3
 
4
 
5
----------------------------------------------------------------------------
6
--  This file is a part of the LEON VHDL model
7
--  Copyright (C) 1999  European Space Agency (ESA)
8
--
9
--  This library is free software; you can redistribute it and/or
10
--  modify it under the terms of the GNU Lesser General Public
11
--  License as published by the Free Software Foundation; either
12
--  version 2 of the License, or (at your option) any later version.
13
--
14
--  See the file COPYING.LGPL for the full details of the license.
15
 
16
 
17
-----------------------------------------------------------------------------   
18
-- Entity:      dcom
19
-- File:        dcom.vhd
20
-- Author:      Jiri Gaisler - Gaisler Research
21
-- Description: UART for debug support unit
22
------------------------------------------------------------------------------  
23
 
24
library IEEE;
25
use IEEE.std_logic_1164.all;
26
use IEEE.std_logic_unsigned."-";
27
use IEEE.std_logic_unsigned."+";
28
use IEEE.std_logic_arith.conv_unsigned;
29
use work.macro.all;
30
use work.amba.all;
31
use work.ambacomp.all;
32
use work.leon_iface.all;
33
 
34
 
35
entity dcom is
36
   port (
37
      rst    : in  std_logic;
38
      clk    : in  clk_type;
39
      dcomi  : in  dcom_in_type;
40
      dcomo  : out dcom_out_type;
41
      dsuo   : in  dsu_out_type;
42
      apbi   : in  apb_slv_in_type;
43
      apbo   : out apb_slv_out_type;
44
      ahbi : in  ahb_mst_in_type;
45
      ahbo : out ahb_mst_out_type
46
      );
47
end;
48
 
49
architecture struct of dcom is
50
 
51
type dcom_state_type is (idle, addr1, read1, read2, write1, write2);
52
 
53
type reg_type is record
54
  addr    : std_logic_vector(31 downto 0);
55
  data    : std_logic_vector(31 downto 0);
56
  len     : std_logic_vector(5 downto 0);
57
  write   : std_logic;
58
  clen    : std_logic_vector(1 downto 0);
59
  state   : dcom_state_type;
60
  hresp   : std_logic_vector(1 downto 0);
61
  txresp  : std_logic;
62
  dmode   : std_logic;
63
  dsuact  : std_logic;
64
end record;
65
 
66
signal r, rin : reg_type;
67
signal dmai : ahb_dma_in_type;
68
signal dmao : ahb_dma_out_type;
69
signal uarti : dcom_uart_in_type;
70
signal uarto : dcom_uart_out_type;
71
 
72
begin
73
 
74
  comb : process(dmao, rst, uarto, dcomi, ahbi, dsuo, r)
75
  variable v : reg_type;
76
  variable enable : std_logic;
77
  variable newlen : std_logic_vector(5 downto 0);
78
  variable vuarti : dcom_uart_in_type;
79
  variable vdmai : ahb_dma_in_type;
80
  variable newaddr : std_logic_vector(31 downto 2);
81
 
82
  begin
83
 
84
    v := r;
85
    vuarti.rxd := dcomi.dsurx;
86
    vuarti.read := '0'; vuarti.write := '0'; vuarti.data := r.data(31 downto 24);
87
    vdmai.start := '0'; vdmai.burst := '0'; vdmai.size := "10";
88
    vdmai.address := r.addr(31 downto 2) & "00"; vdmai.wdata := r.data;
89
    vdmai.write := r.write; v.dsuact := dsuo.dsuact;
90
 
91
    -- save hresp
92
    if dmao.ready = '1' then v.hresp := ahbi.hresp; end if;
93
 
94
    -- detect entering into debug mode
95
    v.dmode := (r.dmode or (dsuo.dsuact and not r.dsuact)) and dsuo.dresp;
96
    -- address incrementer
97
-- pragma translate_off
98
    if not is_x(r.len) then
99
-- pragma translate_on
100
      newlen := r.len - 1;
101
-- pragma translate_off
102
   end if;
103
    if not is_x(r.addr(31 downto 2)) then
104
-- pragma translate_on
105
      newaddr := r.addr(31 downto 2) + 1;
106
-- pragma translate_off
107
   end if;
108
-- pragma translate_on
109
 
110
 
111
    case r.state is
112
    when idle =>                -- idle state
113
      v.clen := "00";
114
      if uarto.dready = '1' then
115
        if uarto.data(7) = '1' then v.state := addr1; end if;
116
        v.write := uarto.data(6); v.len := uarto.data(5 downto 0);
117
        vuarti.read := '1';
118
      end if;
119
      -- send response byte if debug mode was entered
120
      if (r.dmode and dsuo.dresp) = '1' then
121
        v.txresp := '1'; v.dmode := '0';
122
      end if;
123
    when addr1 =>               -- receive address
124
      if uarto.dready = '1' then
125
        v.addr := r.addr(23 downto 0) & uarto.data;
126
        vuarti.read := '1'; v.clen := r.clen + 1;
127
      end if;
128
      if (r.clen(1) and not v.clen(1)) = '1' then
129
        if r.write = '1' then v.state := write1; else v.state := read1; end if;
130
      end if;
131
    when read1 =>               -- read AHB
132
      if dmao.active = '1' then
133
        if dmao.ready = '1' then
134
          v.data := dmao.rdata; v.state := read2;
135
        end if;
136
      elsif r.txresp = '0' then vdmai.start := '1'; end if;
137
      v.clen := "00";
138
    when read2 =>               -- send read-data on uart
139
      if uarto.thempty = '1' then
140
        v.data := r.data(23 downto 0) & uarto.data;
141
        vuarti.write := '1'; v.clen := r.clen + 1;
142
        if (r.clen(1) and not v.clen(1)) = '1' then
143
          v.addr(31 downto 2) := newaddr; v.len := newlen;
144
          if (v.len(5) and not r.len(5)) = '1' then v.state := idle;
145
          else v.state := read1; end if;
146
          if dsuo.lresp = '1' then v.txresp := '1'; end if;
147
        end if;
148
      end if;
149
    when write1 =>              -- receive write-data
150
      if uarto.dready = '1' then
151
        v.data := r.data(23 downto 0) & uarto.data;
152
        vuarti.read := '1'; v.clen := r.clen + 1;
153
      end if;
154
      if (r.clen(1) and not v.clen(1)) = '1' then v.state := write2; end if;
155
    when write2 =>              -- write AHB
156
      if dmao.active = '1' then
157
        if dmao.ready = '1' then
158
          v.addr(31 downto 2) := newaddr; v.len := newlen;
159
          if (v.len(5) and not r.len(5)) = '1' then v.state := idle;
160
          else v.state := write1; end if;
161
          if dsuo.lresp = '1' then v.txresp := '1'; end if;
162
        end if;
163
      else vdmai.start := '1'; end if;
164
      v.clen := "00";
165
 
166
    end case;
167
 
168
    -- send response byte
169
    if r.txresp = '1' then
170
      v.dmode := '0';
171
      if (uarto.lock and uarto.enable and uarto.thempty) = '1' then
172
        vuarti.data := "00000" & dsuo.dsuact & r.hresp; vuarti.write := '1';
173
        v.txresp := '0';
174
      end if;
175
    end if;
176
 
177
    vuarti.dsuen := dsuo.dsuen;
178
 
179
    if (uarto.lock and rst) = '0' then
180
      v.state := idle; v.write := '0'; v.dmode := '0'; v.txresp := '0';
181
    end if;
182
 
183
    rin <= v;
184
    dmai <= vdmai;
185
    uarti <= vuarti;
186
    dcomo.dsutx <= uarto.txd;
187
 
188
  end process;
189
 
190
  ahbmst0 : ahbmst port map (rst, clk, dmai, dmao, ahbi, ahbo);
191
  dcom_uart0 : dcom_uart port map (rst, clk, apbi, apbo, uarti, uarto);
192
 
193
 
194
  regs : process(clk)
195
  begin if rising_edge(clk) then r <= rin; end if; end process;
196
 
197
end;

powered by: WebSVN 2.1.0

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