1. buffer 설계 (buffer, tri-state buffer)
1.1 buffer
; 출력 신호의 Fan out(팬아웃)을 증가시키는 용도.
buffer 사용 예
1.2 tristate buffer
; 기본 buffer에 HIGH-Z 상태가 추가되었다.
HIGH-Z : 임피던스가 엄청 높은 상태 ~ OPEN상태
1.2.1 VHDL 로직 구현
1.2.2 test bench of tri-state buffer
1.2.3 simulation
1.3 IO buffer(입출력 버퍼)
1.3.1 VHDL 로직 구현
1.3.2 test bench
위의 tb_tribuf에 component만 추가해주고
din => i로 매칭하면 된다.
1.3.3 simulation
1.4 bus(버스)의 공유
1.4.3 simulation
00ZZZ00ZZ
1.4.4 잘못된 bus 제어
11XX01XX
- std_logic_1164패키지 : std_logic, std_ulogic 형의 정의.
- 'U' : 초기화가 안 되었을 경우의 기본값으로 사용됨
- 'X' : ‘0’값과 ‘1’ 값의 충돌로 값이 정의가 안 되는 경우
- '0' : 트랜지스터가 GND 값이 됨
- '1' : 트랜지스터가 VCC 값이 됨
- 'Z' : 삼상태 버퍼 출력이 고저항 상태일 때
- 'W‘ : ‘L’값과 ‘H’ 값의 충돌로 값이 정의가 안 되는 경우
- 'L' : pull down 저항에 의해서 연결되어 외부 신호가 없을 때 ‘0’으로 출력되는 경우
- 'H' : pull up 저항에 의해서 연결되어 외부 신호가 없을 때 ‘1’로 출력되는 경우
- '-' : Don't care, 어떠한 값이 되어도 상관없는 경우
resolved 함수의 정의
resolved table 내용
2. finite state machine
2.1 moore 방식(moore machine)
2.2 mealy 방식 (mealy machine)
2.3 상태천이도
2.4 설계 예
2.4.1 신호기 설계
2.4.1.1 VHDL 로직 구현
2.4.1.2 testbench
2.4.1.3 Simulation
2.4.2 패턴 검출기 설계
2.4.2.0 조건
- 클럭을이용하여 생성한 비트스트림이 지속적으로 입력
입력 예) 111101101011110110110110111010
- 입력 비트스트림에서 다음의 패턴을 검출
“011011”
- 위의 패턴이 입력될 경우 detect_flag를 ‘1'로 출력하고
나머지 경우에는 ’0‘을 출력
- 위의 패턴이 연속적으로 입력될 경우에도 마지막 6번째
‘1’이 입력될 때마다 detect_flag를 ‘1’로 출력
2.4.2.1 상태 천이도
작성 예
올바른 상태 천이도
2.4.2.2 VHDL 로직 구현
위에 그림의 코드가 조금 잘못되었다(오타)
=> process이름을 next_state -> nex_state로 수정했다.
=> current_state라는 부분을 cur_state(signal)로 수정함
library ieee;
use ieee.std_logic_1164.all;
entity pattern_detector is
port(
bitstream : in std_logic;
detect_flag : out std_logic;
reset_disp_n : in std_logic;
dispclk : in std_logic);
end pattern_detector;
architecture behavie of pattern_detector is
type state_type is
(idle, tap1, tap2, tap3, tap4, tap5, tap6);
signal cur_state, next_state : state_type;
begin
state_reg : process(dispclk, reset_disp_n)
begin
if(reset_disp_n = '0' ) then
cur_state <= idle;
elsif(dispclk = '1' and dispclk'event) then
cur_state <= next_state;
end if;
end process;
nex_state : process(cur_state, bitstream)
begin
case cur_state is
when idle => detect_flag <= '0';
if bitstream = '1' then
next_state <= idle;
else next_state <= tap1;
end if;
when tap1 => detect_flag <= '0';
if bitstream = '1' then
next_state <= tap2;
else next_state <= tap1;
end if;
when tap2 => detect_flag <= '0';
if bitstream = '1' then
next_state <= tap3;
else next_state <= tap1;
end if;
when tap3 => detect_flag <= '0';
if bitstream = '1' then
next_state <= idle;
else next_state <= tap4;
end if;
when tap4 => detect_flag <= '0';
if bitstream = '1' then
next_state <= tap5;
else next_state <= tap1;
end if;
when tap5 => detect_flag <= '0';
if bitstream = '1' then
next_state <= tap6;
else next_state <= tap1;
end if;
when tap6 => detect_flag <= '1';
if bitstream = '1' then
next_state <= idle;
else next_state <= tap1;
end if;
when others => detect_flag <= '0';
next_state <= idle;
end case;
end process;
end;
2.4.2.3 testbench
library ieee;
use ieee.std_logic_1164.all;
entity tb_pattern_detector is
end tb_pattern_detector;
architecture sim of tb_pattern_detector is
component pattern_detector
port(
bitstream : in std_logic;
detect_flag : out std_logic;
reset_disp_n : in std_logic;
dispclk : in std_logic);
end component;
signal bitstream,rst_n : std_logic;
signal clk : std_logic;
constant HALF_PERIOD_100M : time := 5 ns;
begin
clk_gen : process
begin
while(true) loop
clk <= '0'; wait for HALF_PERIOD_100M;
clk <= '1'; wait for HALF_PERIOD_100M;
end loop;
end process;
rst_n <= '0', '1' after 20 ns;
bitstream <='1', '1' after 10 ns, '1' after 20 ns, '1' after 30 ns,
'0' after 40 ns, '1' after 50 ns, '1' after 60 ns, '0' after 70 ns,
'1' after 80 ns, '0' after 90 ns, '1' after 100 ns, '1' after 110 ns,
'1' after 120 ns, '1' after 130 ns, '0' after 140 ns, '1' after 150 ns,
'1' after 160 ns, '0' after 170 ns, '1' after 180 ns, '1' after 190 ns,
'0' after 200 ns, '1' after 210 ns, '1' after 220 ns, '0' after 230 ns,
'1' after 240 ns, '1' after 250 ns, '1' after 260 ns, '0' after 270 ns,
'1' after 280 ns, '0' after 290 ns;
u0 : pattern_detector port map( bitstream => bitstream,
detect_flag => open,
reset_disp_n => rst_n,
dispclk => clk);
end;
2.4.2.4 simulation
2.4.2.5 FILE(파일) 입력을 통한 검증
- 짧은 데이터 : after 문을 이용하여 쉽게 생성 가능
- 대용량 데이터의 테스트 경우 파일 처리 필요
-> 데이터가 파일 형태로 저장되어 있는 경우
- test bench
bs_val이 line이기 때문에, bitstream.txt의
내용이 한줄 씩 입력되어있어야 제대로 입력받는다.
library ieee;
use ieee.std_logic_1164.all;
use std.textio.all;
entity tb_pattern_detector is
end tb_pattern_detector;
architecture sim of tb_pattern_detector is
component pattern_detector
port(
bitstream : in std_logic;
detect_flag : out std_logic;
reset_disp_n : in std_logic;
dispclk : in std_logic);
end component;
signal bitstream,reset_disp_n : std_logic;
signal clk : std_logic;
constant HALF_PERIOD_100M : time := 5 ns;
begin
clk_gen : process
begin
while(true) loop
clk <= '0'; wait for HALF_PERIOD_100M;
clk <= '1'; wait for HALF_PERIOD_100M;
end loop;
end process;
reset_disp_n <= '0', '1' after 20 ns;
-- bitstream <='1', '1' after 10 ns, '1' after 20 ns, '1' after 30 ns,
--'0' after 40 ns, '1' after 50 ns, '1' after 60 ns, '0' after 70 ns,
--'1' after 80 ns, '0' after 90 ns, '1' after 100 ns, '1' after 110 ns,
--'1' after 120 ns, '1' after 130 ns, '0' after 140 ns, '1' after 150 ns,
--'1' after 160 ns, '0' after 170 ns, '1' after 180 ns, '1' after 190 ns,
--'0' after 200 ns, '1' after 210 ns, '1' after 220 ns, '0' after 230 ns,
--'1' after 240 ns, '1' after 250 ns, '1' after 260 ns, '0' after 270 ns,
--'1' after 280 ns, '0' after 290 ns;
process(clk, reset_disp_n)
file INFILE_BS : text open read_mode is "bitstream.txt";
variable bs_val : line ;
variable bs_int : integer range 0 to 1;
begin
if(reset_disp_n ='0') then
bitstream <='0';
elsif(clk='1' and clk'event) then
if not(endfile(INFILE_BS)) then
readline(INFILE_BS,bs_val);
read(bs_val,bs_int);
end if;
if bs_int = 0 then bitstream <='0';
else bitstream <='1'; end if;
end if;
end process;
u0 : pattern_detector port map( bitstream => bitstream,
detect_flag => open,
reset_disp_n => reset_disp_n,
dispclk => clk);
end;
- simulation
파일 입력을 통한 시뮬레이션 파형
파일 입력을 통한 시뮬레이션 파형
2.4.3 동기신호 검출기 설계
- 디지털 데이터의 동기신호 정보 표현
디지털 데이터의 동기신호 정보 표현
- 디지털 데이터의 EAV/SAV 시퀀스 정보
2.4.3.1 조건
- 클럭을이용하여 이용하여 생성한 영상 데이터 스트림이
지속적으로 입력
- > 입력 예) 23 35 129 210 255 0 0 80
- 입력 영상 데이터 스트림에서 다음의 패턴을 검출
- > 255 0 0
- 위의 패턴이 입력될 경우 detect_flag를 ‘1'로 출력하고
나머지 경우에는 ’0‘을 출력
2.4.3.2 상태천이도
2.4.3.3 VHDL 로직 구현
2.4.3.4 testbench
2.4.3.5 simulation
3. ALU 설계
3.1 ALU 종류 및 기능
3.2 ALU 설계시 고려사항
- 각각 4비트의 두 개의 입력 데이터 ; A(3 downto 0), B(3 downto 0)
- 자리 올림 데이터 ; 입력 Cn, 출력 Cn+4
- 입력 제어 신호 ; S(2 downto 0)
- 4비트의 출력 데이터 ; F(3 downto 0)
3.3 Carry ; 자리올림, 자리 빌림 규칙
3.4 VHDL 로직 구현
3.5 testbench
3.6 simulation
4. 8bit ALU로 확장
4.1 VHDL 로직 구현
4.2 testbench
4.3 simulation
5. 여러가지 ALU 표현 방식(생성문, generic..)
생성문을 이용한 32비트 ALU
제네릭과 생성문을 이용한 ALU
생성문 사용 시 콤포넌트 연결 구조
'전공지식정리 > 디지털시스템설계' 카테고리의 다른 글
VHDL12. 주파수 분주기, 시계용 카운터, 디지털 시계 회로, (0) | 2020.12.08 |
---|---|
VHDL11. 메모리 인터페이스 회로 설계(ROM,RAM,SDRAM) (0) | 2020.12.08 |
VHDL9. 기법(논리합성, 설계) (0) | 2020.12.08 |
VHDL8. 순차회로 (0) | 2020.12.08 |
VHDL7. 조합회로 (0) | 2020.12.08 |