슬라이드 제목 없음

Download Report

Transcript 슬라이드 제목 없음

Combinational Logic
Lecture #8
1
Combination Logic - 강의순서

Decoder 3x8


Process – Case Statement
Mux 4x1
Signal Assignment, Conditional
 Signal Assignment, Selected
 Process – if Statement
 Process – Case Statement


Mux 8x1
Mixed Modeling
 Process – Case Statement


Mux 8x1 4bits
Process – Case Statement, Constants이용
 Signal Assignment, Selected


4 bits Adder
Combinational Logic
2
Combination Logic
– Decoder 3x8
(CASE)
library ieee; use ieee.std_logic_1164.all;
entity decoder38_proc is
port( d2, d1, d0 : in std_logic;
y0,y1,y2,y3,y4,y5,y6,y7 : out std_logic);
end decoder38_proc;
architecture xxx of decoder38_proc is
signal d : std_logic_vector(2 downto 0);
signal t : std_logic_vector( 0 to 7);
begin
d <= d2&d1&d0;
process(d)
begin
case d is
when "000" => t<="10000000";
when "001" => t<="01000000";
when "010" => t<="00100000";
when "011" => t<="00010000";
when "100" => t<="00001000";
when "101" => t<="00000100";
when "110" => t<="00000010";
when others => t<="00000001";
end case;
end process;
y0 <= t(0); y1 <= t(1); y2 <= t(2); y3 <= t(3);
y4 <= t(4); y5 <= t(5); y6 <= t(6); y7 <= t(7);
end xxx;
Combinational Logic
회로보다는
설계사양에
관심을 둔 설
계방식.
같은 표현
d(2) <= d2;
d(1) <= d1;
d(0) <= d0;
3
Combination Logic
– Decoder 3x8

(CASE)
Timing Simulation Result
Combinational Logic
4
Combination Logic – Mux 4x1
(Signal Assignment, Conditional)
library ieee;
use ieee.std_logic_1164.all;
entity mux41_ when is
port( a, b, c, d: in std_logic;
s : in std_logic_vector(1 downto 0);
y
: out std_logic);
end mux41_ when;
architecture a of mux41_when is
BEGIN
y <= a when (s=“00”) else
b when (s=“01”) else
c when (s=“10”) else
d;
END a;
Combinational Logic
5
Combination Logic – Mux 4x1
(Signal Assignment, Selected)
library ieee;
use ieee.std_logic_1164.all;
entity mux41_with is
port( a, b, c, d: in std_logic;
s
: in std_logic_vector(1 downto 0);
y
: out std_logic);
end mux41_with;
architecture a of mux41_with is
BEGIN
WITH s SELECT
y<= a WHEN "00",
b WHEN "01",
c WHEN "10",
d WHEN others;
END a;
Combinational Logic
6
Combination Logic – Mux 4x1(IF)
library ieee;
use ieee.std_logic_1164.all;
entity mux41_if_proc is
port( a,b,c,d : in std_logic;
s : in std_logic_vector(1 downto 0);
y : out std_logic);
end mux41_if_proc;
architecture proc of mux41_if_proc is
begin
process(a,b,c,d,s)
begin
if( s="00") then
y<=a;
elsif( s="01") then
y<=b;
elsif( s="10") then
y<=c;
else
y<=d;
end if;
end process;
end proc;
Combinational Logic
7
Combination Logic – Mux 4x1(CASE)
library ieee;
use ieee.std_logic_1164.all;
entity mux41_case_proc is
port( a,b,c,d : in std_logic;
s : in std_logic_vector(1 downto 0);
y : out std_logic);
end mux41_case_proc;
architecture proc of mux41_case_proc is
begin
process(a,b,c,d,s)
begin
case s is
when "00" => y<=a;
when "01" => y<=b;
when "10" => y<=c;
when others => y<=d;
end case;
end process;
end proc;
Combinational Logic
8
Combination Logic - Mux 8X1
( Mixed Modeling)
Library ieee; Use ieee.std_logic_1164.all;
entity mux8_1 is
port( a, b, c, d, e, f, g, h : in std_logic;
s2, s1, s0
: in std_logic;
y
: out std_logic);
end mux8_1;
architecture xxx of mux8_1 is
component decoder3_8
port( a, b, c : in std_logic;
d0,d1,d2,d3,d4,d5,d6,d7 : out std_logic);
end component;
signal t : std_logic_vector(7 downto 0);
signal d0,d1,d2,d3,d4,d5,d6,d7 : std_logic;
begin
U1: decoder3_8 port map( s2,s1,s0,d0,d1,d2,d3,d4,d5,d6,d7);
t(0) <= a and d0; t(1) <= b and d1; t(2) <= c and d2;
t(3) <= d and d3; t(4) <= e and d4; t(5) <= f and d5;
t(6) <= g and d6; t(7) <= h and d7;
y <= t(0) or t(1) or t(2) or t(3) or t(4) or t(5) or t(6) or t(7);
end xxx;
Combinational Logic
t(0)
t(1)
t(2)
t(3)
t(4)
t(5)
t(6)
t(7)
Decoder3_8.vhd는
미리 작성된 상태임
Mixed Modeling :
structure + dataflow
9
Combination Logic – Mux 8X1
(Constants)
library ieee; use ieee.std_logic_1164.all;
entity mux8_1_proc is
port( a,b,c,d,e,f,g,h : in std_logic;
s2, s1, s0
: in std_logic;
y
: out std_logic);
end mux8_1_proc;
architecture proc of mux8_1_proc is
constant bits3_0 : std_logic_vector(2 downto 0) := "000";
constant bits3_1 : std_logic_vector(2 downto 0) := "001";
constant bits3_2 : std_logic_vector(2 downto 0) := "010";
constant bits3_3 : std_logic_vector(2 downto 0) := "011";
constant bits3_4 : std_logic_vector(2 downto 0) := "100";
constant bits3_5 : std_logic_vector(2 downto 0) := "101";
constant bits3_6 : std_logic_vector(2 downto 0) := "110";
constant bits3_7 : std_logic_vector(2 downto 0) := "111";
begin
process(a,b,c,d,e,f,g,h,s2,s1,s0)
variable sel : std_logic_vector(2 downto 0);
begin
sel := s2 & s1 & s0;
같
은
case sel is
표
when bits3_0 => y<= a;
현
when bits3_1 => y<= b;
when bits3_2 => y<= c;
when bits3_3 => y<= d;
when bits3_4 => y<= e;
sel(2) := s2;
sel(1) := s1;
when bits3_5 => y<= f;
sel(0) := s0;
when bits3_6 => y<= g;
when others => y<= h;
end case;
Combinational
Logic
end process;
end proc;
10
Combination Logic – Mux 8x1 4bits
(Signal Assignment, Selected)
library ieee;
use ieee.std_logic_1164.all;
entity mux81_4bits_with is
port( a, b, c, d, e, f, g, h : in
std_logic_vector(3 downto 0);
s2, s1, s0 : in std_logic;
y
: out std_logic_vector(3 downto 0)
);
end mux81_4bits_with;
architecture a of mux81_4bits_with is
signal s : std_logic_vector(2 downto 0);
BEGIN
s <= s2 & s1 & s0;
-- s(2)<=s2; s(1)<=s1;s(0)<=s0;
WITH s SELECT
y <=
a WHEN "000",
b WHEN "001",
c WHEN "010",
d WHEN "011",
e WHEN "100",
f WHEN "101",
g WHEN "110",
h WHEN others;
END a;
Combinational Logic
11
Combination Logic – Mux 8x1 4bits
(CASE)
library ieee; use ieee.std_logic_1164.all;
entity mux81_4bits_proc is
port( a,b,c,d,e,f,g,h : in std_logic_vector(3 downto 0);
s2, s1, s0
: in std_logic;
y
: out std_logic_vector(3 downto 0));
end mux81_4bits_proc;
architecture proc of mux81_4bits_proc is
signal sel : std_logic_vector(2 downto 0);
begin
sel <= s2 & s1 & s0;
process(a,b,c,d,e,f,g,h,sel)
begin
case sel is
when "000" => y<= a;
when "001" => y<= b;
when "010" => y<= c;
when "011" => y<= d;
when "100" => y<= e;
when "101" => y<= f;
when "110" => y<= g;
when others => y<= h;
end case;
end process;
end proc;
Combinational Logic
12
Combination Logic – 4 bits Adder
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity add_4bits_proc is
port( a, b : in std_logic_vector(3 downto 0);
s : out std_logic_vector(3 downto 0)
);
end add_4bits_proc;
+ 연산자
가 사용될
때 꼭 사용.
architecture a of add_4bits_proc is
begin
s <= a+b;
end a;
Combinational Logic
13
PXA255-FPGA
실습장비 PXA255-FPGA에 대한 개요
및 예제 실습
14
내용 순서




PXA255-FPGA BLOCK DIAGRAM
PXA255-FPGA SPEC
PXA255-FPGA 사용 방법
PXA255-FPGA 예제 실습(LED)
Combinational Logic
15
PXA255-FPGA BLOCK DIAGRAM
Combinational Logic
16
PXA255-FPGA SPEC

PXA255-FPGA BOARD 사양
FPGA
Altera cyclone EP1C6
LOGIC ELEMENTS
5980
LOGIC GATE
120000 Logic Gate
RAM BIT
92160 Bit
외부 CPU
PXA255
외부 INTERFACE
32 BIT address/data bus
입력 I/O
PUSH S/W, DIP S/W, IMAGE SENSOR
출력 I/O
TEXT LCD, LED, 7SEGMENT, BUZZER,
DOTMATRIX, VGA
Combinational Logic
17
7-SEG
TEXT-LCD
DIP S/W
VGA
DOT
AD/DA PORT
CAMERA CONN
FPGA
BUZZER
JTAG PORT
DIP S/W
I/O 100PIN
PUSH S/W
STEP MOTOR
Combinational Logic
LED
EXTERN I/O
18
PXA255-FPGA 동작방법 (1)

PXA255-PRO보드와 PXA255-FPGA보드와의 연동방법
DATA BUS
CONTORL SIGNAL
ADDRESS BUS
PXA255
Main Board
PXA255-FPGA4 보드
I/O 주변장치
FPGA
Combinational Logic
LED,FND,DOT MATRIX,LCD,
7-SEG,BUZZER,CAMERA,MOTOR,
SENSOR(온도,기울기,조도)
19
PXA255-FPGA 동작방법 (2)

PXA255 SRAM Write timing Diagram(PXA255
DATASHEET)
Combinational Logic
20
PXA255-FPGA 동작방법 (3)

PXA255 memory map
Combinational Logic
21
PXA255-FPGA 동작방법 (4)

디바이스 메모리맵 :
Combinational Logic
22
PXA255-FPGA 동작방법 (5)

PXA255-FPGA보드 단독 동작 모드
POWER
JACK
PXA255-FPGA4 보드
I/O 주변장치
FPGA
Combinational Logic
LED,FND,DOT MATRIX,LCD,
7-SEG,BUZZER,CAMERA,MOTOR,
SENSOR(온도,기울기,조도)
23
PXA255-FPGA 동작방법 (6)

DIP SW을 이용한 동작 모드 선택

PXA255-PRO 보드와 PXA255-FPGA보드와의 연동 방법
ON

1
2
PXA255-FPGA보드 단독 동작 모드
ON
Combinational Logic
1
2
24
PXA255-FPGA 예제 프로그램(LED)

개요


PXA255-FPGA를 이용하여 LED에 대한 동작을 이해하고 디
바이스 드라이버를 작성하여 LED를 제어 한다
system 요구사항


Hardware 요구사항

PXA255-PRO

PXA255-FPGA

ByteBlaster Interface Cable
Software 요구사항


Quartus II V2.2이상
사용 Hardware Description Language

VHDL
Combinational Logic
25
PXA255-FPGA 예제 프로그램(LED)

FPGA - LED 회로도 구성
Combinational Logic
26
PXA255-FPGA 예제 프로그램(LED)
Combinational Logic
27
Quartus II Project 파일 생성 (1)

New Project Wizard를
통한 Quartus Project
생성하기

File 메뉴에서 New
Project Wizard를 실행하
여 새로운 프로젝트를 만
들어보자.
Combinational Logic
28
Quartus II Project 파일 생성 (2)

New Project Wizard ①

Project를 설치할 경로 와 프로젝트의 이름과 top-level entity
이름을 지정하는 부분이 있다
Combinational Logic
29
Quartus II Project 파일 생성 (3)

New Project Wizard ②




오른쪽의 그림은 다음 단
계인 설계된 파일이 있으
면 추가 하는 단계
추가할 파일이 프로젝트
디렉토리에 있다면 [ADD
ALL] 버튼을 클릭하면 모
두 추가
[...] 버튼을 클릭하여 그림
과 같이 4개의 파일을 추
가
[Next]버튼을 눌러 다음
설정으로 이동
Combinational Logic
30
Quartus II Project 파일 생성 (4)

New Project Wizard ③


EDA Tool 에 대한 설정을 하는 부분
Thirth party EDA tool을 사용한다면 설정하고, 사용하지 않는
다면 [Next]버튼을 눌러 다음 설정으로 이동
Combinational Logic
31
Quartus II Project 파일 생성 (5)

New Project Wizard ④


Device Family를 설정하는 부분
PXA255-FPGA보드는 Cyclone을 사용하고 있으므로 Cyclone
으로 설정
Combinational Logic
32
Quartus II Project 파일 생성 (6)

New Project Wizard ⑤


PXA255-FPGA에는 EP1C12Q240C8을 사용하고 있으므로
해당 Device를 선택
오른쪽 메뉴의 Filter사용 하면 쉽게 선택할 수 있다
Combinational Logic
33
Quartus II Project 파일 생성 (7)

New Project Wizard ⑥


지금까지 설정을 확인하는 단계
프로젝트경로와 프로젝트 이름, top-level design entity 이름,
추가한 파일의 개수를 확인
Combinational Logic
34
Quartus II Project 파일 생성 (8)

Project 생성
Combinational Logic
35
Quartus II Project 파일 생성 (9)

Pin Assignment


Pin Assign File 수정 io_top.csf 파일을 열어
서 옆 그림과 같이 CHIP
(io_top) 섹션에 핀 매핑
에 대한 정보를 수정
Quartus II 에는 핀을 매
핑 할 수 있는 별도의 메
뉴가 존재하지만
io_top.csf 파일을 수정
하면 보다 손쉽게 매핑 할
수 있다
CHIP(io_top)
{
LED[0] : LOCATION = Pin_1;
LED[1] : LOCATION = Pin_2;
LED[2] : LOCATION = Pin_3;
LED[3] : LOCATION = Pin_4;
LED[4] : LOCATION = Pin_5;
LED[5] : LOCATION = Pin_6;
LED[6] : LOCATION = Pin_7;
LED[7] : LOCATION = Pin_8;
MAIN_CLK1 : LOCATION =
Pin_29;
...... 이하 계속 .......
Combinational Logic
36
Quartus II Project 파일 생성 (10)

사용하지 않는 핀들에 대한 설정

Device 설정 창에서 Device & Pin Options을 선택
Combinational Logic
37
Quartus II Project 파일 생성 (11)

Unused Pin에 대한 설정


Reserve all unused pins에서 As Input, tri stated를 선택
외부에 아무런 영향을 주지 않기 위함
Combinational Logic
38
Quartus II Project 파일 생성 (12)

Configuration에 대한 설정

그림과 같이 Configuration scheme와 device를 설정
Combinational Logic
39
Quartus II Project 파일 생성 (13)

기타 설정


General 탭에서 Auto-restart configuration after error을 선택
FPGA에서 에러가 발생하면 자동으로 다시 Configuration하게 설
정
Combinational Logic
40
Quartus II Project 파일 생성 (14)

Compilation


지금까지의 설정이 정상적으로 이
루어졌다면 Processing 메뉴에서
Start Compilation을 실행
컴파일이 완료되면 ‘Full
compilation was successful‘ 이
라는 메시지를 보여주며 컴파일이
끝나게 된다
Combinational Logic
41
Quartus II Project 파일 생성 (15)

Configuration


지금까지의 과정이 모두 끝났다면 FPGA로 Configuration을
하여야 한다
Programmer 실행 - EPC2에 다운로드 하거나 FPGA에
Configuration 하기 위해서 Programmer를 실행
Combinational Logic
42
Quartus II Project 파일 생성 (16)

Configuration 파일 불러오기


Byteblaster 케이블이 JTAG 포트에 연결된 상태에서 [Auto
Detect] 를 하면 EPC2와 EP1C6 두 개의 장치를 검출
<none>를 더블 클릭하여 EPC2에는 io_top.pof 파일을, EP1C6
에는 io_top.sof파일을 설정한다
Combinational Logic
43
Quartus II Project 파일 생성 (17)

Configuration



Program/Configure에 체크 옵션에 체크를 한다
[Start]버튼을 클릭하면 체크한 항목에 대해서만 Download
및 Configuration을 수행한다
[Start]버튼을 클릭하여 실행한다.
Combinational Logic
44