Top Banner
CSC321 Homework Due Due Tuesday after spring break Turn in Design information • State diagram • State table • K-map simplifications and expressions for flip- flop inputs • Circuit diagrams for flip-flop input expressions Code listing for your gray-code simulation class Code listing for your test function Output screen dump of the working simulation
32

CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

Jan 17, 2018

Download

Documents

Leslie Thompson

CSC321 Register Transfer Language We need some new symbols to avoid (or cause) confusion R1 R2 R Bitwise AND R1 R2 R Bitwise OR R2 R Bitwise NOT
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Homework Due

• Due Tuesday after spring break• Turn in

– Design information• State diagram• State table• K-map simplifications and expressions for flip-flop inputs• Circuit diagrams for flip-flop input expressions

– Code listing for your gray-code simulation class– Code listing for your test function– Output screen dump of the working simulation

Page 2: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Logic Microoperations

• Counter-part to the arithmetic microoperations we looked at last week

• Similar to Boolean functions (expressions) except that the operands are registers (bit strings) rather than individual Boolean variables– This is exactly what you implemented in code

Page 3: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Register Transfer Language

• We need some new symbols to avoid (or cause) confusion

R1 R2R1011010110100111001001010

Bitwise AND

R1 R2R1011010110100111001101111

Bitwise OR

R2R1 0100111010010001

Bitwise NOT

Page 4: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Context

will always be a bitwise AND microop. will always be a bitwise OR microop. will always be a single bit AND will be a single bit OR in a Boolean

function (never a bitwise OR microop.) will be an arithmetic ADD in an arithmetic

function

Page 5: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Context

R1 R2,R1P + Q: R4 R5R3

What operation is this?

What operation is this?

What operation is this?

Page 6: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Logical Microoperations

• Given two binary variables there are 16 different logical microoperations that can be performed– How can this be given that there are only 4

combinations of input values?

Page 7: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Logical Microoperations

Inputs Outputs

x y F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15

0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1

1 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1

1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

Page 8: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Logical Microoperations

• Some of them are not intuitive (or useful)• They can all be created using AND, OR,

NOT, and XOR functions– You should be able to create the table of

functions (page 110, Table 4-6)• How would you go about doing this?

Page 9: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Hardware Implementation

• We know how to implement Boolean functions using combination logic

• How do we implement them to perform bitwise microoperations?

Page 10: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Hardware Implementation

0

1

2

3

S0

S1

Fi

Ai

Bi

4x1MUX

• If you need n-bit microoperations (n-bit registers) you have n of these circuits

• …with a lot of logic gates!

Page 11: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Hardware Implementation

• But doesn’t that MUX only implement 4 expressions?

• What about the other 12?• We can use a bigger MUX or realize that

many of the other 12 are useless and the ones that are useful can be derived from the 4 that we implemented, keeping hardware costs down

Page 12: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

But Why?

• What can be done with logic microoperations?– Most useful when we consider the bits of a

given register as separate signals

Page 13: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

• In Java if we need 8 boolean variables we generally do something like this…

• This may be very inefficient dependent on how the Java compiler generates the byte code

Logic Microoperations

boolean b7 = false;boolean b6 = false;…boolean b0 = false;

ORboolean b[] = new boolean[8];for (int i = 0; i < 8; ++i) {b[i] = false;

}

Page 14: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

• A more memory efficient way to represent the same information would be…

• This is referred to as “bit packing”• But how do we get to the individual bits

within the byte?

Logic Microoperations

byte b = 0;

Page 15: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Logic Microoperations

• Through bitwise logic operations– Selective-set– Selective-complement– Selective-clear– Mask– Insert– Clear

Page 16: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

• We want to set certain bits to 1 while leaving the others unchanged

• Any ideas?

Selective-Set

01101010? 1111000011111010

Page 17: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Selective-Complement

• We want to complement (invert) certain bits while leaving the others unchanged

• Any ideas?

01101010? 1111000010011010

Page 18: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Selective-Clear

• We want to clear (0) certain bits while leaving the others unchanged

• Any ideas?

01101010? 1111000000001010

Page 19: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Mask

• Similar to Selective-clear but the “selection” is done with 0’s rather than 1’s

• Any ideas?

01101010? 1111000001100000

Page 20: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Insert

• Insert (replace) a group of bits into the existing bit string while leaving other bits unchanged

• Any ideas?

01101010? 1101xxxx11011010

Page 21: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Clear

• Compare the two values and if they are equal, produce a string of 0’s

• Any ideas?

01101010? 0110101000000000

Page 22: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Usage

• These types of operations are especially useful when designing hardware

• But, they are also heavily used in software– Device drivers (s/w that talks to h/w)– Embedded systems (small programmable h/w

devices)– High speed applications such as games or other

video applications

Page 23: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Shift Microoperations

• Serial modification/transfer of bits similar to the shift registers we looked at previously

• Three basic types of shift– Logical shift– Circular shift (often called rotation)– Arithmetic shift

Page 24: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Logical Shift

• Acts like a shift register with a 0 shifted in to the vacated bit position– Shifts can be to the left or the right– Bits that are shifted “off the end” are lost

1110101011010100

01110101

R1 ← shl R1

R1 ← shr R1

Page 25: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Circular Shift

• Acts like a shift register with the end bit shifted in to the vacated bit position– Shifts can be to the left or the right– No information is lost

1110101011010101

01110101

R1 ← cil R1

R1 ← cir R1R1 ← rotl R1

R1 ← rotr R1

Page 26: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Arithmetic Shift

• Shifts are performed with special attention paid to the MSB (the sign bit – 2’s complement notation)– Left arithmetic shifts correspond to integer divide by

powers of 2• Division must leave the sign bit unchanged• Division cannot causes an overflow

– Right arithmetic shifts correspond to integer multiply by powers of 2

• Multiplication must leave the sign bit unchanged• Multiplication must be overflow aware

Page 27: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Arithmetic Shift Right

• Leaves the sign bit unchanged and shifts the number (including the sign bit) to the right

• Did it work as expected?

10101010 11010101R1 ← ashr R1

Page 28: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Arithmetic Shift Left

• Inserts 0 into LSB (why?)• If MSB changes after the shift an overflow has

occurred (why?)• Can predict overflow by comparing MSB (bit n-1)

to next bit (bit n-2)

• Did it work as expected?

• Did it work as expected?

11101010 11010100R1 ← ashl R1

01101010 11010100R1 ← ashl R1

Page 29: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Arithmetic Shift Left

• What is the “overflow rule”? • How can you implement it?

Page 30: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Implementation

• The arithmetic, logic, and shift microoperations are generally implemented in a single “unit” – the ALU (Arithmetic-Logic Unit)

• The ALU is generally made up of combinational circuits (as opposed to sequential circuits)– Why should this be the case?

Page 31: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

ALU Block DiagramStage i

Arithmetic Circuit Stage i

Logic Circuit Stage i

4x1MUX

S3S2S1S0

shl

Cin

Cout

BiAi

Ai-1Ai+1

shr

Fi

select

0123

• Combinational circuits that we looked at previously are inserted into the boxes

Page 32: CSC321 Homework Due Due Tuesday after spring break Turn in –Design information State diagram State table K-map simplifications and expressions for flip-flop.

CSC321

Table of MicrooperationsOperation Select Resultant operation/function

S3 S2 S1 S0 Cin Operation Function

0 0 0 0 0 F=A Transfer

0 0 0 0 1 F=A+1 Increment

0 0 0 1 0 F=A+B Add

0 0 0 1 1 F=A+B+1 Add w/carry

0 0 1 0 0 F=A+B’ Sub w/borrow

0 0 1 0 1 F=A+B’+1 Subtract

0 0 1 1 0 F=A-1 Decrement

0 0 1 1 1 F=A Transfer

0 1 0 0 x F=A B AND

0 1 0 1 x F=A B OR

0 1 1 0 x F=A B XOR

0 1 1 1 x F=A’ Complement

1 0 x x x F=shr A Shift right

1 1 x x x F= shl A Shift left