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

Subversion Repositories rio

[/] [rio/] [branches/] [2.0.0-development/] [rtl/] [vhdl/] [RioLogicalMaintenance.vhd] - Blame information for rev 46

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

Line No. Rev Author Line
1 39 magro732
-------------------------------------------------------------------------------
2
-- 
3
-- RapidIO IP Library Core
4
-- 
5
-- This file is part of the RapidIO IP library project
6
-- http://www.opencores.org/cores/rio/
7
-- 
8
-- Description
9
-- Contains a platform to build endpoints on.
10
-- 
11
-- To Do:
12 46 magro732
-- -
13 39 magro732
-- 
14
-- Author(s): 
15
-- - Magnus Rosenius, magro732@opencores.org 
16
-- 
17
-------------------------------------------------------------------------------
18
-- 
19
-- Copyright (C) 2013 Authors and OPENCORES.ORG 
20
-- 
21
-- This source file may be used and distributed without 
22
-- restriction provided that this copyright statement is not 
23
-- removed from the file and that any derivative work contains 
24
-- the original copyright notice and the associated disclaimer. 
25
-- 
26
-- This source file is free software; you can redistribute it 
27
-- and/or modify it under the terms of the GNU Lesser General 
28
-- Public License as published by the Free Software Foundation; 
29
-- either version 2.1 of the License, or (at your option) any 
30
-- later version. 
31
-- 
32
-- This source is distributed in the hope that it will be 
33
-- useful, but WITHOUT ANY WARRANTY; without even the implied 
34
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
35
-- PURPOSE. See the GNU Lesser General Public License for more 
36
-- details. 
37
-- 
38
-- You should have received a copy of the GNU Lesser General 
39
-- Public License along with this source; if not, download it 
40
-- from http://www.opencores.org/lgpl.shtml 
41
-- 
42
-------------------------------------------------------------------------------
43
 
44
-------------------------------------------------------------------------------
45
-- RioLogicalMaintenance
46
-- This logical layer module handles ingress maintenance requests and converts
47 46 magro732
-- them into accesses on a Wishbone similar bus accessing the configuration
48 39 magro732
-- space.
49
-------------------------------------------------------------------------------
50
library ieee;
51
use ieee.std_logic_1164.all;
52
use ieee.numeric_std.all;
53
use work.rio_common.all;
54
 
55
 
56
-------------------------------------------------------------------------------
57
-- Entity for RioLogicalMaintenance.
58
-------------------------------------------------------------------------------
59
entity RioLogicalMaintenance is
60
  port(
61
    clk : in std_logic;
62
    areset_n : in std_logic;
63
    enable : in std_logic;
64
 
65 46 magro732
    readRequestReady_i : in std_logic;
66
    writeRequestReady_i : in std_logic;
67
    offset_i : in std_logic_vector(20 downto 0);
68
    wdptr_i : in std_logic;
69
    payloadLength_i : in std_logic_vector(3 downto 0);
70
    payloadIndex_o : out std_logic_vector(3 downto 0);
71
    payload_i : in std_logic_vector(31 downto 0);
72
    done_o : out std_logic;
73
 
74
    readResponseReady_o : out std_logic;
75
    writeResponseReady_o : out std_logic;
76
    wdptr_o : out std_logic;
77
    payloadLength_o : out std_logic_vector(3 downto 0);
78
    payloadIndex_i : in std_logic_vector(3 downto 0);
79
    payload_o : out std_logic_vector(31 downto 0);
80
    done_i : in std_logic;
81
 
82 39 magro732
    configStb_o : out std_logic;
83
    configWe_o : out std_logic;
84
    configAdr_o : out std_logic_vector(21 downto 0);
85
    configDat_o : out std_logic_vector(31 downto 0);
86
    configDat_i : in std_logic_vector(31 downto 0);
87 46 magro732
    configAck_i : in std_logic);
88 39 magro732
end entity;
89
 
90
 
91
-------------------------------------------------------------------------------
92
-- 
93
-------------------------------------------------------------------------------
94
architecture RioLogicalMaintenance of RioLogicalMaintenance is
95
 
96
  type StateType is (IDLE,
97
                     CONFIG_READ, CONFIG_READ_RESPONSE,
98
                     CONFIG_WRITE, CONFIG_WRITE_RESPONSE);
99
  signal state : StateType;
100 46 magro732
 
101
  signal payloadWrite : std_logic;
102
  signal payloadIndex : std_logic_vector(3 downto 0);
103
 
104 39 magro732
  signal configAdr : std_logic_vector(21 downto 0);
105
  signal configDat : std_logic_vector(31 downto 0);
106 46 magro732
 
107 39 magro732
begin
108
 
109 46 magro732
  wdptr_o <= wdptr_i;
110
 
111 39 magro732
  configAdr_o <= configAdr;
112
  configDat_o <= configDat;
113 46 magro732
 
114
  payloadLength_o <= payloadLength_i;
115
  payloadIndex_o <= payloadIndex;
116 39 magro732
 
117
  -----------------------------------------------------------------------------
118
  -- 
119
  -----------------------------------------------------------------------------
120
  Maintenance: process(clk, areset_n)
121
  begin
122
    if (areset_n = '0') then
123 46 magro732
      state <= IDLE;
124
 
125 39 magro732
      configStb_o <= '0';
126
      configWe_o <= '0';
127
      configAdr <= (others=>'0');
128
      configDat <= (others=>'0');
129
 
130 46 magro732
      readResponseReady_o <= '0';
131
      writeResponseReady_o <= '0';
132 39 magro732
 
133 46 magro732
      done_o <= '0';
134 39 magro732
 
135 46 magro732
      payloadWrite <= '0';
136
      payloadIndex <= (others=>'0');
137 39 magro732
    elsif (clk'event and clk = '1') then
138 46 magro732
      payloadWrite <= '0';
139 39 magro732
 
140 46 magro732
      if (payloadWrite = '1') then
141
        payloadIndex <= std_logic_vector(unsigned(payloadIndex) + 1);
142 39 magro732
      end if;
143
 
144
      case state is
145
        when IDLE =>
146
          ---------------------------------------------------------------------
147
          -- 
148
          ---------------------------------------------------------------------
149 46 magro732
          payloadIndex <= (others=>'0');
150
          if (readRequestReady_i = '1') then
151 39 magro732
            configStb_o <= '1';
152
            configWe_o <= '0';
153 46 magro732
            configAdr <= offset_i & wdptr_i;
154 39 magro732
            state <= CONFIG_READ;
155 46 magro732
          elsif (writeRequestReady_i = '1') then
156 39 magro732
            configStb_o <= '1';
157
            configWe_o <= '1';
158 46 magro732
            configAdr <= offset_i & wdptr_i;
159
            configDat <= payload_i;
160 39 magro732
            state <= CONFIG_WRITE;
161
          end if;
162
 
163
        when CONFIG_READ =>
164
          ---------------------------------------------------------------------
165
          -- 
166
          ---------------------------------------------------------------------
167
          if (configAck_i = '1') then
168 46 magro732
            payloadWrite <= '1';
169 39 magro732
 
170 46 magro732
            if (payloadIndex /= payloadLength_i) then
171 39 magro732
              configAdr <= std_logic_vector(unsigned(configAdr) + 1);
172
            else
173 46 magro732
              done_o <= '1';
174 39 magro732
              configStb_o <= '0';
175
              state <= CONFIG_READ_RESPONSE;
176
            end if;
177
          end if;
178
 
179
        when CONFIG_READ_RESPONSE =>
180
          ---------------------------------------------------------------------
181
          -- 
182
          ---------------------------------------------------------------------
183 46 magro732
          if (done_i = '1') then
184
            done_o <= '0';
185
            readResponseReady_o <= '0';
186 39 magro732
            state <= IDLE;
187
          else
188 46 magro732
            readResponseReady_o <= '1';
189 39 magro732
          end if;
190
 
191
        when CONFIG_WRITE =>
192
          ---------------------------------------------------------------------
193
          -- 
194
          ---------------------------------------------------------------------
195
          if (configAck_i = '1') then
196 46 magro732
            payloadWrite <= '1';
197 39 magro732
 
198 46 magro732
            if (payloadIndex /= payloadLength_i) then
199 39 magro732
              configAdr <= std_logic_vector(unsigned(configAdr) + 1);
200 46 magro732
              configDat <= payload_i;
201
              payloadIndex <= std_logic_vector(unsigned(payloadIndex) + 1);
202 39 magro732
            else
203 46 magro732
              done_o <= '1';
204 39 magro732
              configStb_o <= '0';
205
              state <= CONFIG_WRITE_RESPONSE;
206
            end if;
207
          end if;
208
 
209
        when CONFIG_WRITE_RESPONSE =>
210
          ---------------------------------------------------------------------
211
          -- 
212
          ---------------------------------------------------------------------
213 46 magro732
          if (done_i = '1') then
214
            done_o <= '0';
215
            writeResponseReady_o <= '0';
216 39 magro732
            state <= IDLE;
217
          else
218 46 magro732
            writeResponseReady_o <= '1';
219 39 magro732
          end if;
220
 
221
        when others =>
222
 
223
      end case;
224
    end if;
225
  end process;
226
 
227
  -----------------------------------------------------------------------------
228
  -- Payload content memory.
229
  -----------------------------------------------------------------------------
230
 
231
  PayloadMemory: MemorySimpleDualPort
232
    generic map(ADDRESS_WIDTH=>4, DATA_WIDTH=>32)
233
    port map(clkA_i=>clk,
234 46 magro732
             enableA_i=>payloadWrite,
235
             addressA_i=>payloadIndex,
236
             dataA_i=>configDat_i,
237 39 magro732
             clkB_i=>clk,
238 46 magro732
             enableB_i=>'1',
239
             addressB_i=>payloadIndex_i,
240
             dataB_o=>payload_o);
241 39 magro732
 
242
end architecture;

powered by: WebSVN 2.1.0

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