1 |
11 |
ashwin_men |
|
2 |
|
|
-- Copyright (C) 2012
|
3 |
|
|
-- Ashwin A. Mendon
|
4 |
|
|
--
|
5 |
|
|
-- This file is part of SATA2 core.
|
6 |
|
|
--
|
7 |
|
|
-- This program is free software; you can redistribute it and/or modify
|
8 |
|
|
-- it under the terms of the GNU General Public License as published by
|
9 |
|
|
-- the Free Software Foundation; either version 3 of the License, or
|
10 |
|
|
-- (at your option) any later version.
|
11 |
|
|
--
|
12 |
|
|
-- This program is distributed in the hope that it will be useful,
|
13 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
-- GNU General Public License for more details.
|
16 |
|
|
--
|
17 |
|
|
-- You should have received a copy of the GNU General Public License
|
18 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
library ieee;
|
22 |
|
|
use ieee.std_logic_1164.all;
|
23 |
|
|
use ieee.std_logic_arith.all;
|
24 |
|
|
use ieee.std_logic_unsigned.all;
|
25 |
|
|
|
26 |
|
|
-------------------------------------------------------------------------------
|
27 |
|
|
-- ENTITY: NPI_CORE
|
28 |
|
|
-- PURPOSE: Interface SATA Core with MPMC via NPI
|
29 |
|
|
--
|
30 |
|
|
-- GENERICS:
|
31 |
|
|
-- CHIPSCOPE - True if Core should include ILA
|
32 |
|
|
-- RAM_OFFSET - Start address for connected RAMDisk
|
33 |
|
|
-- BLOCK_SIZE - Block Size in Bytes
|
34 |
|
|
-- BLOCK_SIZE_WIDTH - 2^(BLOCK_SIZE_WIDTH) = BLOCK_SIZE/8
|
35 |
|
|
--
|
36 |
|
|
-- PORTS:
|
37 |
|
|
-- NPI_* - Native Port Interface Signals to MPMC
|
38 |
|
|
--
|
39 |
|
|
-------------------------------------------------------------------------------
|
40 |
|
|
|
41 |
|
|
entity npi_core is
|
42 |
|
|
generic (
|
43 |
|
|
-- Generics
|
44 |
|
|
CHIPSCOPE : boolean := false;
|
45 |
|
|
END_SWAP : boolean := true;
|
46 |
|
|
RAM_OFFSET : std_logic_vector(0 to 7) := x"04";
|
47 |
|
|
BLOCK_SIZE : integer := 512
|
48 |
|
|
);
|
49 |
|
|
port (
|
50 |
|
|
-- ChipScope ILA Control
|
51 |
|
|
npi_if_ila_control : in std_logic_vector(35 downto 0);
|
52 |
|
|
npi_if_tx_ila_control : in std_logic_vector(35 downto 0);
|
53 |
|
|
npi_ila_control : in std_logic_vector(35 downto 0);
|
54 |
|
|
-- Clock Sources
|
55 |
|
|
MPMC_Clk : in std_logic;
|
56 |
|
|
user_clk : in std_logic;
|
57 |
|
|
-- Reset Source
|
58 |
|
|
reset : in std_logic;
|
59 |
|
|
-- SATA Core Signals
|
60 |
|
|
NPI_CORE_DIN : in std_logic_vector(31 downto 0);
|
61 |
|
|
NPI_CORE_WE : in std_logic;
|
62 |
|
|
NPI_CORE_FULL : out std_logic;
|
63 |
|
|
NPI_CORE_DOUT : out std_logic_vector(31 downto 0);
|
64 |
|
|
NPI_CORE_DOUT_WE : out std_logic;
|
65 |
|
|
SATA_CORE_FULL : in std_logic;
|
66 |
|
|
req_type : in std_logic_vector(1 downto 0);
|
67 |
|
|
new_cmd : in std_logic;
|
68 |
|
|
num_read_bytes_in : in std_logic_vector(31 downto 0);
|
69 |
|
|
num_write_bytes_in : in std_logic_vector(31 downto 0);
|
70 |
|
|
NPI_init_wr_addr_in : in std_logic_vector(31 downto 0);
|
71 |
|
|
NPI_init_rd_addr_in : in std_logic_vector(31 downto 0);
|
72 |
|
|
NPI_ready_for_cmd : out std_logic;
|
73 |
|
|
-- NPI Signals
|
74 |
|
|
NPI_AddrAck : in std_logic;
|
75 |
|
|
NPI_WrFIFO_AlmostFull : in std_logic;
|
76 |
|
|
NPI_RdFIFO_Empty : in std_logic;
|
77 |
|
|
NPI_InitDone : in std_logic;
|
78 |
|
|
NPI_WrFIFO_Empty : in std_logic;
|
79 |
|
|
NPI_RdFIFO_Latency : in std_logic_vector(1 downto 0);
|
80 |
|
|
NPI_RdFIFO_RdWdAddr : in std_logic_vector(3 downto 0);
|
81 |
|
|
NPI_RdFIFO_Data : in std_logic_vector(63 downto 0);
|
82 |
|
|
NPI_AddrReq : out std_logic;
|
83 |
|
|
NPI_RNW : out std_logic;
|
84 |
|
|
NPI_WrFIFO_Push : out std_logic;
|
85 |
|
|
NPI_RdFIFO_Pop : out std_logic;
|
86 |
|
|
NPI_RdModWr : out std_logic;
|
87 |
|
|
NPI_WrFIFO_Flush : out std_logic;
|
88 |
|
|
NPI_RdFIFO_Flush : out std_logic;
|
89 |
|
|
NPI_Size : out std_logic_vector(3 downto 0);
|
90 |
|
|
NPI_WrFIFO_BE : out std_logic_vector(7 downto 0);
|
91 |
|
|
NPI_Addr : out std_logic_vector(31 downto 0);
|
92 |
|
|
NPI_WrFIFO_Data : out std_logic_vector(63 downto 0)
|
93 |
|
|
);
|
94 |
|
|
end entity npi_core;
|
95 |
|
|
|
96 |
|
|
------------------------------------------------------------------------------
|
97 |
|
|
-- ARCHITECTURE
|
98 |
|
|
------------------------------------------------------------------------------
|
99 |
|
|
architecture BEH of npi_core is
|
100 |
|
|
|
101 |
|
|
-----------------------------------------------------------------------------
|
102 |
|
|
-- NPI Signals
|
103 |
|
|
-----------------------------------------------------------------------------
|
104 |
|
|
signal core_rfd : std_logic;
|
105 |
|
|
signal data_to_mem : std_logic_vector(0 to 63);
|
106 |
|
|
signal data_to_mem_we : std_logic;
|
107 |
|
|
signal data_to_mem_re : std_logic;
|
108 |
|
|
signal data_to_core : std_logic_vector(0 to 63);
|
109 |
|
|
signal data_to_core_we : std_logic;
|
110 |
|
|
signal num_rd_bytes : std_logic_vector(0 to 31);
|
111 |
|
|
signal num_wr_bytes : std_logic_vector(0 to 31);
|
112 |
|
|
signal init_rd_addr : std_logic_vector(0 to 31);
|
113 |
|
|
signal init_wr_addr : std_logic_vector(0 to 31);
|
114 |
|
|
signal rd_req_start : std_logic;
|
115 |
|
|
signal rd_req_start_next : std_logic;
|
116 |
|
|
signal wr_req_start : std_logic;
|
117 |
|
|
signal wr_req_start_next : std_logic;
|
118 |
|
|
signal rd_req_done : std_logic;
|
119 |
|
|
signal wr_req_done : std_logic;
|
120 |
|
|
|
121 |
|
|
-- AGS: Added on 8/19
|
122 |
|
|
-- Request Type: RnW Signal (1 = Read Request / 0 = Write Request)
|
123 |
|
|
signal req_type_r : std_logic_vector(1 downto 0);
|
124 |
|
|
signal new_cmd_r, new_cmd_r2 : std_logic;
|
125 |
|
|
signal new_cmd_started : std_logic;
|
126 |
|
|
signal NPI_CORE_DOUT_next : std_logic_vector(31 downto 0);
|
127 |
|
|
signal NPI_CORE_DOUT_out : std_logic_vector(31 downto 0);
|
128 |
|
|
signal NPI_CORE_DOUT_WE_next : std_logic ;
|
129 |
|
|
signal NPI_CORE_DOUT_WE_out : std_logic ;
|
130 |
|
|
|
131 |
|
|
signal NPI_ready_for_cmd_out, NPI_ready_for_cmd_next : std_logic;
|
132 |
|
|
-----------------------------------------------------------------------------
|
133 |
|
|
-- TX FIFO Signals
|
134 |
|
|
-----------------------------------------------------------------------------
|
135 |
|
|
signal tx_fifo_din : std_logic_vector(0 to 63);
|
136 |
|
|
signal tx_fifo_re : std_logic;
|
137 |
|
|
signal tx_fifo_we : std_logic;
|
138 |
|
|
signal tx_fifo_dout : std_logic_vector(0 to 31);
|
139 |
|
|
signal tx_fifo_empty : std_logic;
|
140 |
|
|
signal tx_fifo_full : std_logic;
|
141 |
|
|
signal tx_fifo_prog_full : std_logic;
|
142 |
|
|
signal tx_fifo_valid : std_logic;
|
143 |
|
|
|
144 |
|
|
-----------------------------------------------------------------------------
|
145 |
|
|
-- RX FIFO Signals
|
146 |
|
|
-----------------------------------------------------------------------------
|
147 |
|
|
signal rx_fifo_din : std_logic_vector(0 to 31);
|
148 |
|
|
signal rx_fifo_re : std_logic;
|
149 |
|
|
signal rx_fifo_we : std_logic;
|
150 |
|
|
signal rx_fifo_dout : std_logic_vector(0 to 63);
|
151 |
|
|
signal rx_fifo_empty : std_logic;
|
152 |
|
|
signal rx_fifo_full : std_logic;
|
153 |
|
|
signal rx_fifo_prog_full : std_logic;
|
154 |
|
|
signal rx_fifo_prog_full_next : std_logic;
|
155 |
|
|
signal rx_fifo_valid : std_logic;
|
156 |
|
|
|
157 |
|
|
-----------------------------------------------------------------------------
|
158 |
|
|
-- RX FSM Signals (From Router / Aurora Core to NPI Component)
|
159 |
|
|
-----------------------------------------------------------------------------
|
160 |
|
|
type LL_RX_FSM_TYPE is (idle, check_req_type, issue_wr_req, issue_rd_req, done);
|
161 |
|
|
signal ll_rx_fsm_cs, ll_rx_fsm_ns : LL_RX_FSM_TYPE := idle;
|
162 |
|
|
signal ll_rx_fsm_value, ll_rx_fsm_value_r : std_logic_vector(0 to 3);
|
163 |
|
|
|
164 |
|
|
-----------------------------------------------------------------------------
|
165 |
|
|
-- TX FSM Signals (To Router / Aurora Core)
|
166 |
|
|
-----------------------------------------------------------------------------
|
167 |
|
|
type LL_TX_FSM_TYPE is (idle, xfer_data, done, dead);
|
168 |
|
|
signal ll_tx_fsm_cs, ll_tx_fsm_ns : LL_TX_FSM_TYPE := idle;
|
169 |
|
|
signal ll_tx_fsm_value, ll_tx_fsm_value_r : std_logic_vector(0 to 3);
|
170 |
|
|
|
171 |
|
|
-----------------------------------------------------------------------------
|
172 |
|
|
-- RX FIFO Declaration
|
173 |
|
|
-----------------------------------------------------------------------------
|
174 |
|
|
component rx_fifo
|
175 |
|
|
port (
|
176 |
|
|
din : in std_logic_vector(31 downto 0);
|
177 |
|
|
rd_clk : in std_logic;
|
178 |
|
|
rd_en : in std_logic;
|
179 |
|
|
rst : in std_logic;
|
180 |
|
|
wr_clk : in std_logic;
|
181 |
|
|
wr_en : in std_logic;
|
182 |
|
|
dout : out std_logic_vector(63 downto 0);
|
183 |
|
|
empty : out std_logic;
|
184 |
|
|
full : out std_logic;
|
185 |
|
|
prog_full : out std_logic;
|
186 |
|
|
valid : out std_logic);
|
187 |
|
|
end component;
|
188 |
|
|
|
189 |
|
|
-----------------------------------------------------------------------------
|
190 |
|
|
-- TX FIFO Declaration
|
191 |
|
|
-----------------------------------------------------------------------------
|
192 |
|
|
component tx_fifo
|
193 |
|
|
port (
|
194 |
|
|
din : in std_logic_vector(63 downto 0);
|
195 |
|
|
rd_clk : in std_logic;
|
196 |
|
|
rd_en : in std_logic;
|
197 |
|
|
rst : in std_logic;
|
198 |
|
|
wr_clk : in std_logic;
|
199 |
|
|
wr_en : in std_logic;
|
200 |
|
|
dout : out std_logic_vector(31 downto 0);
|
201 |
|
|
empty : out std_logic;
|
202 |
|
|
full : out std_logic;
|
203 |
|
|
prog_full : out std_logic;
|
204 |
|
|
valid : out std_logic);
|
205 |
|
|
end component;
|
206 |
|
|
|
207 |
|
|
-----------------------------------------------------------------------------
|
208 |
|
|
-- ILA Instance
|
209 |
|
|
-----------------------------------------------------------------------------
|
210 |
|
|
component npi_if_ila
|
211 |
|
|
port (
|
212 |
|
|
control : in std_logic_vector(35 downto 0);
|
213 |
|
|
clk : in std_logic;
|
214 |
|
|
trig0 : in std_logic_vector(31 downto 0);
|
215 |
|
|
trig1 : in std_logic_vector(31 downto 0);
|
216 |
|
|
trig2 : in std_logic_vector(31 downto 0);
|
217 |
|
|
trig3 : in std_logic_vector(3 downto 0);
|
218 |
|
|
trig4 : in std_logic_vector(23 downto 0);
|
219 |
|
|
trig5 : in std_logic_vector(63 downto 0);
|
220 |
|
|
trig6 : in std_logic_vector(63 downto 0);
|
221 |
|
|
trig7 : in std_logic_vector(31 downto 0));
|
222 |
|
|
end component;
|
223 |
|
|
|
224 |
|
|
component npi_if_tx_ila
|
225 |
|
|
port (
|
226 |
|
|
control : in std_logic_vector(35 downto 0);
|
227 |
|
|
clk : in std_logic;
|
228 |
|
|
trig0 : in std_logic_vector(3 downto 0);
|
229 |
|
|
trig1 : in std_logic_vector(31 downto 0);
|
230 |
|
|
trig2 : in std_logic_vector(7 downto 0));
|
231 |
|
|
end component;
|
232 |
|
|
|
233 |
|
|
-------------------------------------------------------------------------------
|
234 |
|
|
-- BEGIN
|
235 |
|
|
-------------------------------------------------------------------------------
|
236 |
|
|
begin
|
237 |
|
|
|
238 |
|
|
-----------------------------------------------------------------------------
|
239 |
|
|
-- NPI Output Signals
|
240 |
|
|
-----------------------------------------------------------------------------
|
241 |
|
|
core_rfd <= not(tx_fifo_prog_full);
|
242 |
|
|
data_to_mem <= rx_fifo_dout when (ll_rx_fsm_cs = issue_wr_req) else (others => '0');
|
243 |
|
|
data_to_mem_we <= rx_fifo_valid when (ll_rx_fsm_cs = issue_wr_req) else '0';
|
244 |
|
|
tx_fifo_re <= not(tx_fifo_empty) when (SATA_CORE_FULL = '0') else '0';
|
245 |
|
|
|
246 |
|
|
-----------------------------------------------------------------------------
|
247 |
|
|
-- PROCESS: LL_RX_FSM_VALUE_PROC
|
248 |
|
|
-- PURPOSE: RX FSM State Indicator for ChipScope
|
249 |
|
|
-----------------------------------------------------------------------------
|
250 |
|
|
LL_RX_FSM_VALUE_PROC : process (ll_rx_fsm_cs) is
|
251 |
|
|
begin
|
252 |
|
|
case (ll_rx_fsm_cs) is
|
253 |
|
|
when idle => ll_rx_fsm_value <= x"0";
|
254 |
|
|
when check_req_type => ll_rx_fsm_value <= x"1";
|
255 |
|
|
when issue_wr_req => ll_rx_fsm_value <= x"2";
|
256 |
|
|
when issue_rd_req => ll_rx_fsm_value <= x"3";
|
257 |
|
|
when done => ll_rx_fsm_value <= x"4";
|
258 |
|
|
when others => ll_rx_fsm_value <= x"5";
|
259 |
|
|
end case;
|
260 |
|
|
end process LL_RX_FSM_VALUE_PROC;
|
261 |
|
|
|
262 |
|
|
-----------------------------------------------------------------------------
|
263 |
|
|
-- PROCESS: LL_RX_FSM_STATE_PROC
|
264 |
|
|
-- PURPOSE: Register RX FSM to MPMC Clock (200 MHz)
|
265 |
|
|
-----------------------------------------------------------------------------
|
266 |
|
|
LL_RX_FSM_STATE_PROC : process (MPMC_Clk) is
|
267 |
|
|
begin
|
268 |
|
|
if ((MPMC_Clk'event) and (MPMC_Clk='1')) then
|
269 |
|
|
if (reset='1') then
|
270 |
|
|
wr_req_start <= '0';
|
271 |
|
|
rd_req_start <= '0';
|
272 |
|
|
ll_rx_fsm_cs <= idle;
|
273 |
|
|
rx_fifo_prog_full <= '0';
|
274 |
|
|
ll_rx_fsm_value_r <= (others => '0');
|
275 |
|
|
req_type_r <= "00";
|
276 |
|
|
new_cmd_r <= '0';
|
277 |
|
|
init_rd_addr <= (others => '0');
|
278 |
|
|
init_wr_addr <= (others => '0');
|
279 |
|
|
num_wr_bytes <= (others => '0');
|
280 |
|
|
num_rd_bytes <= (others => '0');
|
281 |
|
|
NPI_ready_for_cmd_out <= '0';
|
282 |
|
|
else
|
283 |
|
|
wr_req_start <= wr_req_start_next;
|
284 |
|
|
rd_req_start <= rd_req_start_next;
|
285 |
|
|
ll_rx_fsm_cs <= ll_rx_fsm_ns;
|
286 |
|
|
rx_fifo_prog_full <= rx_fifo_prog_full_next;
|
287 |
|
|
ll_rx_fsm_value_r <= ll_rx_fsm_value;
|
288 |
|
|
req_type_r <= req_type;
|
289 |
|
|
new_cmd_r <= new_cmd;
|
290 |
|
|
init_rd_addr <= NPI_init_rd_addr_in;
|
291 |
|
|
init_wr_addr <= NPI_init_wr_addr_in;
|
292 |
|
|
num_wr_bytes <= num_write_bytes_in;
|
293 |
|
|
num_rd_bytes <= num_read_bytes_in;
|
294 |
|
|
NPI_ready_for_cmd_out <= NPI_ready_for_cmd_next;
|
295 |
|
|
end if;
|
296 |
|
|
end if;
|
297 |
|
|
end process LL_RX_FSM_STATE_PROC;
|
298 |
|
|
|
299 |
|
|
-----------------------------------------------------------------------------
|
300 |
|
|
-- PROCESS: LL_RX_FSM_LOGIC_PROC
|
301 |
|
|
-- PURPOSE: Next State and Output Function for RX FSM
|
302 |
|
|
-----------------------------------------------------------------------------
|
303 |
|
|
LL_RX_FSM_LOGIC_PROC : process (ll_rx_fsm_cs,
|
304 |
|
|
rd_req_start,
|
305 |
|
|
rx_fifo_empty, rx_fifo_valid, rx_fifo_dout,
|
306 |
|
|
rx_fifo_prog_full, data_to_mem_re, wr_req_done,
|
307 |
|
|
req_type_r, new_cmd_r
|
308 |
|
|
) is
|
309 |
|
|
begin
|
310 |
|
|
wr_req_start_next <= wr_req_start;
|
311 |
|
|
rd_req_start_next <= rd_req_start;
|
312 |
|
|
ll_rx_fsm_ns <= ll_rx_fsm_cs;
|
313 |
|
|
NPI_ready_for_cmd_next <= NPI_ready_for_cmd_out;
|
314 |
|
|
|
315 |
|
|
case (ll_rx_fsm_cs) is
|
316 |
|
|
-------------------------------------------------------------------------
|
317 |
|
|
-- Idle State: 0 - Wait for data from AIREN which is in RX_FIFO
|
318 |
|
|
-------------------------------------------------------------------------
|
319 |
|
|
when idle =>
|
320 |
|
|
wr_req_start_next <= '0';
|
321 |
|
|
rd_req_start_next <= '0';
|
322 |
|
|
rx_fifo_re <= '0';
|
323 |
|
|
NPI_ready_for_cmd_next <= '1';
|
324 |
|
|
if (new_cmd_r2 = '1') then
|
325 |
|
|
ll_rx_fsm_ns <= check_req_type;
|
326 |
|
|
end if;
|
327 |
|
|
|
328 |
|
|
when check_req_type =>
|
329 |
|
|
if (req_type_r = "01") then
|
330 |
|
|
ll_rx_fsm_ns <= issue_rd_req;
|
331 |
|
|
NPI_ready_for_cmd_next <= '0';
|
332 |
|
|
elsif ((req_type_r = "10") and (rx_fifo_prog_full = '1') and (rx_fifo_empty = '0')) then
|
333 |
|
|
ll_rx_fsm_ns <= issue_wr_req;
|
334 |
|
|
NPI_ready_for_cmd_next <= '0';
|
335 |
|
|
else
|
336 |
|
|
rx_fifo_re <= '0';
|
337 |
|
|
ll_rx_fsm_ns <= check_req_type;
|
338 |
|
|
end if;
|
339 |
|
|
|
340 |
|
|
-------------------------------------------------------------------------
|
341 |
|
|
-- Issue Write Request State: 4 - Issue NPI Write Request
|
342 |
|
|
-------------------------------------------------------------------------
|
343 |
|
|
when issue_wr_req =>
|
344 |
|
|
rx_fifo_re <= data_to_mem_re;
|
345 |
|
|
if (wr_req_done = '1') then
|
346 |
|
|
wr_req_start_next <= '0';
|
347 |
|
|
ll_rx_fsm_ns <= done;
|
348 |
|
|
else
|
349 |
|
|
wr_req_start_next <= '1';
|
350 |
|
|
ll_rx_fsm_ns <= issue_wr_req;
|
351 |
|
|
end if;
|
352 |
|
|
|
353 |
|
|
-------------------------------------------------------------------------
|
354 |
|
|
-- Issue Read Request State: 5 - Issue NPI Read Request
|
355 |
|
|
-------------------------------------------------------------------------
|
356 |
|
|
when issue_rd_req =>
|
357 |
|
|
rx_fifo_re <= '0';
|
358 |
|
|
tx_fifo_we <= data_to_core_we;
|
359 |
|
|
tx_fifo_din <= data_to_core;
|
360 |
|
|
if (rd_req_done = '1') then
|
361 |
|
|
rd_req_start_next <= '0';
|
362 |
|
|
ll_rx_fsm_ns <= done;
|
363 |
|
|
else
|
364 |
|
|
rd_req_start_next <= '1';
|
365 |
|
|
ll_rx_fsm_ns <= issue_rd_req;
|
366 |
|
|
end if;
|
367 |
|
|
|
368 |
|
|
-------------------------------------------------------------------------
|
369 |
|
|
-- Done State: 6 - Signal TX FSM To Transfer
|
370 |
|
|
-------------------------------------------------------------------------
|
371 |
|
|
when done =>
|
372 |
|
|
rx_fifo_re <= '0';
|
373 |
|
|
NPI_ready_for_cmd_next <= '1';
|
374 |
|
|
ll_rx_fsm_ns <= idle;
|
375 |
|
|
|
376 |
|
|
when others =>
|
377 |
|
|
rx_fifo_re <= '0';
|
378 |
|
|
ll_rx_fsm_ns <= idle;
|
379 |
|
|
end case;
|
380 |
|
|
end process LL_RX_FSM_LOGIC_PROC;
|
381 |
|
|
|
382 |
|
|
-- De-Assert new_cmd after 1 clk cycle
|
383 |
|
|
NEW_CMD_PROC: process (MPMC_Clk)
|
384 |
|
|
begin
|
385 |
|
|
if ((MPMC_Clk'event) and (MPMC_Clk = '1')) then
|
386 |
|
|
if (reset = '1') then
|
387 |
|
|
new_cmd_r2 <= '0';
|
388 |
|
|
new_cmd_started <= '0';
|
389 |
|
|
elsif(new_cmd_r = '0') then
|
390 |
|
|
new_cmd_started <= '0';
|
391 |
|
|
elsif (new_cmd_r = '1' and new_cmd_started = '0') then
|
392 |
|
|
new_cmd_r2 <= '1';
|
393 |
|
|
new_cmd_started <= '1';
|
394 |
|
|
elsif (new_cmd_started = '1') then
|
395 |
|
|
new_cmd_r2 <= '0';
|
396 |
|
|
end if;
|
397 |
|
|
end if;
|
398 |
|
|
end process NEW_CMD_PROC;
|
399 |
|
|
|
400 |
|
|
-----------------------------------------------------------------------------
|
401 |
|
|
-- RX FIFO Instance
|
402 |
|
|
-----------------------------------------------------------------------------
|
403 |
|
|
rx_fifo_din <= NPI_CORE_DIN;
|
404 |
|
|
rx_fifo_we <= NPI_CORE_WE;
|
405 |
|
|
NPI_CORE_FULL <= rx_fifo_full;
|
406 |
|
|
|
407 |
|
|
rx_fifo_i : rx_fifo
|
408 |
|
|
port map (
|
409 |
|
|
din => rx_fifo_din,
|
410 |
|
|
rd_clk => MPMC_Clk,
|
411 |
|
|
rd_en => rx_fifo_re,
|
412 |
|
|
rst => reset,
|
413 |
|
|
wr_clk => user_clk,
|
414 |
|
|
wr_en => rx_fifo_we,
|
415 |
|
|
dout => rx_fifo_dout,
|
416 |
|
|
empty => rx_fifo_empty,
|
417 |
|
|
full => rx_fifo_full,
|
418 |
|
|
prog_full => rx_fifo_prog_full_next,
|
419 |
|
|
valid => rx_fifo_valid);
|
420 |
|
|
|
421 |
|
|
|
422 |
|
|
-----------------------------------------------------------------------------
|
423 |
|
|
-- PROCESS: LL_TX_FSM_VALUE_PROC
|
424 |
|
|
-- PURPOSE: State Indicator for ChipScope
|
425 |
|
|
-----------------------------------------------------------------------------
|
426 |
|
|
LL_TX_FSM_VALUE_PROC : process (ll_tx_fsm_cs) is
|
427 |
|
|
begin
|
428 |
|
|
case (ll_tx_fsm_cs) is
|
429 |
|
|
when idle => ll_tx_fsm_value <= x"0";
|
430 |
|
|
when xfer_data => ll_tx_fsm_value <= x"1";
|
431 |
|
|
when done => ll_tx_fsm_value <= x"2";
|
432 |
|
|
when dead => ll_tx_fsm_value <= x"3";
|
433 |
|
|
when others => ll_tx_fsm_value <= x"4";
|
434 |
|
|
end case;
|
435 |
|
|
end process LL_TX_FSM_VALUE_PROC;
|
436 |
|
|
|
437 |
|
|
-----------------------------------------------------------------------------
|
438 |
|
|
-- PROCESS: LL_TX_FSM_STATE_PROC
|
439 |
|
|
-- PURPOSE: Register TX and RX FSMs to Router_Clk
|
440 |
|
|
-----------------------------------------------------------------------------
|
441 |
|
|
LL_TX_FSM_STATE_PROC : process (user_clk)
|
442 |
|
|
begin
|
443 |
|
|
if ((user_clk'event) and (user_clk = '1')) then
|
444 |
|
|
if (reset = '1') then
|
445 |
|
|
ll_tx_fsm_cs <= idle;
|
446 |
|
|
NPI_CORE_DOUT_out <= (others => '0');
|
447 |
|
|
NPI_CORE_DOUT_WE_out <= '0';
|
448 |
|
|
ll_tx_fsm_value_r <= (others => '0');
|
449 |
|
|
else
|
450 |
|
|
ll_tx_fsm_cs <= ll_tx_fsm_ns;
|
451 |
|
|
NPI_CORE_DOUT_out <= NPI_CORE_DOUT_next;
|
452 |
|
|
NPI_CORE_DOUT_WE_out <= NPI_CORE_DOUT_WE_next;
|
453 |
|
|
ll_tx_fsm_value_r <= ll_tx_fsm_value;
|
454 |
|
|
end if;
|
455 |
|
|
end if;
|
456 |
|
|
end process;
|
457 |
|
|
|
458 |
|
|
-----------------------------------------------------------------------------
|
459 |
|
|
-- PROCESS: LL_TX_FSM_LOGIC_PROC
|
460 |
|
|
-- PURPOSE: Next State and Output Function
|
461 |
|
|
-----------------------------------------------------------------------------
|
462 |
|
|
LL_TX_FSM_LOGIC_PROC : process (ll_tx_fsm_cs, ll_rx_fsm_cs,
|
463 |
|
|
tx_fifo_empty, tx_fifo_dout,
|
464 |
|
|
tx_fifo_valid) is
|
465 |
|
|
begin
|
466 |
|
|
ll_tx_fsm_ns <= ll_tx_fsm_cs;
|
467 |
|
|
NPI_CORE_DOUT_next <= NPI_CORE_DOUT_out;
|
468 |
|
|
NPI_CORE_DOUT_WE_next <= NPI_CORE_DOUT_WE_out;
|
469 |
|
|
|
470 |
|
|
case (ll_tx_fsm_cs) is
|
471 |
|
|
-------------------------------------------------------------------------
|
472 |
|
|
-- Idle State: 0 - Wait for valid data in TX FIFO
|
473 |
|
|
-------------------------------------------------------------------------
|
474 |
|
|
when idle =>
|
475 |
|
|
NPI_CORE_DOUT_next <= (others => '0');
|
476 |
|
|
NPI_CORE_DOUT_WE_next <= '0';
|
477 |
|
|
-- If it is a Write Request to RAMDisk (wait until Write is complete)
|
478 |
|
|
if (tx_fifo_empty = '0') and (ll_rx_fsm_cs = issue_wr_req) then
|
479 |
|
|
ll_tx_fsm_ns <= idle;
|
480 |
|
|
elsif (tx_fifo_empty = '0') then
|
481 |
|
|
ll_tx_fsm_ns <= xfer_data;
|
482 |
|
|
end if;
|
483 |
|
|
|
484 |
|
|
-------------------------------------------------------------------------
|
485 |
|
|
-- Xfer Data State: 1 - Transfer Data to Sata Core
|
486 |
|
|
-------------------------------------------------------------------------
|
487 |
|
|
when xfer_data =>
|
488 |
|
|
NPI_CORE_DOUT_next <= tx_fifo_dout;
|
489 |
|
|
if (SATA_CORE_FULL = '0') then
|
490 |
|
|
NPI_CORE_DOUT_WE_next <= '1';
|
491 |
|
|
else
|
492 |
|
|
NPI_CORE_DOUT_WE_next <= '0';
|
493 |
|
|
end if;
|
494 |
|
|
if (tx_fifo_empty = '1') then
|
495 |
|
|
--ll_tx_fsm_ns <= xfer_data;
|
496 |
|
|
ll_tx_fsm_ns <= idle;
|
497 |
|
|
end if;
|
498 |
|
|
|
499 |
|
|
-------------------------------------------------------------------------
|
500 |
|
|
-- Dead State: 4 - Stay in Dead State if something goes horribly wrong
|
501 |
|
|
-------------------------------------------------------------------------
|
502 |
|
|
when dead =>
|
503 |
|
|
NPI_CORE_DOUT_next <= (others => '0');
|
504 |
|
|
NPI_CORE_DOUT_WE_next <= '0';
|
505 |
|
|
ll_tx_fsm_ns <= dead;
|
506 |
|
|
|
507 |
|
|
when others =>
|
508 |
|
|
NPI_CORE_DOUT_next <= (others => '0');
|
509 |
|
|
NPI_CORE_DOUT_WE_next <= '0';
|
510 |
|
|
ll_tx_fsm_ns <= dead;
|
511 |
|
|
|
512 |
|
|
end case;
|
513 |
|
|
end process LL_TX_FSM_LOGIC_PROC;
|
514 |
|
|
|
515 |
|
|
NPI_CORE_DOUT_WE <= NPI_CORE_DOUT_WE_out;
|
516 |
|
|
NPI_CORE_DOUT <= NPI_CORE_DOUT_out;
|
517 |
|
|
NPI_ready_for_cmd <= NPI_ready_for_cmd_out;
|
518 |
|
|
|
519 |
|
|
-----------------------------------------------------------------------------
|
520 |
|
|
-- TX FIFO Instance
|
521 |
|
|
-----------------------------------------------------------------------------
|
522 |
|
|
tx_fifo_i : tx_fifo
|
523 |
|
|
port map (
|
524 |
|
|
din => tx_fifo_din,
|
525 |
|
|
rd_clk => user_clk,
|
526 |
|
|
rd_en => tx_fifo_re,
|
527 |
|
|
rst => reset,
|
528 |
|
|
wr_clk => MPMC_Clk,
|
529 |
|
|
wr_en => tx_fifo_we,
|
530 |
|
|
dout => tx_fifo_dout,
|
531 |
|
|
empty => tx_fifo_empty,
|
532 |
|
|
full => tx_fifo_full,
|
533 |
|
|
prog_full => tx_fifo_prog_full,
|
534 |
|
|
valid => tx_fifo_valid);
|
535 |
|
|
|
536 |
|
|
|
537 |
|
|
-----------------------------------------------------------------------------
|
538 |
|
|
-- NPI Instance
|
539 |
|
|
-----------------------------------------------------------------------------
|
540 |
|
|
npi_i : entity work.npi
|
541 |
|
|
generic map(
|
542 |
|
|
CHIPSCOPE => CHIPSCOPE,
|
543 |
|
|
END_SWAP => END_SWAP
|
544 |
|
|
)
|
545 |
|
|
port map(
|
546 |
|
|
npi_ila_control => npi_ila_control ,
|
547 |
|
|
MPMC_Clk => MPMC_Clk ,
|
548 |
|
|
NPI_Reset => reset ,
|
549 |
|
|
core_rfd => core_rfd ,
|
550 |
|
|
data_to_mem => data_to_mem ,
|
551 |
|
|
data_to_mem_we => data_to_mem_we ,
|
552 |
|
|
data_to_mem_re => data_to_mem_re ,
|
553 |
|
|
data_to_core => data_to_core ,
|
554 |
|
|
data_to_core_we => data_to_core_we ,
|
555 |
|
|
num_rd_bytes => num_rd_bytes ,
|
556 |
|
|
num_wr_bytes => num_wr_bytes ,
|
557 |
|
|
init_rd_addr => init_rd_addr ,
|
558 |
|
|
init_wr_addr => init_wr_addr ,
|
559 |
|
|
rd_req_start => rd_req_start ,
|
560 |
|
|
rd_req_done => rd_req_done ,
|
561 |
|
|
wr_req_start => wr_req_start ,
|
562 |
|
|
wr_req_done => wr_req_done ,
|
563 |
|
|
NPI_AddrAck => NPI_AddrAck ,
|
564 |
|
|
NPI_WrFIFO_AlmostFull => NPI_WrFIFO_AlmostFull,
|
565 |
|
|
NPI_RdFIFO_Empty => NPI_RdFIFO_Empty ,
|
566 |
|
|
NPI_InitDone => NPI_InitDone ,
|
567 |
|
|
NPI_WrFIFO_Empty => NPI_WrFIFO_Empty ,
|
568 |
|
|
NPI_RdFIFO_Latency => NPI_RdFIFO_Latency ,
|
569 |
|
|
NPI_RdFIFO_RdWdAddr => NPI_RdFIFO_RdWdAddr ,
|
570 |
|
|
NPI_RdFIFO_Data => NPI_RdFIFO_Data ,
|
571 |
|
|
NPI_AddrReq => NPI_AddrReq ,
|
572 |
|
|
NPI_RNW => NPI_RNW ,
|
573 |
|
|
NPI_WrFIFO_Push => NPI_WrFIFO_Push ,
|
574 |
|
|
NPI_RdFIFO_Pop => NPI_RdFIFO_Pop ,
|
575 |
|
|
NPI_RdModWr => NPI_RdModWr ,
|
576 |
|
|
NPI_WrFIFO_Flush => NPI_WrFIFO_Flush ,
|
577 |
|
|
NPI_RdFIFO_Flush => NPI_RdFIFO_Flush ,
|
578 |
|
|
NPI_Size => NPI_Size ,
|
579 |
|
|
NPI_WrFIFO_BE => NPI_WrFIFO_BE ,
|
580 |
|
|
NPI_Addr => NPI_Addr ,
|
581 |
|
|
NPI_WrFIFO_Data => NPI_WrFIFO_Data
|
582 |
|
|
);
|
583 |
|
|
|
584 |
|
|
-----------------------------------------------------------------------------
|
585 |
|
|
-- RAMDISK ILA Instance
|
586 |
|
|
-----------------------------------------------------------------------------
|
587 |
|
|
CHIPSCOPE_ILA_GEN: if (CHIPSCOPE) generate
|
588 |
|
|
npi_if_ila_i : npi_if_ila
|
589 |
|
|
port map (
|
590 |
|
|
CONTROL => npi_if_ila_control ,
|
591 |
|
|
CLK => MPMC_Clk ,
|
592 |
|
|
trig0 => init_rd_addr ,
|
593 |
|
|
trig1 => init_wr_addr ,
|
594 |
|
|
trig2 => rx_fifo_din ,
|
595 |
|
|
trig3 => ll_rx_fsm_value_r ,
|
596 |
|
|
trig4(0) => core_rfd ,
|
597 |
|
|
trig4(1) => data_to_mem_we ,
|
598 |
|
|
trig4(2) => data_to_mem_re ,
|
599 |
|
|
trig4(3) => rd_req_start ,
|
600 |
|
|
trig4(4) => wr_req_start ,
|
601 |
|
|
trig4(5) => rd_req_done ,
|
602 |
|
|
trig4(6) => wr_req_done ,
|
603 |
|
|
trig4(7) => '0',
|
604 |
|
|
trig4(8) => tx_fifo_re ,
|
605 |
|
|
trig4(9) => tx_fifo_we ,
|
606 |
|
|
trig4(10) => tx_fifo_empty ,
|
607 |
|
|
trig4(11) => tx_fifo_full ,
|
608 |
|
|
trig4(12) => tx_fifo_prog_full ,
|
609 |
|
|
trig4(13) => tx_fifo_valid ,
|
610 |
|
|
trig4(14) => rx_fifo_re ,
|
611 |
|
|
trig4(15) => rx_fifo_we ,
|
612 |
|
|
trig4(16) => rx_fifo_empty ,
|
613 |
|
|
trig4(17) => rx_fifo_full ,
|
614 |
|
|
trig4(18) => rx_fifo_valid ,
|
615 |
|
|
trig4(19) => rx_fifo_prog_full ,
|
616 |
|
|
trig4(20) => new_cmd_r,
|
617 |
|
|
trig4(21) => NPI_ready_for_cmd_out,
|
618 |
|
|
trig4(22) => new_cmd_r2 ,
|
619 |
|
|
trig4(23) => '0' ,
|
620 |
|
|
trig5 => rx_fifo_dout,
|
621 |
|
|
trig6 => tx_fifo_din,
|
622 |
|
|
trig7 => num_rd_bytes
|
623 |
|
|
);
|
624 |
|
|
|
625 |
|
|
npi_if_tx_ila_i : npi_if_tx_ila
|
626 |
|
|
port map (
|
627 |
|
|
CONTROL => npi_if_tx_ila_control ,
|
628 |
|
|
CLK => user_clk ,
|
629 |
|
|
trig0 => ll_tx_fsm_value_r ,
|
630 |
|
|
trig1 => NPI_CORE_DOUT_out,
|
631 |
|
|
trig2(0) => core_rfd ,
|
632 |
|
|
trig2(1) => rd_req_start ,
|
633 |
|
|
trig2(2) => rd_req_done ,
|
634 |
|
|
trig2(3) => NPI_CORE_DOUT_we_out,
|
635 |
|
|
trig2(4) => tx_fifo_re,
|
636 |
|
|
trig2(5) => tx_fifo_empty,
|
637 |
|
|
trig2(6) => tx_fifo_prog_full,
|
638 |
|
|
trig2(7) => SATA_CORE_FULL
|
639 |
|
|
);
|
640 |
|
|
|
641 |
|
|
end generate CHIPSCOPE_ILA_GEN;
|
642 |
|
|
|
643 |
|
|
|
644 |
|
|
end BEH;
|