Line 38... |
Line 38... |
//
|
//
|
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
//
|
//
|
module addepad(i_clk, i_ce, i_en, i_cancel, i_v, i_d, o_v, o_d);
|
module addepad(i_clk, i_ce, i_en, i_cancel, i_v, i_d, o_v, o_d);
|
|
parameter MINNIBBLES=120;
|
|
localparam LGNCOUNT=(MINNIBBLES<63)? 6
|
|
:((MINNIBBLES<127)? 7:((MINNIBBLES<255)? 8:9));
|
input i_clk, i_ce, i_en, i_cancel;
|
input i_clk, i_ce, i_en, i_cancel;
|
input i_v; // Valid
|
input i_v; // Valid
|
input [3:0] i_d; // Data nibble
|
input [3:0] i_d; // Data nibble
|
output reg o_v;
|
output reg o_v;
|
output reg [3:0] o_d;
|
output reg [3:0] o_d;
|
|
|
// 60 bytes translates to 120 nibbles, so let's keep track of our
|
reg [(LGNCOUNT-1):0] r_ncnt;
|
// minimum number of nibbles to transmit
|
|
reg [119:0] r_v;
|
|
|
|
initial r_v = 120'hff_ffff_ffff_ffff_ffff_ffff_ffff_ffff;
|
|
initial o_v = 1'b0;
|
initial o_v = 1'b0;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if (i_ce)
|
if (i_ce)
|
begin
|
begin
|
if (((!i_v)&&(!o_v))||(i_cancel))
|
if (((!i_v)&&(!o_v))||(i_cancel))
|
begin
|
begin
|
r_v <= 120'hff_ffff_ffff_ffff_ffff_ffff_ffff_ffff;
|
r_ncnt <= 0;
|
o_v <= 1'b0;
|
o_v <= 1'b0;
|
end else if (i_v)
|
end else if (i_v)
|
begin
|
begin
|
o_v <= i_v;
|
o_v <= i_v;
|
r_v <= { r_v[118:0], 1'b0 };
|
r_ncnt <= (r_ncnt<MINNIBBLES) ? r_ncnt+1'b1 : r_ncnt;
|
end else begin
|
end else begin
|
o_v <= r_v[119];
|
o_v <= (r_ncnt<MINNIBBLES);
|
r_v <= { r_v[118:0], 1'b0 };
|
r_ncnt <= (r_ncnt<MINNIBBLES) ? r_ncnt+1'b1 : r_ncnt;
|
end
|
end
|
|
|
if (i_v)
|
if (i_v)
|
o_d <= i_d;
|
o_d <= i_d;
|
else
|
else
|