📄 pl4_lite_data_monitor.v
字号:
begin
TDatDataIndex <= #`TFF (TDatDataIndex + 1'b1) % `STORAGE_SIZE;
// If data matches
if (RDatData[TDatDataIndex][15:0] == TDat[15:0]);
// do nothing
// Data does not match
else
$display("TDat Error: Data Mismatch #4. Expected %h, Received %h. %0d ps", RDatData[TDatDataIndex][15:0], TDat[15:0], $time);
end // TCtl == 0
end // not training or idle
end // !Reset_n
end // Interperete TDat
//******************************************************************************
// tdat_reset_delay
//******************************************************************************
// Create TDatResetComplete signal which is asserted once the OSERDES of
// TDat and TCtl should have completed the reset process and should be
// producing valid (non-Z, non-X, non-U) data
//******************************************************************************
always @(posedge TDClk_align or negedge Reset_n)
begin: tdat_reset_delay
if (!Reset_n)
begin
TDatResetComplete <= #`TFF 1'b0;
ClkCnt = 'b0;
end
else
begin
// Wait 16 TDClk_align periods
// before asserting TDatResetComplete
if (ClkCnt == 15)
TDatResetComplete <= #`TFF 1'b1;
else
ClkCnt = ClkCnt + 1;
end
end
//******************************************************************************
// check_tdat_training
//******************************************************************************
// Check for Training on TDat.
//******************************************************************************
always @(TDClk_align or negedge Reset_n or negedge TDatResetComplete)
begin: check_tdat_training
if (!Reset_n || !TDatResetComplete)
begin
TDatTrainingCnt <= #`TFF 'b0;
TDatTraining <= #`TFF 1'b0;
TDatSinceTrain <= #`TFF 'b0;
SrcOofTrain <= #`TFF 1'b0;
TDatTrainPatterns <= #`TFF 'b0;
end
else
begin
// if it is a training control word
if ((TCtl == 1'b1) && (TDat == `TRAINING_CTL))
begin
TDatTraining <= #`TFF 1'b1;
TDatTrainPatterns <= #`TFF TDatTrainPatterns;
TDatSinceTrain <= #`TFF 'b0;
if (SrcOof == 1)
SrcOofTrain <= #`TFF 1'b1;
else
SrcOofTrain <= #`TFF SrcOofTrain;
end
// if it is a non training control word
else if ((TCtl == 1'b1) && (TDat != `TRAINING_CTL))
begin
TDatTraining <= #`TFF 1'b0;
TDatTrainPatterns <= #`TFF 'b0;
TDatSinceTrain <= #`TFF TDatSinceTrain + 1'b1;
SrcOofTrain <= #`TFF 'b0;
// If the Source Core was out of frame, check to see if it is still out
// of frame
if (SrcOofTrain == 1)
begin
if (SrcOof == 1)
$display ("TDat Error: Protocol Violation #1: Source Core out of frame, expected training. %0d ps", $time);
end
// If it was in Periodic training then check to see that AlphaData
// number of patterns were sent
else if ((TDatTraining == 1'b1) && ((TDatTrainPatterns != AlphaData) &&
(AlphaData != 0) && (DataMaxT != 0) && (TDatFirst == 1'b1)))
begin
$display ("TDat Error: Protocol Violation #2: Expected %d number of training patterns, received %d. %0d ps", AlphaData, TDatTrainPatterns, $time);
end
// If it is a payload control word, check to see if it has
// been more than DataMaxT + 16 cycles since training (plus 16 gives two
// credit leaway in when an error is flagged). There is no need to
// check the burst boundary because the core will always send a PC on
// a burst boundary
if ((TDat[15] == 1'b1) || (TDat[12] == 1'b1))
begin
if ((TDatSinceTrain >= (DataMaxT + 16)) && (DataMaxT != 'b0) && (SrcBurstMode == 0) &&
(AlphaData != 'b0))
begin
$display("TDat Error: Protocl Violation #3: Expected training. DataMaxT = %d, Number of cycles since training = %d. %0d ps", DataMaxT, TDatSinceTrain, $time);
end
end
end
// if it is a training data word set the since training counter
// (TDatSinceTrain) to zero and set the training flag (TDatTraining).
// If TDatTrainingCnt is equal to 9 then increment the training
// patterns counter (TDatTrainPatterns) and reset TDatTrainingCnt.
// Otherwise increment TDatTrainingCnt
else if ((TDat == ~`TRAINING_CTL) && (TDatTraining == 1'b1))
begin
TDatTraining <= #`TFF 1'b1;
TDatSinceTrain <= #`TFF 1'b0;
if (TDatTrainingCnt == 4'd9)
begin
TDatTrainingCnt <= #`TFF 'b0;
TDatTrainPatterns <= #`TFF TDatTrainPatterns + 1;
end
else
begin
TDatTrainingCnt <= #`TFF TDatTrainingCnt + 1;
TDatTrainPatterns <= #`TFF TDatTrainPatterns;
end
end
// Else it is a data word so just increment the TDatSinceTrain counter
else
begin
TDatTraining <= #`TFF 1'b0;
TDatTrainPatterns <= #`TFF 'b0;
TDatSinceTrain <= #`TFF TDatSinceTrain + 1'b1;
end
end
end // Check TDat Training
//****************************************************************************
// check_idle_request
//****************************************************************************
// This process checks the IdleRequest signal and if it is high it checks
// to see if a idles or training are being received.
//****************************************************************************
always @(TDClk_align or negedge Reset_n or negedge TDatResetComplete)
begin: check_idle_request
if (!Reset_n || !TDatResetComplete)
SinceIdleRequest <= #`TFF 'b0;
else
if (IdleRequest == 0)
begin
SinceIdleRequest <= #`TFF 'b0;
end
else if (IdleRequest == 1)
begin
// 82 ensures that the idle request propagates through the core
if (SinceIdleRequest < 82)
SinceIdleRequest <= #`TFF SinceIdleRequest + 1'b1;
// If it is training, ignore it
else if ((TCtl ==1) && (TDat == ~`TRAINING_CTL));
// If it is payload control word, then print an error.
else if ((TCtl == 1) && (TDat[15] != 1'b0) && (TDat[12] != 1'b0))
$display("TDat Error: Protocol Violation #4. IdleRequest Asserted, expected Idles. %0d ps", $time);
end
end
//****************************************************************************
// check_training_request
//****************************************************************************
// This process checks the TrainingRequest signal and if it is high or has
// pulsed then it checks to see if training is being received on TDat
//****************************************************************************
always @(TDClk_align or negedge Reset_n or negedge TDatResetComplete)
begin: check_training_request
if (!Reset_n || !TDatResetComplete)
begin
FirstTrain <= #`TFF 1'b0;
AlphaDataCnt <= #`TFF 'b0;
AlphaDataPatternCnt <= #`TFF 'b0;
TrainingRequestSent <= #`TFF 1'b0;
SinceTrainReq <= #`TFF 'b0;
PCFlag <= #`TFF 'b0;
FirstIdle <= #`TFF 1'b0;
end
// The source will not begin sending training until it a time period after
// it is enabled. Therefore wait for the first training pattern to be
// sent before checking TrainingRequest
else if (!FirstTrain)
begin
if ((TDat == `TRAINING_CTL) && (TCtl == 1'b1))
FirstTrain <= #`TFF 1'b1;
AlphaDataCnt <= #`TFF 'b0;
AlphaDataPatternCnt <= #`TFF 'b0;
TrainingRequestSent <= #`TFF 1'b0;
SinceTrainReq <= #`TFF 'b0;
PCFlag <= #`TFF 'b0;
FirstIdle <= #`TFF 1'b0;
end
// Check to see if training request is high or has pulsed. If it has
// pulsed then check to see if training patterns are being sent. If it
// stayed high see if there has been a payload control word. If there
// has and if there have been less then AlphaData number of
// training patterns sent then check to see that training is begin
// received.
else
begin
// If TrainingRequest went high
if ((TrainReqPulse == 1) || (TrainingRequestSent == 1))
begin
// If it has been less than 82 cycles since training request went high
// then just check for training (82 gives training request time to
// propagate through the core)
if (SinceTrainReq < 82)
begin
if (TDatTraining == 1)
begin
TrainingRequestSent <= #`TFF 1'b0;
SinceTrainReq <= #`TFF 'b0;
end
else
begin
TrainingRequestSent <= #`TFF 1'b1;
SinceTrainReq <= #`TFF SinceTrainReq + 1'b1;
end
end
// If it has been more than 82 cycles then check for a PC word and
// check for training
else if ((TCtl == 1) && (PCFlag == 0))
begin
if (TDatTraining == 1)
begin
TrainingRequestSent <= #`TFF 1'b0;
SinceTrainReq <= #`TFF 'b0;
end
else
begin
TrainingRequestSent <= #`TFF 1'b1;
PCFlag <= #`TFF 1'b1;
end
end
// If a payload control word was sent, then check for training, if no
// training was received, then look for an idle. There can be one
// idle between the data and training. If there is not an idle, or
// there is multiple idles then flag an error.
else if (PCFlag == 1)
begin
PCFlag <= #`TFF 1'b0;
if ((TDatTraining == 1) || ((TCtl == 1) && (TDat == `TRAINING_CTL)))
begin
FirstIdle <= #`TFF 1'b0;
TrainingRequestSent <= #`TFF 1'b0;
SinceTrainReq <= #`TFF 'b0;
end
else if ((TCtl == 1) && (TDat[15:4] == 12'h000) && (FirstIdle == 0))
begin
TrainingRequestSent <= #`TFF 1'b1;
FirstIdle <= 1'b1;
end
else
begin
TrainingRequestSent <= #`TFF 1'b1;
FirstIdle <= 1'b0;
$display("TDat Error: Protocol Violation #5. TrainingRequest asserted, expected training. %0d ps", $time);
end
end
end
end
end
//******************************************************************************
// create_train_request_pulse
//******************************************************************************
// Creates a pulse on TrainReqPulse every time TrainingRequest goes high
//******************************************************************************
always @(TDClk_align or negedge Reset_n or negedge TDatResetComplete)
begin: create_train_pulse
if (!Reset_n || !TDatResetComplete)
begin
TrainingRequestLast <= #`TFF 1'b0;
TrainReqPulse <= #`TFF 1'b0;
end
else
begin
TrainingRequestLast <= #`TFF TrainingRequest;
if ((TrainingRequest == 1) && (TrainingRequestLast == 0))
TrainReqPulse <= #`TFF 1'b1;
else
TrainReqPulse <= #`TFF 1'b0;
end
end
//******************************************************************************
// check_tdat_sop
//******************************************************************************
// Check SOP spacing on TDat to ensure minimum spacing requirements
//******************************************************************************
always @(TDClk_align or negedge Reset_n or negedge TDatResetComplete)
begin: check_tdat_sop
if (!Reset_n || !TDatResetComplete)
TDatSopCnt <= #`TFF 'b0;
else
begin
// For non-control words, increment the counter
if (TCtl == 1'b0)
begin
if (TDatSopCnt < 7)
TDatSopCnt <= #`TFF TDatSopCnt + 1;
else
TDatSopCnt <= #`TFF 'd7;
end
// For control words, investigate further
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -