0% found this document useful (0 votes)
121 views

Welcome To 6.004! Computation Structures

This document introduces MIT's 6.004 computation structures course for Spring 2021. It provides an overview of the course staff, a brief history of computing devices, and an outline of course topics including assembly language, digital design, computer architecture, and computer systems. It emphasizes that the course will teach students to design a simple processor from scratch using hardware description languages.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views

Welcome To 6.004! Computation Structures

This document introduces MIT's 6.004 computation structures course for Spring 2021. It provides an overview of the course staff, a brief history of computing devices, and an outline of course topics including assembly language, digital design, computer architecture, and computer systems. It emphasizes that the course will teach students to design a simple processor from scratch using hardware description languages.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Welcome to 6.004!

Computation Structures

Spring 2021
6.004 Course Staff

Instructors

Song Han Silvina Hanono Wachman Mengjia Yan


[email protected] [email protected] [email protected]

Teaching Assistants

Isabelle Miles Kendall Zack Soumya Sarah Catherine


Chong Dai Garner Pitcher Ram Spector Zeng

February 16, 2021 MIT 6.004 Spring 2021 L01-2


Computing Devices Then…

ENIAC, 1943 30 tons, 200KW, ~1000 ops/sec

February 16, 2021 MIT 6.004 Spring 2021 L01-3


Computing Devices Now

Typical 2020 laptop


1kg, 10W, 10 billion ops/s

February 16, 2021 MIT 6.004 Spring 2021 L01-4


An Introduction to the Digital World

Computer programs
Virtual machines
Computer systems
Operating systems, virtual memory, I/O
Instruction set + memory
Computer architecture
Processors, caches, pipelining
Digital circuits
Digital design
Combinational and sequential circuits
Bits, Logic gates
Devices
Materials
Atoms
February 16, 2021 MIT 6.004 Spring 2021 L01-5
The Power of Engineering
Abstractions
Good abstractions let us
reason about behavior while
shielding us from the details Virtual machines
of the implementation

Corollary: Implementation
technologies can evolve Instruction set + memory
while preserving the
engineering investment at
other levels Digital circuits

Leads to hierarchical design:


• Limited complexity at each
Bits, Logic gates
level ⇒ shorten design
time, easier to verify
• Reusable building blocks

February 16, 2021 MIT 6.004 Spring 2021 L01-6


Course Outline
§ Module 1: Assembly language
§ From high-level programming languages
to the language of the computer

§ Module 2: Digital design


§ Combinational and sequential circuits

§ Module 3: Computer architecture


§ Simple and pipelined processors
§ Caches and the memory hierarchy

§ Module 4: Computer systems


§ Operating system and virtual memory
§ Parallelism and synchronization

February 16, 2021 MIT 6.004 Spring 2021 L01-7


Our Focus: Programmable
General-Purpose Processors
§ Microprocessors are the basic building block of
computer systems
§ Understanding them is crucial even if you do not plan to
work as a hardware designer
§ Microprocessors are the most sophisticated digital
systems that exist today
§ Understanding them will help you design all kinds of
hardware

By the end of the term you will have


designed a simple processor from scratch!

February 16, 2021 MIT 6.004 Spring 2021 L01-8


We Rely on Modern Design Tools
§ We will use RISC-V, a simple
and modern instruction set

Minispec
source
§ We will design hardware
using Minispec, a new Minispec compiler
hardware description
Bluespec yosys
language built for 6.004 compiler synthesis
§ Based on Bluespec,
but heavily simplified
Compiled
Simulation circuit
(gates)

February 16, 2021 MIT 6.004 Spring 2021 L01-9


Course Mechanics
§ 2 lectures/week: slides, videos, and reference
materials on website
§ 2 recitations/week: work through tutorial problems
using skills and concepts from previous lecture

§ 7 mandatory lab exercises


§ Online submission + virtual check-off meetings
§ Due throughout the term (7 free late days meant to give
you flexibility, cover short illnesses, etc.; see website)
§ One optional open-ended design project
§ Due at the end of the term
§ 3 quizzes: Mar 18, Apr 22, May 13 (7:30-9:30pm
ET)
§ If you have a conflict, contact us to schedule a makeup
February 16, 2021 MIT 6.004 Spring 2021 L01-10
Lectures
§ Lectures are synchronous, through Zoom
§ Video recordings will be available on the website

§ Two ways of asking questions:


§ Unmute yourself and ask – for questions specific to lecture
§ Zoom chat – for relevant but less direct questions

§ If you can, please enable video J


§ Helps you stay engaged, helps us get to know you
and get nonverbal feedback like in an in-person lecture
§ Your video won’t appear on recordings, and recordings
won’t be publicly available

February 16, 2021 MIT 6.004 Spring 2021 L01-11


Recitations
§ 12 recitation sections on Wed & Fri
§ If you have a conflict with your assigned section,
or prefer the 9pm section, let us know via Piazza

§ Recitations
§ Solve tutorial problems with instructor or in small groups
§ You must watch the preceding lecture and attempt
a few short post-lecture problems before each recitation

§ Recitation participation is worth 5% of your grade


§ Everyone has 4 excused absences

§ You may opt out of recitation participation by Mar


19
§ If you opt out, that 5% of grade will come from quizzes
§ We believe recitations are the right choice for most of you
February 16, 2021 MIT 6.004 Spring 2021 L01-12
Grading
§ 80 points from labs,
20 points from design project,
90 points from quizzes,
10 points from recitation participation

§ Fixed grade cutoffs:


§ A: Points >= 165
§ B: Points >= 145
§ C: Points >= 125
§ F: Points < 125 or not all labs complete

February 16, 2021 MIT 6.004 Spring 2021 L01-13


Online Resources
§ The course website has up-to-date information,
handouts, and references to supplemental reading:
http://6004.mit.edu

§ We use Piazza extensively


§ Fastest way to get your questions answered
§ All course announcements are made on Piazza

§ We will hold regular virtual office hours to help you


with labs, infrastructure, and any other questions
§ Schedule and lab queue are available on the website

February 16, 2021 MIT 6.004 Spring 2021 L01-14


Binary Number Encoding
and Arithmetic

February 16, 2021 MIT 6.004 Spring 2021 L01-15


Digital Information Encoding
§ Digital systems represent and process information
using discrete symbols or digits

Voltage
1
§ These are typically binary digits
(bits): 0 and 1 0
Time

§ We can implement operations like +, >, AND, etc.


on binary numbers in hardware very efficiently

February 16, 2021 MIT 6.004 Spring 2021 L01-16


Encoding Positive Integers
It is straightforward to encode positive integers as
a sequence of bits. Each bit is assigned a weight.
Ordered from right to left, these weights are
increasing powers of 2. The value of an N-bit
number is given by the following formula:
%&' 211210 29 28 27 26 25 24 23 22 21 20
𝑣 = # 2" 𝑏" 0 1 1 1 1 1 0 1 0 0 0 0
"#$

What value does 011111010000 encode?


V = 0*211 + 1*210 + 1*29 + …
= 1024 + 512 + 256 +128 + 64 + 16 = 2000

Smallest number? 0 Largest number? 2N-1


February 16, 2021 MIT 6.004 Spring 2021 L01-17
Hexadecimal Notation
Long strings of bits are tedious and error-prone to transcribe,
so we often use a higher-radix notation, choosing the radix so
that it’s simple to recover the original bit string.

A popular choice is to transcribe numbers in base-16, called


hexadecimal. Each group of 4 adjacent bits is represented as a
single hexadecimal digit.

Hexadecimal - base 16 211210 29 28 27 26 25 24 23 22 21 20


0000 - 0 1000 - 8
0001 - 1 1001 - 9 0 1 1 1 1 1 0 1 0 0 0 0
0010 - 2 1010 - A
0011 - 3 1011 - B
0100 - 4 1100 - C
0101 - 5 1101 - D 7 D 0
0110 - 6 1110 - E
0111 - 7 1111 - F
0b011111010000 = 0x7D0

February 16, 2021 MIT 6.004 Spring 2021 L01-18


Binary Addition and Subtraction
§ Addition and subtraction in base 2 are performed
just like in base 10
Base 10 Base 2
carry
1 11 1 What does this mean?
14 1110 -23 + 0b110
+ 7 + 111 We need a way to
represent negative
21 1 0 10 1 numbers!
borrow
-1 -1-1-1 -1
14 1110 011
– 7 – 111 – 101
07 0 11 1 110
???
February 16, 2021 MIT 6.004 Spring 2021 L01-19
Binary Modular Arithmetic
§ If we use a fixed number of bits, addition and other
operations may produce results outside the range that
the output can represent (up to 1 extra bit for addition)
§ This is known as an overflow
§ Common approach: Ignore the extra bit
§ Gives rise to modular arithmetic: With N-bit numbers, equivalent
to following all operations with mod 2N
§ Visually, numbers “wrap around”:
Example: (3 – 5) mod 23 ?
0
000 0
7 1
7 000 1
111 001
111 001
6 + 2
6 2
110 – 010
110 010
5 3
5 3
101 4 011
101 4 011
100
100
February 16, 2021 MIT 6.004 Spring 2021 L01-20
Encoding Negative Integers
Attempt #1: Use a sign-magnitude representation for
decimal numbers, encoding the sign of the number
(using “+” and “-”) separately from its magnitude (using
decimal digits).
We could use the same approach for binary
representations:

1 1 1 1 1 1 0 1 0 0 0 0
“0” for “+”
“1” for “-”
=-2000

What issues might this encoding have?


Two representations for 0 (+0, -0)
Addition and subtraction use different algorithms
and are more complex than with unsigned numbers
February 16, 2021 MIT 6.004 Spring 2021 L01-21
Deriving a Better Encoding

Can you simply relabel some of the digits to


represent negative numbers while retaining the
nice properties of modular arithmetic?
Yes!
0
-1 7 000 1
111 001

-2 6 2
110 010
-3 5 3
101 -4 4 011
100 This is called two’s
complement encoding
February 16, 2021 MIT 6.004 Spring 2021 L01-22
Two’s Complement Encoding
In two’s complement encoding, the high-order bit of
the N-bit representation has negative weight:
N bits
!"'
𝑣 = −2!"#𝑏!"# + ' 2$ 𝑏$ -2N-1 2N-2 … … … 23 22 21 20
$%&

• Negative numbers have “1” in the high-order bit


• Most negative number? 10…0000 -2N-1
• Most positive number? 01…1111 +2N-1 - 1
• If all bits are 1? 11…1111 -1

February 16, 2021 MIT 6.004 Spring 2021 L01-23


Two’s Complement and Arithmetic
§ To negate a number (i.e., compute –A given A), we
invert all the bits and add one
Why does this work?
-A + A = 0 = -1 + 1
-A = (-1 – A) + 1

1 ...1 1
- An-1...A1A0
An-1...A1A0

§ To compute A-B, we can simply use addition and


compute A+(-B)
§ Result: Same circuit can add and subtract!
February 16, 2021 MIT 6.004 Spring 2021 L01-24
Two’s Complement Example
Compute 3 – 6 using 4-bit 2’s complement addition
§ 3: 0011 1
§ 6: 0110
0011
+ 1010
§ -6: 1010
1 10 1
Compute 3 – 2 using 3-bit 2’s complement addition
§ 3: 011 What does this 1 mean?
11
§ 2: 010 011 0
-1 000 1
§ -2: 110 + 110 111
-2
001
2
110 010
1 00 1 -3 3
101 -4 011
Keep only last 3 bits 100
Zero crossing
February 16, 2021 MIT 6.004 Spring 2021 L01-25
Summary
§ Digital systems encode information using binary for
efficiency and reliability

§ We can encode unsigned integers using strings of bits;


long addition and subtraction are done as in decimal

§ Two’s complement allows encoding negative integers


while preserving the simplicity of unsigned arithmetic

February 16, 2021 MIT 6.004 Spring 2021 L01-26


Post-Lecture Questions
6004.mit.edu > Material > Lectures > L1 questions

February 16, 2021 MIT 6.004 Spring 2021 L01-27


Thank you!

Next lecture:
Introduction to assembly language
and RISC-V

February 16, 2021 MIT 6.004 Spring 2021 L01-28

You might also like