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

Subversion Repositories turbo8051

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

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
module dpath_ctrl (
45
              rst_n               ,
46
              clk                 ,
47
 
48
    // gmac core to memory write interface
49
              g_rx_mem_rd         ,
50
              g_rx_mem_eop        ,
51
              g_rx_mem_addr       ,
52
 
53
    // Memory to gmac core interface
54
              g_tx_mem_wr         ,
55
              g_tx_mem_eop        ,
56
              g_tx_mem_addr       ,
57
              g_tx_mem_req        ,
58
              g_tx_mem_req_length ,
59
              g_tx_mem_ack
60
 
61
      );
62
 
63
 
64
input         rst_n                 ;
65
input         clk                   ;
66
 
67
// gmac core to memory write interface
68
input         g_rx_mem_rd           ;
69
input         g_rx_mem_eop          ;
70
output [15:0] g_rx_mem_addr         ;
71
 
72
// Memory to gmac core interface
73
input         g_tx_mem_wr           ;
74
output        g_tx_mem_eop          ;
75
output [15:0] g_tx_mem_addr         ;
76
 
77
output        g_tx_mem_req          ;
78
output [15:0] g_tx_mem_req_length   ;
79
input         g_tx_mem_ack          ;
80
 
81
 
82
reg    [15:0] g_rx_mem_addr         ;
83
reg    [15:0] g_tx_mem_addr         ;
84
reg    [15:0] g_tx_mem_req_length   ;
85
reg    [15:0] rx_plen               ;
86
reg    [15:0] tx_plen               ;
87
reg           g_tx_mem_req          ;
88 24 dinesha
 
89
wire     g_tx_mem_eop =  ((tx_plen +1) == g_tx_mem_req_length) ? 1'b1 : 1'b0;
90 22 dinesha
 
91
 
92
always @(negedge rst_n or posedge clk) begin
93
   if(rst_n == 0) begin
94
      g_rx_mem_addr <= 0;
95
      g_tx_mem_addr <= 0;
96
      rx_plen       <= 0;
97
      tx_plen       <= 0;
98
   end
99
   else begin
100
      //-----------------------------
101
      // Finding the Frame Size
102
      //----------------------------
103
      if(g_rx_mem_rd) begin
104
         g_rx_mem_addr <= g_rx_mem_addr+1;
105
         if(g_rx_mem_eop) rx_plen <= 0;
106 24 dinesha
         else rx_plen <= rx_plen +1;
107 22 dinesha
      end
108
      //------------------------
109
      // Generate Tx Request at last transfer of RX Req
110
      //------------------------
111
      //
112
      if(g_rx_mem_eop && g_rx_mem_rd)  begin
113
          g_tx_mem_req_length <= rx_plen+1;
114
          g_tx_mem_req <= 1;
115
      end else if (g_tx_mem_ack) begin
116
          g_tx_mem_req <= 0;
117
      end
118
 
119
      //------------------------
120
      // Generate of EOP for TX Interface at last transfer
121
      //-------------------------
122
      if(g_tx_mem_wr) begin
123
         g_tx_mem_addr <= g_tx_mem_addr+1;
124
         if(g_tx_mem_req_length == (tx_plen +1)) begin
125 48 dinesha
            tx_plen      <= 0;
126 22 dinesha
         end else begin
127 48 dinesha
            tx_plen      <= tx_plen +1;
128 22 dinesha
         end
129
      end
130
   end
131
end
132
 
133
 
134
endmodule

powered by: WebSVN 2.1.0

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