[VHDL] D Flip-Flop

Programming 2016. 2. 11. 23:01



dff.vhd

library ieee;
use ieee.std_logic_1164.all;

entity dff is
	port ( d : IN std_logic;
		clk : IN std_logic;
		set, rst : IN std_logic;
		q : OUT std_logic );
end dff;

architecture arch_dff of dff is
begin
	process_dff : process(clk) is
	begin
		if ( rst = '1' ) then
			q <= '0';
		elsif ( set = '1' ) then
			q <= '1';
		elsif ( clk = '1' and clk'event ) then
			q <= d;
		end if;
	end process;
end arch_dff;



dff_tb.vhd

library ieee;
use ieee.std_logic_1164.all;

entity dff_tb is
end dff_tb;

architecture arch_dff_tb of dff_tb is
	signal input_d, input_clk : std_logic;
	signal input_set, input_rst : std_logic;
	signal output_q : std_logic;

	component dff is
		port ( d : IN std_logic;
			clk : IN std_logic;
			set, rst : IN std_logic;
			q : OUT std_logic );
	end component;

begin
	dff_port : dff port map ( input_d, input_clk,
				  input_set, input_rst, output_q );
	
	process_clk : process begin
		input_clk <= '0';
		wait for 10 ns;
		input_clk <= '1';
		wait for 10 ns;
	end process;

	process_rst : process begin
		input_rst <= '1';
		wait for 20 ns;
		input_rst <= '0';
		wait for 200 ns;
	end process;

	process_d : process begin
		input_d <= '0';
		wait for 40 ns;
		input_d <= '1';
		wait for 60 ns;
	end process;

end arch_dff_tb;



VHDL을 이용해 짜 본 D Flip-Flop 이다.

enable을 넣으면 D Latch가 되겠지만 넣기 귀찮아서 넣지 않았다.




위 이미지는 시뮬레이션을 돌려 본 화면이다.

현재 가리키고 있는 부분은 input_d에 1, input_clk에 1이 들어가 있고 input_rst가 0이므로 output_q가 1로 정상적인 출력을 보이고 있다.

만약 여기서 input_rst가 1이었을 경우에는 output_q 가 0이 나올 것이다.

'Programming' 카테고리의 다른 글

[VHDL] Ripple Carry Adder  (0) 2016.02.12
[VHDL] Full Adder  (0) 2016.02.11
파이썬 웹 이미지 크롤러 (GUI)  (0) 2016.02.03
[C++] 가상함수(Virtual Function)  (0) 2016.01.20
Assembly Programming - atoi  (0) 2015.10.11
블로그 이미지

__미니__

E-mail : skyclad0x7b7@gmail.com 나와 계약해서 슈퍼 하-카가 되어 주지 않을래?

,