Escolar Documentos
Profissional Documentos
Cultura Documentos
Tuesday, May 16
Flip-Flops and Sequential Circuits
Components of a Microcontroller
Register Model
Lecture #2 2
Important Resources for ECE251
Embedded Systems: Introduction to ARM Cortex-M
Microcontrollers, Jonathan Valvano, On reserve in Morgan
Embedded Systems: Real Time Interfacing to ARM Cortex-M
Microcontrollers, Jonathan Valvano. On reserve in Morgan
The Definitive Guide to Arm Cortex-M3 and Cortex-M4 Processors,
Joseph Yiu. Access to be determined.
Tiva TM4C123GH6PM Microcontroller Data Sheet (1409 pages)
Various other Reference Manuals, User Guides, and web page
references that can sometimes be helpful: found on ECE251 main
website.
Check the ECE251 website regularly to find more helpful
resources for the course.
Lecture #2 3
Flip-Flops
A key memory device in microprocessors is the flip-flop.
Remember: Flip-flops are clocked. Latches are not. Computers
use clocked circuits => flip-flops.
Q Q
J K
Clk
a0
a1
.
.
. Read/Write
aN-1 Clk
d0 d1 . . . dM-1
The above has N address lines and M data lines. The capacity of this
memory system is _________ bits.
Why the power of 2 for addresses, but not data?
Lecture #2 5
Sequential Circuits
Sequential circuits are logic circuits with memory (state), including
registers and/or memory cells
In Output Output
Logic
Memory
Clk
Hint: What are the two types, and what is the difference between them?
Lecture #2 6
Sequential Circuits continued
Another type of sequential circuit:
In
Next State
Sn
Logic Sn+1
Memory
Clk
Output
Output
Logic
Moore
Input
Output
State Next State
Mealy
Lecture #2 8
New Content: Computer Block Diagrams
Lecture #2 9
Features of the ARM Cortex M4 Microcontroller
(Specifically the TM4C123GH6PM that well be using)
Lecture #2 10
TM4C123GH6MP Block Diagram
So, where
is the CPU?
Lecture #2 11
TM4C123GH6MP Block Diagram
CPU
Lecture #2 12
Embedded System
Lecture #2 13
Samsung Gear Fit Fitness Tracker
Lecture #2 15
Semiconductor Memory
- Random access memory (RAM): same amount of time is
required to access any location on the same chip. Read/write.
- Read-only memory (ROM): can only be read; cannot be
written to directly by the processor
Read-Only Memory
- Mask-programmed read-only memory (MROM):
programmed when being manufactured
- Programmable read-only memory (PROM): the memory
chip can be programmed by the end user
Lecture #2 16
Erasable Programmable ROM (EPROM)
1. Electrically programmable many times
2. Erased by ultraviolet light (through a window)
3. Erasable in bulk (whole chip in one erasure operation)
Flash Memory
1. Electrically programmable many times
2. Electrically erasable many times
3. Can only be erased in bulk
Lecture #2 17
Computer Software
- Computer programs (programs) are known as software
- A program is a sequence of instructions
Machine Instruction
- A sequence of binary digits that can be executed by the processor
- Hard to understand, program, and debug for human being
- E.g. in the ARM Cortex M4, instruction 0010 0010 0110 0100 puts the
number 100 in register #2. How many bytes long is this instruction?
- OK, the instruction is also 0x2264. Does that help much? What is 0x64
in base 10?
So what might 0x22 be? Thats 0010 0010 or 00100 010. OK, 001002 is move
immediate and 0102 is register #2
Assembly Language
- Defined by machine instructions
- An assembly instruction is a mnemonic representation of a machine
instruction, e.g. ADD represents a register add (0001100)
- Assembly programs must be translated to binary before it can be executed:
Assembler does this translation:
ADD R2 R1 R0 0001100 010 001 000 = 0x1888
- In this course well be dealing with Assembly Language almost exclusively.
Lecture #2 18
High-level Language
- Syntax of a high-level language is similar to English
- A translator is required to translate the program written in a
high-level language -- done by a compiler
- High-level languages allow the user to work on the program logic
at a more conceptual level (e.g. you dont have to worry about
whats in register R2).
- Our textbook uses some C language examples, which are helpful if
you understand C, but is not necessary to this course.
Source Code
- A program written in assembly or high-level language
Object Code
- The output of an assembler or compiler--machine instructions
and data in binary (ones and zeroes) form.
Lecture #2 19
So Why Use Assembly Language in 251?
Writing software in a higher level language is more efficient
Employers want new engineers who are good with higher level
language coding
BUT
The goal of this course is understanding how processors work,
not writing large programs to do complex tasks
Assembly Language is a readable version of the instructions the
processor understands
Programming things like big register manipulation is actually
more straightforward in assembly language than in a high level
language (arguable point, but we arent going to argue about it!)
Employers also usually like engineers who understand well the
inner workings of the computers they are using
Lecture #2 20
ARM Cortex-M4 Registers
This is important!
Learn it!
Lecture #2 21
ARM Cortex-M4 Registers
Lecture #2 22
We will represent number bases with these prefixes
Base Prefix Example
binary 0b 0b10001010
octal @ @1234567
decimal 12345678
hexadecimal $0x 0x5678
or hex
Memory Addressing
- Memory consists of a sequence of directly addressable locations.
- A location is referred to as an information unit.
- A memory location can be used to store data and instructions.
- A memory location has two components: an address and its contents.
Address Contents
Lecture #2 23
Data transfers between the CPU and the memory are done over the
common buses: address bus and data bus.
E.g. [0x20] refers to the contents of memory location at address 0x20, i.e. at address 32.
E.g. [R1] refers to the contents of register R1; similarly with other registers.
Value Address means that the data value Value is stored at memory or register
address Address. E.g. 0x20 R1 means that the value 0x20 is placed in register R1.
What does 0xAB 0x2000 mean?
Lecture #2 24
Operation of a Computer (see Section 1.4 in text)
Computers execute programs instruction-by-instruction. Lets look at the execution of
instructions in detail:
0. Program counter register PC points to (i.e. contains the address of) the memory
location containing the next instruction to be executed. This counter will be updated to
point to the following instruction during or after execution of the current instruction.
1. Instruction Fetch: Using the current value of PC, read the next instruction to execute
from memory. Store this data in the instruction register, IR. That is: [[PC]] IR
PC is the name of the register;
[PC] is the address of the instruction to be executed;
[[PC]] is the instruction itself, contained at the memory address [PC].
Note that IR is an internal register, not accessible with computer instructions.
Lecture #2 27