lecture 04 modeling, analysis and simulation in logic...

24
Dr. Yinong Chen Lecture 04 Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Upload: others

Post on 07-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Dr. Yinong Chen

Lecture 04

Modeling, Analysis and Simulation

in Logic Design

逻辑设计中的建模、分析与仿真

Page 2: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

Engineering Design Process工程设计过程

19 September 20172

Identify

and define

problem

建模Modeling

分析Analysis

最终选择Final

Selection

实现和测试Implementation

and testing

sketch

possible

solutions

research

仿真Simulation

原型Prototyping

定义问题 研究 勾画可能的解答

ALU

Page 3: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen3

Contents 内容

Logic Design and Modeling in Truth Table

逻辑设计与用真值表的建模1

Building Blocks of Digital Systems

数字系统的构建块2

Memory Design

存贮器设计3

4Arithmetic / Logic Unit (ALU) Design & Testing

算术/逻辑部件ALU的设计与测试

Simulate ALU Design in VIPLE

用VIPLE仿真ALU设计5

Page 4: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

Logic Design: Analogue versus Digital

empty

full

tank dial

infinite range of values

Tank

水箱

light : on / off

finite set of values Tank

水箱

4

Analogue Digital逻辑设计:模拟与数字

Tank

水箱

Page 5: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

Propositional Logic and its Elements

Propositional logic is a language for modeling and

specification 命题逻辑是一种建模和规范语言。

Proposition: A statement that can either be true or false:

命题:一个语句,它的的值可以是真,或是假– One plus two is three

– There are two Nobel prize winners at Arizona State University

– The sky is blue

– How old are you?

– You must ride a bike to school!

Logic connectives

– AND (), OR (), NOT (), IMPLIES ()

– light is on tank is full

– (Light is off) (bulb is not broken) tank is empty

Truth and falsity values – Truth Table 真值表5

命题逻辑及其构成要素

Page 6: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

真值表 是逻辑规范/电路模型Truth Table is a Logic Specification/Model for Circuits

NOT

propositional variable statement

P ¬ P

false true

true false

AND

P Q P Q

false false false

false true false

true false false

true true true

a b ab

0 0 0

0 1 0

1 0 0

1 1 1

a a

0 1

1 0

6

Page 7: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

Truth Table 真值表 (Contd.)

OR

P Q P Q

false false false

false true true

true false true

true true true

a b ab

0 0 0

0 1 1

1 0 1

1 1 1

7

Page 8: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen8

Building Blocks of Digital Circuits数字线路的基本构件

AND gate

c = ab

a

b

a

b

c c

OR gate

c = a b

NOT

c = a

ca

Building Blocks

a b ab

0 0 0

0 1 0

1 0 0

1 1 1

f4-1

Multiplexor

a

b

c

d

e1

0

1

2

3

e1 e0 f

0 0 a

0 1 b

1 0 c

1 1 d

e0

Truth Tables

f2-1

Multiplexora

b0

1

e0

If (e0=0) (f=a) else (f=b);

a b ab

0 0 0

0 1 1

1 0 1

1 1 1

NAND gate

c = ab

a

b

a

b

c c

NOR gate

c = a b

a

b

c

XOR gate

c = ab ab

a b ab ab a b ab

0 0 1 1 0

0 1 1 0 1

1 0 1 0 1

1 1 0 0 0

a a

0 1

1 0

Page 9: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen9

Memory Design 存储器设计: bit and Byte

Q'

Q

set

reset

One-bit memory design

One bit can store a

“1” or a “0”

input

output

1-b

it

1-b

it

1-b

it

1-b

it

1-b

it

1-b

it

1-b

it

1-b

it

8 bits = 1 Byte

Can store

a “character”

Or a short integer

output

input

01

Least

significant

bit

Most

significant

bit

Page 10: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen10

Memory: Word, Long Word

存储器: 字,长字

Word 字

1 Byte 1 Byte 1 Byte 1 Byte

8 7 2 1 031 30 29

double word 双字

Can store: a long int and a double float

1 Byte 1 Byte 1 Byte 1 Byte

8 7 2 1 063 62 61

1 Byte 1 Byte 1 Byte 1 Byte

Can store:

int and float

In a 32-bit computer:

4 Bytes = 1 word and 8 bytes = 1 double word

Page 11: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen11

Th

e E

nti

re M

emo

ry,

wit

h 3

2-b

it a

dd

ress

sp

ace

an

d b

yte

-ad

dre

ssab

le整

个内

存,

32位

地址

空间

和字

节可

寻址

1 byte 1 byte 1 byte 1 byte

2 1 031 30 29

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

1 byte 1 byte 1 byte 1 byte

00000000h

00000004h

00000008h

0000000Ch

00000010h

00000014h

00000018h

0000001Ch

00000020h

00000024h

00000028h

0000002Ch

00000030h

FFFFFFF0h

FFFFFFF4h

FFFFFFF8h

FFFFFFFCh

. . . . . . . . . . . . . . .

Hex address

Page 12: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen12

Five Component Model of a Computer-- A Conceptual Model

计算机的5-部件概念模型

Input

输入

Memory 存储器 Peripherals 外设

Bus总线

Control Unit

控制器

Processor处理器

Output

输出

ALU

Page 13: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen13

Arithmetic/Logic Unit (ALU)算术/逻辑单元

ALU

Operation code (3)

Operation code function

0 0 0 AND

0 0 1 OR

0 1 0 ADD

1 1 0 SUB Adder

操作码 功能

Page 14: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen14

Truth Table and Design of a One-Bit Adder真值表和1-位加法器的设计

a =

b =

c =

a carryOut Sum

0 0 0

0 0 1

0 0 1

0 1 0

1 0 1

1 1 0

1 1 0

1

b

0

0

1

1

0

0

1

1

carryIn

0

1

0

1

0

1

0

1 1 1

input output

carryOut

sum

One-bit adder

a

b

carryIn

Truth Table

Page 15: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

Inputs carryOut r

000001 d 0

000010 d 0

000011 d 1

000100 d 0

000101 d 0

000110 d 0

000111 d 1

001000 d 0

001001 d 1

001010 d 1

001011 d 1

001100 d 0

001101 d 1

001110 d 1

001111 d 1

010000 0 0

010001 0 1

010010 0 1

010011 1 0

010100 0 1

010101 1 0

010110 1 0

010111 1 1

011000

011001

011010

011011

011100

011101

011110

011111

10000015

One-Bit ALU Design 1位-ALU的设计

operation function

0 0 0 AND

0 0 1 OR

0 1 0 ADD

1 1 0 SUB

1-bit

ALU

a

b

r

operationCarryIn

carryOut

Six inputs and two outputs

Partial Truth Table

AND

OR

ADD

SUB

operation

0

1

0

1

2

3

+

carryIn

a

b

r

carryOut

Component-based design

Page 16: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen16

32-Bit ALU with 96 Inputs

32-ALU, 有96条输入线

1-bit

ALU

a0

b0r0

operationCarryIn

1-bit

ALU

a1

b1r1

1-bit

ALU

a31

b31r31

.

.

.

carryOut

operation function

0 0 0 AND

0 0 1 OR

0 1 0 ADD

1 1 0 SUB

ALU

Operation (3)

0

Page 17: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

Simulation of 1-bit Adder 1-位计算器仿真

17

carryOut

sumOne-bit adder

logic design

a

b

carryIn

VIPLE Implementation

Define Before Using: Define the input whenever you see a warning sign

Page 18: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

Testing the One-Bit Adder 测试1-位加法器

Page 19: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen19

Converting Decimal to Binary Pattern for Automated Test Case Generation

为自动测试输入生成,把二进制转换成十进制

19

CountTo7 a b carryIn

0 0 0 0

1 0 0 1

2 0 1 0

3 0 1 1

4 1 0 0

5 1 0 1

6 1 1 0

7 1 1 1

if CountTo7 = 0, 1, 2, 3, then a = 0, else a = 1;

if CountTo7 = 0, 1, 4, 5, then b = 0, else b = 1;

if CountTo7 = 0, 2, 4, 6, then carryIn = 0, else carryIn = 1;

Page 20: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

Automated Test Case Generation自动测试输入生成

20

Test

Cases

Count from

0 to 7

Count from

0 to 63 for

1-bit ALU

Page 21: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

One-Bit ALU 1-位算逻部件的设计

21

operation

0

1

0

1

2

3

+

CarryIn

a

b

r

carryOut

1-bit

ALU

a

b

r

operationCarryIn

carryOut

1-bit adder

4-to-1

multiplexer

2-to-1

multiplexer

Page 22: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong ChenDefine Before Using: Define the input whenever you see a warning sign

One-Bit ALU VIPLE Implementation1-位算逻部件的实现

Page 23: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

Testing the One-Bit ALU 测试 1-位算逻部件的

Page 24: Lecture 04 Modeling, Analysis and Simulation in Logic Designneptune.fulton.ad.asu.edu/VIPLE/Lectures/L04ALUCn.pdf · Modeling, Analysis and Simulation in Logic Design 逻辑设计中的建模、分析与仿真

Yinong Chen

Automated Test Case Generation自动测试输入生成

24

Count from

0 to 7

Count from

0 to 63 for

1-bit ALU

63

Test

Cases