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

Subversion Repositories sdr_ctrl

[/] [sdr_ctrl/] [trunk/] [rtl/] [wb2sdrc/] [wb2sdrc.v] - Diff between revs 31 and 33

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 31 Rev 33
Line 2... Line 2...
 
 
  This file is part of the sdram controller project
  This file is part of the sdram controller project
  http://www.opencores.org/cores/sdr_ctrl/
  http://www.opencores.org/cores/sdr_ctrl/
 
 
  Description: WISHBONE to SDRAM Controller Bus Transalator
  Description: WISHBONE to SDRAM Controller Bus Transalator
  This module translate the WISHBONE protocol to custom sdram controller i/f
     1. This module translate the WISHBONE protocol to custom sdram controller i/f
 
     2. Also Handle the clock domain change from Application layer to Sdram layer
 
 
  To Do:
  To Do:
    nothing
    nothing
 
 
  Author(s):  Dinesh Annayya, dinesha@opencores.org
  Author(s):  Dinesh Annayya, dinesha@opencores.org
Line 136... Line 137...
wire                    rddatafifo_full;
wire                    rddatafifo_full;
 
 
reg                     pending_read;
reg                     pending_read;
 
 
 
 
// Generate Address Enable only when internal fifo (Address + data are not full
//-----------------------------------------------------------------------------
 
// Ack Generaltion Logic
 
//  If Write Request - Acknowledge if the command and write FIFO are not full
 
//  If Read Request  - Generate the Acknowledgment once read fifo has data
 
//                     available
 
//-----------------------------------------------------------------------------
 
 
assign wb_ack_o = (wb_stb_i && wb_cyc_i && wb_we_i) ?  // Write Phase
assign wb_ack_o = (wb_stb_i && wb_cyc_i && wb_we_i) ?  // Write Phase
                          ((!cmdfifo_full) && (!wrdatafifo_full)) :
                          ((!cmdfifo_full) && (!wrdatafifo_full)) :
                  (wb_stb_i && wb_cyc_i && !wb_we_i) ? // Read Phase 
                  (wb_stb_i && wb_cyc_i && !wb_we_i) ? // Read Phase 
                           !rddatafifo_empty : 1'b0;
                           !rddatafifo_empty : 1'b0;
 
 
// Accept the cmdfifo only when burst start + address enable + address
//---------------------------------------------------------------------------
// valid is asserted
// Command FIFO Write Generation
wire           cmdfifo_wr   = (wb_stb_i && wb_cyc_i && wb_we_i) ? wb_ack_o :
//    If Write Request - Generate write, when Write fifo and command fifo is
                              (wb_stb_i && wb_cyc_i && !wb_we_i) ? !pending_read: 1'b0 ;
//                       not full
 
//    If Read Request - Generate write, when command fifo not full and there
 
//                      is no pending read request.
 
//---------------------------------------------------------------------------
 
wire           cmdfifo_wr   = (wb_stb_i && wb_cyc_i && wb_we_i && (!cmdfifo_full) ) ? wb_ack_o :
 
                              (wb_stb_i && wb_cyc_i && !wb_we_i && (!cmdfifo_full)) ? !pending_read: 1'b0 ;
 
 
 
//---------------------------------------------------------------------------
 
// command fifo read generation
 
//    Command FIFo read will be generated, whenever SDRAM Controller
 
//    Acknowldge the Request
 
//----------------------------------------------------------------------------
 
 
wire           cmdfifo_rd   = sdr_req_ack;
wire           cmdfifo_rd   = sdr_req_ack;
 
 
 
//---------------------------------------------------------------------------
 
// Application layer request is generated towards the controller, whenever
 
// Command FIFO is not full
 
// --------------------------------------------------------------------------
assign         sdr_req      = !cmdfifo_empty;
assign         sdr_req      = !cmdfifo_empty;
 
 
 
//----------------------------------------------------------------------------
 
// Since Burst length is not known at the start of the Burst, It's assumed as
 
// Single Cycle Burst. We need to improvise this ...
 
// --------------------------------------------------------------------------
wire [bl-1:0]  burst_length  = 1;  // 0 Mean 1 Transfer
wire [bl-1:0]  burst_length  = 1;  // 0 Mean 1 Transfer
 
 
 
//-----------------------------------------------------------------------------
 
// In Wish Bone Spec, For Read Request has to be acked along with data.
 
// We need to identify the pending read request.
 
// Once we accept the read request, we should not accept one more read
 
// request, untill we have transmitted the read data.
 
//  Pending Read will 
 
//     set - with Read Request 
 
//     reset - with Read Request + Ack
 
// ----------------------------------------------------------------------------
always @(posedge wb_rst_i or posedge wb_clk_i) begin
always @(posedge wb_rst_i or posedge wb_clk_i) begin
   if(wb_rst_i) begin
   if(wb_rst_i) begin
       pending_read <= 1'b0;
       pending_read <= 1'b0;
   end else begin
   end else begin
      pending_read <=  wb_stb_i & wb_cyc_i & !wb_we_i & !wb_ack_o;
      pending_read <=  wb_stb_i & wb_cyc_i & !wb_we_i & !wb_ack_o;
   end
   end
end
end
 
 
 
//---------------------------------------------------------------------
 
// Async Command FIFO. This block handle the clock domain change from
 
// Application layer to SDRAM Controller
 
// ------------------------------------------------------------------
   // Address + Burst Length + W/R Request 
   // Address + Burst Length + W/R Request 
    async_fifo #(.W(30+bl+1),.DP(4)) u_cmdfifo (
    async_fifo #(.W(30+bl+1),.DP(4)) u_cmdfifo (
     // Write Path Sys CLock Domain
     // Write Path Sys CLock Domain
          .wr_clk     (wb_clk_i),
          .wr_clk     (wb_clk_i),
          .wr_reset_n (!wb_rst_i),
          .wr_reset_n (!wb_rst_i),
Line 197... Line 237...
      $display("ERROR:%m COMMAND FIFO READ OVERFLOW");
      $display("ERROR:%m COMMAND FIFO READ OVERFLOW");
   end
   end
end
end
// synopsys translate_on
// synopsys translate_on
 
 
 
//---------------------------------------------------------------------
 
// Write Data FIFO Write Generation, when ever Acked + Write Request
 
//   Note: Ack signal generation already taking account of FIFO full condition
 
// ---------------------------------------------------------------------
 
 
wire  wrdatafifo_wr  = wb_ack_o & wb_we_i ;
wire  wrdatafifo_wr  = wb_ack_o & wb_we_i ;
 
 
 
//------------------------------------------------------------------------
 
// Write Data FIFO Read Generation, When ever Next Write request generated
 
// from SDRAM Controller
 
// ------------------------------------------------------------------------
wire  wrdatafifo_rd  = sdr_wr_next;
wire  wrdatafifo_rd  = sdr_wr_next;
 
 
 
 
 
//------------------------------------------------------------------------
 
// Async Write Data FIFO
 
//    This block handle the clock domain change over + Write Data + Byte mask 
 
//    From Application layer to SDRAM controller layer
 
//------------------------------------------------------------------------
 
 
   // Write DATA + Data Mask FIFO
   // Write DATA + Data Mask FIFO
    async_fifo #(.W(dw+(dw/8)), .DP(16)) u_wrdatafifo (
    async_fifo #(.W(dw+(dw/8)), .DP(16)) u_wrdatafifo (
       // Write Path , System clock domain
       // Write Path , System clock domain
          .wr_clk     (wb_clk_i),
          .wr_clk     (wb_clk_i),
          .wr_reset_n (!wb_rst_i),
          .wr_reset_n (!wb_rst_i),
Line 241... Line 296...
 
 
// -------------------------------------------------------------------
// -------------------------------------------------------------------
//  READ DATA FIFO
//  READ DATA FIFO
//  ------------------------------------------------------------------
//  ------------------------------------------------------------------
wire    rd_eop; // last read indication
wire    rd_eop; // last read indication
 
 
 
// Read FIFO write generation, when ever SDRAM controller issues the read
 
// valid signal
wire    rddatafifo_wr = sdr_rd_valid;
wire    rddatafifo_wr = sdr_rd_valid;
wire    rddatafifo_rd = wb_ack_o & !wb_we_i & (rddatafifo_empty == 0);
 
 
 
   // READ DATA FIFO depth is kept small, assuming that Sys-CLock > SDRAM Clock
// Read FIFO read generation, when ever ack is generated along with read
 
// request.
 
// Note: Ack generation is already accounted the write FIFO Not Empty
 
//       condition
 
wire    rddatafifo_rd = wb_ack_o & !wb_we_i;
 
 
 
//-------------------------------------------------------------------------
 
// Async Read FIFO
 
// This block handles the clock domain change over + Read data from SDRAM
 
// controller to Application layer.
 
//  Note: 
 
//    1. READ DATA FIFO depth is kept small, assuming that Sys-CLock > SDRAM Clock
   // READ DATA + EOP
   // READ DATA + EOP
 
//    2. EOP indicate, last transfer of Burst Read Access. use-full for future
 
//       Tag handling per burst
 
//
 
// ------------------------------------------------------------------------
    async_fifo #(.W(dw+1), .DP(4)) u_rddatafifo (
    async_fifo #(.W(dw+1), .DP(4)) u_rddatafifo (
       // Write Path , SDRAM clock domain
       // Write Path , SDRAM clock domain
          .wr_clk     (sdram_clk),
          .wr_clk     (sdram_clk),
          .wr_reset_n (sdram_resetn),
          .wr_reset_n (sdram_resetn),
          .wr_en      (rddatafifo_wr),
          .wr_en      (rddatafifo_wr),

powered by: WebSVN 2.1.0

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