aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ettus <matt@ettus.com>2011-03-28 16:51:02 -0700
committerMatt Ettus <matt@ettus.com>2011-05-26 17:31:22 -0700
commitb51ef6e5a461dd4d1c42252e902bdbedfa5dc8a7 (patch)
treea836452f7065ef6bd13895821ecdb5a3cf093983
parentd0bfde4213dcab7fe3c5db404ef0f01354d56f67 (diff)
downloaduhd-b51ef6e5a461dd4d1c42252e902bdbedfa5dc8a7.tar.gz
uhd-b51ef6e5a461dd4d1c42252e902bdbedfa5dc8a7.tar.bz2
uhd-b51ef6e5a461dd4d1c42252e902bdbedfa5dc8a7.zip
should split and reframe packets properly
-rw-r--r--usrp2/gpif/gpif_tb.v46
-rw-r--r--usrp2/gpif/packet_splitter.v39
2 files changed, 58 insertions, 27 deletions
diff --git a/usrp2/gpif/gpif_tb.v b/usrp2/gpif/gpif_tb.v
index 1cb84e9fb..a71796d86 100644
--- a/usrp2/gpif/gpif_tb.v
+++ b/usrp2/gpif/gpif_tb.v
@@ -12,12 +12,11 @@ module gpif_tb();
wire CF, DF;
wire gpif_full_d, gpif_full_c;
- wire [18:0] data_o, ctrl_o;
- wire src_rdy, dst_rdy;
+ wire [18:0] data_o, ctrl_o, data_splt;
+ wire src_rdy, dst_rdy, src_rdy_splt, dst_rdy_splt;
wire ctrl_src_rdy, ctrl_dst_rdy;
assign ctrl_dst_rdy = 1;
- assign dst_rdy = 1;
initial $dumpfile("gpif_tb.vcd");
initial $dumpvars(0,gpif_tb);
@@ -29,6 +28,8 @@ module gpif_tb();
wire [18:0] data_int;
wire src_rdy_int, dst_rdy_int;
+
+ assign dst_rdy_splt = 1;
gpif_wr gpif_write
(.gpif_clk(gpif_clk), .gpif_rst(gpif_rst),
@@ -47,19 +48,19 @@ module gpif_tb();
packet_splitter #(.FRAME_LEN(256)) rx_packet_splitter
(.clk(sys_clk), .reset(sys_rst), .clear(0),
.data_i(data_o), .src_rdy_i(src_rdy), .dst_rdy_o(dst_rdy),
- .data_o(data_o), .src_rdy_o(src_rdy), .dst_rdy_i(dst_rdy));
+ .data_o(data_splt), .src_rdy_o(src_rdy_splt), .dst_rdy_i(dst_rdy_splt));
always @(posedge sys_clk)
if(ctrl_src_rdy & ctrl_dst_rdy)
$display("CTRL: %x",ctrl_o);
always @(posedge sys_clk)
- if(src_rdy & dst_rdy)
+ if(src_rdy_splt & dst_rdy_splt)
begin
- if(data_o[16])
+ if(data_splt[16])
$display("<-------- DATA SOF--------->");
- $display("DATA: %x",data_o);
- if(data_o[17])
+ $display("DATA: %x",data_splt);
+ if(data_splt[17])
$display("<-------- DATA EOF--------->");
end
@@ -68,8 +69,10 @@ module gpif_tb();
#10000;
repeat (1)
begin
+ @(posedge gpif_clk);
+
WR <= 1;
- gpif_data <= 10; // Length
+ gpif_data <= 256; // Length
@(posedge gpif_clk);
gpif_data <= 16'h00;
@(posedge gpif_clk);
@@ -79,20 +82,43 @@ module gpif_tb();
@(posedge gpif_clk);
end
WR <= 0;
+
+ while(DF)
+ @(posedge gpif_clk);
+ repeat (16)
+ @(posedge gpif_clk);
+
+ WR <= 1;
+ repeat(256)
+ begin
+ gpif_data <= gpif_data - 1;
+ @(posedge gpif_clk);
+ end
+ WR <= 0;
+
+
+/*
+ while(DF)
+ @(posedge gpif_clk);
+
repeat (20)
@(posedge gpif_clk);
WR <= 1;
gpif_data <= 16'h5;
@(posedge gpif_clk);
+ gpif_data <= 16'h00;
+ @(posedge gpif_clk);
repeat(254)
begin
gpif_data <= gpif_data - 1;
@(posedge gpif_clk);
end
+ WR <= 0;
+ */
end
end // initial begin
- initial #100000 $finish;
+ initial #200000 $finish;
endmodule // gpif_tb
diff --git a/usrp2/gpif/packet_splitter.v b/usrp2/gpif/packet_splitter.v
index 43515dd8b..f8028a4df 100644
--- a/usrp2/gpif/packet_splitter.v
+++ b/usrp2/gpif/packet_splitter.v
@@ -19,6 +19,8 @@ module packet_splitter
localparam PS_FRAME = 1;
localparam PS_NEW_FRAME = 2;
localparam PS_PAD = 3;
+
+ wire eof_i = data_i[17];
always @(posedge clk)
if(reset | clear)
@@ -34,30 +36,33 @@ module packet_splitter
end
PS_FRAME :
if(src_rdy_i & dst_rdy_i)
- if(frame_len == 0)
- if(length == 0)
- state <= PS_IDLE;
- else
- begin
- state <= PS_NEW_FRAME;
- frame_len <= FRAME_LEN;
- length <= length - 1;
- end
+ if((frame_len == 2) & ((length == 2) | eof_i))
+ state <= PS_IDLE;
+ else if(frame_len == 2)
+ begin
+ state <= PS_NEW_FRAME;
+ length <= length - 1;
+ end
+ else if((length == 2)|eof_i)
+ begin
+ frame_len <= frame_len - 1;
+ state <= PS_PAD;
+ end
else
- if(length == 0)
- begin
- frame_len <= frame_len - 1;
- state <= PS_PAD;
- end
+ begin
+ frame_len <= frame_len - 1;
+ length <= length - 1;
+ end
PS_NEW_FRAME :
if(src_rdy_i & dst_rdy_i)
begin
- frame_len <= frame_len - 1;
+ frame_len <= FRAME_LEN;
state <= PS_FRAME;
+ length <= length - 1;
end
PS_PAD :
if(dst_rdy_i)
- if(frame_len == 0)
+ if(frame_len == 2)
state <= PS_IDLE;
else
frame_len <= frame_len - 1;
@@ -70,7 +75,7 @@ module packet_splitter
assign src_rdy_o = src_rdy_i | (state == PS_PAD);
wire occ_out = 0;
- wire eof_out = (frame_len == 0) & (state != PS_IDLE);
+ wire eof_out = (frame_len == 2) & (state != PS_IDLE) & (state != PS_NEW_FRAME);
wire sof_out = (state == PS_IDLE) | (state == PS_NEW_FRAME);
wire [15:0] data_out = data_i[15:0];