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

Subversion Repositories turbo8051

[/] [turbo8051/] [trunk/] [rtl/] [lib/] [g_dpath_ctrl.v] - Blame information for rev 79

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

Line No. Rev Author Line
1 22 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Tubo 8051 cores Data Path controller                        ////
4
////                                                              ////
5
////  This file is part of the Turbo 8051 cores project           ////
6
////  http://www.opencores.org/cores/turbo8051/                   ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Turbo 8051 definitions.                                     ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17 76 dinesha
////  Revision : Mar 2, 2011                                      //// 
18
////                                                              ////
19 22 dinesha
//////////////////////////////////////////////////////////////////////
20
////                                                              ////
21
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
22
////                                                              ////
23
//// This source file may be used and distributed without         ////
24
//// restriction provided that this copyright statement is not    ////
25
//// removed from the file and that any derivative work contains  ////
26
//// the original copyright notice and the associated disclaimer. ////
27
////                                                              ////
28
//// This source file is free software; you can redistribute it   ////
29
//// and/or modify it under the terms of the GNU Lesser General   ////
30
//// Public License as published by the Free Software Foundation; ////
31
//// either version 2.1 of the License, or (at your option) any   ////
32
//// later version.                                               ////
33
////                                                              ////
34
//// This source is distributed in the hope that it will be       ////
35
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
36
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
37
//// PURPOSE.  See the GNU Lesser General Public License for more ////
38
//// details.                                                     ////
39
////                                                              ////
40
//// You should have received a copy of the GNU Lesser General    ////
41
//// Public License along with this source; if not, download it   ////
42
//// from http://www.opencores.org/lgpl.shtml                     ////
43
////                                                              ////
44
//////////////////////////////////////////////////////////////////////
45
 
46 50 dinesha
module g_dpath_ctrl (
47 22 dinesha
              rst_n               ,
48
              clk                 ,
49
 
50 50 dinesha
              rx_buf_base_addr    ,
51
              tx_buf_base_addr    ,
52
 
53 22 dinesha
    // gmac core to memory write interface
54
              g_rx_mem_rd         ,
55
              g_rx_mem_eop        ,
56
              g_rx_mem_addr       ,
57 50 dinesha
              g_rx_block_rxrd     ,
58 22 dinesha
 
59 50 dinesha
       // descr handshake    
60
              g_rx_desc_req       ,
61
              g_rx_desc_discard   ,
62
              g_rx_desc_data      ,
63
              g_rx_desc_ack       ,
64 22 dinesha
 
65 50 dinesha
              g_rx_pkt_done       ,
66
              g_rx_pkt_len        ,
67
              g_rx_pkt_status     ,
68
              g_rx_pkt_drop
69
 
70
 
71 22 dinesha
      );
72
 
73
 
74
input         rst_n                 ;
75
input         clk                   ;
76
 
77 50 dinesha
input [3:0]   rx_buf_base_addr      ; // 8K Rx Base Address
78
input [3:0]   tx_buf_base_addr      ; // 8K tx Base Address
79
 
80 22 dinesha
// gmac core to memory write interface
81
input         g_rx_mem_rd           ;
82
input         g_rx_mem_eop          ;
83
output [15:0] g_rx_mem_addr         ;
84 50 dinesha
output        g_rx_block_rxrd       ; // Block Rx Read between EOP and PktDone
85 22 dinesha
 
86 50 dinesha
input         g_rx_pkt_done         ; // End of current Packet
87
input [11:0]  g_rx_pkt_len          ; // Packet Length 
88
input [15:0]  g_rx_pkt_status       ; // Packet Status
89
input         g_rx_pkt_drop         ; // Packet drop and rewind the pointer
90 22 dinesha
 
91
 
92 50 dinesha
//-----------------------------------
93
// Descriptor handshake
94
//----------------------------------
95
output        g_rx_desc_req         ; // rx desc request
96
output        g_rx_desc_discard     ; // rx desc discard indication
97
output [31:0] g_rx_desc_data        ; // rx desc data
98
input         g_rx_desc_ack         ; // rx desc ack
99 22 dinesha
 
100 24 dinesha
 
101 50 dinesha
reg          g_rx_desc_req         ;
102
reg          g_rx_desc_discard     ; // rx desc discard indication
103
reg  [31:0]  g_rx_desc_data      ; // rx desc data
104
 
105
reg    [11:0] g_rx_mem_addr_int     ;
106
 
107
wire [15:0]   g_rx_mem_addr  = {rx_buf_base_addr,g_rx_mem_addr_int[11:0]};
108
 
109 22 dinesha
 
110 50 dinesha
reg         bStartFlag; // Indicate a SOP transaction, used for registering Start Address
111
reg         g_rx_block_rxrd; // Block Rx Read at the end of EOP and Enable on Packet Done
112
reg [11:0]  g_rx_saddr;
113
 
114 22 dinesha
always @(negedge rst_n or posedge clk) begin
115
   if(rst_n == 0) begin
116 50 dinesha
      g_rx_mem_addr_int <= 0;
117
      bStartFlag        <= 1;
118
      g_rx_block_rxrd   <= 0;
119
      g_rx_saddr        <= 0;
120
      g_rx_desc_discard <= 0;
121
      g_rx_desc_data    <= 0;
122
      g_rx_desc_req     <= 0;
123 22 dinesha
   end
124
   else begin
125 50 dinesha
      if(bStartFlag && g_rx_mem_rd) begin
126
         g_rx_saddr   <= g_rx_mem_addr_int[11:0];
127
         bStartFlag   <= 0;
128
      end else if (g_rx_mem_rd && g_rx_mem_eop) begin
129
         bStartFlag   <= 1;
130
      end
131
 
132
      if(g_rx_mem_rd && g_rx_mem_eop)
133
         g_rx_block_rxrd   <= 1;
134
      else if(g_rx_pkt_done)
135
         g_rx_block_rxrd   <= 0;
136
 
137 22 dinesha
      //-----------------------------
138
      // Finding the Frame Size
139
      //----------------------------
140 50 dinesha
      if(g_rx_pkt_done && g_rx_pkt_drop) begin
141
         g_rx_mem_addr_int <= g_rx_saddr;
142
      end else if(g_rx_mem_rd && g_rx_mem_eop) begin
143
         // Realign to 32 bit boundary and add one free space at eop
144 57 dinesha
         g_rx_mem_addr_int[1:0]  <= 0;
145
         g_rx_mem_addr_int[11:2] <= g_rx_mem_addr_int[11:2]+1;
146 50 dinesha
      end else if(g_rx_mem_rd ) begin
147
         g_rx_mem_addr_int <= g_rx_mem_addr_int+1;
148 22 dinesha
      end
149 50 dinesha
      // Descriptor Request Generation
150
      if(g_rx_pkt_done) begin
151
          g_rx_desc_req   <= 1;
152
          if(g_rx_pkt_drop) begin
153
             g_rx_desc_discard <= 1;
154
          end else begin
155
             g_rx_desc_discard <= 0;
156
             g_rx_desc_data  <= {g_rx_pkt_status[5:0],rx_buf_base_addr[3:0],
157
                                 g_rx_saddr[11:2],g_rx_pkt_len[11:0]};
158
          end
159 22 dinesha
      end
160 50 dinesha
      else if (g_rx_desc_ack) begin
161
         g_rx_desc_req  <= 0;
162
         g_rx_desc_discard <= 0;
163 22 dinesha
      end
164
   end
165
end
166
 
167
 
168
endmodule

powered by: WebSVN 2.1.0

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