0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VHDL入門 > CLKの立ち上げ時に反転する

Last updated at Posted at 2016-05-26

参考: VHDLによるFPGA設計 & デバッグ by 松村謙 & 坂巻 佳壽美

実装

CLKの立ち上がりを検出して、FLIPという信号(Qに接続)をH/L反転する

code

if (CLK'event and CLK = '1') thenで立ち上がりを検知。

http://qiita.com/nYaaJee/items/7404a387f9e404757869
で別の方法も合わせて詳しい。

design.vhd
library IEEE;
use IEEE.std_logic_1164.all;

entity CLOCK is
port ( CLK: in std_logic;
       Q : out std_logic);
end CLOCK;

architecture RTL of CLOCK is
    signal FLIP : std_logic := '0';
begin
  Q <= FLIP;
  process(CLK)
  begin
    if (CLK'event and CLK = '1') then
      if (FLIP = '0') then
        FLIP <= '1';
   	  else
        FLIP <= '0';
      end if;
    end if;
  end process;
end;
testbench.vhd
library IEEE;
use IEEE.std_logic_1164.all;

entity testbench is
end testbench;

architecture SIM of testbench is
    signal I_CLK : std_logic := '1';
    signal I_Q : std_logic := '0';
component CLOCK
    port ( CLK: in std_logic;
       Q : out std_logic);
end component;

begin
    process begin
        I_CLK <= '1';
        wait for 10 ns;
        I_CLK <= '0';
        wait for 10 ns;
    end process;

    process begin
        wait for 100 ns;
        -- to end the testbench
        assert false
        report "end." severity FAILURE;
    end process;

    U1: CLOCK port map(CLK => I_CLK, Q => I_Q);
end SIM;

結果

CLKの立ち上がり時にFLIP(=Q)が反転した。

qiita.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?