vhdl 과 asic 설계 no.-1 8- 비트 마이크로프로세서 설계 김영철 교수 ...

27
VHDL 과 ASIC 과과 NO.-1 8- 비비 비비비비비비비비 비비 김김김 김김 김김김김김 김김김김김 [email protected] r

Upload: cory-walker

Post on 17-Dec-2015

246 views

Category:

Documents


10 download

TRANSCRIPT

Page 1: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-1

8- 비트 마이크로프로세서 설계

김영철 교수

전남대학교 전자공학과 [email protected]

Page 2: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-2

명령어 형식과 종류에 따른 의미 정의

명령어 형식 (Instruction Format)

명령어에 대한 Op-code, Mnemonic-code 및 의미

OP C ODE ADDRESS7 5 4 0

Opcode

Mnemoniccode

의 미

000 HALT If zero-flag=’0’ then stop program

001 SKIP If zero-flag=’1’ then skip current instruction and execute next instruction

010 ADD ACC <- ACC + MEM[address]011 AND ACC <- ACC and MEM[address]100 XOR ACC <- ACC xor MEM[address]101 LOAD ACC <- MEM[address]110 STORE MEM[address] <- ACC111 JUMP PC <- Address

Page 3: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-3

명령어 수행 Timing 정의와 각 Stage 에 대한 의미 정의

명령어 수행에 대한 Timing Diagram

명령어 수행에 따른 Timing Stage 의 종류와 의미

IF

S0

ID EXE MEM WB

S1 S2 S3 S4

Stage Stage에 대한 동작 의미IF(Instruction

Fetch)수행이 요구되는 1-바이트 명령어를 프로그램 메모리로 부터 읽어 명령어 레지스터에 저장하는 명령어 페치의 기능을 수행한다.

ID (InstructionDecoding and

OperandFetch)

명령어 레지스터에 있는 명령어의 연산자(op-code)에 따른 의미 분석을수행하는 명령어 해독의 기능을 수행한다. 또한, 명령어의 수행에 요구되는 연산부(operand)를 data 메모리에서 읽는 연산부 페치의 기능을 수행한다.

EXE (Instruc-tion Execution)

수행할 명령어가 ALU의 연산이 요구되는 경우에 ALU 의 ADD, AND,XOR 및 BYPASS로 구분되는 execution의 기능을 수행한다.

MEM (MemoryStore)

EXE 단계에서의 ALU 수행 결과를 STORE 명령어인 경우 메모리에 저장하는 기능을 수행한다.

WB (Accumu-lator Store)

명령어가 ADD, AND, XOR 인 경우는 ALU의 수행 결과를, LOAD 명령어인 경우는 메모리의 내용을 ACC 레지스터에 저장하는 기능을 수행한다.

Page 4: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-4

Instruction Fetch 수행을 위한 하드웨어 정의

ROM

ALUREG

AC CREG

RAM

MEMREG

ZEROFLAG

c lockgenerator

mux8

ALU

mux5inc

'1'

reset

c lockc lk_hot

control

c lk_hot

PC _ enIR_ enAC C _ enALU_ reg_ enmem_ reg_ enzero_ enmux8_ selmux5_ selmem_ rdmem_ wrIR_ en

AC C _ en

ALU_ reg_ en

mem_ reg_ en

zero_ en

mux8_ sel

mux5_ sel

mem_ rd

mem_ wr

PC _ en

85

5

5

5

3

8

8

8

8

8

8

8

5

3

5

5

0

0

1

1

PCREG

IRREG

Page 5: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-5

Instruction Decoding 수행을 위한 하드웨어 정의

PCREG

ROM

ALUREG

AC CREG

RAM

ZEROFLAG

c lockgenerator

mux8

ALU

mux5inc

'1'

reset

c lock c lk_hot

control

c lk_hot

PC _ enIR_ enAC C _ enALU_ reg_ enmem_ reg_ enzero_ enmux8_ selmux5_ selmem_ rdmem_ wrIR_ en

AC C _ en

ALU_ reg_ en

mem_ reg_ en

zero_ en

mux8_ sel

mux5_ sel

mem_ rd

mem_ wr

PC _ en

85

5

5

5

3

8

8

8

8

8

8

8

5

3

5

5

0

0

1

1

IRREG

MEMREG

Page 6: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-6

Instruction Execution 수행을 위한 하드웨어 정의

ROMIR

reg

RAM

c lockgenerator

mux8

ALU

mux5inc

'1'

reset

c lockc lk_hot

control

c lk_hot

PC _ enIR_ enAC C _ enALU_ reg_ enmem_ reg_ enzero_ enmux8_ selmux5_ selmem_ rdmem_ wrIR_ en

AC C _ en

ALU_ reg_ en

mem_ reg_ en

zero_ en

mux8_ sel

mux5_ sel

mem_ rd

mem_ wr

PC _ en

85

5

5

5

3

8

8

8

8

8

8

8

5

3

5

5

0

0

1

1

AC Creg AC C

regALUreg MEM

reg

zeroreg

PCreg

Page 7: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-7

Instruction Execution 수행을 위한 ALU 기능 정의

ALU 의 기능 신호에 대한 정의와 의미 정의기능 선택신호

기능과 의미 관련되는명령어

010 ACC REG와 MEM REG의 값을 더하는 기능을 수행하여결과를 ALU REG에 저장한다.

ADD

011 ACC REG와 MEM REG의 값에 대하여 비트 단위로AND의 기능을 수행 하여 결과를 ALU 레지스터에 저장한다.

AND

100 ACC REG와 MEM REG의 값에 대하여 비트 단위로 OR의 기능을 수행 하여 결과를 ALU REG에 저장한다.

XOR

101 MEM REG의 값을 bypass 하는 기능을 수행 하여 결과를 ALU REG에 저장한다.

LOAD

110 ACC REG의 값을 bypass 하는 기능을 수행 하여 결과를ALU REG에 저장한다.

STORE

위와 다른경우

수행 결과를 ALU REG에 저장하지 않으므로 면적 최소화를 위하여 출력을 don’t care로 한다.

위와 다른명령어

Page 8: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-8

Store into Memory 수행을 위한 하드웨어 정의

PCREG

ROMIR

REG

AC CREG

RAM

c lockgenerator

mux8

ALU

mux5inc

'1'

reset

c lockc lk_hot

control

c lk_hot

PC _ enIR_ enAC C _ enALU_ reg_ enmem_ reg_ enzero_ enmux8_ selmux5_ selmem_ rdmem_ wrIR_ en

AC C _ en

ALU_ reg_ en

mem_ reg_ en

zero_ en

mux8_ sel

mux5_ sel

mem_ rd

mem_ wr

PC _ en

85

5

5

5

3

8

8

8

8

8

8

8

5

3

5

5

0

0

1

1

MEMREG

ALUREG

ZEROFLAG

Page 9: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-9

Write Back into Accumulator 수행을 위한 하드웨어 정의

PCREG

ROMIR

REG

ALUREG

RAM

ZEROFLAG

c lockgenerator

mux8

ALU

mux5inc

'1'

reset

c lockc lk_hot

control

c lk_hot

PC _ enIR_ enAC C _ enALU_ reg_ enmem_ reg_ enzero_ enmux8_ selmux5_ selmem_ rdmem_ wrIR_ en

AC C _ en

ALU_ reg_ en

mem_ reg_ en

zero_ en

mux8_ sel

mux5_ sel

mem_ rd

mem_ wr

PC _ en

85

5

5

5

3

8

8

8

8

8

8

8

5

3

5

5

0

0

1

1

MEMREG

AC CREG

Page 10: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-10

RTL Component 에 대한 분석

하드웨어 구성에 대한 분석

조합 논리 회로 요소 순서 논리 회로 요소 입력이 5-비트인 2*1 MUX 입력이 8-비트인 2*1 MUX 5-비트의 입력 data에 대하여 1을증가하는 회로

5가지의 기능을 갖는 8-비트ALU

어드레스가 5-비트이고, data 버스가 8-비트인 ROM

어드레스가 5-비트이고, data 버스가 8-비트인 RAM

enable 신호 및 초기화 신호를갖는 1-비트 플립 플롭

enable 신호 및 초기화 신호를 갖는 5-비트 레지스터 enable 신호와 초기화 신호를 갖는 8-비트 레지스터 출력이 5-비트인 파형 발생기 여러 가지 제어 신호를 명령어와수행5-단계에 따라 생성하는 FSM

Page 11: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-11

조합논리회로에 대한 VHDL 설계 (1)

5- 비트 2*1 MUX 에 대한 VHDL 표현

library IEEE; use IEEE.std_logic_1164.all;

entity MUX5 is

port ( A,B : in std_logic_vector(4 downto 0);

SEL : in std_logic;

Y : out std_logic_vector(4 downto 0));

end MUX5;

architecture RTL of MUX5 is

begin

process(A,B,SEL)

begin

if SEL=’1’ then

Y <= A;

elsif SEL=’0’ then

Y <= B;

else

Y <= “-----“;

end if;

end process;

end RTL;

8- 비트 2*1 MUX 에 대한 VHDL 표현

library IEEE; use IEEE.std_logic_1164.all;

entity MUX8 is

port ( A,B : in std_logic_vector(7 downto 0);

SEL : in std_logic;

Y : out std_logic_vector(7 downto 0));

end MUX8;

architecture RTL of MUX8 is

begin

process(A,B,SEL)

begin

if SEL=’1’ then

Y <= A;

elsif SEL=’0’ then

Y <= B;

else

Y <= “--------“;

end if;

end process;

end RTL;

Page 12: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-12

조합논리회로에 대한 VHDL 설계 (2)

1 증가 회로에 대한 VHDL 표현library IEEE; use IEEE.std_logic_1164.all;use IEEE.std_logic_unsigned.all;entity INC is port ( PC_ADDR : in std_logic_vector(4 downto 0); INC_ADDR : out std_logic_vector(4 downto 0));end INC;architecture RTL of INC isbegin INC_ADDR <= PC_ADDR + 1;end RTL; ALU 에 대한 VHDL 표현 library IEEE; use IEEE.std_logic_1164.all;use IEEE.std_logic_unsigned.all;entity ALU is port (OPCODE: in std_logic_vector(2 downto 0); OP1,OP2 : in std_logic_vector(7 downto 0); ZERO_FLAG : out std_logic; ALU_OUT : out std_logic_vector(7 downto 0));end ALU;

architecture RTL of ALU isbegin process(OPCODE,OP1,OP2) variable TMP: std_logic_vector(7 downto 0); begin case OPCODE is when “010” => TMP := OP1 + OP2; when “011” => TMP := OP1 and OP2; when “100” => TMP := OP1 xor OP2; when “101” => TMP := OP2; when others => TMP := OP1; end case; if TMP = 0 then ZERO_FLAG <= ‘1’; else ZERO_FLAG <= ‘0’; end if; ALU_OUT <= TMP; end process;end RTL;

Page 13: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-13

Memory 에 대한 VHDL 설계 (1)

검증용 Program Data

DB ; store fn_2 in temp location

111 00011101 11010110 11011010 11001110 11010101 11011110 11001100 11100001 00000111 00011000 00000111 00011000 00001000 00001000 00000100 10000

BA ; load fn_2

59 ; add fn_1DA ; store result as new fn_2BB ; load temp locationD9 ; store as new fn_19C ; compare fn_1 to limit

E3 ; jump to address 300 ; haltE3 ; jump to address 301 ; fn_101 ; fn_2

90 ; limit

00 ; temp location

E3 ; jump to address 3

opcode comment

03456789

1011121325262728

address

DB ; store fn_2 in temp location

20 ; if limit skip to halt else jump

Page 14: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-14

Memory 에 대한 VHDL 설계 (2)

ROM 에 대한 VHDL 표현library IEEE; use IEEE.std_logic_1164.all;use IEEE.std_logic_unsigned.all;entity ROM is port ( ROM_ADDR : in std_logic_vector(4 downto 0); ROM_DATA : out std_logic_vector(7 downto 0));end ROM;architecture RTL of ROM is subtype ROMWORD is std_logic_vector(7

downto 0); type ROMTABLE is array(0 to 31) of ROM

WORD; constant ROM_TBL : ROMTABLE := ( “111

00011”,”00000000”, 중간 생략 ............................................);

begin ROM_DATA <= ROM_TBL(conv_integer(ROM_ADDR));end RTL;

RAM 에 대한 VHDL 표현library IEEE; use IEEE.std_logic_1164.all;use IEEE.std_logic_unsigned.all;entity RAM is port (RAM_ADDR : in std_logic_vector(4 downto 0); RAM_IN : in std_logic_vector(7 downto 0); RAM_OUT : out std_logic_vector(7 downto 0); MEM_RD, MEM_WR : in std_logic);end RAM;architecture RAM_A of RAM is subtype WORD is std_logic_vector(7 downto 0); type RAM is array(0 to 31) of WORD; signal TMP: RAM := (….., "00000000","00000001", "00000001", "00000000", "10010000", "00000000", ”00000000", "00000000");begin process (MEM_RD, RAM_ADDR, RAM_IN) begin if MEM_RD = '1' then RAM_OUT <= TMP(conv_integer(RAM_ADDR)); elsif MEM_WR = '1' then TMP(conv_integer(RAM_ADDR)) <= RAM_IN; end if; end process;end RAM_A;

Page 15: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-15

순서 논리 회로에 대한 VHDL 설계 (1)

Flip-Flop 과 Register 의 Symbol 정의

1-Bit Flip-Flop 에 대한 VHDL 표현 library IEEE; use IEEE.std_logic_1164.all;

entity REG1 is

port ( CLK,RST,D,EN : in std_logic;

Q : out std_logic);

end REG1;

architecture RTL of REG1 is

begin

process(CLK,RST)

begin

if RST = '0' then

Q <= '0';

elsif EN = '1' then

if CLK = '0' and CLK'event then

Q <= D;

end if;

end if;

end process;

end RTL;

en

d

c lk

q

rst

en

d

c lk

q

rst

reg5

5 5en

d

c lk

q

rst

reg8

88

Page 16: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-16

순서 논리 회로에 대한 VHDL 설계 (2)

5-Bit Register 에 대한 VHDL 표현library IEEE; use IEEE.std_logic_1164.all;

entity REG5 is

port ( CLK,RST,EN : in std_logic;

D : in std_logic_vector(4 downto 0);

Q : out std_logic_vector(4 downto 0));

end REG1;

architecture RTL of REG5 is

begin

process(CLK,RST)

begin

if RST = '0' then

Q <= (others=>’0’);

elsif EN = '1' then

if CLK = '0' and CLK'event then

Q <= D;

end if;

end if;

end process;

end RTL;

8-Bit Register 에 대한 VHDL 표현library IEEE; use IEEE.std_logic_1164.all;

entity REG8 is

port ( CLK,RST,EN : in std_logic;

D : in std_logic_vector(7 downto 0);

Q : out std_logic_vector(7 downto 0));

end REG8;

architecture RTL of REG8 is

begin

process(CLK,RST)

begin

if RST = '0' then

Q <= (others=>’0’);

elsif EN = '1' then

if CLK = '0' and CLK'event then

Q <= D;

end if;

end if;

end process;

end RTL;

Page 17: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-17

순서 논리 회로에 대한 VHDL 설계 (3)

명령어 수행 Timing Stage 를 구분하기 위한 One-Hot Code 신호 생성

c lock

c lk_hot(4)

c lk_hot(3)

c lk_hot(2)

c lk_hot(1)

c lk_hot(0)

S0(IF) S1(ID) S2(EXE) S3(MEM)S4(WB)

Page 18: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-18

One-Hot Code 생성을 위한 FSM 형태의 VHDL 설계

library IEEE; use IEEE.std_logic_1164.all;

entity CLK_GEN is

port( CLK,RST : in std_logic;

CLK_HOT : out

std_logic_vector(4 downto 0));

end CLK_GEN;

architecture CLK_GEN_A of CLK_GEN is

signal CURRENT_STATE,NEXT_STATE :

std_logic_vector(4 downto 0);

begin

process(CLK,RST)

begin

if RST = '0' then

CURRENT_STATE <= "00000";

elsif CLK = '0' and CLK'event then

CURRENT_STATE <=

NEXT_STATE;

end if;

end process;

process(CURRENT_STATE)

begin

if CURRENT_STATE = "00000" then

NEXT_STATE <= "00001";

elsif CURRENT_STATE = "00001" then

NEXT_STATE <= "00010";

elsif CURRENT_STATE = "00010" then

NEXT_STATE <= "00100";

elsif CURRENT_STATE = "00100" then

NEXT_STATE <= "01000";

elsif CURRENT_STATE = "01000" then

NEXT_STATE <= "10000";

elsif CURRENT_STATE = "10000" then

NEXT_STATE <= "00001";

else

NEXT_STATE <= "00001";

end if;

end process;

CLK_HOT <= CURRENT_STATE;

end CLK_GEN_A;

Page 19: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-19

명령어 수행 Stage 에 따른 제어 신호에 대한 정의

명령어 수행 Stage 와 제어 신호clock

pc_en

ir_en

acc_en

alu_en

mem

_en

mux5_sel

mux8_sel

mem

_rd

mem

_wr

12

3

4

5

67

8

9

10

11

12zero_en

S0

S1

S2

S3

S4

Page 20: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-20

명령어에 따른 제어 신호 생성 Timing 의 정의

명령어와 제어 신호 발생 위치 정의opcode

000

001

010

011

100

101

110

111

instruc tion

halt

skip

add

and

xor

load

store

jump

control wave

3

1, 2, 3

1, 3, 4, 5, 6, 7, 9, 10, 12

1, 3, 4, 5, 6, 7, 9, 10, 12

1, 3, 4, 5, 6, 7, 9, 10, 12

1, 3, 4, 5, 6, 7, 9, 10

1, 3, 5, 11

1, 2, 3, 8

Page 21: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-21

제어 신호 생성에 대한 VHDL 표현 (1)

library IEEE; use IEEE.std_logic_1164.all;package CONTROL_P is constant S4 : std_logic_vector(4 downto 0) := "10000"; constant S3 : std_logic_vector(4 downto 0) := "01000"; constant S2 : std_logic_vector(4 downto 0) := "00100"; constant S1 : std_logic_vector(4 downto 0) := "00010"; constant S0 : std_logic_vector(4 downto 0) := "00001";end CONTROL_P;--library IEEE; use IEEE.std_logic_1164.all;use work.CONTROL_P.all;entity CONTROL is PORT( OP_D : in std_logic_vector(2 downto 0);

CLK_HOT : in std_logic_vector(4 downto 0); ZERO_D : in std_logic; CLK_D : in std_logic; ACC_EN_D : out std_logic; ALU_REG_EN_D : out std_logic; MEM_RD_D : out std_logic; MEM_WR_D : out std_logic; PC_EN_D : out std_logic; IR_EN_D : out std_logic; MEM_REG_EN_D : out std_logic; ZERO_EN : out std_logic; MUX5_SEL : out std_logic; MUX8_SEL : out std_logic);end CONTROL;

architecture CONTROL_A of CONTROL is

signal ACC_EN_S,PC_EN_S : std_logic;

signal IR_EN_S,ALU_REG_EN_S : std_logic;

signal MEM_WR_S,MEM_REG_EN_S : std_logic;

signal ZERO_EN_S : std_logic;

signal MUX5_SEL_S,MUX8_SEL_S : std_logic;

begin

process(CLK_D)

begin

if CLK_D = '1' and CLK_D'event then

ACC_EN_D <= ACC_EN_S;

PC_EN_D <= PC_EN_S;

IR_EN_D <= IR_EN_S;

ALU_REG_EN_D <= ALU_REG_EN_S;

MEM_WR_D <= MEM_WR_S;

MEM_REG_EN_D <= MEM_REG_EN_S;

ZERO_EN <= ZERO_EN_S;

MUX5_SEL <= MUX5_SEL_S;

MUX8_SEL <= MUX8_SEL_S;

end if;

end process;

Page 22: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-22

제어 신호 생성에 대한 VHDL 표현 (2)

process(CLK_HOT,OP_D,ZERO_D)

variable OP_D_COND : std_logic;

begin

if OP_D="010" or OP_D="011" OR

OP_D="100" then

OP_D_COND := '1';

else

OP_D_COND := '0';

end if;

case CLK_HOT is

when S0 =>

ACC_EN_S <= '0';

PC_EN_S <= '0';

MEM_WR_S <= '0';

MEM_RD_D <= '0';

IR_EN_S <= '1';

MUX5_SEL_S <= '1';

MUX8_SEL_S <= '1';

MEM_REG_EN_S <= '0';

ALU_REG_EN_S <= '0';

ZERO_EN_S <= '0';

when S1 =>

ACC_EN_S <= '0';

PC_EN_S <= '0';

MEM_WR_S <= '0';

IR_EN_S <= '0';

MUX5_SEL_S <= '1';

if OP_D_COND = '1' or OP_D = "101" then

MEM_REG_EN_S <= '1';

MEM_RD_D <= '1';

else

MEM_REG_EN_S <= '0';

MEM_RD_D <= '0';

end if;

if OP_D_COND = '1' or OP_D = "101" then

MUX8_SEL_S <= '0';

else

MUX8_SEL_S <= '1';

end if;

ALU_REG_EN_S <= '0';

ZERO_EN_S <= '0';

Page 23: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-23

제어 신호 생성에 대한 VHDL 표현 (3)

when S2 => if OP_D = "000" then PC_EN_S <= '0'; else PC_EN_S <= '1'; end if; ACC_EN_S <= '0'; MEM_WR_S <= '0'; IR_EN_S <= '0'; MUX5_SEL_S <= '1'; if OP_D_COND = '1' or OP_D = "101" then MEM_RD_D <= '1'; else MEM_RD_D <= '0'; end if; if OP_D_COND = '1' then ZERO_EN_S <= '1'; else ZERO_EN_S <= '0'; end if; MUX8_SEL_S <= '1'; MEM_REG_EN_S <= '0'; if (OP_D_COND = '1') or (OP_D = "101") or (OP_D = "110") then ALU_REG_EN_S <= '1'; else ALU_REG_EN_S <= '0'; end if;

when S3 => if (OP_D = "001" and ZERO_D = '1') or OP_D = "111" then PC_EN_S <= '1'; else PC_EN_S <= '0'; end if; ACC_EN_S <= '0'; IR_EN_S <= '0'; if OP_D = "110" then MEM_WR_S <= '1'; else MEM_WR_S <= '0'; end if; if OP_D = "111" then MUX5_SEL_S <= '0'; else MUX5_SEL_S <= '1'; end if; MUX8_SEL_S <= '1'; ALU_REG_EN_S <= '0'; if OP_D_COND = '1' or OP_D = "101" then MEM_REG_EN_S <= '1'; else MEM_REG_EN_S <= '0'; end if; ZERO_EN_S <= '0'; MEM_RD_D <= '0';

Page 24: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-24

제어 신호 생성에 대한 VHDL 표현 (4)

when S4 =>

if OP_D_COND = '1' or OP_D = "101" then

ACC_EN_S <= '1';

else

ACC_EN_S <= '0';

end if;

MEM_WR_S <= '0';

IR_EN_S <= '0';

MUX5_SEL_S <= '1';

MUX8_SEL_S <= '1';

ALU_REG_EN_S <= '0';

MEM_RD_D <= '0';

MEM_REG_EN_S <= '0';

PC_EN_S <= '0';

ZERO_EN_S <= '0';

when others =>

ACC_EN_S <= '0';

PC_EN_S <= '0';

MEM_WR_S <= '0';

MEM_RD_D <= '0';

IR_EN_S <= '1';

MUX5_SEL_S <= '1';

MUX8_SEL_S <= '1';

MEM_REG_EN_S <= '0';

ALU_REG_EN_S <= '0';

ZERO_EN_S <= '0';

end case;

end process;

end CONTROL_A;

Page 25: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-25

마이크로프로세서에 대한 최상위 레벨에 대한 VHDL 표현

Entity 에 대한 VHDL 표현entity U_P is

port ( RESET,CLOCK : in std_logic);

end U_P;

Architecture 에 대한 VHDL 표현architecture U_P_A of U_P is

--component 에 대한 선언 ........

-- 중간 기억 장소인 signal 에 대한 선언 ......…

-- 사용 Component 의 Configuration 정의begin

U0: MUX5 port map (PC_ADDR, IR_ADDR, MUX5_SEL, MUX5_OUT);

U1: MUX8 port map (ALU_OUT, RAM_OUT, MUX8_SEL, MEM_REG_IN);

U2: INC port map (PC_REG_OUT, PC_ADDR);

U3: REG1 port map (CLOCK, RESET, ZERO_IN, ZERO_EN, ZERO_OUT);

U4: REG5 port map (CLOCK, RESET, PC_EN, MUX5_OUT, PC_REG_OUT);

U5: REG8 port map (CLOCK, RESET, IR_EN, ROM_OUT, IR_OUT);

U6: REG8 port map CLOCK,RESET,ACC_EN ,ACC_IN,ACC_OUT);

U7: REG8 port map (CLOCK, RESET, ALU_REG_EN, ALU_IN, ALU_OUT);

U8: REG8 port map (CLOCK, RESET, MEM_REG_EN, MEM_REG_IN, ACC_IN);

U9: ALU port map (OPCODE, ACC_OUT, ACC_IN, ZERO_IN, ALU_IN);

U10: CONTROL port map (OPCODE, CLK_HOT, ZERO_OUT, CLOCK, ACC_EN, ALU_REG_IN, MEM_RD, MEM_WR, PC_EN, IR_EN, EM_REG_IN ZERO_EN, MUX5_SEL, MUX8_SEL);

U11: CLK_GEN port map (CLOCK, RESET, CLK_HOT);

U12: ROM port map (PC_REG_OUT, ROM_OUT);

U13: RAM port map (IR_ADDR, ALU_OUT, RAM_OUT, MEM_RD, MEM_WR);

end U_P_A;

Page 26: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-26

검증 기준 값 정의와 Test Bench VHDL 표현

Program 수행에 대한 검증 기준 값

Test Bench 에 대한 VHDL 표현library IEEE;

use IEEE.std_logic_1164.all;

entity TEST_BENCH is

end TEST_BENCH;

시간 data 버스의 값

시간 data 버스의값

355 01H 805 02H1255 03H 1704 05H2155 08H 2605 0DH3055 15H 3505 22H3955 37H 4405 59H4855 90H

architecture TEST_BENCH_A of

TEST_BENCH is

component U_P

port (RESET,CLOCK : in std_logic);

end component;

signal RESET : std_logic :='0';

signal CLOCK : std_logic :='1';

for U0: U_P use entity work.U_P(U_P_A);

begin

U0 : U_P port map (RESET,CLOCK);

RESET <= '1' after 10 ns;

CLOCK <= not CLOCK after 5 ns;

end TEST_BENCH_A;

configuration TEST_BENCH_C of TEST_BENCH is

for TEST_BENCH_A

end for;

end TEST_BENCH_C;

Page 27: VHDL 과 ASIC 설계 NO.-1  8- 비트 마이크로프로세서 설계  김영철 교수  전남대학교 전자공학과  yckim@chonnam.chonnam.ac.kr

VHDL 과 ASIC 설계 NO.-27

시뮬레이션 결과에 대한 Waveform