counter_time.vhd

来自「Bcode_s_m_h.rar实现GPSB码接收、译码等工程」· VHDL 代码 · 共 47 行

VHD
47 行
字号
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity counter_time is
port(clk,b_data:in std_logic;
     q:out std_logic_vector(3 downto 0));
end counter_time;
architecture a of counter_time is
  signal k:std_logic:='1';
  signal n:integer range 0 to 40;
  signal q_out: std_logic_vector(3 downto 0);
begin
  process(b_data)
  begin
  if((b_data and b_data)='1')then
  k<='1';
  else
  k<='0';
  end if;
  end process;
process(clk,k)
begin
  if(clk'event and clk='1')then
  if(k='1')then 
  n<=n+1;
  else
   n<=0;
  end if;
  end if;
end process;
process(n)
begin
  if(n=40 and b_data='0')then
  q_out<="1111";
  elsif(n=25 and b_data='0')then
  q_out<="0111";
  elsif(n=10 and b_data='0')then
  q_out<="0011";
  else
  q_out<="0000";
  end if;
end process;
q<=q_out;
end a;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?