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/] [uart/] [dcom.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:      dcom
20
-- File:        dcom.vhd
21
-- Author:      Jiri Gaisler - Gaisler Research
22
-- Description: DSU Communications module
23
------------------------------------------------------------------------------  
24
 
25
library ieee;
26
use ieee.std_logic_1164.all;
27
library grlib;
28
use grlib.amba.all;
29
use grlib.stdlib.all;
30
library gaisler;
31
use gaisler.misc.all;
32
use gaisler.libdcom.all;
33
 
34
entity dcom is
35
   port (
36
      rst    : in  std_ulogic;
37
      clk    : in  std_ulogic;
38
      dmai   : out ahb_dma_in_type;
39
      dmao   : in  ahb_dma_out_type;
40
      uarti  : out dcom_uart_in_type;
41
      uarto  : in  dcom_uart_out_type;
42
      ahbi   : in  ahb_mst_in_type
43
      );
44
end;
45
 
46
architecture struct of dcom is
47
 
48
type dcom_state_type is (idle, addr1, read1, read2, write1, write2);
49
 
50
type reg_type is record
51
  addr    : std_logic_vector(31 downto 0);
52
  data    : std_logic_vector(31 downto 0);
53
  len     : std_logic_vector(5 downto 0);
54
  write   : std_ulogic;
55
  clen    : std_logic_vector(1 downto 0);
56
  state   : dcom_state_type;
57
  hresp   : std_logic_vector(1 downto 0);
58
end record;
59
 
60
signal r, rin : reg_type;
61
 
62
begin
63
 
64
  comb : process(dmao, rst, uarto, ahbi, r)
65
  variable v : reg_type;
66
  variable enable : std_ulogic;
67
  variable newlen : std_logic_vector(5 downto 0);
68
  variable vuarti : dcom_uart_in_type;
69
  variable vdmai : ahb_dma_in_type;
70
  variable newaddr : std_logic_vector(31 downto 2);
71
 
72
  begin
73
 
74
    v := r;
75
    vuarti.read := '0'; vuarti.write := '0'; vuarti.data := r.data(31 downto 24);
76
    vdmai.start := '0'; vdmai.burst := '0'; vdmai.size := "10"; vdmai.busy := '0';
77
    vdmai.address := r.addr; vdmai.wdata := r.data;
78
    vdmai.write := r.write; vdmai.irq := '0';
79
 
80
    -- save hresp
81
    if dmao.ready = '1' then v.hresp := ahbi.hresp; end if;
82
 
83
    -- address incrementer
84
    newlen := r.len - 1;
85
    newaddr := r.addr(31 downto 2) + 1;
86
 
87
    case r.state is
88
    when idle =>                -- idle state
89
      v.clen := "00";
90
      if uarto.dready = '1' then
91
        if uarto.data(7) = '1' then v.state := addr1; end if;
92
        v.write := uarto.data(6); v.len := uarto.data(5 downto 0);
93
        vuarti.read := '1';
94
      end if;
95
    when addr1 =>               -- receive address
96
      if uarto.dready = '1' then
97
        v.addr := r.addr(23 downto 0) & uarto.data;
98
        vuarti.read := '1'; v.clen := r.clen + 1;
99
      end if;
100
      if (r.clen(1) and not v.clen(1)) = '1' then
101
        if r.write = '1' then v.state := write1; else v.state := read1; end if;
102
      end if;
103
    when read1 =>               -- read AHB
104
      if dmao.active = '1' then
105
        if dmao.ready = '1' then
106
          v.data := dmao.rdata; v.state := read2;
107
        end if;
108
      else vdmai.start := '1'; end if;
109
      v.clen := "00";
110
    when read2 =>               -- send read-data on uart
111
      if uarto.thempty = '1' then
112
        v.data := r.data(23 downto 0) & uarto.data;
113
        vuarti.write := '1'; v.clen := r.clen + 1;
114
        if (r.clen(1) and not v.clen(1)) = '1' then
115
          v.addr(31 downto 2) := newaddr; v.len := newlen;
116
          if (v.len(5) and not r.len(5)) = '1' then v.state := idle;
117
          else v.state := read1; end if;
118
        end if;
119
      end if;
120
    when write1 =>              -- receive write-data
121
      if uarto.dready = '1' then
122
        v.data := r.data(23 downto 0) & uarto.data;
123
        vuarti.read := '1'; v.clen := r.clen + 1;
124
      end if;
125
      if (r.clen(1) and not v.clen(1)) = '1' then v.state := write2; end if;
126
    when write2 =>              -- write AHB
127
      if dmao.active = '1' then
128
        if dmao.ready = '1' then
129
          v.addr(31 downto 2) := newaddr; v.len := newlen;
130
          if (v.len(5) and not r.len(5)) = '1' then v.state := idle;
131
          else v.state := write1; end if;
132
        end if;
133
      else vdmai.start := '1'; end if;
134
      v.clen := "00";
135
    end case;
136
 
137
    if (uarto.lock and rst) = '0' then
138
      v.state := idle; v.write := '0';
139
    end if;
140
 
141
    rin <= v; dmai <= vdmai; uarti <= vuarti;
142
 
143
  end process;
144
 
145
  regs : process(clk)
146
  begin if rising_edge(clk) then r <= rin; end if; end process;
147
 
148
end;

powered by: WebSVN 2.1.0

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