?? roboclock.vhd
字號:
f_nom_period_low_bond<=12.50 ns; N:=N_high; END IF; tu<=(f_nom_period/N); END PROCESS;---------------------------------------------------------------------------------- Search Mode Process---------------------------------------------------------------------------------- This process is to detect which of the 8 output pin is connected -- to the feedback pin. This process is not repeatable. Because of-- this process, REF_ipd can't be inserted until 10 ns after.-- If feedback is connected to either 1Qx or 2Qx then M=1, if 3Qx then M=4,-- 4Qx then M=2.-------------------------------------------------------------------------------- search_process:PROCESS BEGIN wait for 250 us; -- half PLL lock time a <= '1'; b <= '1'; wait for 250 us; -- half PLL lock time IF (FB_ipd='1') THEN M <=1; ELSE c <= '1'; wait for 2 ns; IF (FB_ipd='1') THEN M <= 4; ELSE d <='1'; wait for 2 ns; IF (FB_ipd='1') THEN M <=2; END IF; END IF; END IF; wait; END PROCESS;---------------------------------------------------------------------------------- Ouput Generate Process (Operation Mode output)---------------------------------------------------------------------------------- This process delay, divide, or multiply the Nominal Frequency (f_nom)-- according to the input of Fx0 and Fx1. The time unit delay (tu)-- is calcualted at tu process.-- Note that these are the outputs connect to the output pins of the-- model during operation mode. -------------------------------------------------------------------------------- output_generate_process:PROCESS VARIABLE temp3: std_logic:='0'; BEGIN WAIT ON f_nom; IF (F10='0' and F11='0') THEN qa1<=transport f_nom after (f_nom_period- 4 * tu); ELSIF (F10='Z' and F11='0') THEN qa1<=transport f_nom after (f_nom_period-3 * tu); ELSIF (F10='1' and F11='0') THEN qa1<=transport f_nom after (f_nom_period-2 * tu); ELSIF (F10='0' and F11='Z') THEN qa1<=transport f_nom after (f_nom_period-1 * tu); ELSIF (F10='Z' and F11='Z') THEN qa1<=transport f_nom ; ELSIF (F10='1' and F11='Z') THEN qa1<=transport f_nom after (1 * tu); ELSIF (F10='0' and F11='1') THEN qa1<=transport f_nom after (2 * tu); ELSIF (F10='Z' and F11='1') THEN qa1<=transport f_nom after (3 * tu); ELSIF (F10='1' and F11='1') THEN qa1<=transport REF_ipd after (4* tu); END IF; IF (F20='0' and F21='0') THEN qa2<=transport f_nom after (f_nom_period - 4 * tu); ELSIF (F20='Z' and F21='0') THEN qa2<=transport f_nom after (f_nom_period-3 * tu); ELSIF (F20='1' and F21='0') THEN qa2<=transport f_nom after (f_nom_period-2 * tu); ELSIF (F20='0' and F21='Z') THEN qa2<=transport f_nom after (f_nom_period-1 * tu); ELSIF (F20='Z' and F21='Z') THEN qa2<=transport f_nom ; ELSIF (F20='1' and F21='Z') THEN qa2<=transport f_nom after (1 * tu); ELSIF (F20='0' and F21='1') THEN qa2<=transport f_nom after (2 * tu); ELSIF (F20='Z' and F21='1') THEN qa2<=transport f_nom after (3 * tu); ELSIF (F20='1' and F21='1') THEN qa2<=transport f_nom after (4* tu); END IF; IF (F30='0' and F31='0') THEN IF (f_nom='1') THEN qa3<= not qa3; END IF; ELSIF (F30='Z' and F31='0') THEN qa3<=transport f_nom after (f_nom_period-6 * tu); ELSIF (F30='1' and F31='0') THEN qa3<=transport f_nom after (f_nom_period-4 * tu); ELSIF (F30='0' and F31='Z') THEN qa3<=transport f_nom after (f_nom_period-2 * tu); ELSIF (F30='Z' and F31='Z') THEN qa3<=transport f_nom ; ELSIF (F30='1' and F31='Z') THEN qa3<=transport f_nom after (2 * tu); ELSIF (F30='0' and F31='1') THEN qa3<=transport f_nom after (4 * tu); ELSIF (F30='Z' and F31='1') THEN qa3<=transport f_nom after (6 * tu); ELSIF (F30='1' and F31='1') THEN IF (f_nom='1') THEN temp3:= not temp3; IF (temp3='1') THEN qa3<= not qa3; END IF; END IF; END IF; IF (F40='0' and F41='0') THEN IF (f_nom='1') THEN qa4<=not qa4; END IF; ELSIF (F40='Z' and F41='0') THEN qa4<=transport f_nom after (f_nom_period-6 * tu); ELSIF (F40='1' and F41='0') THEN qa4<=transport f_nom after (f_nom_period-4 * tu); ELSIF (F40='0' and F41='Z') THEN qa4<=transport f_nom after (f_nom_period-2 * tu); ELSIF (F40='Z' and F41='Z') THEN qa4<=transport f_nom ; ELSIF (F40='1' and F41='Z') THEN qa4<=transport f_nom after (2 * tu); ELSIF (F40='0' and F41='1') THEN qa4<=transport f_nom after (4 * tu); ELSIF (F40='Z' and F41='1') THEN qa4<=transport f_nom after (6 * tu); ELSIF (F40='1' and F41='1') THEN qa4<=transport not f_nom; END IF; END PROCESS;---------------------------------------------------------------------------------- Generate grid siganl---------------------------------------------------------------------------------- This process generate grid signal which is used to sample the reference-- and feedback signal. The period of the reference signal (ref_period)-- is calculated then divided by 64 to obtain the grid signal period-- (grid_period). Grid signal is generated after the second reference-- signal.-- Variable loop1 is used to keep track with the numbe of the loop.-- Note that the last "WAIT FOR grid_period" was void to prevent aliasing.-------------------------------------------------------------------------------- ref_grid_process:PROCESS VARIABLE redge1 : time:= 0 ns; VARIABLE redge2 : time:= 0 ns; VARIABLE temp : time; VARIABLE loop1 : integer:=0; BEGIN wait on REF_ipd; IF (TEST_ipd='0') THEN IF (REF_ipd='1') THEN ref_count<=ref_count+1; redge2 :=redge1; redge1 := NOW; ref_period<= (redge1-redge2); grid_period <= (ref_period/64); IF (ref_count>1) then FOR i in 0 to 30 loop grid<='1'; WAIT FOR grid_period; grid<='0'; WAIT FOR grid_period; loop1:=loop1+1; END LOOP; grid<='1'; WAIT FOR grid_period; grid<='0'; loop1:=0; END IF; END IF; END IF; END PROCESS;---------------------------------------------------------------------------------- Weight Count Process---------------------------------------------------------------------------------- This process samples reference signal and feedback signal with grid signal.-- Weight Count (weight_count) signal is used to adjust the nominal-- period ( to be speed up or slow down). -- The adjusted nominal period is f_nom_period_fin.-- f_nom_period_fin is then to compare with the lower and upper bond-- of the frequency range. If it exceeds the range, it will be clipped.-------------------------------------------------------------------------------- weight_count_process:PROCESS VARIABLE loop2 : integer:=0; VARIABLE loop3 : integer:=0; BEGIN WAIT ON grid; IF (TEST_ipd='0') THEN IF (FB_ipd='1') THEN FOR i in 0 TO 31 LOOP IF( grid='1') THEN IF ( FB_ipd='1' and REF_ipd='0') THEN weight_count<=weight_count-1; ELSIF (REF_ipd='1' and FB_ipd='Z') THEN weight_count<=weight_count+1; ELSE NULL; END IF; loop2:=loop2+1; WAIT FOR grid_period*2; END IF; END LOOP; loop2:=0; f_nom_period_fin<= (f_nom_period+weight_count*grid_period); loop3:=loop3+1; IF (f_nom_period_fin<f_nom_period_low_bond) THEN f_nom_period_fin<=f_nom_period_low_bond; ELSIF (f_nom_period_fin>f_nom_period_up_bond) THEN f_nom_period_fin<=f_nom_period_up_bond; ELSE NULL; END IF; END IF; END IF; END PROCESS;---------------------------------------------------------------------------------- Feedback Process---------------------------------------------------------------------------------- This process is to calculated feedback period.-------------------------------------------------------------------------------- fb_process:PROCESS VARIABLE fedge1 : time:= 0 ns; VARIABLE fedge2 : time:= 0 ns; VARIABLE temp : time:= 0 ns; BEGIN wait on FB_ipd; IF (FB_ipd='1') THEN fb_count<=fb_count+1; fedge2 := fedge1; fedge1 := NOW; IF (fb_count>1) then fb_period<= (fedge1-fedge2); END IF; END IF; END PROCESS;---------------------------------------------------------------------------------- Nominal Period Mux Process---------------------------------------------------------------------------------- This process decides when nominal period gets updated by the adjusted-- nominal period.-------------------------------------------------------------------------------- f_nom_period_mux_process:PROCESS(f_nom_period_ini, f_nom_period_fin,ref_count) BEGIN IF (ref_count<4) THEN f_nom_period<=f_nom_period_ini; ELSE f_nom_period<=f_nom_period_fin; END IF; END PROCESS;END vhdl_behavioral;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -