24h購物| | PChome| 登入
2012-12-30 14:08:13| 人氣1,702| 回應0 | 上一篇 | 下一篇

[VHDL] 垃圾推積區-計數器

推薦 0 收藏 0 轉貼0 訂閱站台



RTL viewer.png





JK正反器

library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_unsigned.all;
entity jkflipflop is
  port(
    Clock: in std_logic := '0';
    PRN: in std_logic := '1';
    CLRN: in std_logic := '0';
    J : in std_logic := '0';
    K : in std_logic := '0';
    Q : out std_logic := '0';
    NQ : out std_logic := '1'
  );
end entity jkflipflop;

architecture rtl of jkflipflop is
  signal Qt : std_logic;
begin
  PROCESS(Clock,PRN,CLRN)
  BEGIN
  IF (CLRN = '0') THEN
    Qt <= '0';
  ELSIF (PRN = '0') THEN
    Qt <= '1';
  ELSIF (FALLING_EDGE(Clock)) THEN
    IF (J = '0' and K = '0') THEN
      Qt <= Qt;
    ELSIF (J = '0' and K = '1') THEN
      Qt <= '0';
    ELSIF (J = '1' and K = '0') THEN
      Qt <= '1';
    ELSIF (J = '1' and K = '1') THEN
      Qt <= not Qt;
    END IF;
  END IF;
  END PROCESS;
  Q <= Qt;
  NQ <= not Qt;
end rtl;


計數器

library ieee;
    use ieee.std_logic_1164.all;
entity syncounter is
  port(
    Clock: in std_logic := '0';
    VDD : in std_logic := '1';
    CLRN: in std_logic := '0';
    Qa : out std_logic := '0';
    Qb : out std_logic := '0';
    Qc : out std_logic := '0';
    Qd : out std_logic := '0'
  );
end entity syncounter;

architecture rtl of syncounter is
  component jkflipflop
    port (
      Clock: in std_logic := '0';
      PRN: in std_logic := '1';
      CLRN: in std_logic := '0';
      J : in std_logic := '0';
      K : in std_logic := '0';
      Q : out std_logic := '0';
      NQ : out std_logic := '1'
    );
  end component jkflipflop;
 
  signal tQa : std_logic := '0';
  signal tQb : std_logic := '0';
  signal tQc : std_logic := '0';
  signal tQd : std_logic := '0';
 
  signal tQaANDtQb : std_logic := '0';
  signal tQaANDtQbANDtQc : std_logic := '0';
begin
  u0 : jkflipflop
  port map (
      Clock => Clock,
      PRN => VDD,
      CLRN => CLRN,
      J => VDD,
      K => VDD,
      Q => tQa
  );
  u1 : jkflipflop
  port map (
      Clock => Clock,
      PRN => VDD,
      CLRN => CLRN,
      J => tQa,
      K => tQa,
      Q => tQb
  ); 
  u2 : jkflipflop
  port map (
      Clock => Clock,
      PRN => VDD,
      CLRN => CLRN,
      J => tQaANDtQb,
      K => tQaANDtQb,
      Q => tQc
  ); 
  u3 : jkflipflop
  port map (
      Clock => Clock,
      PRN => VDD,
      CLRN => CLRN,
      J => tQaANDtQbANDtQc,
      K => tQaANDtQbANDtQc,
      Q => tQd
  );
  tQaANDtQb <= tQa and tQb;
  tQaANDtQbANDtQc <= tQaANDtQb and tQc;
 
  Qa <= tQa;
  Qb <= tQb;
  Qc <= tQc;
  Qd <= tQd;
end rtl;
 

台長: Morris
人氣(1,702) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 不分類 | 個人分類: 亂糟糟筆記 |
此分類下一篇:[VHDL] 垃圾堆積區-移位器除頻器
此分類上一篇:[VHDL] 垃圾堆積區-加法器

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文