'분류 전체보기'에 해당되는 글 695건



확실히 이웃이고 뭐고 그런게 없다 보니까 교류하면서 뭔가를 얻어가는 것은 없다.


하지만 그만큼 티스토리에는 '보호'기능이 있어서 비공개로 하지 않고도 글을 올리는 것도 가능하고


공부한 내용, 그날그날 한 일들을 꼬박꼬박 정리하는 용도로는 참 쓰기 좋은 블로그이다.


이렇게 잡담 카테고리까지 만들었으니 꼭 공부하거나 한 내용의 기록이 아니더라도 조금씩이지만 뻘글을 쓰지 않을까 한다.

'잡담' 카테고리의 다른 글

무슨 일이든 꾸준히 한다는건 대단하더라  (0) 2016.03.27
pthread따위 으으  (0) 2016.03.18
Codegate 2016 Junior 예선 결과  (0) 2016.03.13
요즘 생활에 대한 고찰  (0) 2016.03.12
PinTool 과제  (0) 2015.11.21
블로그 이미지

__미니__

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

,

2016-02-11

2016. 2. 12. 01:27

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.



32-bit Ripple Carry Adder이다.



rca.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;






rca_tb.vhd

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;

entity rca_tb is
end rca_tb;

architecture arch_rca_tb of rca_tb is
	component rca is
		port ( a, b : IN std_logic_vector ( 31 downto 0 );
			cin : IN std_logic;
			s : OUT std_logic_vector (31 downto 0);
			cout : OUT std_logic );
	end component;

	signal input_a : std_logic_vector (31 downto 0) := "00000000000000000000000000000000";
	signal input_b : std_logic_vector (31 downto 0) := "11111111111111111111111111111111";
	signal input_cin : std_logic;
	signal output_s : std_logic_vector (31 downto 0);
	signal output_cout : std_logic;

begin
	rca_port_map : rca port map ( input_a, input_b, input_cin, output_s, output_cout );
	
	process_a : process begin
		input_a <= unsigned(input_a) + 1;
		wait for 10 ns;
	end process;

	process_b : process begin
		input_b <= unsigned(input_b) - 1;
		wait for 10 ns;
	end process;

	process_cin: process begin
		input_cin <= '0';
		wait for 100 ns;
		input_cin <= '1';
		wait for 100 ns;
	end process;

end arch_rca_tb;


10 ns의 간격을 두고 input_a는 1씩 더하며 input_b는 1씩 빼주기 때문에 더한 값은 언제나 "11111111111111111111111111111111"이 된다.

여기서 변수는 당연하게도 맨 처음 올라오는 캐리 비트인 input_cin이며, 이 값이 1일 경우 오버플로우가 일어나 output_s는 모든 비트가 0이 되고, output_cout이 1이 된다.




위는 이 글의 소스 그대로 컴파일하여 시뮬레이션을 돌려 본 결과이다.

5 ns 마다 input_cin이 0, 1을 왔다갔다 하기 때문에 output_s와 output_cout 도 마찬가지로 각각 0, 1을 왔다갔다 한다.



이것은 input_cin의 딜레이를 100 ns로 늘려보았을 때의 결과이다.

보다시피 input_cin이 0인 구간에서는 input_a + input_b 는 항상 "11111111111111111111111111111111"로 고정인 것을 알 수 있다.

input_cin이 1이 되면 자연스럽게 output_s는 모든 비트가 0이 되고 output_cout은 1이 된다.

'Programming' 카테고리의 다른 글

[VHDL] 4-bit Carry Select Adder  (0) 2016.02.17
[VHDL] 4 to 1 Multiplexer  (0) 2016.02.15
[VHDL] Full Adder  (0) 2016.02.11
[VHDL] D Flip-Flop  (0) 2016.02.11
파이썬 웹 이미지 크롤러 (GUI)  (0) 2016.02.03
블로그 이미지

__미니__

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

,

[VHDL] Full Adder

Programming 2016. 2. 11. 23:23


a, b, cin을 입력받아 덧셈의 결과를 s, cout으로 출력해주는 Full Adder이다.



fa.vhd

library ieee;
use ieee.std_logic_1164.all;

entity fa is
	port ( a, b, cin : IN std_logic;
		s, cout : OUT std_logic );
end fa;

architecture arch_fa of fa is
begin
	s <= a XOR b XOR cin;
	cout <= (a AND b) OR (b AND cin) OR (a AND cin);
end arch_fa;






fa_tb.vhd

library ieee;
use ieee.std_logic_1164.all;

entity fa_tb is
end fa_tb;

architecture arch_fa_tb of fa_tb is
	signal input_a, input_b, input_cin : std_logic;
	signal output_s, output_cout : std_logic;

	component fa is
		port ( a, b, cin : IN std_logic;
			s, cout : OUT std_logic );
	end component;

begin
	fa_port_map : fa port map ( input_a, input_b, input_cin, output_s, output_cout );

	process_a : process begin
		input_a <= '0';
		wait for 20 ns;
		input_a <= '1';
		wait for 10 ns;
	end process;

	process_b : process begin
		input_b <= '1';
		wait for 10 ns;
		input_b <= '0';
		wait for 20 ns;
	end process;

	process_cin : process begin
		input_cin <= '1';
		wait for 10 ns;
		input_cin <= '0';
		wait for 10 ns;
	end process;
end arch_fa_tb;


이를 여러 개 연결하여 여러 비트의 덧셈연산을 수행할 수 있다.





시뮬레이션을 돌려 본 화면이다.

현재 가리키고 있는 상태는 input_a에 0, input_b에 1, input_cin에 1이 들어가 output_s는 올림되어 0이 되고, output_cout에 1이 들어간 상태로 정상 작동하는 것을 알 수 있다.

'Programming' 카테고리의 다른 글

[VHDL] 4 to 1 Multiplexer  (0) 2016.02.15
[VHDL] Ripple Carry Adder  (0) 2016.02.12
[VHDL] D Flip-Flop  (0) 2016.02.11
파이썬 웹 이미지 크롤러 (GUI)  (0) 2016.02.03
[C++] 가상함수(Virtual Function)  (0) 2016.01.20
블로그 이미지

__미니__

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

,

[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 나와 계약해서 슈퍼 하-카가 되어 주지 않을래?

,

2016-02-10

2016. 2. 11. 01:56

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

2016-02-09

2016. 2. 9. 22:16

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

2016-02-08

2016. 2. 9. 19:07

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

2016-02-07

2016. 2. 8. 15:03

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.