Loading files
dcf560ce9This file is pinned to the selected release. Download the original to open it in your design tool.
module FPDivSqrtUnit (
port : modport FPDivSqrtUnitIF::FPDivSqrtUnit,
recovery: modport RecoveryManagerIF::FPDivSqrtUnit,
) {
import BasicTypes::*;
import OpFormatTypes::*;
import ActiveListIndexTypes::*;
enum DividerPhase: logic<2> {
// Divider is free
DIVIDER_PHASE_FREE = 0,
// Divider is not processing but reserved
DIVIDER_PHASE_RESERVED = 1,
// In processing
DIVIDER_PHASE_PROCESSING = 2,
// Wait for issuing div from replay queue
DIVIDER_PHASE_WAITING = 3,
}
var regPhase: DividerPhase [FP_DIVSQRT_ISSUE_WIDTH];
var nextPhase: DividerPhase [FP_DIVSQRT_ISSUE_WIDTH];
var finished: logic [FP_DIVSQRT_ISSUE_WIDTH];
var flush: logic [FP_DIVSQRT_ISSUE_WIDTH];
var rst_divider: logic [FP_DIVSQRT_ISSUE_WIDTH];
var regActiveListPtr: ActiveListIndexPath [FP_DIVSQRT_ISSUE_WIDTH];
var nextActiveListPtr: ActiveListIndexPath [FP_DIVSQRT_ISSUE_WIDTH];
for i in 0..FP_DIVSQRT_ISSUE_WIDTH : BlockDivUnit {
inst fpDivSqrter: FP32DivSqrter (
clk : port.clk,
rst : rst_divider[i],
lhs : port.dataInA[i],
rhs : port.dataInB[i],
is_divide: port.is_divide[i],
req : port.Req[i],
finished : finished[i],
result : port.DataOut[i],
);
}
always_ff (port.clk) {
if port.rst {
for i in 0..FP_DIVSQRT_ISSUE_WIDTH {
regPhase[i] = DividerPhase::DIVIDER_PHASE_FREE;
regActiveListPtr[i] = 0;
}
} else {
regPhase = nextPhase;
regActiveListPtr = nextActiveListPtr;
}
}
always_comb {
nextPhase = regPhase;
nextActiveListPtr = regActiveListPtr;
for i in 0..FP_DIVSQRT_ISSUE_WIDTH {
case regPhase[i] {
default: {
nextPhase[i] = DividerPhase::DIVIDER_PHASE_FREE;
}
DividerPhase::DIVIDER_PHASE_FREE: {
// Reserve divider and do not issue any div after that.
if port.Acquire[i] {
nextPhase[i] = DividerPhase::DIVIDER_PHASE_RESERVED;
nextActiveListPtr[i] = port.acquireActiveListPtr[i];
}
}
DividerPhase::DIVIDER_PHASE_RESERVED: {
// Request to the divider
// NOT make a request when below situation
// 1) When any operands of inst. are invalid
// 2) When the divider is waiting for the instruction
// to receive the result of the divider
if port.Req[i] {
// Receive the request of div,
// so move to processing phase
nextPhase[i] = DividerPhase::DIVIDER_PHASE_PROCESSING;
}
}
DividerPhase::DIVIDER_PHASE_PROCESSING: {
// Div operation has finished, so we can get result from divider
if finished[i] {
nextPhase[i] = DividerPhase::DIVIDER_PHASE_WAITING;
}
}
DividerPhase::DIVIDER_PHASE_WAITING: {
if port.Release[i] {
// Divが除算器から結果を取得できたので,
// IQからのdivの発行を許可する
nextPhase[i] = DividerPhase::DIVIDER_PHASE_FREE;
}
}
}
// Cancel divider allocation on pipeline flush
flush[i] = SelectiveFlushDetector(
recovery.toRecoveryPhase,
recovery.flushRangeHeadPtr,
recovery.flushRangeTailPtr,
recovery.flushAllInsns,
regActiveListPtr[i]
);
// 除算器に要求をしたdivがフラッシュされたので,除算器を解放する
if flush[i] {
nextPhase[i] = DividerPhase::DIVIDER_PHASE_FREE;
}
rst_divider[i] = port.rst | flush[i];
// 現状 acquire が issue ステージからくるので,次のサイクルの状態でフリーか
// どうかを判定する必要がある
if nextPhase[i] == DividerPhase::DIVIDER_PHASE_FREE {
port.Free[i] = TRUE;
} else {
port.Free[i] = FALSE;
}
if regPhase[i] == DividerPhase::DIVIDER_PHASE_WAITING {
port.Finished[i] = TRUE;
} else {
port.Finished[i] = FALSE;
}
if regPhase[i] == DividerPhase::DIVIDER_PHASE_PROCESSING {
port.Busy[i] = TRUE;
} else {
port.Busy[i] = FALSE;
}
if regPhase[i] == DividerPhase::DIVIDER_PHASE_RESERVED {
port.Reserved[i] = TRUE;
} else {
port.Reserved[i] = FALSE;
}
port.FFlagsOut[i] = '0;
}
}
}