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

Subversion Repositories oms8051mini

[/] [oms8051mini/] [trunk/] [rtl/] [lib/] [g_dpath_ctrl.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dinesha
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OMS 8051 cores Data Path controller                         ////
4
////                                                              ////
5
////  This file is part of the OMS 8051 cores project             ////
6
////  http://www.opencores.org/cores/oms8051mini/                 ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  OMS 8051 definitions.                                       ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////    nothing                                                   ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Dinesh Annayya, dinesha@opencores.org                 ////
16
////                                                              ////
17
////  Revision : Nov 26, 2016                                     //// 
18
////                                                              ////
19
//////////////////////////////////////////////////////////////////////
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
module g_dpath_ctrl (
47
              rst_n               ,
48
              clk                 ,
49
 
50
              rx_buf_base_addr    ,
51
              tx_buf_base_addr    ,
52
 
53
    // gmac core to memory write interface
54
              g_rx_mem_rd         ,
55
              g_rx_mem_eop        ,
56
              g_rx_mem_addr       ,
57
              g_rx_block_rxrd     ,
58
 
59
       // descr handshake    
60
              g_rx_desc_req       ,
61
              g_rx_desc_discard   ,
62
              g_rx_desc_data      ,
63
              g_rx_desc_ack       ,
64
 
65
              g_rx_pkt_done       ,
66
              g_rx_pkt_len        ,
67
              g_rx_pkt_status     ,
68
              g_rx_pkt_drop
69
 
70
 
71
      );
72
 
73
 
74
input         rst_n                 ;
75
input         clk                   ;
76
 
77
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
// 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
output        g_rx_block_rxrd       ; // Block Rx Read between EOP and PktDone
85
 
86
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
 
91
 
92
//-----------------------------------
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
 
100
 
101
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
 
110
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
always @(negedge rst_n or posedge clk) begin
115
   if(rst_n == 0) begin
116
      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
   end
124
   else begin
125
      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
      //-----------------------------
138
      // Finding the Frame Size
139
      //----------------------------
140
      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
         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
      end else if(g_rx_mem_rd ) begin
147
         g_rx_mem_addr_int <= g_rx_mem_addr_int+1;
148
      end
149
      // 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
      end
160
      else if (g_rx_desc_ack) begin
161
         g_rx_desc_req  <= 0;
162
         g_rx_desc_discard <= 0;
163
      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.