1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
//
// Copyright 2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
module rxmac_to_ll8
(input clk, input reset, input clear,
input [7:0] rx_data, input rx_valid, input rx_error, input rx_ack,
output [7:0] ll_data, output ll_sof, output ll_eof, output ll_error, output ll_src_rdy, input ll_dst_rdy );
reg [2:0] xfer_state;
localparam XFER_IDLE = 0;
localparam XFER_ACTIVE = 1;
localparam XFER_ERROR = 2;
localparam XFER_ERROR2 = 3;
localparam XFER_OVERRUN = 4;
localparam XFER_OVERRUN2 = 5;
assign ll_data = rx_data;
assign ll_src_rdy = ((rx_valid & (xfer_state != XFER_OVERRUN2) )
| (xfer_state == XFER_ERROR)
| (xfer_state == XFER_OVERRUN));
assign ll_sof = ((xfer_state==XFER_IDLE)|(xfer_state==XFER_ERROR)|(xfer_state==XFER_OVERRUN));
assign ll_eof = (rx_ack | (xfer_state==XFER_ERROR) | (xfer_state==XFER_OVERRUN));
assign ll_error = (xfer_state == XFER_ERROR)|(xfer_state==XFER_OVERRUN);
always @(posedge clk)
if(reset | clear)
xfer_state <= XFER_IDLE;
else
case(xfer_state)
XFER_IDLE :
if(rx_valid)
xfer_state <= XFER_ACTIVE;
XFER_ACTIVE :
if(rx_error)
xfer_state <= XFER_ERROR;
else if(~rx_valid)
xfer_state <= XFER_IDLE;
else if(~ll_dst_rdy)
xfer_state <= XFER_OVERRUN;
XFER_ERROR :
if(ll_dst_rdy)
xfer_state <= XFER_ERROR2;
XFER_ERROR2 :
if(~rx_error)
xfer_state <= XFER_IDLE;
XFER_OVERRUN :
if(ll_dst_rdy)
xfer_state <= XFER_OVERRUN2;
XFER_OVERRUN2 :
if(~rx_valid)
xfer_state <= XFER_IDLE;
endcase // case (xfer_state)
endmodule // rxmac_to_ll8
|