Docsity

Embedded Systems Programming, SHARC instruction set (21), Study notes of Embedded Systems Programming

Partial preview of the text

Download Embedded Systems Programming, SHARC instruction set (21) and more Study notes Embedded Systems Programming in PDF only on Docsity!

SHARC instruction set

 SHARC programming model.

 SHARC assembly language.

 SHARC memory organization.

 SHARC data operations.

 SHARC flow of control.

SHARC programming model

 Register files:

 R0-R15 (aliased as F0-F15 for floating

point)

 Status registers.

 Loop registers.

 Data address generator registers.

 Interrupt registers.

SHARC memory space

IOP registers 0x

forbidden normal word addressing short word addressing 0x 0x interrupt vectors

SHARC data types

 32-bit IEEE single-precision floating-

point.

 40-bit IEEE extended-precision

floating-point.

 32-bit integers.

 Memory organized internally as 32-

bit words.

SHARC mode registers

 Most important:

 ASTAT: arithmetic status.

 STKY: sticky.

 MODE 1: mode 1.

Rounding and saturation

 Floating-point can be:

 rounded toward zero;

 rounded toward nearest.

 ALU supports saturation arithmetic

(ALUSAT bit in MODE1).

 Overflow results in max value, not

rollover.

ALU/shifter status flags

ALU:

 zero, overflow, negative, fixed-point carry,

inputsign, floating-point invalid, last op

was floating-point, compare accumulation

registers, floating-point under/oveflow,

fixed-point overflow, floating-point invalid

Shifter:

 zero, overflow, sign

Flag operations

 All ALU operations set AZ (zero), AN

(negative), AV (overflow), AC (fixed-

point carry), AI (floating-point

invalid) bits in ASTAT.

 STKY is sticky version of some ASTAT

bits.

Multifunction computations

Can issue some computations in parallel:

 dual add-subtract;

 fixed-point multiply/accumulate and

add,subtract,average

 floating-point multiply and ALU operation

 multiplication and dual add/subtract

Multiplier operand from R0-R7, ALU

operand from R8-R15.

SHARC load/store

 Load/store architecture: no memory-

direct operations.

 Two data address generators (DAGs):

 program memory;

 data memory.

 Must set up DAG registers to control

loads/stores.

Data address generators

Provide indexed, modulo, bit-reverse

indexing.

MODE1 bits determine whether

primary or alternate registers are

active.

BASIC addressing

 Immediate value:

R0 = DM(0x20000000);

 Direct load:

R0 = DM(_a);! Loads contents of _a

 Direct store:

DM(_a)= R0;! Stores R0 at _a

Data in program memory

 Can put data in program memory to

read two values per cycle:

F0 = DM(M0,I0), F1 = PM(M8,I9);

 Compiler allows programmer to

control which memory values are

stored in.

Example: C assignments

 C:

x = (a + b) - c;

 Assembler:

R0 = DM(_a)! Load a R1 = DM(_b);! Load b R3 = R0 + R1; R2 = DM(_c);! Load c R3 = R3-R2; DM(_x) = R3;! Store result in x