FPGAでカウンターを作る

とりあえずソースは次のようなものを。
CPU_RESETボタンを押すとカウンターを初期化しようと思ったんですが、押したときは'0'らしい?
しかもQ_4には"1111"を入れるとLED全消灯らしい。どうも符号が逆で解りにくい。


リセットボタンを押すとリセットは働くけど、ボタン1を押してカウンターは一つづつ増えずに変な値になる。
ボタン1を押している間にクロックが何回も変わって、その度にカウントされているのかもしれない。
押して離したらカウントするみたいな仕組みがいるかもしれない。
あと、vectorの場合のテストベクターの作り方が解らないので、シミュレーションはしていない。
そのへんを今後は勉強していこう

ibrary ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;

entity test is
	port
	(
		CLK : in std_logic;
		RESET : in std_logic;
		D : in std_logic;
		Q : out std_logic;
		Q_4 : out std_logic_vector(3 downto 0)
	);
end test;

architecture test_Body of test is
signal DBUF_4: std_logic_vector(3 downto 0);
begin
  process(CLK)
  begin
    if CLK'event and CLK = '1' then
      if D = '0' then
        DBUF_4 <= DBUF_4 + 1;
      end if;

 	  if RESET = '0' then
	    DBUF_4 <= "1111";
	  end if;

    end if;


  end process;
  Q_4 <= DBUF_4;
end test_Body;


ちなみにCycloneIII開発スタータキットのLEDのピンアサインは
rm_cii_starter_board.pdfに記載がありますが、

Table 2&#8211;11. Board LED Pinout (Part 1 of 2)
Signal Name FPGA Pin Name Direction Type
LED0 P13 Output 2.5 V
LED1 P12 Output 2.5 V
LED2 N12 Output 2.5 V
LED3 N9 Output 2.5 V