Professional Documents
Culture Documents
HDL개요
HDL개요
정정화
Design through Various Levels of
Abstraction
Architecture level
Behavior RAM ROM
ALU
Area Estimates
PLA I/O
Register Transfer
Level
Functions
Timing
Logic Level
0 &
0
Bits
Timing
Current Level
Voltages
Currents
Polysilicon
Physical Level
Metal
(=Layout)
Dimensions Diffusion
Contact
Device Level Gate
In Characteristic
Source Drain
Depth
Bebavioral Domain Structure Domain Physical Domain
System Performance specs. CPU`s Physical partitions
Level Memories
Switches
Controllers
Buses
Algorithm Algorithms Hardware modules Clusters
Level (manipulation of data Data structures
structure)
1 1 q4 1 1
q v 1 z v
Memory
State element
diagram State input
assignment equation
Minimal
Functional State Transition
state Circuit
description table table
table
Analysis Process
Design Process
(Logic Synthesis)
Structure of Digital System
Data path
Logic circuit
Control Branch
signal information
Sequential control
Logic circuit
T1 address bus (PC)
T2 PC (PC) + 1
1
T3 IR (M)
T4 decode
SPEC s MAG
Functional
• Data & Instruction Format
Simulation
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
op ADR
Collection of
Condions
OP : OP Code
Gate Level
Circuit Design
ADR : Address
Instruction Set
OP Code Operation
LOAD 000100 ACC (M(ADR))
STORE 001000 M(ADR) ACC
ADD 010000 ACC ACC+(M(ADR)
BRANCH 100000 BRANCH TO ADR
BRANCH-POSITIVE 100001 BRANCH TO ADR IF
(ACC)>=0
ACC : Accumulator
ADR : Address part in instruction
M(ADR) : Address No. of memory
State Diagram for instruction Cycle
ADS
entity CPU is
port ( CLOCK : in std_logic;
RESET : in std_logic);
end CPU;
architecture BEHAVIORAL of CPU is
type STATE_TYPE is (ADS, IFT, DEC, LDA, STA, ADD, BRA, BRP);
type MEMORY is array(0 to 6) of std_logic_vector(15 downto 0);
signal CURRENT_STATE, NEXT_STATE : STATE_TYPE;
signal MEM : MEMORY := MEMORY'("0001000000000011",
"0100000000000100",
"0010000000000101",
"0000000000000111",
"0000000000001001",
"0000000000000000",
"0000000000000000"
);
signal ACC, IR : std_logic_vector(15 downto 0);
signal MAR, IAR : integer range 0 to 1023;
begin
-- process to hold combinational logic
COMBIN : process(CURRENT_STATE, RESET)
variable temp : std_logic_vector(15 downto 0);
begin
if RESET = '1' then
MAR <= '0';
IAR <= '0';
NEXT_STATE <= ADS;
else
case CURRENT_STATE is
when ADS =>
MAR <= IAR;
IAR <= IAR+1;
NEXT_STATE <= IFT;
when IFT =>
IR <= MEM(MAR);
NEXT_STATE <= DEC;
when DEC =>
MAR <= vector2int(IR(9 downto 0));
case IR(15 downto 10) is
when "000100" =>
NEXT_STATE <= LDA;
when "001000" =>
NEXT_STATE <= STA;
when "010000" =>
NEXT_STATE <= ADD;
when "100000" =>
NEXT_STATE <= BRA;
when "100001" =>
NEXT_STATE <= BRP;
when others =>
null;
end case;
when LDA =>
ACC <= MEM(MAR);
NEXT_STATE <= ADS;
when STA =>
MEM(MAR) <= ACC;
NEXT_STATE <= ADS;
when ADD =>
temp := add_sub(ACC, MEM(MAR), TRUE);
ACC <= temp;
NEXT_STATE <= ADS;
when BRA =>
IAR <= MAR;
NEXT_STATE <= ADS;
when BRP =>
if ACC(15) = '0' then
IAR <= MAR;
end if;
end case;
end if;
end process;
-- process to hold syschronous elements (flip-flops)
SYSCH : process
begin
wait until CLOCK'event and CLOCK = '1';
CURRENT_STATE <= NEXT_STATE;
end process;
end BEHAVIORAL;
configuration CFG_CPU_BEHAVIORAL of CPU is
for BEHAVIORAL
end for;
end CFG_CPU_BEHAVIORAL;
library IEEE;
use IEEE.std_logic_1164.all;
package MATH is
function add_sub(L, R : std_logic_vector; ADD : BOOLEAN)
return std_logic_vector;
function vector2int(S : std_logic_vector(9 downto 0))
return INTEGER;
end MATH;
package body MATH is
function add_sub(L, R : std_logic_vector; ADD : BOOLEAN)
return std_logic_vector is
variable carry : std_logic;
variable A, B, sum : std_logic_vector(L'length-1 downto 0);
begin
if ADD then
-- prepare for an "add" operation
A := L;
B := R;
carry := '0';
else
-- prepare for a "subtract" operation
A := L;
B := not R;
carry := '1';
end if;
-- create a ripple-carry chain; sum up bits
for i in 0 to A'left loop
sum(i) := A(i) xor B(i) xor carry;
carry := (A(i) and B(i)) or (A(i) and carry) or (carry and B(i));
end loop;
return sum; -- result
end;
function vector2int(S : std_logic_vector(9 downto 0))
return INTEGER is
variable result : INTEGER range 0 to 1023 := 0;
begin
for i in 9 downto 0 loop
result := result * 2;
if S(i) = '1' then
result := result + 1;
end if;
end loop;
return result;
end vector2int;
end MATH;
Time CLK <(10)>
ADS 0 0 0
상태의 수 : 8 개
IFT 0 0 1
3 개의 F.F. 가
DCE 0 1 0 필요
LDA 0 1 1 ST(0)
STA 1 0 0 ST(1)
ADD 1 0 1 ST(2)
BRA 1 1 0
BRP 1 1 1
|* ㄱ ST(0)& ㄱ ST(1)& ㄱ ST(2)*|ST(2)<-1
|* ㄱ ST(0)& ㄱ ST(1)&ST(2)*|ST(1)<-1, ST(2)<-0.
|* ㄱ ST(0)&ST(1)& ㄱ ST(2)&(IR(0:5):=4)*|ST(2)<-1.
|* ㄱ ST(0)&ST(1)& ㄱ ST(2)&(IR(0:5):=8)*|ST(0)<-1,ST(1)<-1.
|* ㄱ ST(0)&ST(1)& ㄱ ST(2)&(IR(0:5):=16)*|ST(0)<-1,ST(1)<-1.ST(2)<-2
|* ㄱ ST(0)&ST(1)& ㄱ ST(2)&(IR(0:5):=32)*|ST(0)<-1.
|* ㄱ ST(0)&ST(1)& ㄱ ST(2)&(IR(0:5):=33)*|ST(2)<-1.ST(2)<-2
|* ㄱ ST(0)& ㄱ ST(1)&ST(2)*|ST(1)<-0, ST(2)<-0.
|*ST(0)& ㄱ ST(1)& ㄱ ST(2)*|ST(0)<-0.
|*ST(0)& ㄱ ST(1)&ST(2)*|ST(0)<-0, ST(2)<-0.
|*ST(0)&ST(1)& ㄱ ST(2)*|ST(0)<-0, ST(1)<-0.
|*ST(0)&ST(1)&ST(2)*|ST(0)<-0, ST(1)<-0ST(2)<-0.