📄 pl4_lite_data_monitor.v
字号:
// 3. Inserts PC word when data follows non-PC word
// 4. Inserts payload resume if current burst is longer than SrcBurstLen
// 5. Drops reserved control or PC words followed by a PC word
// 6. Checks for idles following non EOP control word
// 7. Inserts EOP abort if if idle follows data on non-credit boundary
// 8. Drops Payload resume to same channel on credit boundaries
// 9. Inserts EOP abort if SOP or payload resume follows data on non-credit
// boundary
// 10. Drops least significant byte if EOP is set to one credit valid
// 11. Drops the current EOP word if two EOP's are received back to back
//*****************************************************************************
always @(RDClk or negedge Reset_n)
begin: interprete_rdat
if (!Reset_n)
begin
RDatDataIndex <= #`TFF 'b0;
CurrentAddress <= #`TFF 'b0;
FirstPC <= #`TFF 1'b0;
for (cnt = 0; cnt < `STORAGE_SIZE; cnt = cnt + 1)
begin
RDatData[cnt] <= {16{1'b0}};
RCtlData[cnt] <= 'b0;
end
end
else
begin
// If it is a training data word do not store it
if (((InTraining == 1) && (RCtl == 1'b0)) ||
((RCtl == 1'b1) && (RDat == `TRAINING_CTL)));
// Wait for a valid payload control word with SOP before storing any data.
else if (FirstPC == 0)
begin
// If there is a valid payload control word followed by data, then
// store the data and set the FirstPC flag
if ((RDatData[RDatDataIndexMinus1][15] == 1) &&
(RDatData[RDatDataIndexMinus1][12] == 1) &&
(RCtlData[RDatDataIndexMinus1] == 1) && (RCtl == 0))
begin
FirstPC <= #`TFF 1'b1;
RDatData[RDatDataIndex] <= #`TFF RDat;
RCtlData[RDatDataIndex] <= #`TFF RCtl;
CurrentAddress <= #`TFF RDatData[RDatDataIndexMinus1][11:4];
RDatDataIndex <= #`TFF RDatDataIndexPlus1;
end
// If it is the first data sent, then store it and increment the
// pointer RDatDataIndex. Since it is the first data, strip any EOP
// information
else if (RDatDataIndex == 0)
begin
RDatData[RDatDataIndex] <= #`TFF {RDat[15], 2'b00, RDat[12:0]};
RCtlData[RDatDataIndex] <= #`TFF RCtl;
RDatDataIndex <= #`TFF RDatDataIndexPlus1;
end
// Otherwise keep the pointer the same and write over the previous
// value stored. Since it is the first word, strip any EOP
// information
else
begin
RDatData[RDatDataIndexMinus1] <= #`TFF {RDat[15], 2'b00, RDat[12:0]};
RCtlData[RDatDataIndexMinus1] <= #`TFF RCtl;
RDatDataIndex <= #`TFF RDatDataIndex;
end
end
// If it is a data word
else if (RCtl == 0)
begin
// If the last word was a control word find out which type
if (RCtlData[RDatDataIndexMinus1] == 1)
begin
// If the last control word was a reserved control word then change
// it into a payload control word with the last address that data
// was sent to (as per spec)
if ((RDatData[RDatDataIndexMinus1][15] == 0) &&
(RDatData[RDatDataIndexMinus1][12] == 1))
begin
$display("RDat Warning: Protocol Violation #1: Reserved control word followed by data. %0d ps", $time);
RDatData[RDatDataIndexMinus1] <= #`TFF {4'b1000, CurrentAddress,
4'b1111};
RDatData[RDatDataIndex] <= #`TFF RDat;
RCtlData[RDatDataIndex] <= #`TFF RCtl;
RDatDataIndex <= #`TFF RDatDataIndexPlus1;
end
// If the last control word was a payload control word then store
// the data value and update the current address
else if (RDatData[RDatDataIndexMinus1][15] == 1)
begin
RDatData[RDatDataIndex] <= #`TFF RDat;
RCtlData[RDatDataIndex] <= #`TFF RCtl;
CurrentAddress <= #`TFF RDatData[RDatDataIndexMinus1][11:4];
RDatDataIndex <= #`TFF RDatDataIndexPlus1;
end
// Otherwise insert a payload resume on the current address and
// print a warning. Then store the data
else
begin
$display("RDat Warning: Protocol Violation #2: Data follows non payload control. %0d ps", $time);
RDatData[RDatDataIndex] <= #`TFF {4'b1000, CurrentAddress, 4'b1111};
RCtlData[RDatDataIndex] <= #`TFF 1'b1;
RDatData[RDatDataIndexPlus1] <= #`TFF RDat;
RCtlData[RDatDataIndexPlus1] <= #`TFF RCtl;
RDatDataIndex <= #`TFF RDatDataIndexPlus2;
end
end
// If the last word was data then check for to see if the number of
// bursts is greater then SrcBurstLen. If it is insert a payload
// control word and then store the next address. Otherwise
// just store the new data and increment the counter
else
begin
if (BurstCnt >= SrcBurstLen)
begin
RDatData[RDatDataIndex] <= #`TFF {4'b1000, CurrentAddress, 4'b1111};
RCtlData[RDatDataIndex] <= #`TFF 1'b1;
RDatData[RDatDataIndexPlus1] <= #`TFF RDat;
RCtlData[RDatDataIndexPlus1] <= #`TFF RCtl;
RDatDataIndex <= #`TFF RDatDataIndexPlus2;
end
else
begin
RDatData[RDatDataIndex] <= #`TFF RDat;
RCtlData[RDatDataIndex] <= #`TFF RCtl;
RDatDataIndex <= #`TFF RDatDataIndexPlus1;
end
end
end // (RCtl == 0)
else // (RCtl == 1)
begin
// If the current word was a reserved control word then drop it
if ((RDat[15] == 0) &&
(RDat[12] == 1) &&
(RCtl == 1))
$display("RDat Warning : Protocol Violation #10. Reserved control word received. Control word will be dropped. %0d ps", $time);
// If the current word is an idle
else if (RDat[15:12] == 4'h0)
begin
if (RDat[11:4] != 8'h00)
$display("RDat Warning : Protocol Violation #11. IDLE control word with non-zero channel received. %0d ps", $time);
// If the last word was an idle replace last idle with current idle
if ((RCtlData[RDatDataIndex] == 1) &&
(RDatData[RDatDataIndex][15:4] == 12'h000))
begin
RDatData[RDatDataIndex] <= #`TFF RDat;
RCtlData[RDatDataIndex] <= #`TFF RCtl;
end
// If the last word was training, store idle but don't increment
// counter (Idle will be overwritten next cycle).
else if (InTraining == 1)
begin
RDatData[RDatDataIndex] <= #`TFF RDat;
RCtlData[RDatDataIndex] <= #`TFF RCtl;
end
// If the last word was a control word, check for EOP
else if (RCtlData[RDatDataIndexMinus1] == 1)
begin
// If there was an EOP ignore the idle
if (RDatData[RDatDataIndexMinus1][14:13] != 2'b00);
// If there was no EOP then print error message
else
begin
$display("RDat Warning: Protocol Violation #3. Idle follows non EOP control word. %0d ps", $time);
end
end// Last word was control word
// If the last word was data check for a credit boundary
else if (RCtlData[RDatDataIndexMinus1] == 0)
begin
// If there was a credit boundary and there is more than one data
// word between the current word and the last payload control.
if ((CreditBoundaryLast == 1) &&
((RCtlData[RDatDataIndexMinus2] == 0) ||
(RDatData[RDatDataIndexMinus2][15] == 0))); // do nothing
// If there was no credit boundary then display warning and change
// the idle to an EOP abort.
else
begin
$display("RDat Warning: Protocol Violation #4. Idle follows data on a non credit boundary. %0d ps", $time);
RDatData[RDatDataIndex] <= 16'h2000;
RCtlData[RDatDataIndex] <= 1'b1;
RDatDataIndex <= RDatDataIndexPlus1;
end
end
// if last word was undefined ignore current word
else;
end
// If the last word was data check for EOP or a credit boundary before
// storing the data
else if (RCtlData[RDatDataIndexMinus1] == 0)
begin
// If there was no EOP then the end of data should have been on
// a credit boundary. If it was not then there will be an EOP abort
// in the next control word.
if (RDat[14:13] == 2'b00)
begin
// If it is on a credit boundary
if (CreditBoundaryLast == 1)
begin
// If the control word is a payload resume to the same channel then
// drop it.
if ((RDat[15] == 1) && (RDat[12] == 0) &&
(RDat[11:4] == CurrentAddress));
// Otherwise store the control word
else
begin
RDatData[RDatDataIndex] <= #`TFF RDat;
RCtlData[RDatDataIndex] <= #`TFF RCtl;
RDatDataIndex <= #`TFF RDatDataIndexPlus1;
end
end
// If it is an SOP or a payload resume
else
begin
$display("RDat Warning: Protocol Violation #5. Non EOP control word on a non-credit boundary. %0d ps", $time);
RDatData[RDatDataIndex] <= #`TFF {12'h200, RDat[3:0]};
RDatData[RDatDataIndexPlus1] <= #`TFF {RDat[15], 2'b00, RDat[12:0]};
RCtlData[RDatDataIndex] <= #`TFF RCtl;
RCtlData[RDatDataIndexPlus1] <= #`TFF RCtl;
RDatDataIndex <= #`TFF RDatDataIndexPlus2;
end
end
// There is an eop so store the control word. Check the number of
// bytes valid in the last data word and if it is only 1 byte, zero
// out the least significant byte (7:0). If the control word also
// has PC data then strip it out and store it in the next buffer
// slot
else
begin
if ((RDat[15] == 1'b1) || (RDat[12] == 1'b1))
begin
RDatData[RDatDataIndex] <= #`TFF {1'b0, RDat[14:13], 13'b0};
RCtlData[RDatDataIndex] <= #`TFF RCtl;
RDatData[RDatDataIndexPlus1] <= #`TFF {RDat[15], 2'b00, RDat[12:0]};
RCtlData[RDatDataIndexPlus1] <= #`TFF RCtl;
RDatDataIndex <= #`TFF RDatDataIndexPlus2;
end
else
begin
RDatData[RDatDataIndex] <= #`TFF RDat;
RCtlData[RDatDataIndex] <= #`TFF RCtl;
RDatDataIndex <= #`TFF RDatDataIndexPlus1;
end
if (RDat[14:13] == 2'b11)
RDatData[RDatDataIndexMinus1] <=
#`TFF {RDatData[RDatDataIndexMinus1][15:8], 8'h00};
end
end
// If the last word was an EOP then check the current word. If it is
// a EOP then drop the current word. If it is any other control word
// then store it
else if (RDatData[RDatDataIndexMinus1][14:13] != 2'b00)
begin
// If the current word is an EOP then drop the EOP part (keep any
// payload control part)
if (RDat[14:13] != 2'b00)
begin
$display("RDat Warning: Protocol Violation #6. EOP control word follows EOP control word. Second EOP will be dropped. %0d ps", $time);
if ((RDat[15] == 1'b1) || (RDat[12] == 1'b1))
begin
RDatData[RDatDataIndex] <= #`TFF {RDat[15], 2'b00, RDat[12:0]};
RDatDataIndex <= #`TFF RDatDataIndexPlus1;
end
end
else
begin
RDatData[RDatDataIndex] <= #`TFF RDat;
RCtlData[RDatDataIndex] <= #`TFF RCtl;
RDatDataIndex <= #`TFF RDatDataIndexPlus1;
end
end
// If the last word was a payload control word then check to see if
// current word is payload control or reserved control. If it is then
// drop the last word (keep any EOP information) and store the current
// word. If it is not payload control then drop the last word and
// insert a payload resume to the current address
else if (RDatData[RDatDataIndexMinus1][15] == 1)
begin
if ((RDat[15] == 1) || (RDat[12] == 1))
begin
$display("RDat Warning: Protocol Violation #7. Payload control word followed by payload control word. First word will be dropped (Only PC bits). %0d ps", $time);
RDatData[RDatDataIndexMinus1] <=
#`TFF {RDat[15], RDatData[RDatDataIndexMinus1][14:13], RDat[12:0]};
end
else
begin
RDatData[RDatDataIndexMinus1] <=
#`TFF {4'b1000, CurrentAddress, 4'b1111};
$display("RDat Warning: Protocol Violation #8. Payload control followed by non-data word. %0d ps", $time);
end
end // last control word was payload
// If the last word was idle or training then store the control word
else
begin
RDatData[RDatDataIndex] <= #`TFF RDat;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -