summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ettus <matt@ettus.com>2010-10-08 14:01:33 -0700
committerMatt Ettus <matt@ettus.com>2010-10-08 14:01:33 -0700
commit37f928fa5a3c01bd522a1d0db17d88ce4cdd0e03 (patch)
tree0662e958984222a8203de1b2fdea372d649525b4
parent26ada69153c8db487dda81ca63a5ea9c7ac6ba88 (diff)
downloaduhd-37f928fa5a3c01bd522a1d0db17d88ce4cdd0e03.tar.gz
uhd-37f928fa5a3c01bd522a1d0db17d88ce4cdd0e03.tar.bz2
uhd-37f928fa5a3c01bd522a1d0db17d88ce4cdd0e03.zip
checkpoint in flow control packet generation
-rw-r--r--usrp2/vrt/gen_context_pkt.v37
-rw-r--r--usrp2/vrt/trigger_context_pkt.v52
-rw-r--r--usrp2/vrt/vita_tx_chain.v28
-rw-r--r--usrp2/vrt/vita_tx_control.v10
-rw-r--r--usrp2/vrt/vita_tx_deframer.v62
5 files changed, 147 insertions, 42 deletions
diff --git a/usrp2/vrt/gen_context_pkt.v b/usrp2/vrt/gen_context_pkt.v
index 780a027ba..f840ec6e1 100644
--- a/usrp2/vrt/gen_context_pkt.v
+++ b/usrp2/vrt/gen_context_pkt.v
@@ -3,10 +3,12 @@
module gen_context_pkt
#(parameter PROT_ENG_FLAGS=1)
(input clk, input reset, input clear,
- input trigger, output sent,
+ input trigger, input error, output sent,
input [31:0] streamid,
input [63:0] vita_time,
input [31:0] message,
+ input [15:0] seqnum0,
+ input [15:0] seqnum1,
output [35:0] data_o, output src_rdy_o, input dst_rdy_i);
localparam CTXT_IDLE = 0;
@@ -17,17 +19,30 @@ module gen_context_pkt
localparam CTXT_TICS = 5;
localparam CTXT_TICS2 = 6;
localparam CTXT_MESSAGE = 7;
- localparam CTXT_DONE = 8;
+ localparam CTXT_FLOWCTRL = 8;
+ localparam CTXT_DONE = 9;
reg [33:0] data_int;
wire src_rdy_int, dst_rdy_int;
- wire [3:0] seqno = 0;
+ reg [3:0] seqno;
reg [3:0] ctxt_state;
reg [63:0] err_time;
+
+ always @(posedge clk)
+ if(reset | clear)
+ stored_message <= 0;
+ else
+ if(error)
+ stored_message <= message;
+ else if(state == CTXT_FLOWCTRL)
+ stored_message <= 0;
always @(posedge clk)
if(reset | clear)
- ctxt_state <= CTXT_IDLE;
+ begin
+ ctxt_state <= CTXT_IDLE;
+ seqno <= 0;
+ end
else
case(ctxt_state)
CTXT_IDLE :
@@ -41,9 +56,10 @@ module gen_context_pkt
end
CTXT_DONE :
- if(~trigger)
- ctxt_state <= CTXT_IDLE;
-
+ begin
+ ctxt_state <= CTXT_IDLE;
+ seqno <= seqno + 4'd1;
+ end
default :
if(dst_rdy_int)
ctxt_state <= ctxt_state + 1;
@@ -53,13 +69,14 @@ module gen_context_pkt
always @*
case(ctxt_state)
- CTXT_PROT_ENG : data_int <= { 2'b01, 16'd1, 16'd24 };
- CTXT_HEADER : data_int <= { 1'b0, (PROT_ENG_FLAGS ? 1'b0 : 1'b1), 12'b010100001101, seqno, 16'd6 };
+ CTXT_PROT_ENG : data_int <= { 2'b01, 16'd1, 16'd28 };
+ CTXT_HEADER : data_int <= { 1'b0, (PROT_ENG_FLAGS ? 1'b0 : 1'b1), 12'b010100001101, seqno, 16'd7 };
CTXT_STREAMID : data_int <= { 2'b00, streamid };
CTXT_SECS : data_int <= { 2'b00, err_time[63:32] };
CTXT_TICS : data_int <= { 2'b00, 32'd0 };
CTXT_TICS2 : data_int <= { 2'b00, err_time[31:0] };
- CTXT_MESSAGE : data_int <= { 2'b10, message };
+ CTXT_MESSAGE : data_int <= { 2'b00, message };
+ CTXT_FLOWCTRL : data_int <= { 2'b10, {seqnum1,seqnum0} };
default : data_int <= {2'b00, 32'b00};
endcase // case (ctxt_state)
diff --git a/usrp2/vrt/trigger_context_pkt.v b/usrp2/vrt/trigger_context_pkt.v
new file mode 100644
index 000000000..51790dfae
--- /dev/null
+++ b/usrp2/vrt/trigger_context_pkt.v
@@ -0,0 +1,52 @@
+
+
+module trigger_context_pkt
+ #(parameter BASE=0)
+ (input clk, input reset, input clear,
+ input set_stb, input [7:0] set_addr, input [31:0] set_data,
+ input packet_consumed, output reg trigger);
+
+ wire [23:0] cycles;
+ wire [15:0] packets;
+ wire [6:0] dummy1;
+ wire [14:0] dummy2;
+ wire enable_timed, enable_consumed;
+ reg [30:0] cycle_count, packet_count;
+
+
+ setting_reg #(.my_addr(BASE_CTRL+X), .at_reset(0)) sr_settings
+ (.clk(clk),.rst(reset),.strobe(set_stb),.addr(set_addr),
+ .in(set_data),.out({enable_cycle,dummy1,cycles}),.changed());
+
+ setting_reg #(.my_addr(BASE_CTRL+X), .at_reset(0)) sr_settings
+ (.clk(clk),.rst(reset),.strobe(set_stb),.addr(set_addr),
+ .in(set_data),.out({enable_consumed,dummy2,packets}),.changed());
+
+ always @(posedge clk)
+ if(reset | clear)
+ cycle_count <= 0;
+ else
+ if(trigger)
+ cycle_count <= 0;
+ else if(enable_cycle)
+ cycle_count <= cycle_count + 1;
+
+ always @(posedge clk)
+ if(reset | clear)
+ packet_count <= 0;
+ else
+ if(trigger)
+ packet_count <= 0;
+ else if(packet_consumed & enable_consumed)
+ packet_count <= packet_count + 1;
+
+ always @(posedge clk)
+ if(reset | clear)
+ trigger <= 0;
+ else
+ if((cycle_count > cycles)|(packet_count > packets))
+ trigger <= 1;
+ else
+ trigger <= 0;
+
+endmodule // trigger_context_pkt
diff --git a/usrp2/vrt/vita_tx_chain.v b/usrp2/vrt/vita_tx_chain.v
index 662cdca62..12e94b1a8 100644
--- a/usrp2/vrt/vita_tx_chain.v
+++ b/usrp2/vrt/vita_tx_chain.v
@@ -24,9 +24,10 @@ module vita_tx_chain
wire trigger, sent;
wire [31:0] debug_vtc, debug_vtd, debug_tx_dsp;
- wire error;
+ wire error, packet_consumed;
wire [31:0] error_code;
wire clear_seqnum;
+ wire [15:0] current_seqnum;
assign underrun = error;
assign message = error_code;
@@ -40,6 +41,7 @@ module vita_tx_chain
.set_stb(set_stb),.set_addr(set_addr),.set_data(set_data),
.data_i(tx_data_i), .src_rdy_i(tx_src_rdy_i), .dst_rdy_o(tx_dst_rdy_o),
.sample_fifo_o(tx1_data), .sample_fifo_src_rdy_o(tx1_src_rdy), .sample_fifo_dst_rdy_i(tx1_dst_rdy),
+ .current_seqnum(current_seqnum),
.debug(debug_vtd) );
vita_tx_control #(.BASE(BASE_CTRL), .WIDTH(32*MAXCHAN)) vita_tx_control
@@ -47,7 +49,7 @@ module vita_tx_chain
.set_stb(set_stb),.set_addr(set_addr),.set_data(set_data),
.vita_time(vita_time),.error(error),.error_code(error_code),
.sample_fifo_i(tx1_data), .sample_fifo_src_rdy_i(tx1_src_rdy), .sample_fifo_dst_rdy_o(tx1_dst_rdy),
- .sample(sample_tx), .run(run), .strobe(strobe_tx),
+ .sample(sample_tx), .run(run), .strobe(strobe_tx), .packet_consumed(packet_consumed),
.debug(debug_vtc) );
dsp_core_tx #(.BASE(BASE_DSP)) dsp_core_tx
@@ -59,13 +61,21 @@ module vita_tx_chain
generate
if(REPORT_ERROR==1)
- gen_context_pkt #(.PROT_ENG_FLAGS(PROT_ENG_FLAGS)) gen_tx_err_pkt
- (.clk(clk), .reset(reset), .clear(clear_vita),
- .trigger(error), .sent(),
- .streamid(streamid), .vita_time(vita_time), .message(message),
- .data_o(err_data_o), .src_rdy_o(err_src_rdy_o), .dst_rdy_i(err_dst_rdy_i));
+ begin
+ gen_context_pkt #(.PROT_ENG_FLAGS(PROT_ENG_FLAGS)) gen_tx_err_pkt
+ (.clk(clk), .reset(reset), .clear(clear_vita),
+ .trigger(trigger),.error(error), .sent(),
+ .streamid(streamid), .vita_time(vita_time), .message(message),
+ .seqnum0(current_seqnum), .seqnum1(16'd0),
+ .data_o(err_data_o), .src_rdy_o(err_src_rdy_o), .dst_rdy_i(err_dst_rdy_i));
+ trigger_context_pkt #(.BASE(BASE_CTRL)) trigger_context_pkt
+ (.clk(clk), .reset(reset), .clear(clear_vita),
+ .set_stb(set_stb),.set_addr(set_addr),.set_data(set_data),
+ .packet_consumed(packet_consumed), .trigger(trigger));
+ end
endgenerate
-
- assign debug = debug_vtc | debug_vtd;
+
+ //assign debug = debug_vtc | debug_vtd;
+ assign debug = { debug_vtd[15:0], current_seqnum };
endmodule // vita_tx_chain
diff --git a/usrp2/vrt/vita_tx_control.v b/usrp2/vrt/vita_tx_control.v
index d0516bec8..61cd9edb5 100644
--- a/usrp2/vrt/vita_tx_control.v
+++ b/usrp2/vrt/vita_tx_control.v
@@ -8,7 +8,8 @@ module vita_tx_control
input [63:0] vita_time,
output error,
output reg [31:0] error_code,
-
+ output reg packet_consumed,
+
// From vita_tx_deframer
input [5+64+16+WIDTH-1:0] sample_fifo_i,
input sample_fifo_src_rdy_i,
@@ -154,9 +155,14 @@ module vita_tx_control
assign sample_fifo_dst_rdy_o = (ibs_state == IBS_ERROR) | (strobe & (ibs_state == IBS_RUN)); // FIXME also cleanout
assign run = (ibs_state == IBS_RUN) | (ibs_state == IBS_CONT_BURST);
- //assign error = (ibs_state == IBS_ERROR_DONE);
assign error = send_error;
+ always @(posedge clk)
+ if(reset)
+ packet_consumed <= 0;
+ else
+ packet_consumed <= eop & sample_fifo_src_rdy_i & sample_fifo_dst_rdy_o;
+
assign debug = { { now,early,late,too_early,eop,eob,sob,send_at },
{ sample_fifo_src_rdy_i, sample_fifo_dst_rdy_o, strobe, run, error, ibs_state[2:0] },
{ 8'b0 },
diff --git a/usrp2/vrt/vita_tx_deframer.v b/usrp2/vrt/vita_tx_deframer.v
index f9cd7d00d..f7902e645 100644
--- a/usrp2/vrt/vita_tx_deframer.v
+++ b/usrp2/vrt/vita_tx_deframer.v
@@ -13,6 +13,8 @@ module vita_tx_deframer
output [5+64+16+(32*MAXCHAN)-1:0] sample_fifo_o,
output sample_fifo_src_rdy_o,
input sample_fifo_dst_rdy_i,
+
+ output [15:0] current_seqnum,
// FIFO Levels
output [15:0] fifo_occupied,
@@ -45,23 +47,29 @@ module vita_tx_deframer
reg [1:0] vector_phase;
wire line_done;
- reg seqnum_err;
- reg [3:0] seqnum_reg;
- wire [3:0] seqnum = data_i[19:16];
- wire [3:0] next_seqnum = seqnum_reg + 4'd1;
+ wire [15:0] seqnum = data_i[15:0];
+ reg [15:0] seqnum_reg;
+ wire [15:0] next_seqnum = seqnum_reg + 16'd1;
+ wire [3:0] vita_seqnum = data_i[19:16];
+ reg [3:0] vita_seqnum_reg;
+ wire [3:0] next_vita_seqnum = vita_seqnum_reg[3:0] + 4'd1;
+ reg seqnum_err;
+
+ assign curren_seqnum = seqnum_reg;
// Output FIFO for packetized data
- localparam VITA_HEADER = 0;
- localparam VITA_STREAMID = 1;
- localparam VITA_CLASSID = 2;
- localparam VITA_CLASSID2 = 3;
- localparam VITA_SECS = 4;
- localparam VITA_TICS = 5;
- localparam VITA_TICS2 = 6;
- localparam VITA_PAYLOAD = 7;
- localparam VITA_STORE = 8;
- localparam VITA_TRAILER = 9;
-
+ localparam VITA_TRANS_HEADER = 0;
+ localparam VITA_HEADER = 1;
+ localparam VITA_STREAMID = 2;
+ localparam VITA_CLASSID = 3;
+ localparam VITA_CLASSID2 = 4;
+ localparam VITA_SECS = 5;
+ localparam VITA_TICS = 6;
+ localparam VITA_TICS2 = 7;
+ localparam VITA_PAYLOAD = 8;
+ localparam VITA_STORE = 9;
+ localparam VITA_TRAILER = 10;
+
wire [15:0] hdr_len = 2 + has_streamid_reg + has_classid_reg + has_classid_reg + has_secs_reg +
has_tics_reg + has_tics_reg + has_trailer_reg;
@@ -70,15 +78,22 @@ module vita_tx_deframer
always @(posedge clk)
if(reset | clear_seqnum)
- seqnum_reg <= 4'hF;
+ begin
+ seqnum_reg <= 16'hFFFF;
+ vita_seqnum_reg <= 4'hF;
+ end
else
- if((vita_state==VITA_HEADER) & src_rdy_i)
- seqnum_reg <= seqnum;
+ begin
+ if((vita_state==VITA_TRANS_HEADER) & src_rdy_i)
+ seqnum_reg <= seqnum;
+ if((vita_state==VITA_HEADER) & src_rdy_i)
+ vita_seqnum_reg <= vita_seqnum;
+ end // else: !if(reset | clear_seqnum)
always @(posedge clk)
if(reset | clear)
begin
- vita_state <= VITA_HEADER;
+ vita_state <= VITA_TRANS_HEADER;
{has_streamid_reg, has_classid_reg, has_secs_reg, has_tics_reg, has_trailer_reg, is_sob_reg, is_eob_reg}
<= 0;
seqnum_err <= 0;
@@ -97,6 +112,11 @@ module vita_tx_deframer
end
else if(src_rdy_i)
case(vita_state)
+ VITA_TRANS_HEADER :
+ begin
+ seqnum_err <= ~(seqnum == next_seqnum);
+ vita_state <= VITA_HEADER;
+ end
VITA_HEADER :
begin
{has_streamid_reg, has_classid_reg, has_secs_reg, has_tics_reg, has_trailer_reg, is_sob_reg, is_eob_reg}
@@ -113,7 +133,7 @@ module vita_tx_deframer
vita_state <= VITA_TICS;
else
vita_state <= VITA_PAYLOAD;
- seqnum_err <= ~(seqnum == next_seqnum);
+ seqnum_err <= seqnum_err | ~(vita_seqnum == next_vita_seqnum);
end // case: VITA_HEADER
VITA_STREAMID :
if(has_classid_reg)
@@ -191,7 +211,7 @@ module vita_tx_deframer
// sob, eob, has_secs (send_at) ignored on all lines except first
assign fifo_i = {sample_d,sample_c,sample_b,sample_a,seqnum_err,has_secs_reg,is_sob_reg,is_eob_reg,eop,
- 12'd0,seqnum_reg,send_time};
+ 12'd0,seqnum_reg[3:0],send_time};
assign dst_rdy_o = ~(vita_state == VITA_PAYLOAD) & ~((vita_state==VITA_STORE)& ~fifo_space) ;