VHDL Processes: Cwru Eecs 318
VHDL Processes: Cwru Eecs 318
VHDL Processes: Cwru Eecs 318
LECTURE 8:
VHDL PROCESSES
Instructor: Francis G. Wolff
wolff@eecs.cwru.edu
Case Western Reserve University
This presentation uses powerpoint animation: please viewshow
behavioral
Y
b
n
n
0
n
Datapath
Datapathis
isnnbits
bitswide
wide
WITH
WITHssSELECT
SELECT
YY<=
<=aa WHEN
WHEN0,
0,
bb WHEN
WHENOTHERS;
OTHERS;
WITH
WITHss SELECT
SELECT
YY<=
<= aaWHEN
WHEN0,
0,
bb WHEN
WHENOTHERS;
OTHERS;
Where
Whereis
isthe
the difference?
difference?
LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
USE IEEE.std_logic_arith.all;
n
n
0
1
ENTITY Generic_Mux IS
S
GENERIC (n: INTEGER);
PORT (Y:
OUT std_logic_vector(n-1 downto 0);
a:
IN
std_logic_vector(n-1 downto 0);
b:
IN
std_logic_vector(n-1 downto 0);
S:
IN
std_logic_vector(0 downto 0)
);
END ENTITY;
Q
Q
R
0
0
1
1
NAND
S Qn+1
0 U
1 1
0 0
1 Qn
ENTITY Latch IS
PORT(R, S: IN std_logic; Q, NQ: OUT std_logic);
END ENTITY;
ARCHITECTURE latch_arch OF Latch IS
BEGIN
Q
<= R NAND NQ;
NQ
<= S NAND Q;
END ARCHITECTURE;
NAND
R S Qn+1
R
Q
0 0 U
0 1 1
1 0 0
Q
S
1 1 Qn
ARCHITECTURE Latch2_arch OF Latch IS Sequential
Sequential
Statements
BEGIN
Statements
PROCESS (R, S) BEGIN
IF R= 0 THEN
Q <= 1; NQ<=0;
ELSIF S=0 THEN
Q <= 0; NQ<=1;
END IF;
END PROCESS;
END ARCHITECTURE;
R
ARCHITECTURE Latch_arch OF GC_Latch IS BEGIN
PROCESS (R, S, LE) BEGIN
IF LE=1 THEN
IF R= 0 THEN
Q <= 1; NQ<=0;
ELSIF S=0 THEN
Q <= 0; NQ<=1;
END IF;
END IF;
END PROCESS;
END ARCHITECTURE;
PROCESS
PROCESS(Clock,
(Clock,Reset,
Reset, Preset)
Preset) BEGIN
BEGIN
IF
IFReset=1
Reset=1 THEN
THEN--highest
--highestpriority
priority
Q
Q <=
<= 0;
0;
ELSIF
ELSIF Preset=1
Preset=1 THEN
THEN
Q
Q <=
<= 0;
0;
ELSIF
ELSIF rising_edge(Clock)
rising_edge(Clock) THEN
THEN
Q
Q <=
<= D;
D;
END
ENDIF;
IF;
END
ENDPROCESS;
PROCESS;
PCSource
PCWrite
ALUOp
Outputs
IorD
ALUSrcB
MemRead
ALUSrcA
Control
MemWrite
RegWrite
MemtoReg
Op
RegDst
IRWrite
[5 0]
26
Instruction [25 0]
PC
0
M
u
x
1
Instruction
[31-26]
Address
Memory
MemData
Write
data
Instruction
[25 21]
Read
register 1
Instruction
[20 16]
Read
Read
register 2 data 1
Registers
Write
Read
register data 2
Instruction
[15 0]
Instruction
register
Instruction
[15 0]
Memory
data
register
0
M
Instruction u
x
[15 11]
1
0
M
u
x
1
B
4
16
Sign
extend
32
Shift
left 2
Jump
address [31-0]
Zero
ALU ALU
result
0
1 M
u
2 x
3
ALU
control
Instruction [5 0]
Register
RegisterTransfer
TransferLevel
Level(RTL)
(RTL)View
View
ALUOut
1 u
x
PC [31-28]
0
M
u
x
1
Write
data
Shift
left 2
28
PCWriteCond
PCWrite
MemRead
MemWrite
IorDMux FSM
IRWrite
Clock Reset
PCSourceMux
ALUOp
ALUSrcAMux
ALUSrcBMux
RegWrite
RegDstMux
MemtoReg
IRopcode
R-Format
Clock=1
Ifetch
Reg/Dec
Exec
Decode
Wr
Clock=1
Exec
Rtype
Fetch
Clock=1
Cycle 3 Cycle 4
Write
Rtype
Clock=1
Start
R-Format
Ifetch
Cycle 3 Cycle 4
Reg/Dec
MemRead=1,
MemRead=1, MemWrite=0
MemWrite=0
IorD=1
(MemAddrPC)
IorD=1
(MemAddrPC)
IRWrite=1
(IRMem[PC])
IRWrite=1
(IRMem[PC])
ALUOP=ADD
ALUOP=ADD (PC4+PC)
(PC4+PC)
ALUSrcA=0
ALUSrcA=0 (=PC)
(=PC)
ALUSrcB=1
ALUSrcB=1 (=4)
(=4)
PCWrite=1,
PCWrite=1,PCSource=1
PCSource=1(=ALU)
(=ALU)
RegWrite=0,
RegWrite=0,
RegDst=X,
RegDst=X, MemtoReg=X
MemtoReg=X
Instruction Fetch
Exec
Wr
Decode
Exec
Write
Reg