Processes | |
onescnt | ( CLK , res_n ) |
count ones | |
zeroscnt | ( CLK , res_n ) |
count zeros | |
Signals | |
res_n | std_logic := ' 1 ' |
ok | std_logic := ' 0 ' |
per_cnt_0 | std_logic_vector ( 3 downto 0 ) := ( others = > ' 0 ' ) |
per_cnt_1 | std_logic_vector ( 3 downto 0 ) := ( others = > ' 0 ' ) |
This architecture checks an incoming signal for a period specified with PERIOD. At least three consecutive periods must be correct.
Definition at line 55 of file period_check.vhd.
onescnt | ( CLK , | |
res_n ) |
count ones
Definition at line 68 of file period_check.vhd.
00068 onescnt : process (CLK, res_n) 00069 variable cnt : integer range 0 to 255 := 0; 00070 begin -- process onescnt 00071 if res_n = '0' then -- asynchronous reset (active low) 00072 cnt := 0; 00073 per_cnt_1 <= (others => '0'); 00074 elsif CLK'event and CLK = '1' then -- rising clock edge 00075 if EN = '1' and ok = '0' then 00076 if A = '1' then 00077 cnt := cnt + 1; 00078 else 00079 if cnt = PERIOD/2 then 00080 per_cnt_1 <= per_cnt_1 + '1'; 00081 elsif cnt /= 0 then 00082 per_cnt_1 <= (others => '0'); 00083 else 00084 per_cnt_1 <= per_cnt_1; 00085 end if; 00086 cnt := 0; 00087 end if; 00088 else 00089 cnt := cnt; 00090 per_cnt_1 <= per_cnt_1; 00091 end if; 00092 end if; 00093 end process onescnt;
zeroscnt | ( CLK , | |
res_n ) |
count zeros
Definition at line 96 of file period_check.vhd.
00096 zeroscnt : process (CLK, res_n) 00097 variable cnt : integer range 0 to 255 := 0; 00098 begin -- process onescnt 00099 if res_n = '0' then -- asynchronous reset (active low) 00100 cnt := 0; 00101 per_cnt_0 <= (others => '0'); 00102 elsif CLK'event and CLK = '1' then -- rising clock edge 00103 if EN = '1' and ok = '0' then 00104 if A = '0' then 00105 cnt := cnt + 1; 00106 else 00107 if cnt = PERIOD/2 then 00108 per_cnt_0 <= per_cnt_0 + '1'; 00109 elsif cnt /= 0 then 00110 per_cnt_0 <= (others => '0'); 00111 else 00112 per_cnt_0 <= per_cnt_0; 00113 end if; 00114 cnt := 0; 00115 end if; 00116 else 00117 cnt := cnt; 00118 per_cnt_0 <= per_cnt_0; 00119 end if; 00120 end if; 00121 end process zeroscnt;