procedure for testbench

procedureを使うと、シミュレーションが楽に書ける。

architecture test of test_module is

procedure pe(signal CLK : in std_logic) is
begin
    wait until CLK'event and CLK='1';
end pe;

procedure pe( num : in integer;
                          signal CLK : in std_logic) is
begin
    for I in 1 to num loop
        wait until CLK'event and CLK='1';
    end loop;
end pe;

begin
end test;

注意するのは"signal"の記述で、これが
ある→procedureの中でその信号の変化を読める(この場合だと、CLKの変化を読んでいる。一方、numは「変化」を読んでいる訳ではない。
ない→procedureの中でその信号の変化は読まない。
ということ。
もうちょっと巨大なprocedureとしては、こんなのがある。

architecture test of test_module is

    procedure write_reg(
                                        signal CLK : in std_logic;
                                        Rd_dt_in : in std_logic_vector(31 downto 0);
                                        Rd_dt_out : out std_logic_vector(31 downto 0);
                                        signal Sof1_out : out std_logic) is
    constant dly_rd_dt : time := 1ns;
    constant dly_Sof1 : time := 2ns;

    begin
        wait until CLK'event and CLK='1';
            Rd_dt_out<=Rd_dt_in after dly_rd_dt;
       wait until CLK'event and CLK='1';
           Sof1_out<='0' after dly_Sof1;
       wait until CLK'event and CLK='1';
           Sof1_out<='1' agter dly_Sof1;
    end ;

begin
...
...
end test;

とかで書き込める。