CS233
Discussion Section 4
Solution
Finite state machine design
Youve been tasked by an airline to build a device that smashes every 3rd suitcase that is checked.
To implement this circuit, design a finite-state machine with a 1-bit input, sensor, and a 1
CS398 Exam 3
December 6th, 2012
Name:
NETID:
Circle the section that attend (so we can hand back your exam).
Monday
Tuesday
AYA (1-3pm) Craig
AYE (9-11am) Maria
AYB (2-4pm) Jon
AYF (10am-noon) Ting
AYC (3-5pm) Michael
AYG (11am-1pm) Ting
AYD (4-6pm) Ting
CS233
Lab 9
Handout
The cheapest, fastest and most reliable components of a computer system are those that arent
there.
Gordon Bell
Learning Objectives
1. Understanding memory-mapped I/O in hardware
2. Understanding interrupt handling in hardware
3. Unde
CS233
Lab 3
Learning Objectives
1. Learn more Verilog features
2. Build a 32-bit ALU
Work that needs to be handed in
Implement and test the alu32 module and its subcomponents in Verilog. These les need to be
submitted for the rst deadline:
1. mux.v: your
CS233
Lab 9
Handout
Always code as if the (person) who ends up maintaining your code will be a violent psychopath who
knows where you live.
M. Golding
Learning Objectives
1. Introduction to memory-mapped I/O
2. Introduction to interrupt handlers
Work tha
CS233
Lab 2
Handout
Beware of bugs in the above code; I have only proved it correct, not tried it.
Donald E. Knuth
Learning Objectives
1. Combinational logic design.
2. Using bitwise logical and shifting operations in a high-level language like C+.
Work t
CS233
Lab 7
Handout
He who hasnt hacked assembly language as a youth has no heart. He who does so as an adult
has no brain. John Moore
Real programmers can write assembly code in any language. Larry Wall
Learning Objectives
1.
2.
3.
4.
Arithmetic and logi
CS233
Lab 8
Handout
Beauty is more important in computing than anywhere else in technology because software is so complicated. Beauty is the ultimate defense against complexity. . The geniuses of the computer eld, on the
the other hand, are the people wit
CS233
Lab 10
Handout
Always code as if the (person) who ends up maintaining your code will be a violent psychopath who
knows where you live.
M. Golding
Learning Objectives
1. Introduction to memory-mapped I/O
2. Introduction to interrupt handlers
Work th
CS233
Lab 11
Handout
As long as there were no machines, programming was no problem at all; when we had a few weak computers, programming became a mild problem, and now [1972] that we have gigantic computers, programming
has become a gigantic problem. As t
CS233
Discussion section
Handout
Combinational Design
Your friend1 is rather picky about what pizzas they are willing to eat. From your observations,
they will only eat pizzas that conform to the following rules:
1. The pizza should have exactly one veget
CS233
Discussion Section 13
Handout
Memory Access Pattern
1. For the Barcelona (64KB, 2-way set-associative cache with 64-byte blocks), estimate the miss rate of
the two following code fragments: (assume ints are 4-bytes data types and variables i and j a
Finite State Machines
1
Todays lecture
!
!
!
Goal: Build a sequen9al circuit from a state diagram
! Step 0: Problem specica3on
! Step 1: Build the state diagram
! Setp 2: Build the state table
! Step 3: Build the sequen3al ci
CS233
Lab 5
Handout
Learning Objectives
1. Building an instruction decoder
2. Understanding a simple computer datapath
Work that needs to be handed in (via SVN)
1. decoder.v: This le contains the module mips_decode, which takes an instructions opcode
and
Number Systems (in Binary)
1
Todays lecture
!
!
!
!
Represen:ng things with bits
! N bits gets you 2N representa0ons
Unsigned binary number representa:on
! Conver0ng between binary and decimal
! Hexadecimal nota0on
Binary Addi:on & Bit
Registers and Register Files
1
Todays lecture
!
!
Memory
! Addressable storage
Register Files
! Registers
! Decoders
2
How can we store more than 1 bit?
!
We build registers out of ip ops.
! Example 4-bit register made of four D ip o
Recursion:
Deni&on:
Recursion: If you s(ll don't get it, see: "Recursion".
1
Todays lecture
!
!
!
!
ASCII & NULL-terminated strings
2-dimensional arrays in C
Recursion
! My turn (Example)
! Your turn
Callee-saved Registers
! M
CS233
Lab 1
Handout
Learning Objectives
1. Introduction to Verilog syntax
2. Introduction to Verilog tools (iverilog, gtkwave)
3. Practice with Verilog coding, testing, and debugging
Work that needs to be handed in
1. First deadline: Implement the sc2_blo
Cache Performance:
Analyzing Memory Access Pa2erns and
Predic4ng the Number of Cache Misses
Craig Zilles and Maria Gazaran
1
Todays lecture
!
!
Review: Cache Size Rela<onships
Predic<ng Cache Performance from Code
! Memory access
CS233
Lab 3
Learning Objectives
1. Learn more Verilog features
2. Build a 32-bit ALU
Work that needs to be handed in
Implement and test the alu32 module and its subcomponents in Verilog. These les need to be
submitted by the rst deadline:
1. mux.v: your 4
CS233
Lab 2
Handout
Beware of bugs in the above code; I have only proved it correct, not tried it. Donald E. Knuth
Learning Objectives
1. Combinational logic design.
2. Using bitwise logical and shifting operations in a high-level language like C+.
Work t
CS233
Lab 4
Handout
Learning Objectives
1. Sequential logic design
2. Register le implementation
Work that needs to be handed in (via SVN)
By the rst deadline
1. Complete a reader for L in l_reader.v and corresponding test cases in l_reader_tb.v. Just
as
CS233
Discussion Section 5
Solution
1. Write MIPS code for the following expression. Assume the following register allocation:
m = $12, n = $5, and p = $9.
m = n + (p | 0x7f);
$10, $9, 0x7f
$12, $5, $10
or
add
2. What MIPS instruction is encoded by the fo
CS233
Discussion section
Handout
For the following expression:
g(x, y) = (x0 + y)0
Draw a circuit for g(x,y):
Fill out a truth table for g(x, y). (Weve provided extra columns to compute x0 and x0 + y.)
x
0
0
1
1
y
0
1
0
1
g(x,y)
1
CS233
Discussion section
CS233
CS233
1
Discussion Section 10
Discussion Section 10
Handout
Handout
1 Warmup: Stalling vs. Forwarding
Warmup: Stalling vs. Forwarding
Suppose we have the following chunk of code containing only R-type instructions.
Suppose we have the following chun
Exam 6: Pipelining, Cache Analysis, and Cache Conscious Programming
Performance: latency vs. bandwidth, speedup, CPU iron law, CPI, computing clock cycle
time
Pipelining: true data dependences, structural/data/control dependences, implementing
pipelinin
CS232
Discussion 12: Cache Coherence
CS233
Discussion Section 15
Handout
Problem 1
The Modified-Shared-Invalid (MSI) protocol maintains the following invariant:
Given the following
state
of isa always
multi-core
computer,
write the
Each block of
memory
in
CS233
Discussion section
Handout
For the following expression:
g(x, y) = (x0 + y)0
Draw a circuit for g(x,y):
x
NOT
OR
y
NOT
(x+y)
Fill out a truth table for g(x, y). (Weve provided extra columns to compute x0 and x0 + y.)
x
0
0
1
1
y
0
1
0
1
x0
1
1
0
0
x
CS233
MIPS introduction
See, its not magic. Im like the anti-Harry Potter. Craig Zilles
Preliminaries
1. You have the following files in your SVN in a directory called QtSpimExercise: max.c,
max.s and max_test.s.
2. Set your editors tab width to 8 spaces,
AYD week 11 solution
Calculate the number of cycles from the fetch of the first instruction to the writeback of the last
instruction for the following code on the 5-stage pipeline from lecture (full forwarding, branches
predicted not taken and resolved in
Number Systems II:
2sComplement,Arithmetic,Overflow,&
WritingBitwiseLogical&ShiftingCode
Logic and arithmetic are two primary ways of
manipulating stored state
Computercando2things
1) Storestate(Howdoweinterpretstoredbits?)
2) Manipulatestate(Howdoweperfo
Computing components from ALU1
XOR In
gate A,B
Out
Delay
out
30ps
Full In Out
Adder A,B Sum
What is the worst cast propagation delay from B to out?
(consider both arithmetic and logic operations)
A: 120ps
B: 150ps
C: 160ps
D: 170ps
E: 190ps
Delay
60ps
Cin
Building an Arithmetic
Machine
Todays lecture
TheArithmeticMachine
Programmablehardware
InstructionSetArchitectures(ISA)
Instructions&Registers
AssemblyLanguage
MachineLanguage
Building an arithmetic machine
WithanALUandaregisterfile,wecanbuildacal