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

Subversion Repositories turbo8051

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

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

powered by: WebSVN 2.1.0

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