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

Subversion Repositories sata_controller_core

[/] [sata_controller_core/] [trunk/] [sata2_bus_v1_00_a/] [base_system/] [pcores/] [sata_core_v1_00_a/] [hdl/] [vhdl/] [user_logic.vhd] - Blame information for rev 11

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 11 ashwin_men
------------------------------------------------------------------------------
2
-- user_logic.vhd - entity/architecture pair
3
------------------------------------------------------------------------------
4
--
5
-- ***************************************************************************
6
-- ** Copyright (c) 1995-2010 Xilinx, Inc.  All rights reserved.            **
7
-- **                                                                       **
8
-- ** Xilinx, Inc.                                                          **
9
-- ** XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"         **
10
-- ** AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND       **
11
-- ** SOLUTIONS FOR XILINX DEVICES.  BY PROVIDING THIS DESIGN, CODE,        **
12
-- ** OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,        **
13
-- ** APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION           **
14
-- ** THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,     **
15
-- ** AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE      **
16
-- ** FOR YOUR IMPLEMENTATION.  XILINX EXPRESSLY DISCLAIMS ANY              **
17
-- ** WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE               **
18
-- ** IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR        **
19
-- ** REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF       **
20
-- ** INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS       **
21
-- ** FOR A PARTICULAR PURPOSE.                                             **
22
-- **                                                                       **
23
-- ***************************************************************************
24
--
25
------------------------------------------------------------------------------
26
-- Filename:          user_logic.vhd
27
-- Version:           1.00.a
28
-- Description:       User logic.
29
-- Date:              Fri Jun 17 14:13:01 2011 (by Create and Import Peripheral Wizard)
30
-- VHDL Standard:     VHDL'93
31
------------------------------------------------------------------------------
32
-- Naming Conventions:
33
--   active low signals:                    "*_n"
34
--   clock signals:                         "clk", "clk_div#", "clk_#x"
35
--   reset signals:                         "rst", "rst_n"
36
--   generics:                              "C_*"
37
--   user defined types:                    "*_TYPE"
38
--   state machine next state:              "*_ns"
39
--   state machine current state:           "*_cs"
40
--   combinatorial signals:                 "*_com"
41
--   pipelined or register delay signals:   "*_d#"
42
--   counter signals:                       "*cnt*"
43
--   clock enable signals:                  "*_ce"
44
--   internal version of output port:       "*_i"
45
--   device pins:                           "*_pin"
46
--   ports:                                 "- Names begin with Uppercase"
47
--   processes:                             "*_PROCESS"
48
--   component instantiations:              "<ENTITY_>I_<#|FUNC>"
49
------------------------------------------------------------------------------
50
 
51
-- DO NOT EDIT BELOW THIS LINE --------------------
52
library ieee;
53
use ieee.std_logic_1164.all;
54
use ieee.std_logic_arith.all;
55
use ieee.std_logic_unsigned.all;
56
 
57
library proc_common_v3_00_a;
58
use proc_common_v3_00_a.proc_common_pkg.all;
59
 
60
-- DO NOT EDIT ABOVE THIS LINE --------------------
61
 
62
--USER libraries added here
63
 
64
------------------------------------------------------------------------------
65
-- Entity section
66
------------------------------------------------------------------------------
67
-- Definition of Generics:
68
--   C_SLV_DWIDTH                 -- Slave interface data bus width
69
--   C_NUM_REG                    -- Number of software accessible registers
70
--
71
-- Definition of Ports:
72
--   Bus2IP_Clk                   -- Bus to IP clock
73
--   Bus2IP_Reset                 -- Bus to IP reset
74
--   Bus2IP_Data                  -- Bus to IP data bus
75
--   Bus2IP_BE                    -- Bus to IP byte enables
76
--   Bus2IP_RdCE                  -- Bus to IP read chip enable
77
--   Bus2IP_WrCE                  -- Bus to IP write chip enable
78
--   IP2Bus_Data                  -- IP to Bus data bus
79
--   IP2Bus_RdAck                 -- IP to Bus read transfer acknowledgement
80
--   IP2Bus_WrAck                 -- IP to Bus write transfer acknowledgement
81
--   IP2Bus_Error                 -- IP to Bus error response
82
------------------------------------------------------------------------------
83
 
84
entity user_logic is
85
  generic
86
  (
87
    -- ADD USER GENERICS BELOW THIS LINE ---------------
88
    --USER generics added here
89
    CHIPSCOPE                      : boolean := false;
90
    DATA_WIDTH                     : natural := 32;
91
    -- ADD USER GENERICS ABOVE THIS LINE ---------------
92
 
93
    -- DO NOT EDIT BELOW THIS LINE ---------------------
94
    -- Bus protocol parameters, do not add to or delete
95
    C_SLV_DWIDTH                   : integer := 32;
96
    C_NUM_REG                      : integer := 8
97
    -- DO NOT EDIT ABOVE THIS LINE ---------------------
98
  );
99
  port
100
  (
101
    -- ADD USER PORTS BELOW THIS LINE ------------------
102
    user_logic_ila_control     : in std_logic_vector (35 downto 0);
103
    cmd_layer_ila_control      : in std_logic_vector (35 downto 0);
104
    sata_rx_frame_ila_control  : in std_logic_vector (35 downto 0);
105
    sata_tx_frame_ila_control  : in std_logic_vector (35 downto 0);
106
    sata_phy_ila_control       : in std_logic_vector (35 downto 0);
107
    oob_control_ila_control    : in std_logic_vector (35 downto 0);
108
    scrambler_ila_control      : in std_logic_vector (35 downto 0);
109
    descrambler_ila_control    : in std_logic_vector (35 downto 0);
110
    -----------------------------------------------------
111
    --TILE0_REFCLK_PAD_P_IN : in std_logic;     -- MGTCLKA,  clocks GTP_X0Y0-2 
112
    --TILE0_REFCLK_PAD_N_IN : in std_logic;     -- MGTCLKA 
113
    TXP0_OUT              : out std_logic;
114
    TXN0_OUT              : out std_logic;
115
    RXP0_IN               : in std_logic;
116
    RXN0_IN               : in std_logic;
117
    TILE0_PLLLKDET_OUT_N  : out std_logic;
118
    DCMLOCKED_OUT         : out std_logic;
119
    LINKUP_led            : out std_logic;
120
    GEN2_led              : out std_logic;
121
    RESET                 : in std_logic;
122
    --GTX_RESET_IN          : in std_logic; 
123
    --new_cmd_in            : in std_logic; 
124
    CLKIN_150             : in std_logic;
125
    SATA_CORE_DOUT        : out std_logic_vector(0 to 31);
126
    SATA_CORE_DOUT_WE     : out std_logic;
127
    SATA_CORE_CLK_OUT     : out std_logic;
128
    SATA_CORE_DIN         : in std_logic_vector(0 to 31);
129
    SATA_CORE_DIN_WE      : in std_logic;
130
    SATA_CORE_FULL        : out std_logic;
131
    NPI_CORE_REQ_TYPE     : out std_logic_vector (0 to 1);
132
    NPI_CORE_NEW_CMD      : out std_logic;
133
    NPI_CORE_NUM_RD_BYTES : out std_logic_vector (0 to 31);
134
    NPI_CORE_NUM_WR_BYTES : out std_logic_vector (0 to 31);
135
    NPI_CORE_INIT_WR_ADDR : out std_logic_vector (0 to 31);
136
    NPI_CORE_INIT_RD_ADDR : out std_logic_vector (0 to 31);
137
    NPI_CORE_READY_FOR_CMD: in std_logic;
138
 
139
    --USER ports added here
140
    -- ADD USER PORTS ABOVE THIS LINE ------------------
141
 
142
    -- DO NOT EDIT BELOW THIS LINE ---------------------
143
    -- Bus protocol ports, do not add to or delete
144
    Bus2IP_Clk                     : in  std_logic;
145
    Bus2IP_Reset                   : in  std_logic;
146
    Bus2IP_Data                    : in  std_logic_vector(0 to C_SLV_DWIDTH-1);
147
    Bus2IP_BE                      : in  std_logic_vector(0 to C_SLV_DWIDTH/8-1);
148
    Bus2IP_RdCE                    : in  std_logic_vector(0 to C_NUM_REG-1);
149
    Bus2IP_WrCE                    : in  std_logic_vector(0 to C_NUM_REG-1);
150
    IP2Bus_Data                    : out std_logic_vector(0 to C_SLV_DWIDTH-1);
151
    IP2Bus_RdAck                   : out std_logic;
152
    IP2Bus_WrAck                   : out std_logic;
153
    IP2Bus_Error                   : out std_logic
154
    -- DO NOT EDIT ABOVE THIS LINE ---------------------
155
  );
156
 
157
  attribute SIGIS : string;
158
  attribute SIGIS of Bus2IP_Clk    : signal is "CLK";
159
  attribute SIGIS of Bus2IP_Reset  : signal is "RST";
160
 
161
end entity user_logic;
162
 
163
------------------------------------------------------------------------------
164
-- Architecture section
165
------------------------------------------------------------------------------
166
 
167
architecture IMP of user_logic is
168
 
169
  --USER signal declarations added here, as needed for user logic
170
 
171
  ------------------------------------------
172
  -- Signals for user logic slave model s/w accessible register example
173
  ------------------------------------------
174
  signal ctrl_reg                       : std_logic_vector(0 to C_SLV_DWIDTH-1);
175
  signal cmd_reg                        : std_logic_vector(0 to C_SLV_DWIDTH-1);
176
  signal status_reg                     : std_logic_vector(0 to C_SLV_DWIDTH-1);
177
  signal sector_addr_reg                : std_logic_vector(0 to C_SLV_DWIDTH-1);
178
  signal sector_count_reg               : std_logic_vector(0 to C_SLV_DWIDTH-1);
179
  signal sector_timer_reg               : std_logic_vector(0 to C_SLV_DWIDTH-1);
180
  signal npi_rd_addr_reg                : std_logic_vector(0 to C_SLV_DWIDTH-1);
181
  signal npi_wr_addr_reg                : std_logic_vector(0 to C_SLV_DWIDTH-1);
182
  signal slv_reg_write_sel              : std_logic_vector(0 to 7);
183
  signal slv_reg_read_sel               : std_logic_vector(0 to 7);
184
  signal slv_ip2bus_data                : std_logic_vector(0 to C_SLV_DWIDTH-1);
185
  signal slv_read_ack                   : std_logic;
186
  signal slv_write_ack                  : std_logic;
187
 
188
  constant SECTOR_NDWORDS               : integer := 128;  -- 128 DWORDS / 512 Byte Sector    
189
  constant READ_DMA_CMD                 : std_logic_vector(1 downto 0) := "01";
190
  constant WRITE_DMA_CMD                : std_logic_vector(1 downto 0) := "10";
191
  constant NPI_READ_REQ     : std_logic_vector(1 downto 0) := "01";
192
  constant NPI_WRITE_REQ     : std_logic_vector(1 downto 0) := "10";
193
  constant BYTES_PER_SECTOR : integer := 512;
194
 
195
  signal sw_reset                       : std_logic;
196
  signal sata_phy_clk                   : std_logic;
197
  signal GTXRESET                       : std_logic;
198
  signal LINKUP_led_i                   : std_logic;
199
 
200
  signal new_cmd_in                     : std_logic;
201
  signal new_cmd                        : std_logic;
202
  signal cmd_started                    : std_logic;
203
  signal cmd_type                       : std_logic_vector(1 downto 0);
204
  signal ready_for_cmd                  : std_logic;
205
  signal sata_dout                      : std_logic_vector(31 downto 0);
206
  signal sata_dout_re                   : std_logic;
207
  signal sector_count_int               : integer;
208
  signal sector_count                   : std_logic_vector(31 downto 0);
209
  signal sector_addr                    : std_logic_vector(31 downto 0);
210
  signal read_fifo_empty                : std_logic;
211
  signal sata_core_full_i               : std_logic;
212
  signal sata_user_data_clk_in_i        : std_logic;
213
 
214
  -- NPI 
215
  signal  npi_ready_for_cmd      : std_logic;
216
  signal  npi_new_cmd            : std_logic;
217
  signal  npi_req_type           : std_logic_vector(1 downto 0);
218
  signal  npi_num_rd_bytes       : std_logic_vector(31 downto 0);
219
  signal  npi_init_rd_addr       : std_logic_vector(31 downto 0);
220
  signal  npi_num_wr_bytes       : std_logic_vector(31 downto 0);
221
  signal  npi_init_wr_addr       : std_logic_vector(31 downto 0);
222
  signal  npi_new_cmd_next       : std_logic;
223
  signal  npi_req_type_next      : std_logic_vector(1 downto 0);
224
  signal  npi_num_rd_bytes_next  : std_logic_vector(31 downto 0);
225
  signal  npi_init_rd_addr_next  : std_logic_vector(31 downto 0);
226
  signal  npi_num_wr_bytes_next  : std_logic_vector(31 downto 0);
227
  signal  npi_init_wr_addr_next  : std_logic_vector(31 downto 0);
228
 
229
 -----------------------------------------------------------------------------
230
  -- TestBench FSM Declaration (curr and next states)
231
 -----------------------------------------------------------------------------
232
  type TEST_FSM_TYPE is (wait_for_cmd, wait_for_ready_low, wait_for_ack,
233
                         dead
234
                         );
235
  signal test_fsm_curr, test_fsm_next : TEST_FSM_TYPE := wait_for_cmd;
236
  signal test_fsm_value               : std_logic_vector (0 to 3);
237
 
238
  -- USER FIFO DECLARATION
239
  component user_fifo
240
        port (
241
        wr_clk: IN std_logic;
242
        rd_clk: IN std_logic;
243
        rst: IN std_logic;
244
        din: IN std_logic_VECTOR(31 downto 0);
245
        wr_en: IN std_logic;
246
        rd_en: IN std_logic;
247
        dout: OUT std_logic_VECTOR(31 downto 0);
248
        full: OUT std_logic;
249
        prog_full: OUT std_logic;
250
        empty: OUT std_logic);
251
  end component;
252
 
253
  component user_logic_ila
254
    port (
255
      control : in std_logic_vector(35 downto 0);
256
      clk     : in std_logic;
257
      trig0   : in std_logic_vector(3  downto 0);
258
      trig1   : in std_logic_vector(31 downto 0);
259
      trig2   : in std_logic_vector(31 downto 0);
260
      trig3   : in std_logic_vector(31 downto 0);
261
      trig4   : in std_logic_vector(31 downto 0);
262
      trig5   : in std_logic_vector(7 downto 0)
263
   );
264
  end component;
265
 
266
 
267
 
268
begin
269
 
270
  --USER logic implementation added here
271
 
272
  ------------------------------------------
273
  -- Example code to read/write user logic slave model s/w accessible registers
274
  -- 
275
  -- Note:
276
  -- The example code presented here is to show you one way of reading/writing
277
  -- software accessible registers implemented in the user logic slave model.
278
  -- Each bit of the Bus2IP_WrCE/Bus2IP_RdCE signals is configured to correspond
279
  -- to one software accessible register by the top level template. For example,
280
  -- if you have four 32 bit software accessible registers in the user logic,
281
  -- you are basically operating on the following memory mapped registers:
282
  -- 
283
  --    Bus2IP_WrCE/Bus2IP_RdCE   Memory Mapped Register
284
  --                     "1000"   C_BASEADDR + 0x0
285
  --                     "0100"   C_BASEADDR + 0x4
286
  --                     "0010"   C_BASEADDR + 0x8
287
  --                     "0001"   C_BASEADDR + 0xC
288
  -- 
289
  ------------------------------------------
290
  slv_reg_write_sel <= Bus2IP_WrCE(0 to 7);
291
  slv_reg_read_sel  <= Bus2IP_RdCE(0 to 7);
292
  slv_write_ack     <= Bus2IP_WrCE(0) or Bus2IP_WrCE(1) or Bus2IP_WrCE(2) or Bus2IP_WrCE(3) or Bus2IP_WrCE(4) or Bus2IP_WrCE(5)  or Bus2IP_WrCE(6) or Bus2IP_WrCE(7);
293
  slv_read_ack      <= Bus2IP_RdCE(0) or Bus2IP_RdCE(1) or Bus2IP_RdCE(2) or Bus2IP_RdCE(3) or Bus2IP_RdCE(4) or Bus2IP_RdCE(5)  or Bus2IP_RdCE(6) or Bus2IP_RdCE(7);
294
 
295
  -- implement slave model software accessible register(s)
296
  SLAVE_REG_WRITE_PROC : process( Bus2IP_Clk ) is
297
  begin
298
    if Bus2IP_Clk'event and Bus2IP_Clk = '1' then
299
      if Bus2IP_Reset = '1' then
300
        ctrl_reg <= (others => '0');
301
        cmd_reg <= (others => '0');
302
        sector_addr_reg  <= (others => '0');
303
        sector_count_reg <= (others => '0');
304
        npi_rd_addr_reg  <= (others => '0');
305
        npi_wr_addr_reg  <= (others => '0');
306
      else
307
        case slv_reg_write_sel is
308
          when "10000000" =>
309
            for byte_index in 0 to (C_SLV_DWIDTH/8)-1 loop
310
              if ( Bus2IP_BE(byte_index) = '1' ) then
311
                ctrl_reg(byte_index*8 to byte_index*8+7) <= Bus2IP_Data(byte_index*8 to byte_index*8+7);
312
              end if;
313
            end loop;
314
          when "01000000" =>
315
            for byte_index in 0 to (C_SLV_DWIDTH/8)-1 loop
316
              if ( Bus2IP_BE(byte_index) = '1' ) then
317
                cmd_reg(byte_index*8 to byte_index*8+7) <= Bus2IP_Data(byte_index*8 to byte_index*8+7);
318
              end if;
319
            end loop;
320
         when "00010000" =>
321
            for byte_index in 0 to (C_SLV_DWIDTH/8)-1 loop
322
              if ( Bus2IP_BE(byte_index) = '1' ) then
323
                sector_addr_reg(byte_index*8 to byte_index*8+7) <= Bus2IP_Data(byte_index*8 to byte_index*8+7);
324
              end if;
325
            end loop;
326
          when "00001000" =>
327
            for byte_index in 0 to (C_SLV_DWIDTH/8)-1 loop
328
              if ( Bus2IP_BE(byte_index) = '1' ) then
329
                sector_count_reg(byte_index*8 to byte_index*8+7) <= Bus2IP_Data(byte_index*8 to byte_index*8+7);
330
              end if;
331
            end loop;
332
          when "00000010" =>
333
            for byte_index in 0 to (C_SLV_DWIDTH/8)-1 loop
334
              if ( Bus2IP_BE(byte_index) = '1' ) then
335
                npi_rd_addr_reg(byte_index*8 to byte_index*8+7) <= Bus2IP_Data(byte_index*8 to byte_index*8+7);
336
              end if;
337
            end loop;
338
          when "00000001" =>
339
            for byte_index in 0 to (C_SLV_DWIDTH/8)-1 loop
340
              if ( Bus2IP_BE(byte_index) = '1' ) then
341
                npi_wr_addr_reg(byte_index*8 to byte_index*8+7) <= Bus2IP_Data(byte_index*8 to byte_index*8+7);
342
              end if;
343
            end loop;
344
          when others => null;
345
        end case;
346
      end if;
347
    end if;
348
  end process SLAVE_REG_WRITE_PROC;
349
 
350
  -- implement slave model software accessible register(s) read mux
351
  SLAVE_REG_READ_PROC : process(slv_reg_read_sel, ctrl_reg, cmd_reg, status_reg, sector_addr_reg,
352
                                 sector_count_reg, sector_timer_reg, npi_rd_addr_reg, npi_wr_addr_reg) is
353
  begin
354
 
355
    case slv_reg_read_sel is
356
      when "10000000" => slv_ip2bus_data <= ctrl_reg;
357
      when "01000000" => slv_ip2bus_data <= cmd_reg;
358
      when "00100000" => slv_ip2bus_data <= status_reg;
359
      when "00010000" => slv_ip2bus_data <= sector_addr_reg;
360
      when "00001000" => slv_ip2bus_data <= sector_count_reg;
361
      when "00000100" => slv_ip2bus_data <= sector_timer_reg;
362
      when "00000010" => slv_ip2bus_data <= npi_rd_addr_reg;
363
      when "00000001" => slv_ip2bus_data <= npi_wr_addr_reg;
364
      when others => slv_ip2bus_data <= (others => '0');
365
    end case;
366
 
367
  end process SLAVE_REG_READ_PROC;
368
 
369
 
370
 
371
  ------------------------------------------
372
  -- Example code to drive IP to Bus signals
373
  ------------------------------------------
374
  IP2Bus_Data  <= slv_ip2bus_data when slv_read_ack = '1' else
375
                  (others => '0');
376
 
377
  IP2Bus_WrAck <= slv_write_ack;
378
  IP2Bus_RdAck <= slv_read_ack;
379
  IP2Bus_Error <= '0';
380
 
381
  -------------------------------------------
382
  -- SATA --
383
  -------------------------------------------
384
  sw_reset      <=  ctrl_reg(31); -- Software Reset
385
  -- Testbench Signals
386
  new_cmd_in    <=  ctrl_reg(30);
387
  cmd_type      <=  cmd_reg(30 to 31);
388
  sector_addr   <=  sector_addr_reg;
389
  sector_count_int  <=  conv_integer(sector_count_reg);
390
  sector_count  <=  sector_count_reg;
391
  status_reg(31) <= ready_for_cmd;
392
  status_reg(30) <= LINKUP_led_i;
393
  status_reg(29) <= npi_ready_for_cmd;
394
  sata_dout_re  <=  '1' when (read_fifo_empty = '0') else '0';
395
 
396
  -- De-Assert new_cmd after 1 clk cycle
397
  REG_PROC: process (sata_phy_clk)
398
  begin
399
    if ((sata_phy_clk'event) and (sata_phy_clk = '1')) then
400
      if (GTXRESET = '1') then
401
         new_cmd      <= '0';
402
         cmd_started  <= '0';
403
      elsif(new_cmd_in = '0') then
404
         cmd_started  <= '0';
405
      elsif (new_cmd_in = '1' and cmd_started = '0') then
406
         new_cmd      <= '1';
407
         cmd_started  <= '1';
408
      elsif (cmd_started = '1') then
409
         new_cmd      <= '0';
410
      end if;
411
    end if;
412
  end process REG_PROC;
413
 
414
 -----------------------------------------------------------------------------
415
  -- PROCESS: TEST_FSM_VALUE_PROC
416
  -- PURPOSE: ChipScope State Indicator Signal
417
  -----------------------------------------------------------------------------
418
  TEST_FSM_VALUE_PROC : process (test_fsm_curr) is
419
  begin
420
    case (test_fsm_curr) is
421
      when wait_for_cmd       => test_fsm_value <= x"0";
422
      when wait_for_ready_low => test_fsm_value <= x"1";
423
      when wait_for_ack       => test_fsm_value <= x"2";
424
      when dead               => test_fsm_value <= x"3";
425
      when others             => test_fsm_value <= x"4";
426
    end case;
427
  end process TEST_FSM_VALUE_PROC;
428
 
429
  -----------------------------------------------------------------------------
430
  -- PROCESS: TEST_FSM_STATE_PROC
431
  -- PURPOSE: Registering Signals and Next State
432
  -----------------------------------------------------------------------------
433
  TEST_FSM_STATE_PROC: process (sata_phy_clk)
434
  begin
435
    if ((sata_phy_clk'event) and (sata_phy_clk = '1')) then
436
      if (GTXRESET = '1') then
437
        --Initializing internal signals
438
       npi_new_cmd            <= '0';
439
       npi_req_type           <= (others => '0');
440
       npi_num_rd_bytes       <= (others => '0');
441
       npi_init_rd_addr       <= (others => '0');
442
       npi_num_wr_bytes       <= (others => '0');
443
       npi_init_wr_addr       <= (others => '0');
444
       npi_ready_for_cmd      <= '0';
445
       test_fsm_curr          <= wait_for_cmd;
446
      else
447
        -- Register all Current Signals to their _next Signals
448
        npi_new_cmd            <= npi_new_cmd_next;
449
        npi_req_type           <= npi_req_type_next;
450
        npi_num_rd_bytes       <= npi_num_rd_bytes_next;
451
        npi_init_rd_addr       <= npi_init_rd_addr_next;
452
        npi_num_wr_bytes       <= npi_num_wr_bytes_next;
453
        npi_init_wr_addr       <= npi_init_wr_addr_next;
454
        npi_ready_for_cmd      <= NPI_CORE_READY_FOR_CMD;
455
        test_fsm_curr          <= test_fsm_next;
456
      end if;
457
    end if;
458
  end process TEST_FSM_STATE_PROC;
459
 
460
   -----------------------------------------------------------------------------
461
  -- PROCESS: TEST_FSM_LOGIC_PROC 
462
  -- PURPOSE: Registering Signals and Next State
463
  -----------------------------------------------------------------------------
464
  TEST_FSM_LOGIC_PROC : process (test_fsm_curr, new_cmd
465
                                   ) is
466
  begin
467
    -- Register _next to current signals
468
    test_fsm_next          <= test_fsm_curr;
469
    npi_new_cmd_next       <= npi_new_cmd;
470
    npi_req_type_next      <= npi_req_type;
471
    npi_num_rd_bytes_next  <= npi_num_rd_bytes;
472
    npi_init_rd_addr_next  <= npi_init_rd_addr;
473
    npi_num_wr_bytes_next  <= npi_num_wr_bytes;
474
    npi_init_wr_addr_next  <= npi_init_wr_addr;
475
 
476
    ---------------------------------------------------------------------------
477
    -- Finite State Machine
478
    ---------------------------------------------------------------------------
479
    case (test_fsm_curr) is
480
 
481
     -- x0
482
     when wait_for_cmd =>
483
         if (new_cmd = '1') then
484
            test_fsm_next  <= wait_for_ready_low;
485
         end if;
486
 
487
     -- x1
488
     when wait_for_ready_low =>
489
         if (ready_for_cmd = '0') then
490
           if (cmd_type = WRITE_DMA_CMD) then
491
              npi_req_type_next <= NPI_READ_REQ;
492
              npi_num_rd_bytes_next  <= conv_std_logic_vector((sector_count_int * BYTES_PER_SECTOR), 32);
493
              npi_init_rd_addr_next  <= npi_rd_addr_reg;
494
           else
495
              npi_req_type_next <= NPI_WRITE_REQ;
496
              npi_num_wr_bytes_next  <= conv_std_logic_vector((sector_count_int * BYTES_PER_SECTOR), 32);
497
              npi_init_wr_addr_next  <= npi_wr_addr_reg;
498
           end if;
499
           if (npi_ready_for_cmd = '1') then
500
              npi_new_cmd_next <= '1';
501
           end if;
502
           test_fsm_next  <= wait_for_ack;
503
         end if;
504
 
505
     -- x2
506
     when wait_for_ack =>
507
         if (ready_for_cmd = '1') then
508
            npi_new_cmd_next <= '0';
509
            test_fsm_next  <= wait_for_cmd;
510
         end if;
511
 
512
     -- x3
513
     when dead =>
514
         test_fsm_next  <= dead;
515
 
516
     -- x4
517
     when others =>
518
         test_fsm_next  <= dead;
519
 
520
   end case;
521
 end process TEST_FSM_LOGIC_PROC;
522
 
523
 NPI_CORE_REQ_TYPE     <= npi_req_type;
524
 NPI_CORE_NEW_CMD      <= npi_new_cmd;
525
 NPI_CORE_NUM_RD_BYTES <= npi_num_rd_bytes;
526
 NPI_CORE_NUM_WR_BYTES <= npi_num_wr_bytes;
527
 NPI_CORE_INIT_WR_ADDR <= npi_init_wr_addr;
528
 NPI_CORE_INIT_RD_ADDR <= npi_init_rd_addr;
529
 
530
  -------------------------------------------
531
  -- Sata Command Layer Module Instance
532
  ------------------------------------------
533
  -- Output to NPI 
534
  SATA_CORE_DOUT     <= sata_dout;
535
  SATA_CORE_DOUT_WE  <= sata_dout_re;
536
  SATA_CORE_CLK_OUT  <= sata_phy_clk;
537
  SATA_CORE_FULL     <= sata_core_full_i;
538
  -- Output to NPI
539
 
540
  ------------------------------------------
541
  -- Sata Link Layer Module Instance
542
  ------------------------------------------
543
  --GTXRESET   <=   GTX_RESET_IN or RESET;
544
  GTXRESET          <=   sw_reset or RESET;
545
  LINKUP_led        <=   LINKUP_led_i;
546
 
547
  SATA_CORE_TOP_i: entity work.sata_core_top
548
  generic map (
549
    CHIPSCOPE           => CHIPSCOPE,
550
    DATA_WIDTH          => DATA_WIDTH
551
       )
552
  port map(
553
   -- Clock and Reset Signals
554
    CLKIN_150            => CLKIN_150 , --GTX Ref Clk 
555
    reset                => GTXRESET,
556
    -- ChipScope ILA / Trigger Signals
557
    cmd_layer_ila_control      => cmd_layer_ila_control,
558
    sata_rx_frame_ila_control  => sata_rx_frame_ila_control  ,
559
    sata_tx_frame_ila_control  => sata_tx_frame_ila_control  ,
560
    oob_control_ila_control    => oob_control_ila_control,
561
    sata_phy_ila_control       => sata_phy_ila_control,
562
    scrambler_ila_control      => scrambler_ila_control,
563
    descrambler_ila_control    => descrambler_ila_control,
564
    ---------------------------------------
565
    -- SATA Interface -----
566
      -- Command, Control and Status --
567
    ready_for_cmd        => ready_for_cmd,
568
    new_cmd              => new_cmd,
569
    cmd_type             => cmd_type,
570
    sector_count         => sector_count,
571
    sector_addr          => sector_addr,
572
      -- Data and User Clock --
573
    sata_din             =>  SATA_CORE_DIN,
574
    sata_din_we          =>  SATA_CORE_DIN_WE,
575
    sata_core_full       =>  sata_core_full_i,
576
    sata_dout            =>  sata_dout,
577
    sata_dout_re         =>  sata_dout_re,
578
    sata_core_empty      =>  read_fifo_empty,
579
    SATA_USER_DATA_CLK_IN  => sata_user_data_clk_in_i,
580
    SATA_USER_DATA_CLK_OUT => sata_phy_clk,
581
 
582
    -- Timer --
583
    sata_timer            => sector_timer_reg,
584
    -- Sata Phy Signals
585
    --REFCLK_PAD_P_IN       => TILE0_REFCLK_PAD_P_IN,     
586
    --REFCLK_PAD_N_IN       => TILE0_REFCLK_PAD_N_IN,  
587
    TXP0_OUT              => TXP0_OUT,
588
    TXN0_OUT              => TXN0_OUT,
589
    RXP0_IN               => RXP0_IN,
590
    RXN0_IN               => RXN0_IN,
591
    PLLLKDET_OUT_N        => TILE0_PLLLKDET_OUT_N,
592
    DCMLOCKED_OUT         => DCMLOCKED_OUT,
593
    LINKUP                => LINKUP_led_i
594
);
595
 
596
 
597
  USER_LOGIC_ILA_i : user_logic_ila
598
    port map (
599
      control  => user_logic_ila_control,
600
      clk      => sata_phy_clk,
601
      trig0    => test_fsm_value,
602
      trig1    => SATA_CORE_DIN,
603
      trig2    => (others => '0'),
604
      trig3    => (others => '0'),
605
      trig4    => (others => '0'),
606
      trig5(0) => new_cmd,
607
      trig5(1) => SATA_CORE_DIN_WE,
608
      trig5(2) => sata_core_full_i,
609
      trig5(3) => ready_for_cmd,
610
      trig5(4) => new_cmd,
611
      trig5(5) => npi_ready_for_cmd,
612
      trig5(6) => npi_new_cmd,
613
      trig5(7) => sata_dout_re
614
     );
615
 
616
end IMP;

powered by: WebSVN 2.1.0

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