Please Enable JavaScript!
Mohon Aktifkan Javascript![ Enable JavaScript ]

VHDL의 예[AND]

2010. 10. 4. 21:27programming/architecture

728x90

VHDL
엔티티 이름이 파일명과 같아야함.
확장자 .vhd

MAX PLUS -> new Text editor
save -> compile -> waveform

VHDL의 예 [AND]

## package 부분
library ieee;
use ieee.std_logic_1164.all;

## VHDL 에서 사용할 라이브러리를 지정하는 명령어
## 두번째 줄은 ieee라는 라이브러리에서std_logic_1164라는 이름의
패키지를 가져오겠다는 뜻.


Entity and2 is
port [ A,B : in std_logic;
        OUTPUT : out std_logic];
end and2;
## 이부분을entity라고 부른다.
## 입력,출력을 정해준다.
## 첫 번째 줄은entity의 이름을 써준다.
## port부분은 구체적인 입력과 출력을 정해준다.
## in은 입력을 나타내고, out은 출력을 나타낸다
## std_logic은 어떤 입력 또는 출력등이 1비트인 경우 사용.

architecture and_2_input of and2 is
Begin
OUTPUT <= A and B;
end and_2_input;
##시작은 architectur [이름] of [entity 이름] is
## entity 이름은 위에 선언되어 있는 entity이름을 써준다.
## begin은 architecture 부분이 시작된다는 것을 알려준다.
## OUTPUT <=A and B; 이것은 A,B 입력을 모두 and 연산하고 출력 OUTPUT으로 보내준다는 의미
## 모든구분이 동시에 수행
## 순차적으로 설계하기 위해서는 process문을 사용
## architecture 에서는 여러개의 process문 사용 가능.


# Data flow 표현
a,b and2 data
library ieee;
use ieee.std_logic_1164.all;

Entity and2_data is
port (A, B : in std_logic;
  OUTPUT : out std_logic);
end and2_data;

architecture and_2_input of and2 is
Begin
OUTPUT <= A and B;
end and_2_input;

# Behavioral 표현
a,b OR2
library ieee;
use ieee.std_logic_1164.all;

entity OR2_bh is
port(a,b : in std_logic;
  c: out std_logic);
end OR2_bh;

architecture Behavioral of OR2 is
begin
 process(a,b)
 begin
  if(a ='0') and (b = '0') then
    c<='0';
  else c<='1';

  end if;
 end process;
end Behavioral;
  
# a,b AND2 _ behavioral 표현
library ieee;
use ieee.std_logic_1164.all;

entity and2_bh is
port(a,b : in std_logic;
  c: out std_logic);
end and2_bh;

architecture Behavioral of and2_bh is
begin
 process(a,b)
 begin
  if(a ='1') and (b = '1') then
    c<='1';
  else c<='0';

  end if;
 end process;
end Behavioral;
  

728x90