📄 cal_ctl.vhd
字号:
elsif (state = idleD1) then
if (hxSamp1 = '1' and prevSamp = '0') then
d1Shft <= zoShft;
selTap <= tap3;
waitOneCycle <= '1';
state <= idleD2;
rstate <= idleReset;
resetDcm <= '1';
elsif (hxSamp1 = '0' and prevSamp = '1') then
d1Shft <= ozShft;
selTap <= tap3;
waitOneCycle <= '1';
state <= idleD2;
rstate <= idleReset;
resetDcm <= '1';
elsif (hxSamp1 = '0' and prevSamp = '0') then
--- increment phase shift delay
psEn <= '1';
psinc_val <= '1';
state <= waitDcmD1;
prevSamp <= '0';
elsif (hxSamp1 = '1' and prevSamp = '1') then
--- decrement variable delay
psEn <= '1';
psinc_val <= '0';
state <= waitDcmD1;
prevSamp <= '1';
end if;
elsif (state = waitDcmD1) then
psEn <= '0';
if (psDoneReg = '1') then
state <= idleD1;
end if;
elsif (state = idleD2) then
if (hxSamp1 = '1' and prevSamp = '0') then
d2Shft <= zoShft;
selTap <= tap4;
waitOneCycle <= '1';
state <= idleD3;
rstate <= idleReset;
resetDcm <= '1';
elsif (hxSamp1 = '0' and prevSamp = '1') then
d2Shft <= ozShft;
selTap <= tap4;
waitOneCycle <= '1';
state <= idleD3;
rstate <= idleReset;
resetDcm <= '1';
elsif (hxSamp1 = '0' and prevSamp = '0') then
--- increment phase shift delay
psEn <= '1';
psinc_val <= '1';
state <= waitDcmD2;
prevSamp <= '0';
elsif (hxSamp1 = '1' and prevSamp = '1') then
--- decrement variable delay
psEn <= '1';
psinc_val <= '0';
state <= waitDcmD2;
prevSamp <= '1';
end if;
elsif (state = waitDcmD2) then
psEn <= '0';
if (psDoneReg = '1') then
state <= idleD2;
end if;
elsif (state = idleD3) then
if (hxSamp1 = '1' and prevSamp = '0') then
d3Shft <= zoShft;
selTap <= tap5;
waitOneCycle <= '1';
state <= idleD4;
rstate <= idleReset;
resetDcm <= '1';
elsif (hxSamp1 = '0' and prevSamp = '1' ) then
d3Shft <= ozShft;
selTap <= tap5;
waitOneCycle <= '1';
state <= idleD4;
rstate <= idleReset;
resetDcm <= '1';
elsif (hxSamp1 = '0'and prevSamp = '0') then
--- increment phase shift delay
psEn <= '1';
psinc_val <= '1';
state <= waitDcmD3;
prevSamp <= '0';
elsif (hxSamp1 = '1' and prevSamp = '1') then
--- decrement variable delay
psEn <= '1';
psinc_val <= '0';
state <= waitDcmD3;
prevSamp <= '1';
end if;
elsif (state = waitDcmD3) then
psEn <= '0';
if (psDoneReg = '1') then
state <= idleD3;
end if;
elsif (state = idleD4) then
if (hxSamp1 = '1' and prevSamp = '0') then
d4Shft <= zoShft;
selTap <= tap6;
waitOneCycle <= '1';
state <= idleD5;
rstate <= idleReset;
resetDcm <= '1';
elsif (hxSamp1 = '0' and prevSamp = '1' ) then
d4Shft <= ozShft;
selTap <= tap6;
waitOneCycle <= '1';
state <= idleD5;
rstate <= idleReset;
resetDcm <= '1';
elsif (hxSamp1 = '0' and prevSamp = '0') then
--- increment phase shift delay
psEn <= '1';
psinc_val <= '1';
state <= waitDcmD4;
prevSamp <= '0';
elsif (hxSamp1 = '1'and prevSamp = '1') then
--- decrement variable delay
psEn <= '1';
psinc_val <= '0';
state <= waitDcmD4;
prevSamp <= '1';
end if;
elsif (state = waitDcmD4) then
psEn <= '0';
if (psDoneReg = '1') then
state <= idleD4;
end if;
elsif (state = idleD5) then
if (hxSamp1 = '1' and prevSamp = '0') then
d5Shft <= zoShft;
selTap <= tap1;
waitOneCycle <= '1';
state <= idleD0;
rstate <= idleReset;
resetDcm <= '1';
elsif (hxSamp1 = '0' and prevSamp = '1' ) then
d5Shft <= ozShft;
selTap <= tap1;
waitOneCycle <= '1';
state <= idleD0;
rstate <= idleReset;
resetDcm <= '1';
elsif (hxSamp1 = '0' and prevSamp = '0') then
--- increment phase shift delay
psEn <= '1';
psinc_val <= '1';
state <= waitDcmD5;
prevSamp <= '0';
elsif (hxSamp1 = '1' and prevSamp = '1') then
---- decrement variable delay
psEn <= '1';
psinc_val <= '0';
state <= waitDcmD5;
prevSamp <= '1';
end if;
elsif (state = waitDcmD5) then
psEn <= '0';
if (psDoneReg = '1' ) then
state <= idleD5;
end if;
--- end else if (state == `idleDone) begin
end if;
end if; --- else: !if(wait4Cycle)
end if; ---- else: !if(resetDcm)
if (psDoneReg = '1' and rstate /= waitReset) then
if (psinc_val = '1') then
posPhShft <= posPhShft + 1;
else
negPhShft <= negPhShft + 1;
end if;
end if;
end if;---- // if (dcmlocked)
end if;--- // else: !if(reset)
end if;
end process;
--- Logic to figure out the number of tap delays to use for dqs
--- generate the output tapForDqs
process(clk)
begin
if clk'event and clk = '1' then
if reset = '1' then
lPtr <= "0000";
uPtr <= "0101";
tapForDqs <= defaultTap;
inTapForDqs <= defaultTap;
newTap <= defaultTap;
midPt <= "0011";
okSelCnt <= '0';
else
if (d0Shft > lBound) then
lPtr <= "0000";
elsif (d1Shft > lBound) then
lPtr <= "0001";
elsif (d2Shft > lBound) then
lPtr <= "0010";
elsif (d3Shft > lBound) then
lPtr <= "0011";
elsif (d4Shft > lBound) then
lPtr <= "0100";
else
lPtr <= "0101";
end if;
if (d5Shft < uBound) then
uPtr <= "0101";
elsif (d4Shft < uBound) then
uPtr <= "0100";
elsif (d3Shft < uBound) then
uPtr <= "0011";
elsif (d2Shft < uBound) then
uPtr <= "0010";
elsif (d1Shft < uBound) then
uPtr <= "0001";
else
uPtr <= "0000";
end if;
midPt(3 downto 0) <= ( uPtr(3 downto 0) + lPtr(3 downto 0) );
--------------------
case midPt(3 downto 1) is
when "000" =>
inTapForDqs <= tap1;
when "001" =>
inTapForDqs <= tap2;
when "010" =>
inTapForDqs <= tap3;
when "011" =>
inTapForDqs <= tap4;
when "100" =>
inTapForDqs <= tap5;
when "101" =>
inTapForDqs <= tap6;
when others =>
inTapForDqs <= inTapForDqs;
end case; --- case(midPt[2:0])
--- tap output shouldn't change unless the same tap value is selected n number of times.
newTap <= inTapForDqs;
if (inTapForDqs = newTap) then
if (wait4Cycle = '1') then
selCnt <= selCnt + 1;
end if;
if (selCnt = slipCnt) then
okSelCnt <= '1';
else okSelCnt <= '0';
end if;
else
selCnt <= "0000";
okSelCnt <= '0';
end if;
if (okToSelTap ='1' and okSelCnt = '1') then
tapForDqs <= newTap;
end if;
end if;
end if;
end process;
end arc_cal_ctl;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -