程序代写代做代考 compiler assembler arm assembly Embedded Systems Design

Embedded Systems Design

Motivation
If you are interested in hardware

Somebody has to build them!

(Almost) all engineered systems have a microcontroller core

Low level software is specialized ($$)

1

Motivation
If you are interested in software

Understanding what’s under the hood

Dealing with size and speed restrictions

Low level software is specialized ($$)

2

Motivation
If you are interested in systems

Selecting the right microcontroller can make a project easy

Selecting the wrong microcontroller can make a project impossible or very, very expensive

Low level software is specialized ($$)

3

Levels of Abstraction
High-level Language
Assembly code (mnemonics)
Machine code (1s and 0s)
Hardware (registers, buses, FSM…)
Compiler
Assembler
Digital Logic
ECE 3375

4

The whole course…

This is a “computer” (the thing on your desk)

5

…in one picture
This is a microcontroller(the whole computer, in one chip)

6

Review of some basics
A bit is a binary digit, either 0 or 1. They are usually physically encoded as low voltage (0) and high voltage (1), although other encodings are possible.

An N-bit binary number is a collection of N binary digits bi
with the following property:

Basically, binary numbers encode place values as powers of two.

7

Review of some basics
A hexadecimal (hex) number encodes a base sixteen, system. Individual digits can take values 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F which correspond to (digital) 0-15.

An N-bit hex number is a collection of N hex digits hi
with the following property:

Hex numbers encode place values as powers of sixteen

8

Review of some basics
There is a straightforward mapping between binary and hex. A
group of four bits is called a nibble. Each nibble corresponds
to a single hex digit, as follows:

Hex Bin Dec Hex Bin Dec
0 0000 0 8 1000 8
1 0001 1 9 1001 9
2 0010 2 A 1010 10
3 0011 3 B 1011 11
4 0100 4 C 1100 12
5 0101 5 D 1101 13
6 0110 6 E 1110 14
7 0111 7 F 1111 15

9

Review of some basics
A two hex digit number (made up of two nibbles) is called a
byte and encodes the decimal values 0-255. (We will also use
the terms word, K, M and so on, but let’s leave that for later).

It is straightforward to go from hex to and from decimal; or
from binary to and from decimal, but it is cumbersome to do
by hand and (more important) rarely useful.

The transition from hex to and from binary, however, is easy, often useful and is something you should memorize.

10

Binary Coded Decimal
There is another way of coding binary numbers that you will
encounter in this course, and that is binary coded decimal
(BCD). BCD numbers use each nibble to encode one decimal
digit, rather than one hex digit. In BCD, the number
0110 0011 encodes the value decimal 63, and not hex 63
(decimal 99).

BCD is a less compact way to store numbers (eight bits can
encode only 0-99) and makes addition complicated (the carry
from the first column to the second is unnatural and has to be
forced).

There is no way to tell a BCD value from a standard binary
value, unless you already know which one it is.

11

Aside: The Y2K Mystery
Suppose we get into the habit of storing the year as a one byte number because it’s the 1970s, bits are expensive, and we’re cheap and lazy

What happens when we wrap from 1999 (99) to 2000 (100)?
99
(63H 0110 0011)
(64H 0110 0100)
100

So what was the fuss about, again?
Most of the answer is BCD, which is common in legacy financial systems. There were even cases of senior citizens, born in 1897, losing their pensions (temporarily) because they became babies again in 1998.

12

Negative Numbers
The most common way to store negative numbers is 2s
complement. 2s complement is typically taught in terms of a
“trick” (invert the bits and add one):

5 (0000 0101) becomes -5 (1111 1011)
39 (0010 0111) becomes -39 (1101 1001)

… and so on.

13

Negative Numbers
The trick works, but it’s better to understand that what you have done is give the highest order bit a negative place value

So, in our examples:
-5 (1111 1011) is actually -128 + 123 (0111 1011)
-39 (1101 1001) is actually -128 + 89 (0101 1001)

14

Important take-away
Suppose your computer’s memory stores this binary number: 1001 0110 (96H).
Is it:

?

The answer is that there is no way to tell. They all look the same to the computer. WE impose the meaning by what we do with it.

15

Limitations
Binary representations in computing always cause the exciting
prospect of overflow, because they have finite width.

In unsigned representations, the number following 255
(=0xFF=11111111) requires nine bits to represent. If you are
only doing eight-bit math, the highest order bit is lost, and you
will roll over from 255 to 0 and carry-out the next bit.

Signed representations make the matter somewhat worse. The
number following 127 (0x7F=01111111) can be represented in
eight bits, but it is negative. In fact, it is the largest possible
negative number (-128). This can be disastrous in practice.
Note that this is an arithmetic overflow, but it is not a logical
carry-out.

16

Addition of binary numbers follows the following rules for
adding positive (P) and/or negative (N) numbers:

PP Two positives cannot cause carry-out. If their sum is
negative, the result is invalid.

NN Two negatives will always cause carry-out. If their sum is
positive, the result is invalid.

NP If the negative is larger, will not cause carry-out and will
have negative result. If the positive is larger, will cause
carry-out and have positive result. The result is always
valid.

17

Review of combinational logic
You probably remember AND gates:

18

Review of combinational logic
…and OR gates:

19

But you may have forgotten the concepts of minterms and
decoders. Basically, a minterm is a single AND function that
detects the presence of a binary number.

Consider the following Boolean Expression:

There are two ways to view this operation. We could say “the output is high if all four conditions A3 = 0, A2 = 1, A1 = 1 and A0 = 0 are met simultaneously”.

20

…OR, we could say, “This is a six-detector. It outputs high when the four-bit input A=6” We call this one minterm 6.

In this way, we associate one product (AND) term with each binary number, and call it a minterm. Minterm i is the name given to the product term that detects input i.

21

A decoder extends this concept. Basically, a decoder
(speaking generally) is a simple circuit that detects either a set
of numbers or a range of numbers. Consider this Boolean function:

Again, we have two choices. We could say “the output is high if A3=0 when A1=1 is high”.
OR…
We could say, “this circuit detects all numbers in the set {2,3,6,7} ({0010,0011,0110,0111})”. This is what you used to do with Karnaugh maps

22

Even more useful for us is the concept of detecting a range. Suppose we have the problem of detecting that a number falls anywhere between 0x8000-0xBFFF. Here’s a sampling of the set:
Hex Bin
0x8000 1000 0000 0000 0000
0x8001 1000 0000 0000 0001
0x8002 1000 0000 0000 0010
0x8003 1000 0000 0000 0011
… …
0xBFFC 1011 1111 1111 1100
0xBFFD 1011 1111 1111 1101
0xBFFE 1011 1111 1111 1110
0xBFFF 1011 1111 1111 1111

Circle A0

Circle A0

Circle A0

Circle A0

The detector is a giant OR gate that ORs together one minterm per value. Note that A0 and its complement always appear in pairs.

23

So, OK, A0 doesn’t matter. Well, what about A1?
Hex Bin
8000-8001 1000 0000 0000 000X
8002-8003 1000 0000 0000 001X
8004-8005 1000 0000 0000 010X
8006-8007 1000 0000 0000 011X
… …
BFF8-BFF9 1011 1111 1111 100X
BFFA-BFFB 1011 1111 1111 101X
BFFC-BFFD 1011 1111 1111 110X
BFFE-BFFF 1011 1111 1111 111X

Circle A1

Circle A1

24

So, OK, A1 doesn’t matter either. Well, what about A2?
Hex Bin
8000-8003 1000 0000 0000 00XX
8004-8007 1000 0000 0000 01XX
8008-800B 1000 0000 0000 10XX
800C-800F 1000 0000 0000 11XX
… …
BFF0-BFF3 1011 1111 1111 00XX
BFF4-BFF7 1011 1111 1111 01XX
BFF8-BFFB 1011 1111 1111 10XX
BFFC-BFFF 1011 1111 1111 11XX

Circle A2

Circle A2

There’s a pattern here.

25

We’re going to keep doing this until we get to:
Hex Bin
8000-8FFF 1000 XXXX XXXX XXXX
9000-9FFF 1001 XXXX XXXX XXXX
A000-AFFF 1010 XXXX XXXX XXXX
B000-BFFF 1011 XXXX XXXX XXXX

Circle A12

Circle A12

Hex Bin
8000-9FFF 100X XXXX XXXX XXXX
A000-BFFF 101X XXXX XXXX XXXX

Circle A13

…And finally:
In other words “Detect the range 0x8000-0xBFFF”, is IDENTICAL to, “find me all numbers with A15=1 and A14=0”. We will make heavy use of this concept

26

Review of sequential logic
There are a few basic items to remember. First, the flip-flop

A flip-flop is essentially a one-bit memory. It can be used to store a single bit of information.

It takes a snapshot of its input at the rising edge of the clock. The preset and reset (top and bottom) are asynchronous (independent of the clock) and usually used to put the flip-flop into a known state at reset

27

A collection of flip-flops sitting close together is a register. An N-bit register loads an N-bit value on a rising clock edge when LD=1.
Depending on context, it can be useful to think of an N-bit register as either storing an N-bit number, or N different bits grouped side-by-side for convenience. We will encounter both situations in the course.

Most registers are reset to zero, although in special cases, they may reset to any arbitrary value.

28

A special kind of register is a counter
Counters can be used as standard registers, if the count enable (EN)
is off (low).

If count enable is high, the register will count up
(increase its value by one) on every rising clock edge. When they reach their maximum value, counters typically wrap around to zero and emit a carry-out.

29

Here is a circuit you can build. What does it do?
Computer Bus Structures

In computing systems, we often have multiple sources for the same logical value. We need a special tool for this.

30

The circuit element we use is called a tri-state driver.
Basically, you can think of a tri-state signal as having three
possible outputs: HIGH, LOW, and high impedance (which
really means “SHUT UP”).

If en is high, then the output is the same as the input. If en is
low, then the output is essentially disconnected from the
input, allowing somebody else to drive the same line high or
low.

31

You may remember this board from digital logic.
Intro to the Lab

This is the Cyclone V.
It is BOTH an FPGA AND an ARM-derived microprocessor

32

In digital logic, you were using strictly the FPGA side to create digital logic circuits. In this course we will be writing programs to run on the ARM side, but take advantage of features on the FPGA side.

33

/docProps/thumbnail.jpeg