LoginSignup
1
0

More than 5 years have passed since last update.

VHDL > constantで宣言したstd_logic_vectorのビットを順次取出す

Last updated at Posted at 2016-05-27

やろうとしていること

constant I_DINI: std_logic_vector (7 downto 0) := "11001100";
のように宣言しているI_DINIのビットをLSBから順次取出す。

I_CNTというカウンタをカウントアップして取り出す位置をずらしていく。

code

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

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

architecture RTL of CLOCK is
begin
end;
testbench.vhd
library IEEE;
use IEEE.std_logic_1164.all;

entity testbench is
end testbench;

architecture SIM of testbench is
    constant I_DINI: std_logic_vector (7 downto 0) := "11001100";
    signal I_CLK : std_logic := '1';
    signal I_DAT : std_logic := '0';
    signal I_Q : std_logic := '0';
    signal I_CNT : integer range 0 to 7 := 0;
component CLOCK
    port ( CLK: in std_logic;
       DAT : 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 (I_CLK)
    begin
        if (I_CLK'event and I_CLK = '1') then
          if (I_CNT /= 7) then
            I_CNT <= I_CNT + 1;
          end if;
        end if;
    end process;

    I_DAT <= I_DINI(I_CNT); -- input from constant
    I_Q <= I_DAT;

    process 
    begin
        wait for 160 ns;

        -- to end the testbench
        assert false
        report "end." severity FAILURE;
    end process;

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

I_DAT <= I_DINI(I_CNT); -- input from constant
にてI_DATに取出している。

I_Q関連の処理はうまく動いていない。

今後、ズンドコするには前の値を保持しないといけない。
11110 -> キヨシ.
チャタリング対策のコードが参考になる。

1
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
1
0