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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [lib/] [g_dpath_ctrl.v] - Diff between revs 49 and 50

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

Rev 49 Rev 50
Line 39... Line 39...
//// Public License along with this source; if not, download it   ////
//// Public License along with this source; if not, download it   ////
//// from http://www.opencores.org/lgpl.shtml                     ////
//// from http://www.opencores.org/lgpl.shtml                     ////
////                                                              ////
////                                                              ////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
 
 
module dpath_ctrl (
module g_dpath_ctrl (
              rst_n               ,
              rst_n               ,
              clk                 ,
              clk                 ,
 
 
 
              rx_buf_base_addr    ,
 
              tx_buf_base_addr    ,
 
 
    // gmac core to memory write interface
    // gmac core to memory write interface
              g_rx_mem_rd         ,
              g_rx_mem_rd         ,
              g_rx_mem_eop        ,
              g_rx_mem_eop        ,
              g_rx_mem_addr       ,
              g_rx_mem_addr       ,
 
              g_rx_block_rxrd     ,
 
 
 
       // descr handshake    
 
              g_rx_desc_req       ,
 
              g_rx_desc_discard   ,
 
              g_rx_desc_data      ,
 
              g_rx_desc_ack       ,
 
 
 
              g_rx_pkt_done       ,
 
              g_rx_pkt_len        ,
 
              g_rx_pkt_status     ,
 
              g_rx_pkt_drop
 
 
    // Memory to gmac core interface
 
              g_tx_mem_wr         ,
 
              g_tx_mem_eop        ,
 
              g_tx_mem_addr       ,
 
              g_tx_mem_req        ,
 
              g_tx_mem_req_length ,
 
              g_tx_mem_ack
 
 
 
      );
      );
 
 
 
 
input         rst_n                 ;
input         rst_n                 ;
input         clk                   ;
input         clk                   ;
 
 
 
input [3:0]   rx_buf_base_addr      ; // 8K Rx Base Address
 
input [3:0]   tx_buf_base_addr      ; // 8K tx Base Address
 
 
// gmac core to memory write interface
// gmac core to memory write interface
input         g_rx_mem_rd           ;
input         g_rx_mem_rd           ;
input         g_rx_mem_eop          ;
input         g_rx_mem_eop          ;
output [15:0] g_rx_mem_addr         ;
output [15:0] g_rx_mem_addr         ;
 
output        g_rx_block_rxrd       ; // Block Rx Read between EOP and PktDone
 
 
 
input         g_rx_pkt_done         ; // End of current Packet
 
input [11:0]  g_rx_pkt_len          ; // Packet Length 
 
input [15:0]  g_rx_pkt_status       ; // Packet Status
 
input         g_rx_pkt_drop         ; // Packet drop and rewind the pointer
 
 
 
 
 
//-----------------------------------
 
// Descriptor handshake
 
//----------------------------------
 
output        g_rx_desc_req         ; // rx desc request
 
output        g_rx_desc_discard     ; // rx desc discard indication
 
output [31:0] g_rx_desc_data        ; // rx desc data
 
input         g_rx_desc_ack         ; // rx desc ack
 
 
 
 
// Memory to gmac core interface
reg          g_rx_desc_req         ;
input         g_tx_mem_wr           ;
reg          g_rx_desc_discard     ; // rx desc discard indication
output        g_tx_mem_eop          ;
reg  [31:0]  g_rx_desc_data      ; // rx desc data
output [15:0] g_tx_mem_addr         ;
 
 
 
output        g_tx_mem_req          ;
 
output [15:0] g_tx_mem_req_length   ;
 
input         g_tx_mem_ack          ;
 
 
 
 
 
reg    [15:0] g_rx_mem_addr         ;
 
reg    [15:0] g_tx_mem_addr         ;
 
reg    [15:0] g_tx_mem_req_length   ;
 
reg    [15:0] rx_plen               ;
 
reg    [15:0] tx_plen               ;
 
reg           g_tx_mem_req          ;
 
 
 
wire     g_tx_mem_eop =  ((tx_plen +1) == g_tx_mem_req_length) ? 1'b1 : 1'b0;
reg    [11:0] g_rx_mem_addr_int     ;
 
 
 
wire [15:0]   g_rx_mem_addr  = {rx_buf_base_addr,g_rx_mem_addr_int[11:0]};
 
 
 
 
 
reg         bStartFlag; // Indicate a SOP transaction, used for registering Start Address
 
reg         g_rx_block_rxrd; // Block Rx Read at the end of EOP and Enable on Packet Done
 
reg [11:0]  g_rx_saddr;
 
 
always @(negedge rst_n or posedge clk) begin
always @(negedge rst_n or posedge clk) begin
   if(rst_n == 0) begin
   if(rst_n == 0) begin
      g_rx_mem_addr <= 0;
      g_rx_mem_addr_int <= 0;
      g_tx_mem_addr <= 0;
      bStartFlag        <= 1;
      rx_plen       <= 0;
      g_rx_block_rxrd   <= 0;
      tx_plen       <= 0;
      g_rx_saddr        <= 0;
 
      g_rx_desc_discard <= 0;
 
      g_rx_desc_data    <= 0;
 
      g_rx_desc_req     <= 0;
   end
   end
   else begin
   else begin
 
      if(bStartFlag && g_rx_mem_rd) begin
 
         g_rx_saddr   <= g_rx_mem_addr_int[11:0];
 
         bStartFlag   <= 0;
 
      end else if (g_rx_mem_rd && g_rx_mem_eop) begin
 
         bStartFlag   <= 1;
 
      end
 
 
 
      if(g_rx_mem_rd && g_rx_mem_eop)
 
         g_rx_block_rxrd   <= 1;
 
      else if(g_rx_pkt_done)
 
         g_rx_block_rxrd   <= 0;
 
 
      //-----------------------------
      //-----------------------------
      // Finding the Frame Size
      // Finding the Frame Size
      //----------------------------
      //----------------------------
      if(g_rx_mem_rd) begin
      if(g_rx_pkt_done && g_rx_pkt_drop) begin
         g_rx_mem_addr <= g_rx_mem_addr+1;
         g_rx_mem_addr_int <= g_rx_saddr;
         if(g_rx_mem_eop) rx_plen <= 0;
      end else if(g_rx_mem_rd && g_rx_mem_eop) begin
         else rx_plen <= rx_plen +1;
         // Realign to 32 bit boundary and add one free space at eop
      end
         g_rx_mem_addr_int <= g_rx_mem_addr_int+4-g_rx_mem_addr_int[1:0];
      //------------------------
      end else if(g_rx_mem_rd ) begin
      // Generate Tx Request at last transfer of RX Req
         g_rx_mem_addr_int <= g_rx_mem_addr_int+1;
      //------------------------
      end
      //
      // Descriptor Request Generation
      if(g_rx_mem_eop && g_rx_mem_rd)  begin
      if(g_rx_pkt_done) begin
          g_tx_mem_req_length <= rx_plen+1;
          g_rx_desc_req   <= 1;
          g_tx_mem_req <= 1;
          if(g_rx_pkt_drop) begin
      end else if (g_tx_mem_ack) begin
             g_rx_desc_discard <= 1;
          g_tx_mem_req <= 0;
 
      end
 
 
 
      //------------------------
 
      // Generate of EOP for TX Interface at last transfer
 
      //-------------------------
 
      if(g_tx_mem_wr) begin
 
         g_tx_mem_addr <= g_tx_mem_addr+1;
 
         if(g_tx_mem_req_length == (tx_plen +1)) begin
 
            tx_plen      <= 0;
 
         end else begin
         end else begin
            tx_plen      <= tx_plen +1;
             g_rx_desc_discard <= 0;
 
             g_rx_desc_data  <= {g_rx_pkt_status[5:0],rx_buf_base_addr[3:0],
 
                                 g_rx_saddr[11:2],g_rx_pkt_len[11:0]};
 
          end
         end
         end
 
      else if (g_rx_desc_ack) begin
 
         g_rx_desc_req  <= 0;
 
         g_rx_desc_discard <= 0;
      end
      end
   end
   end
end
end
 
 
 
 

powered by: WebSVN 2.1.0

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