![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
cpad-waltz(S5L840F) internet audio decoder for flash memory media data sheet 1 introduction S5L840F is a single chip digital audio player ic suppor ting various compressed audio format on flash memory media. S5L840F provides 2mbits of embedded nor flas h memory and 76kbytes of sram requiring no external memory. a 16bit risc processor (calmrisc16 tm ) and 24bit mac(mac2424 tm ) are provided as a cpu and dsp function. features ? supply voltage range: - supply voltage (core) : 1.8v - supply voltage (io) : 3.0v ? x-tal oscillator: 32.768 khz ? 16bit risc(calmrisc16) & 24bit mac with 4kb of instruction cache 6kb of x cache 6kb of y cache ? 2mbit nor flash & 76kb sram ? io dma ? supports smc/mmc/sd/memory stic ? lcd controller interface ? 2 channels of iis ? iic / spdif output / uart / spi ? usb1.1 ? 5 channel 10bit adc ? rtc ? gpio typical application ? mp3/wma/etc player ordering information device package operating temperature S5L840F 128-tqfp-1414 ?40 c ? +85 c
block diagram memory controller ahb to apb bridge io dm a 2mbit nor-flash calmadm 3 rtc timer clock gen gpio uart iic(m/s) spi iis out spdif out iis in sd/mmc i/ f smc i/f interrupt controller 10bit adc memory stick i/ f 76kb sram wdt 4kb rom 3 3 2 2 b b i i t t a a h h b b p p l l u u s s 3 3 2 2 b b i i t t a a p p b b lcd if usb1.1 cpad-waltz S5L840F 3 pin configuration 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 128 127 126 125 124 123 122 121 120 119 118 117 116 115 114 113 112 111 110 109 108 107 106 105 104 103 102 101 100 99 98 97 S5L840F (ver 35) 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 p3.1/clk_ms io6/p4.6 d0(ms)/io14/p5.6 io7/p4.7 bs(ms)/io15/p5.7 nre/p6.0 nce0/p6.1 nce1/p6.2 nce2/p6.3 cle/p6.4 ale/p6.5 nwe/p6.6 nwp/p6.7 sd1/p7.0 lrclk/p7.1 intvss4 intvdd4 sd0/p7.2 bclk/p7.3 mclk/p7.4 p10.0 p10.1 p10.2 p10.3 padvdd3 padvss3 intvss3 intvdd3 io4/p4.4 d2(sdc)/io12/p5.4 io5/p4.5 io13/p5.5 p10.6 p10.7 mosi/p1.0 miso/p1.1 spisck/p1.2 runst nreset intvdd5 scl/p1.3 sda/p1.4 nssi/p1.5 padvdd4 padvss4 clksel intvss6 intvdd6 vddpll0 vsspll0 cp0 vddpll1 vsspll1 cp1 avref avss adc0 adc1 adc2 adc3 adc4 p10.4 p10.5 intvss5 rx/p0.4 tx/p0.5 ld1 / p8.1 ld2 / p8.2 ld3 / p8.3 ld4 / p8.4 ld5 / p8.5 ld6 / p8.6 ld7 / p8.7 test2/ debug test1 test_clk tck tms tdi tdo intvss1 intvdd1 padvss1 padvdd1 exhv vcc3f nerr/ sdat/ eint4 / p1.6 sclk/ eint5 / p1.7 vddf vssf xout xin test0/ tool exhven ld0/p8.0 nrst_adm eint6/p0.6/sdwp intvss2 d1(sdc)/io8/p5.0 taout/p0.1 tcck/p0.2 eint7/p0.7/rbn padvdd2 padvss2 intvdd2 io0/p4.0 io1/p4.1 d0(sdc)/io9/p5.1 io2/p4.2 clk_mmc_sdc/p3.0 cmd(sdc)/io10/p5.2 io3/p4.3 ld_re/p9.0 ld_we/p9.1 ld_cs/p9.2 ld_reg/p9.3 ld_rst/p9.4 tack/tacap/p0.0 spdif/p0.3 d3(sdc)/io11/p5.3 eint2/p2.2 eint0/p2.0 eint1/p2.1 eint3/p2.3 dm dp vddusb vssusb pin description pin number pin assignment i/o pin description 1 test2/debug i debug(internal f/f value dump) control 2 test1 i test mode 3 test_clk(for debug) i test clock 4 tck i jtag clock. pull-up. 5 tms i jtag mode selection. pull-up. 6 tdi i jtag input 7 td0 o jtag output 8 exhv b flash high voltage test 9 vcc3f p flash memory internal 3.3v power. 10 nerr/eint4/p1.6 b uart, gpio 11 eint5/p1.7 b uart, gpio 12 vddf p flash memory internal 1.8v power. 13 vssf p gnd for flash core 14 xout o crystal oscillator signal (~100khz) 15 xin i crystal oscillator signal (~100khz) 16 test0/tool_mode i bus/serial controller selection. pull-down 17 exhven i flash high volatge test enable. pull-down 18 ld0/p8.0 b lcd i/f 19 ntrst_adm i adm reset. pull-up. 20 padvss1 p pad power gnd 21 padvdd1 p pad power vdd 3.3v 22 intvss1 p internal logic gnd 23 intvdd1 p internal logic power vdd 1.8v 24 ld1/p8.1 b lcd i/f cpad-waltz S5L840F 5 25 ld2/p8.2 b lcd i/f 26 ld3/p8.3 b lcd i/f 27 ld4/p8.4 b lcd i/f 28 ld5/p8.5 b lcd i/f 29 ld6/p8.6 b lcd i/f 30 ld7/p8.7 b lcd i/f 31 rx/p0.4 b int, gpio 32 tx/p0.5 b int, gpio 33 ld_re/p9.0 b lcd i/f 34 ld_we/p9.1 b lcd i/f 35 ld_cs/p9.2 b lcd i/f 36 ld_reg/p9.3 b lcd i/f 37 ld_rst/p9.4 b lcd i/f 38 tack/tacap/p0.0 b timer a, gpio 39 taout/p0.1 b timer a, gpio 40 tcck/p0.2 b timer c, gpio 41 spdif/p0.3 b spdif, gpio 42 eint6/p0.6/sdwp b int, gpio, sdc_wp 43 eint7/p0.7/rbn b int, gpio, rbn(smc) 44 padvdd2 p pad power vdd 3.3v 45 padvss2 p pad power gnd 46 intvss2 p internal logic gnd 47 intvdd2 p internal logic power vdd 1.8v 48 eint0/p2.0 b int, gpio 49 eint1/p2.1 b int, gpio 50 eint2/p2.2 b int, gpio 51 eint3/p2.3 b int, gpio 52 dm b usb transceive/receive port 53 dp b usb transceive/receive port 54 vddusb p usb power 3.3v 55 vssusb p usb ground 56 io0/p4.0 b io0 for smc /debug scan in 57 d1(sdc)/io8/p5.0 b io8 for smc, d0 for sdc 58 io1/p4.1 b io1 for smc 59 d0(sdc)/io9/p5.1 b io9 for smc, d1 for sdc 60 io2/p4.2 b io2 for smc 61 clk_mmc_sdc/p3.0 b clk for mmc/sdc 62 cmd(sdc)/io10/p5.2 b io10 for smc, cmd/resp for sdc 63 io3/p4.3 b io3 for smc 64 d3(sdc)/io11/p5.3 b io11 for smc, d3 for sdc 65 padvdd3 p pad power vdd 3.3v 66 padvss3 p pad power gnd 67 intvss3 p internal logic gnd 68 intvdd3 p internal logic power vdd 1.8v 69 io4/p4.4 b io4 for smc 70 d2(sdc)/io12/p5.4 b io12 for smc, d2 for sdc 71 io5/p4.5 b io5 for smc 72 io13/p5.5 b io13 for smc 73 p3.1/clk_ms b gpio, clk for ms 74 io6/p4.6 b io6 for smc 75 d0(ms)/io14/p5.6 b io14 for smc, d0 for ms 76 io7/p4.7 b io7 for smc cpad-waltz S5L840F 7 77 bs(ms)/io15/p5.7 b io15 for smc, bs for ms 78 nre/p6.0 b smc control 79 nce0/p6.1 b smc control 80 nce1/p6.2 b smc control 81 nce2/p6.3 b smc control 82 cle/p6.4 b smc control 83 ale/p6.5 b smc control 84 nwe/p6.6 b smc control /debug scan out 85 nwp/p6.7 b smc control 86 sd1/p7.0 b serial data in for iis 87 lrclk/p7.1 b left-right clock for iis 88 intvss4 p internal logic gnd 89 intvdd4 p internal logic power vdd 1.8v 90 sd0/p7.2 b serial data out for iis 91 bclk/p7.3 b bit clock for iis 92 mclk/p7.4 b over-sampling clock for iis 93 p10.0 b gpio 94 p10.1 b gpio 95 p10.2 b gpio 96 p10.3 b gpio 97 avref p adc vref,avdd33a1,avdd33a2 ?? . 3.3v power 98 avss p adc analog gnd. avss33a1,avbb33a1,avss33a2 99 adc0 i adc 100 adc1 i adc 101 adc2 i adc 102 adc3 i adc 103 adc4 i adc 104 p10.4 b gpio 105 p10.5 b gpio 106 p10.6 b gpio 107 p10.7 b gpio 108 mosi/p1.0/tclk0 b spi, gpio, tclk0(not open) 109 miso/p1.1/tclk1 b spi, gpio, tclk1(not open) 110 spisck/p1.2 b spi, gpio 111 runst b jtag runid / test mode select 112 nreset i system reset. pull-up. 113 intvss5 p internal logic gnd 114 intvdd5 p internal logic power vdd 1.8v 115 scl/p1.3 b iic, gpio 116 sda/p1.4 b iic, gpio 117 nssi/p1.5 b spi, iic, uart 118 padvdd4 p pad power vdd 3.3v 119 padvss4 p pad power gnd 120 clksel i clock selection signal. pull-up. 121 intvss6 p internal logic gnd 122 intvdd6 p internal logic power vdd 1.8v 123 vddpll0 p pll power supply vdd 1.8v 124 vsspll0 p pll gnd 125 cp0 o low pass filter circuit for pll0 126 vddpll1 p pll power supply vdd 1.8v 127 vsspll1 p pll gnd 128 cp1 o low pass filter circuit for pll1 cpad-waltz S5L840F 9 absolute maximum ratings characteristic symbol value unit supply voltage vdd 3.8 v input voltage vin 6.5 v storage temperature range tstg -65?150 c electrical characteristics recommended operating conditions characteristic symbol value unit supply voltage vdd 1.65~1.95(core), 2.7~3.3(io) v operating temperature range topr -40?85 c dc characteristics (ta = 25 c, vdd(io) = 3.3v, unle ss otherwise specified) symbol characteristic test conditions min typ max unit vih high level input voltage ? 2.0 ? ? v vil low level input voltage ? ? ? 0.8 v vt switching threshold 1.4 v vt+ schmitt trigger, positive ?going threshold cmos 2.0 v vt- schmitt trigger, negative-going threshold cmos 0.8 v voh high level output voltage ioh = -2ma 2.4 ? ? v vol low level output voltage iol = 2ma ? ? 0.4 v ioz tri-state output leakage current vout = vss or gnd -10 ? 10 a notes: package dimensions low-power & high-performance risc core calmrisc16 technical reference manual mcu team lsi division system lsi business samsung electronics co. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 2 - mcu team lsi division system lsi business april 2000 1. introduction 1.1 feature the main features of calmrisc 16, a 16-bit embedded risc mcu core, are high performance, low power consumption, and efficient coprocessor interface. it can operate up to 100mhz, and consumes 100 a/mhz @3.3v. when operating with mac2424, a 24-bit fixed point dsp coprocessor, calmrisc16 can operate up to 80mhz. through effici ent coprocessor interface, calmrisc16 provides a powerful and flexible mcu+dsp solution. the following gives brief summary of main features of calmrisc16. ? h/w feature - power consumption : 100 a per mhz @3.3v, 0.35 process - maximum frequency : 100mhz @3.3v - 0.78 mm 2 die size ? architecture - harvard risc architecture - 5-stage pipeline ? registers - sixteen 16-bit general registers - eight 6-bit extension registers - 22-bit program counter (pc) - 16-bit status register (sr) - seven saved registers for interrupts. ? instruction set - 16-bit instruction width for 1-word instructions - 32-bit instruction width for 2-word instructions - load/store instruction architecture - delayed branch support - c-language/os support - bit operation for i/o process ? instruction execution time - one instruction/cycle fo r basic instructions ? address space - 4m byte for program memory - 4m byte for data memory excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 3 - mcu team lsi division system lsi business april 2000 1.2. registers in calmrisc16 there are sixteen 16-bit general registers, eight 6-bit extension registers, a 16-bit status register(sr), a program counter (pc), and seven saved registers. general registers & extension registers the following figure shows the st ructure of the general registers and the extension registers. the general registers (from r0 to r15) can be either a source register or a destination register for almost all alu operations, and can be used as an inde x register for memory load/store instructions (e.g., ldw r3, @[a8+r2]). the 6-bit extension registers (from e8 to e15) are used to form a 22-bit address register (from a8 to a15) by concatenating with a general register (from r8 to r15). the address registers are used to generate 22-bit program and data addresses. special registers the special registers consist of 16-bit sr (status register), 22-bit pc (program counter), and saved registers for irq(interrupt), fiq(fast interrupt), and swi(software interrupt). when irq interrupt occurs, the most significant 6 bits of the return address are saved in spch_irq, the least significant 16 bits of r0 r1 r7 r8 r9 r14 r15 address registers registers for byte stack pointer link register e15 e14 e9 e8 pc sr spc_fiq spc_irq ssr_fiq ssr_irq ssr_swi register structure in calmrisc16 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 4 - mcu team lsi division system lsi business april 2000 the return address are saved in spcl_irq, and the status register is saved in ssr_irq. when fiq interrupt occurs, the most significant 6 bits of th e return address are save d in spch_fiq, the least significant 16 bits of the return address are saved in spcl_fiq, and the status register is saved in ssr_fiq. when a swi instruction is executed, the return address is saved in a14 register (e14 concatenated with r14), and the status register is saved in ssr_swi. the least significant bit of pc, spcl_irq and spcl_fiq is read only and its value is always 0. the 16-bit register sr has the following format. 15 8 7 0 t - - - - - - - - pm z1 z0 v te ie fe ? fe : fiq enable bit, fiq is enabled when fe is set. ? ie : irq enable bit, irq is enabled when ie is set. ? te : trq enable bit, trace is enabled when te is set. ? v : overflow flag, set/clear accordingly wh en arithmetic instructions are executed. ? z0 : zero flag of r6, set when r6 equals zero and used as the branch condition when bnzd instruction with r6 is executed. ? z1 : zero flag of r7, set when r7 equals zero and used as the branch condition when bnzd instruction with r7 is executed. ? pm : privilege mode bit. pm = 1 for privilege mode and pm = 0 for user mode ? t : true flag, set/clear as a result of an alu operation. fe, ie, te, and pm bits can be modified only when pm = 1 (privilege mode). the only way to change from user mode to privilege mode is via interrupts including swi instructions. the reserved bit of sr (from bit 7 to bit 14) can be used for other purposes without any notice. hence programmers should not depend on the value of the reserved bits in their programming. the reserved b its are read as 0 value. 1.3. pipeline structure calmrisc16 has a 5-stage pipeline architecture. it take s 5 cycles for an instruc tion to do its operation. in a pipeline architecture, instructions are executed overlapped, hence the throughput is one instruction per cycle. due to data dependency, control dependen cy, and 2 word instructions, the throughput is about 1.2 on the average. the following diagra m depicts the 5-stage pipeline structure. if id ex mem wb in the first stage, which is called if (instruction fe tch) stage, an instruction is fetched from program excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 5 - mcu team lsi division system lsi business april 2000 memory. in the second stage, which is called id (inst ruction decoding) stage, th e fetched instruction is decoded, and the appropriate operands, if any, for alu operation are prepared. in the case of branch or jump instructions, the target address is calculated in id stage. in the third stage, which is called ex (execution) stage, alu operation and data address calcu lation are executed. in the fourth stage, which is called mem (memory) stage, data transfer from/to data memory or program memory is executed. in the fifth stage, which is called wb (write back) stage, a write-back to register file can be executed. the following figure shows an example of pipeline prog ress when 3 consecutive inst ructions are executed. i1 : add r0, 3 if id ex mem wb i2 : add r1, r0 if id ex mem wb i3 : ld r2, r0 if id ex mem wb in the above example, the instructio n i2 needs the result of the instruction i1 before i1 completes. to resolve this problem, the ex stage result of i1 is forwarded to id stage of i2. similar forwarding mechanism occurs from mem stag e of i1 to id stage of i3. the pipeline cannot progress (called a pipeline stall) due to a data dependency, a control dependency, or a resource conflict. when a source operand of an alu instruction is from a register, which is loaded from memory in the previous instruction, 1 cycle of pipeline stall occurs (called load stall). such load stalls can be avoided by smart reordering of the instruction sequences. calmrisc16 has 2 classes of branch instructions, those with a delay slot and without a delay slot. non-delay slot branch instructions incurs a 1 cycle pipeline stall if the branch is taken, due to a control depend ency. for branch instructions with a delay slot, no cycle waste is incurred if the delay slot is filled with a useful instruction (or non nop instruction). pipeline stalls due to resource conflicts occurs when two different instructions access at the same cycle the same resource such as the data memory and the program memory. ldc (data load from program memory) instruction causes a resource conflict on the program memory. bit operations such as bitr and bits (read-modify-write instructions) caus e a resource conflict on the data memory. 1.4 interrupts in calmrisc16, there are five interrupts: reset, fiq, irq, trq, swi. the reset, fiq, and irq interrupts correspond to external requests. trq an d swi interrupts are initiated by an instruction (therefore, in a deterministic way). the follo wing table shows a summary of interrupts. name priority address description reset 1 000000h hardware reset fiq 3 000002h fast interrupt request excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 6 - mcu team lsi division system lsi business april 2000 irq 5 000004h interrupt request trq 2 000006h trace request swi 4 000008h ~ 0000feh software interrupt when nres (an input pin calmrisc16 core) signal is released (transition from 0 to 1), ?jmp addr:22? is automatically executed by calmrisc16. among the 22-bit address addr:22, the most significant 6 bits are forced to 0, and the least signifi cant 16 bits are the contents of 000000h (i.e., reset vector address) of the program memory. in other words, ?jmp {6?h00 1 , pm[000000h]}? instruction is forced to the pipeline. the initial value of pm bit is 1 (that is, in privilege mode) and the initial values of other bits in sr register are 0. all other registers are not initialized (i.e., unknown). when nfiq (an input pin calmrisc16 core) signal is active (transition from 1 to 0), ?jmp addr:22? instruction is automatically executed by calmrisc16. the address of fiq interrupt service routine is in 000002h (i.e., fiq vector address) of the program memory (i.e., ?jmp {6?h00, pm[000002h]}?). the return address is saved in {spch_fiq, spcl_fiq} register pair, and the sr value is saved in ssr_fiq register. pm bit is set. fe, ie, and te bits are cl eared. when ret_fiq instruction is executed, sr value is restored from ssr_fiq, and the return address is restored into pc from {spch_fiq, spcl_fiq}. when nirq signal (an input pin calmrisc16 core) is active (transition from 1 to 0), ?jmp {6?h00, pm[000004h]}? instruction is forced to the instru ction pipeline. the return address is saved in {spch_irq, spcl_irq} register pair, and the sr value is saved in ssr_irq register. pm bit is set. ie and te bits are cleared. when ret_ irq instruction is executed, sr value is restored from ssr_irq, and return address is restored to pc from {spch_irq, spcl_irq}. when te bit is set, trq interrupt happens and ?jmp {6?h00, pm[000006h]}? instruction is executed right after each instruction is executed. trq inte rrupt uses the saved registers of irq(that is, {spch_irq, spcl_irq} register pa ir and ssr_irq) to save the return address and sr, respectively. pm bit is set. ie, te bits are cleared. when ?swi imm:6 2 ? instruction is executed, the return address is saved in the register a14, and the value of sr is saved in ssr_swi. then the program sequence jumps to the ad dress (imm:6 * 4). pm bit is set. ie and te bits are cleared. ?swi 0? and ?swi 1? are prohibited because the addresses are reserved for other interrupts. when ret_swi instruction is executed, sr is restored from ssr_swi, and the return address is restored to pc from a14. 1.5 memory formats 1 6?h00 is defined as 00 (or zero) in 6 bits 2 imm:6 is defined as 6-bit immediate number excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 7 - mcu team lsi division system lsi business april 2000 calmrisc16 adopts a big endian memory format . in a big endian memory format, the most significant byte of word data is stored at an even addr ess, and the least significant byte is stored at an odd address. for example let us assume that the word data ?1234h? is stored at the address 100h. then the higher byte ?12h? is stored at th e address 100h, and the lower byte ?34h? is stored at the address 101h. when the 22-bit data ?123456h? is stored at the addr ess 100h by ?ldw @an, ai? instruction, ?00h? is at the address 100h, ?12h? is at the ad dress 101h, ?34h? is at the address 102h, and ?56h? is at the address 103h. 1.6 signal description name direction description pa[20:0] o program memory address, equivalent to pc[21:1] pd[15:0] i program data npmcs o program memory chip selection nldc o data load from program memory indicator da[21:0] o data memory address da[4:0] is shared with sys and cld instructions di[15:0] i input from data memory, input from coprocessor for cld instruction. do[15:0] o output to data memory, output to coprocessor for cld instruction. ndmcsh o chip selection for higher byte data memory ndmcsl o chip selection for lower byte data memory dmwr o data memory write, 1 means transfer from core to memory ndme o data bus enable signal. nres i hardware reset nfiq i fast interrupt request nirq i interrupt request nexpack o exception acknowledge nwait i wait signal, core is stopped when active. nsysid o sys instruction indicator mclk i main clock input eclk o early clock output iclk o clock output ncopid o coprocessor instruction indicator ncldid o coprocessor load instruction indicator cldwr o write to coprocessor indicator excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 8 - mcu team lsi division system lsi business april 2000 copir[12:0] o instruction to coprocessor, 13-bit immediate field in cop instruction. ec[3:0] i external conditions from coprocessor or peripherals. nbrk o software break indicator nbkack o break acknowledge bkmode[2:0] o break mode, indicates core state when core breaks. bkreq i break request ngidis i global interrupt disable, wh en active, all interrupt is disabled. pdgrant i indicates program memory access is permitted. pdwait i indicates cu rrent program memory access is not complete. dbgrant i indicates data memory access is permitted. dbwait i indicates current data memory access is not complete. dbreq o signal asking for data bus permission. pmode o privilege mode indicator cgrant o indicates that coprocessor may use data bus. cstall i coprocessor indicates that coprocessor pipeline stall occurs. cmw i coprocessor indicates that copr ocessor instruction is multiple word. nseq o indicates that the next program address is sequential. nincpc i if it is 1, pc value is not incremented when sequential execution. cclk o clock output to coprocessor 2. instructions 2.1. alu instructions in operations between a 16-bit general register an d an immediate value, th e immediate value is zero- extended to 16-bit. the following figure sh ows an example of 7-b it immediate numbers. 7-bits immediate 7-bits immediate '0' imm:7 15 7 60 in operations between a 22-bit register and an imme diate value, the immediate value is zero-extended to excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 9 - mcu team lsi division system lsi business april 2000 22-bit. in operations between a 22-bit register and a 16 -bit register, the 16-bit register is zero-extended to 22-bit. the overflow flag in a 16-bit arithmetic ope ration is saved to v flag in sr register. alu instructions are classified into 3 classes as follows. ? aluop register, immediate ? aluop register, register ? aluop register aluop register, immediate add/adc/sub/sbc/and/or/xor/tst/cmp/cmpu rn, #imm:16 the instructions perform an alu operation of which source operands are a 16-bit general register rn and a 16-bit immediate value. in the in structions tst/cmp/cmpu, only t fl ag is updated accordingly as the result. in the instructions add/adc/sub/sbc, the value of t flag is the carry flag of the operations, and the value of v flag indicates whether overflow or underflow occurs. in the instructions and/or/xor/tst, the value of t fl ag indicates whether the result is zero (t=1). ?cmp {gt|ge|eq}, rn, #imm:16 3 ? instructions are for signed comparison opera tions (gt for greater than, ge for greater than or equal to and eq for equal to), and ?cmpu {gt|ge}, rn, #imm:16? instructions are for unsigned comparison operations. add/sub an, #imm:16 the immediate value is zero-extended to 22-bit value. no flag update occurs. add/sub rn, #imm:7 the immediate value is zero-extended to 16-bit value. t flag is updated to the carry of the operation. v flag is updated. and/or/xor/tst r0, #imm:8 the immediate value is zero-extended to 16-bit value. t flag indicates whether the lower 8-bit of the logical operation result is zero. cmp eq, rn, #imm:8 the immediate value is zero-extended to 16-bit value. rn is restricted to r0 to r7. t flag is updated as the result of the instruction. 3 imm:16 is defined as a 16-bit immediate number excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 10 - mcu team lsi division system lsi business april 2000 cmp ge, rn, #imm:6 the immediate value is zero-extended to 16-bit value. the instruction is for signed compare. t flag is updated as the result of the instruction. add/sub an, #imm:5 the immediate value is zero-extended to 22-bit value. no flag is updated. aluop register, register add/sub/adc/sbc/and/or/xor/tst/cmp/cmpu rn, ri the instructions perform an alu operation of which source operands are a pair of 16-bit general registers. in the instructions tst/cmp/cmpu, only t flag is updated as the result. in the instructions add/adc/sub/sbc, the value of t flag is the carry of the operations, and the value of v flag indicates whether overflow or underflow occurs. in the instructions and/or/xor/tst, the value of t flag indicates whether the result is zero. ?cmp {gt|ge|e q}, rn, ri? instructions are for signed comparison, and ?cmpu {gt|ge}, rn, ri? instruc tions are for unsi gned comparison. add/sub an, ri 16-bit general register ri is zero-extended to 22-bit value. the result is saved in the 22-bit register an. no flag update occurs. cmp eq, an, ai the instruction compares two 22-bit registers. mul {ss|su|us|uu}, rn, ri the general registers rn and ri can be one of r0 to r7. the instruction multiplies the lower byte of rn and the lower byte of ri, and the 16-bit result is saved in rn. the optional field, ss, su, us, and uu, indicates whether the source operands are signed value or unsigned value. the first letter of the two letter qualifiers corresponds to rn, and the second correspond s to ri. for example, in the instruction ?mul su, r0, r1?, the 8-bit signed value in the lower byte of r0 and the 8-bit unsigned value in the lower byte of r1 are multiplied, and the 16-bit result is saved in r0. rr/rl/rrc/sr/sra/slb/srb/dt/inc c/decc/com/com2/comc/ext rn for ?dt rn?(decrement and test) and ?com rn?(comp lement) instructions, t flag indicates whether the result is zero. in the instruction of ?ext rn?(sign extend), no flag update occurs. in all other instructions, carry-out of the operation is transferred to t flag. in the instruction of dt, incc, and decc, excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 11 - mcu team lsi division system lsi business april 2000 v flag indicates whether overflow or underflow occurs. 2.2. load instructions ? load instructions? move data from register/memory/immediate to register/memory. when the destination is a memory location, only general regist ers and extension registers can be the source. we can classify ?load instructions? into the following 4 classes. ? ld register, register ? ld register, immediate ? ld data memory, register / ld register, data memory ? ld register, program memory ld register, register ld rn, ri / ld an, ai the instructions move 16-bit or 22-bit data from the so urce register to the des tination register. when the destination register is r6/r7, the zero flag z0/z1 is updated. in all other cases, no flag update occurs. ld rn, ei / ld en, ri in the instruction ?ld rn, ei?, the 6-bit data in ei is zero-extended to 16-bit data, and then transferred to rn. when the destination register is r6/r7, the zero fl ag z0/z1 is updated. in the instruction ?ld en, ri?, least significant 6 bits of ri ar e transferred to en. rn/ri is one of the registers from r0 to r7. ld r0, spr / ld spr, r0 spr : sr, spcl_fiq, spch_fiq, ssr_fiq, spcl_irq, spch_irq, ssr_irq, ssr_swi the instructions transfer data betw een spr (special purpose registers) and r0. no flag update occurs except the case that the destination register is sr. ld an, pc the instruction moves the value of (pc+4) to an. ld register, data memory / ld data memory, register ldw rn, @[sp+edisp:9] / ldw @[sp+edisp:9], rn the instructions transfer 16-bit da ta between a general register rn an d the memory location at the address of (sp+edisp:9). note sp is another name of a15. edisp:9 is an ev en positive displacement from 0 to 510. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 12 - mcu team lsi division system lsi business april 2000 edisp:9 is encoded into an 8-bit displacement value in the instruction map because the lsb is always 0. when the address is calculated, the 8- bit displacement field is shifted to the left by one bit, and then the result is added to the value of sp. even if the addr ess might be specified as odd in assembly mnemonic, the lsb of the address should be trun cated to zero for word alignment. ldw rn, @[ai+edisp:5] / ldw @[ai+edisp:5], rn the instructions transfer 16-bit da ta between a general register rn an d the memory location at the address of (ai+edisp:5). edisp:5 is an even positive displacement from 0 to 30. edisp:5 is encoded into an 4-bit displacement value in the instructio n map because the lsb is always 0. when the address is calculated, the 4-bit displacement field is shifted to the left by one bit, and then the result is added to the value of ai. even if the address might be specified as odd in assembly mnemonic, the lsb of the address should be truncated to zero fo r word alignment. ldw rn, @[ai+disp:16] / ldw @[ai+disp:16], rn the instructions transfer 16-bit da ta between a general register rn an d the memory location at the address of (ai+disp:16). disp:16 is an positive displacement from 0 to ffffh. if the address is odd, the lsb of the address is set to zero for word alignment. ldw rn, @[ai+rj] / ldw @[ai+rj], rn the instructions transfer 16-bit da ta between a general register rn an d the memory location at the address of (ai+rj). the value of rj is zero-extended to 22-bit value. if the address is odd, the lsb of the address is set to zero for word alignment. ldw an, @[ai+edisp:5] / ldw @[ai+edisp:5], an the instructions transfer 22-bit data between an ad dress register an and th e memory location at the address of (ai+edisp:5). edis p:5 is an even positive displacement from 0 to 30. edisp:5 is encoded into an 4-bit displacement value in the instruction map b ecause the lsb is always 0. when the address is calculated, the 4-bit displacement field is shifted to the left by one bit, and then the result is added to the value of ai. even if the address might be specified as odd in assembly mnemoni c, the lsb of the address should be truncated to ze ro for word alignment. ldw an, @[ai+disp:16] / ldw @[ai+disp:16], an the instructions transfer 22-bit data between an ad dress register an and th e memory location at the address of (ai+disp:16). di sp:16 is an positive displacement from 0 to ffffh. if the ad dress is odd, the lsb of the address is set to zero for word alignment. ldw an, @[ai+rj] / ldw @[ai+rj], an excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 13 - mcu team lsi division system lsi business april 2000 the instructions transfer 22-bit data between an ad dress register an and th e memory location at the address of (ai+rj). the value of rj is zero-extended to 22-bit value. if the address is odd, the lsb of the address is set to zero for word alignment. push rn/push rn, rm/p ush an/ push an, am the instruction ?push rn? transfers 16-bit data from the register rn to the memory location at the address of sp, and then increments the value of sp by 2. the register rn should not be r15. the operation of ?push r15? is undefined. the instruction ?push rn, rm? pushes rn and then rm. the registers rn and rm should not be the same. the registers rn and rm should not be r15. the instruction ?push an? pushes rn and then en. when the extension register en is pushed, the value of en is zero- extended to 16-bit data. the register an should not be a15. the instruction ?push an, am? pushes an and then am. the registers an and am should not be the same pop rn/pop rn, rm/pop an/ pop an, am the instruction ?pop rn? decrements the value of sp by 2, and then tran sfers 16-bit data to the register rn from the memory location at the address of sp. the register rn should not be r15. the operation of ?pop r15? is undefined. the instruction ?pop rn, rm? pops rn and then rm. the registers rn and rm should not be the same. the registers rn and rm should not be r15. the instruction ?pop an? pops en and then rn. when the extension register en is popped, the least significant 6 bits are transferred to en. the register an should not be a15. the instructio n ?pop an, am? pops an and then am. the registers an and am should not be the same ldb rn, @[ai+disp:4] / ldb @[ai+disp:4], rn the instructions transfer 8-bit da ta between the general register rn and the memory location at the address of (ai+disp:4). disp:4 is a positive displacement from 0 to 15. th e general register rn is one r0 to r7. in the instruction ?ldb rn, @[ai+disp:4]?, the 8-bit data is zero-extended to 16-bit data, and then written into rn. in the instruction ?ldb @[ai+disp:8], rn?, the least significant byte of rn is transferred to the memory. ldb rn, @[ai+disp:16] / ldb @[ai+disp:16], rn the instructions transfer 8-bit da ta between the general register rn and the memory location at the address of (ai+disp:16). disp:16 is a positive displacement from 0 to ffffh. the general register rn is one of r0 to r7. in the instruction ?ldb rn, @[ ai+disp:16]?, the 8-bit data is zero-extended to 16- bit data, and then written into rn. in the instruction ?ldb @[ai+disp:16], rn?, the least significant byte of rn is transfe rred to the memory. ldb r0, @[a8+disp:8] / ldb @[a8+disp:8], rn excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 14 - mcu team lsi division system lsi business april 2000 the instructions transfer 8-bit da ta between the general register r0 and the memory location at the address of (a8+disp:8). disp:8 is a positive displacement from 0 to 25 5. in the instruction ?ldb r0, @[a8+disp:8]?, the 8-bit data is zero-extended to 16- bit data, and then written into r0. in the instruction ?ldb @[a8+disp:8], r0?, the least significant byte of r0 is transferred to the memory. ldb rn, @[ai+rj] / ldb @[ai+rj], rn the instructions transfer 8-bit da ta between the general register rn and the memory location at the address of (ai+rj). the value of rj is zero-extended to 22-bit value. the general register rn is one of the 8 registers from r0 to r7. in the instruction ?ldb rn , @[ai+rj]?, the 8-bit data is zero-extended to 16- bit data, and then written into r0. in the instruction ?ldb @[ai+rj], rn?, the least significant byte of rn is transferred to the memory. ld register, program memory ldc rn, @ai the instruction transfers 16-bit data to rn from program memory at the address of ai. ld register, # immediate ld rn, #imm:8 / ld rn, #imm:16 / ld an, #imm:22 the instructions move an immediate data to a register. in the instruction ?ld rn, #imm:8?, the immediate value is zero-extended to 16-bit value. 2.3. branch instructions calmrisc16 has 2 classes of branch instru ctions: with a delay slot and without a delay slot. if a delay slot is filled with a useful instruction (or an instruction which is not nop), then the performance degradation due to the control dependency can be minimized. however, if the delay slot ca nnot be used, then it should be nop instruction, which can increase the program code si ze. in this case, the corresponding branch in struction without a delay slot can be used to avoid using nop. some instructions are not permitted to be in the de lay slot. the prohibited instructions are as follows. - all 2-word instructions - all branch and jump instructions incl uding swi, retd, ret_swi, ret_irq, ret - break instructions when a prohibited instruction is in the delay slot, the operation of calm risc16 is undefined or unpredictable. bsrd eoffset:13 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 15 - mcu team lsi division system lsi business april 2000 in the instruction, called branch subroutine with a delay slot, the value (pc + 4) is saved into a14 register, the instruction in the delay slot is executed, and then the program sequence is moved to (pc + 2 + eoffset:13), where pc is the ad dress of the instruction ?bsrd eoffset:13?. the immediate value eoffset:13 is sign-extended to 22-bit and then added to (pc+2). in general, the 13-bit offset field appears as a label in assembly programs. if the instruction in the delay slot reads the value of a14, the value (pc+4) is read. the even offset eoffset:13 is encoded to 12bit signed offset in instruction map by dropping the least significant bit. bra/brad/brt/brtd/brf/brfd eoffset:11 in the branch instructions, the targ et address is (pc + 2 + eoffset:11) . the immediate value eoffset:11 is sign-extended to 22-bit and then added to (pc+2). the ?d? in the mnemonic stands for a delay slot. in general, the 11-bit offset field appears as a labe l in assembly programs. bra and brad instructions always branch to the target address. brt and brtd inst ructions branch to the target address if t flag is set. brf and brfd instructions branch to the ta rget address if t flag is cleared. brad/brtd/brfd instructions are delay slot branch instructions, therefor e the instruction in the delay slot is executed before the branch to the target address or the branch decision is made. the even offset eoffset:11 is encoded to 10-bit signed offset in instruction map by dropping the least significant bit. bra/brad ec:2, eoffset:8 in the branch instructions, the target address is (p c + 2 + eoffset:8). the imme diate value eoffset:8 is sign-extended to 22-bit and then added to (pc+2). the ec:2 field indicates one of the 4 external conditions from ec0 to ec3 (input pin signals to calmrisc16). when the external condition corresponding to ec:2 is set, the program branches to the target address. brad has a delay slot. the even offset eoffset:8 is encoded to 7-bit signed offs et in instruction map by dr opping the least significant bit. bnzd r6/r7, eoffset:8 in the branch instruction, the target address is (pc + 2 + eoffset:8). the immediate value eoffset:8 is sign- extended to 22-bit and then added to (pc+2). ?bnzd r6, eoffset:8? instruction branches to the target address if z0 flag is cleared. ?bnz d r7, eoffset:8? instruction branches if z1 flag is cleared. before the branch operation, the instruction d ecrements r6/r7, updates z0/z1 flag according to the decrement result, and then executes the instruction in the delay slot. th e instruction is used to manage loop counter with just one cycle overhead. in the end of the loop, the value of r6/r7 is ?1. when the instruction in the delay slot read the z0/z1 flag, the result after the decr ement is read. the even offset eoffset:8 is encoded to 7-bit signed offset in instruction map by dropping the least significant bit. jmp/jpt/jpf/jsr addr:22 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 16 - mcu team lsi division system lsi business april 2000 the target address of the instructions is addr:22. jmp always branches to the target address. jpt branches to the target address if the t flag is set. jpf branches if the t flag is cleared. jsr always branches to the target address with saving the return address (pc+4) into a14. the instructions are 2 word instructions. jmp/jpt/jpf/jsr ai the target address of the instructions is the value of ai. jmp always br anches to the target address. jpt branches to the target address if the t flag is set. jpf branches if the t flag is cleared. jsr always branches to the target address with savi ng the return address (pc+2) into a14. swi #imm:6/ ret_swi/ret_irq/ret_fiq refer to the section for interrupts. retd the instruction branches to the address in a14 after the execution of the instruction in the delay slot. when there is no useful instruction adequate to the delay slot, ?jmp a14? can be used instead of ?retd?. 2.4. bit operation the bit operations manipulate a bit in sr register or in a memory location. bitr/bits/bitc/bitt @[a8+r1], #imm:3 the source as well as the destination is the 8-bit data in the data memory at the address (a8 + r1). the #imm:3 field chooses a bit position among the 8 bits. bitr resets the bit #imm:3 of the source, and then writes the result to the destination, the same memory location. bits sets the bit #imm:3 of the source, and then writes the result to the destination. bitc complements the bit #imm:3 of the source, and then writes the result to the destination. bitt does not write any data to the destination. t flag indicates whether the bit #imm:3 of the source is zero. in other words, when the bit #imm:3 of the source is zero, t flag is set. bitr and bits can be used to implement a semaphore mechanism or lock acquisition/release. clrsr/setsr/tstsr bit bit : fe, ie, te, z0, z1, v, pm clrsr instruction clears the correspon ding bit of sr. setsr instruction sets the corresponding bit of sr. tstsr tests whether the corresponding bit is zero, and stores the result in t flag. for example, when ie flag is zero, ?tstsr ie? instruction sets the t fl ag. we can clear the t flag by the instruction ?cmp gt, r0, r0?. we can set the t flag by the instruction ?cmp eq, r0, r0?. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 17 - mcu team lsi division system lsi business april 2000 2.5. miscellaneous instructions sys #imm:5 the instruction activates the output port nsysid. th e #imm:5 is transferred to outside on da[4:0]. the most significant 17 bits remain unchanged. the instruction is for system command to outside such as power down modes. cop #imm:13 the instruction activates th e output port ncopid. the #imm:13 is tran sferred to outside on copir[12:0]. the instruction is used to transfer instruction to coprocessor. the #imm:13 may be from 200h to 1fffh. cld rn, #imm:5 / cld #imm:5, rn the instruction activates th e output port ncopid, ncldid, and cldw r. the least significant 13 bits of the instruction is transferred to outside on copir[ 12:0]. the #imm:5 is transferred to outside on da[4:0]. the instructions move 16-bit data between rn and a coprocessor register implied by the #imm:5 field. cldwr signal indicates whether the data movement is from calmrisc16 to coprocessor. the register rn is one 8 registers from r0 to r7. nop no operation. break the software break instruction activates nbrk signal, and holds pa for one cycle. it?s for debugging operation. 3. calmrisc16 instruction map 15 8 7 0 add rn, #imm:7 0 0 0 0 rn 0 imm:7 sub rn, #imm:7 0 0 0 0 rn 1 imm:7 ld rn, #imm:8 0 0 0 1 rn imm:8 ldw rn, @[sp + edisp:9] 0 0 1 0 rn edisp:9 ldw @[sp + edisp:9], ri 0 0 1 1 ri edisp:9 ldw rn, @[ai + edisp:5] 0 1 0 0 rn 0 ai edisp:5 ldw rn, @[ai + rj] 0 1 0 0 rn 1 ai rj ldw @[an + edisp:5], ri 0 1 0 1 ri 0 an edisp:5 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 18 - mcu team lsi division system lsi business april 2000 ldw @[an + rm], ri 0 1 0 1 ri 1 an rm ldb dn, @[ai + disp:4] 0 1100 dn 0 ai disp:4 ldb dn, @[ai + rj] 0 1100 dn 1 ai rj ldw an, @[ai + disp:4] 0 1101 an 0 ai disp:4 ldw an, @[ai + rj] 0 1101 an 1 ai rj ldb @[an + disp:4], di 0 1110 di 0 an disp:4 ldb @[an + rm], di 0 1110 di 1 an rm ldw @[an + disp:4], ai 0 1111 ai 0 an disp:4 ldw @[an + rm], ai 0 1111 ai 1 an rm add rn, ri 1 0 0 0 rn 0 0 0 0 ri sub rn, ri 1 0 0 0 rn 0 0 0 1 ri adc rn, ri 1 0 0 0 rn 0 0 1 0 ri sbc rn, ri 1 0 0 0 rn 0 0 1 1 ri and rn, ri 1 0 0 0 rn 0 1 0 0 ri or rn, ri 1 0 0 0 rn 0 1 0 1 ri xor rn, ri 1 0 0 0 rn 0 1 1 0 ri tst rn, ri 1 0 0 0 rn 0 1 1 1 ri cmp ge, rn, ri 1 0 0 0 rn 1 0 0 0 ri cmp gt, rn, ri 1 0 0 0 rn 1 0 0 1 ri cmpu ge, rn, ri 1 0 0 0 rn 1 0 1 0 ri cmpu gt, rn, ri 1 0 0 0 rn 1 0 1 1 ri cmp eq, rn, ri 1 0 0 0 rn 1 1 0 0 ri ld rn, ri 1 0 0 0 rn 1 1 0 1 ri rr rn 1 00000001110 rn rl rn 1 00000011110 rn rrc rn 1 00000101110 rn srb rn 1 00000111110 rn sr rn 1 00001001110 rn sra rn 1 00001011110 rn jpf ai 1 00001101110 0 ai jpt ai 1 00001101110 1 ai jmp ai 1 00001111110 0 ai jsr ai 1 00001111110 1 ai slb rn 1 00010001110 rn dt rn 1 00010011110 rn excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 19 - mcu team lsi division system lsi business april 2000 incc rn 1 00010101110 rn decc rn 1 00010111110 rn com rn 1 00011001110 rn com2 rn 1 00011011110 rn comc rn 1 00011101110 rn ext rn 1 00011111110 rn add rn, #imm:16 1 00000001111 rn add an, #imm:16 1 00000011111 0 an sub an, #imm:16 1 00000011111 1 an adc rn, #imm:16 1 00000101111 rn sbc rn, #imm:16 1 00000111111 rn and rn, #imm:16 1 00001001111 rn or rn, #imm:16 1 00001011111 rn xor rn, #imm:16 1 00001101111 rn tst rn, #imm:16 1 00001111111 rn cmp ge, rn, #imm:16 1 00010001111 rn cmp gt, rn, #imm:16 1 00010011111 rn cmpu ge, rn, #imm:16 1 00010101111 rn cmpu gt, rn, #imm:16 1 00010111111 rn cmp eq, rn, #imm:16 1 00011001111 rn ld rn, #imm:16 1 00011011111 rn reserved 1 000111 1111 cmp eq, dn, #imm:8 1 0010 dn imm:8 and r0, #imm:8 1 0011000 imm:8 or r0, #imm:8 1 0011001 imm:8 xor r0, #imm:8 1 0011010 imm:8 tst r0, #imm:8 1 0011011 imm:8 ldb r0, @[a8+ disp:8] 1 0011100 disp:8 ldb @[a8+ disp:8],r0 1 0011101 disp:8 bitr @[a8+r1], bs:3 1 00111100000 0 bs:3 bits @[a8+r1], bs:3 1 00111100000 1 bs:3 bitc @[a8+r1], bs:3 1 00111100001 0 bs:3 bitt @[a8+r1], bs:3 1 00111100001 1 bs:3 sys #imm:5 1 0011110001 imm:5 swi #imm:6 1 001111001 imm:6 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 20 - mcu team lsi division system lsi business april 2000 clrsr bs:3 1 00111101000 0 bs:3 setsr bs:3 1 00111101000 1 bs:3 tstsr bs:3 1 00111101001 0 bs:3 nop 1 00111101001 1 0 0 0 break 1 00111101001 1 0 0 1 ld r0, sr 1 00111101001 1 0 1 0 ld sr, r0 1 00111101001 1 0 1 1 ret_fiq 1 00111101001 1 1 0 0 ret_irq 1 00111101001 1 1 0 1 ret_swi 1 00111101001 1 1 1 0 retd 1 00111101001 1 1 1 1 ld r0, spcl_fiq 1 00111101010 0 0 0 0 ld r0, spch_fiq 1 00111101010 0 0 0 1 ld r0, ssr_fiq 1 00111101010 0 0 1 0 reserved 1 00111101010 0 0 1 1 ld r0, spcl_irq 1 00111101010 0 1 0 0 ld r0, spch_irq 1 00111101010 0 1 0 1 ld r0, ssr_irq 1 00111101010 0 1 1 0 reserved 1 00111101010 0 1 1 1 reserved 1 00111101010 1 0 0 ld r0, ssr_swi 1 00111101010 1 0 1 0 reserved 1 00111101010 1 0 1 1 reserved 1 00111101010 1 1 ld spcl_fiq, r0 1 00111101011 0 0 0 0 ld spch_fiq, r0 1 00111101011 0 0 0 1 ld ssr_fiq, r0 1 00111101011 0 0 1 0 reserved 1 00111101011 0 0 1 1 ld spcl_irq, r0 1 00111101011 0 1 0 0 ld spch_irq, r0 1 00111101011 0 1 0 1 ld ssr_irq, r0 1 00111101011 0 1 1 0 reserved 1 00111101011 0 1 1 1 reserved 1 00111101011 1 0 0 ld ssr_swi, r0 1 00111101011 1 0 1 0 reserved 1 00111101011 1 0 1 1 reserved 1 00111101011 1 1 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 21 - mcu team lsi division system lsi business april 2000 reserved 1 0011110110 reserved 1 00111101110 ld an, pc 1 00111101111 0 an reserved 1 00111101111 1 jpf adr:22 1 001111100 adr[21:16] jpt adr:22 1 001111101 adr[21:16] jmp adr:22 1 001111110 adr[21:16] jsr adr:22 1 001111111 adr[21:16] ldc rn, @ai 1 0 1 0 rn 0 0 0 0 0 ai reserved 1 0 1 0 0 0 0 0 1 ld dn, ei 1 0100 dn 0001 0 ei ld en, di 1 0100 di 0001 1 en cmp eq, an, ai 1 0101 an 0001 0 ai ld an, ai 1 0101 an 0001 1 ai ldw rn, @[ai+disp:16] 1 0 1 0 rn 0 0 1 0 0 ai ldw @[an+disp:16], ri 1 0 1 0 ri 0 0 1 0 1 an ldb dn, @[ai+disp:16] 1 0100 dn 0011 0 ai ldb @[an+disp:16], di 1 0100 di 0011 1 an ldw an, @[ai+disp:16] 1 0101 an 0011 0 ai ldw @[an+disp:16], ai 1 0101 ai 0011 1 an cmp ge, dn, #imm:6 1 0100 dn 01 imm:6 add an, #imm:5 1 0101 an 010 imm:5 sub an, #imm:5 1 0101 an 011 imm:5 cmp eq, an, #imm:22 1 0100 an 10 imm[21:16] ld an, #imm:22 1 0101 an 10 imm[21:16] add an, ri 1 0100 an 1100 ri sub an, ri 1 0101 an 1100 ri mul uu, dn, di 1 0100 dn 1101 0 di mul us, dn, di 1 0100 dn 1101 1 di mul su, dn, di 1 0101 dn 1101 0 di mul ss, dn, di 1 0101 dn 1101 1 di pop rn[, rm] 1 0 1 0 rm 1 1 1 0 0 rn reserved 1 0100 1110 1 pop an[, am] 1 0101 am 1110 1 an push rn[, rm] 1 0 1 0 rm 1 1 1 1 0 rn excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 22 - mcu team lsi division system lsi business april 2000 reserved 1 0100 1111 1 push an[, am] 1 0101 am 1111 1 an bsrd eoffset:13 1 0 1 1 eoffset:13 bra ec:2, eoffset:8 1 100000 ec:2 eoffset:8 reserved 1 100001 brad ec:2, eoffset:8 1 100010 ec:2 eoffset:8 bnzd h, eoffset:8 1 100011h0 eoffset:8 reserved 1 100011 1 bra eoffset:11 1 10010 eoffset:11 brad eoffset:11 1 10011 eoffset:11 brf eoffset:11 1 10100 eoffset:11 brfd eoffset:11 1 10101 eoffset:11 brt eoffset:11 1 10110 eoffset:11 brtd eoffset:11 1 10111 eoffset:11 cld dn, imm:5 1 110000 imm:5 0 dn cld imm:5, di 1 110000 imm:5 1 di cop imm:13 1 1 1 imm:13 ? dn[15:0] : r0 ~ r7 ? h[15:0] : r6, r7 ? an[21:0] : a8 ~ a15, concatenation of en and rn ? en[5:0] : e8 ~ e15, ms 6-bit of an ? sp : equal to a15 ? ec:2 : ec0,ec1,ec2,ec3 ? disp : unsigned displacement ? eoffset : even signed offset ? edisp : even unsigned displacement 4. quick reference instruction op1 op2 operation flag add sub rn #imm:7 ri op1 <- op1 + op2 op1 <- op1 + ~op2 + 1 t=c, z0, z1,v ld rn #imm:8 #imm:16 ri op1 <- op2 z0, z1 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 23 - mcu team lsi division system lsi business april 2000 ldw rn @[sp+edisp:9] @[ai+edisp:5] @[ai+rj] @[ai+disp:16] op1 <- op2 - ldw @[sp+edisp:9] @[an+edisp:5] @[an+rm] @[ai+disp:16] ri op1 <- op2 - ldw an @[ai+edisp:5] @[ai+rj] @[ai+disp:16] op1 <- op2 - ldw @[an+edisp:5] @[an+rm] @[ai+disp:16] ai op1 <- op2 - ldb dn @[sp+disp:8] @[ai+disp:4] @[ai+rj] @[ai+disp:16] op1<-{8?h0,op2[7:0]} - ldb r0 @[a8+disp:8] op1<-{8?h0,op2[7:0]} - ldb @[sp+disp:8] @[an+disp:4] @[ai+rj] @[ai+disp:16] di op1 <- op2[7:0] - ldb @[a8+disp:8] r0 op1 <- op2[7:0] - adc sbc rn ri #imm:16 op1 <- op1 + op2 + t op1 <- op1 + ~op2 + t t=c,v, z0,z1 and or xor rn ri #imm:16 op1 <- op1 & op2 op1 <- op1 | op2 op1 <- op1 ^ op2 t=z, z0,z1 tst rn ri #imm:16 op1 & op2 t=z cmp ge cmp gt cmpu ge cmpu gt cmp eq rn ri #imm:16 op1 + ~op2 + 1, t=~n op1 + ~op2 + 1, t=~n&~z op1 + ~op2 + 1, t=c op1 + ~op2 + 1, t=c&~z op1 + ~op2 + 1, t=z t excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 24 - mcu team lsi division system lsi business april 2000 rr rl rrc srb sr sra slb rn - op1 <- {op1[0],op1[15:1]} op1 <- {op1[14:0],op1[15]} op1 <- {t,op1[15:1]} op1 <- {8?h00,op1[15:8]} op1 <- {0,op1[15:1]} op1 <- {op1[15],op1[15:1]} op1 <- {op1[7:0],8?h00} t=op1[0] t=op1[15] t=op1[0] t=op1[7] t=op1[0] t=op1[0] t= op1[8] dt rn op1 <- op1 + 0xffff t=z, z0,z1,v com rn op1 <- ~op1 t=z,z0, z1 incc decc com2 comc rn op1 <- op1 + t op1 <- op1 + 0xffff + t op1 <- ~op1 + 1 op1 <- ~op1 + t t=c,z0, z1 ext rn op1<-{8{op1[7]},op1[7:0]} z0, z1 jpf jpt jmp jsr ai addr:22 if(t==0) pc <- op1 if(t==1) pc <- op1 pc <- op1 a14 <- pc+(2|4), pc<-op1 - add rn #imm:16 op1 <- op1 + op2 t=c, z0,z1,v add sub an #imm:16 #imm:5 ri op1 <- op1 + op2 op1 <- op1 ? op2 - cmp eq dn #imm:8 op1 + ~op2 + 1 t=z and or xor tst r0 #imm:8 op1 <- op1 & {8?h00,op2} op1 <- op1 | {8?h00,op2} op1 <- op1 ^ {8?h00,op2} op1 & {8?h00,op2} t=z8 bitr bits bitc bitt @[a8+r1] bs:3 op1[op2] <- 0 op1[op2] <- 1 op1[op2] <- ~op1[op2] op1[op2] <- op1[op2] t= op1[op2] sys #imm:5 - da[4:0] <- op1 - swi #imm:6 - a14 <- pc+2, pc <- op2*4 ie, te excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 25 - mcu team lsi division system lsi business april 2000 clrsr setsr tstsr bs:3 - sr[op1] <- 0 sr[op1] <- 1 t <- ~sr[op1] - retd - - pc <- a14 - ld r0 sr spcl_fiq spch_fiq ssr_fiq spcl_irq spch_irq ssr_irq ssr_swi op1 <- op2 - ld sr spcl_fiq spch_fiq ssr_fiq spcl_irq spch_irq ssr_irq ssr_swi r0 op1 <- op2 ld an pc ai #imm:22 op1 <- op2 + 4 op1 <- op2 op1 <- op2 - cmp eq an ai #imm:22 op1 + ~op2 + 1 t=z22 ldc rn @ai op1 <- pm[op2] - ld rn ei op1 <- {10?h000, op2} - ld en ri op1 <- op2[5:0] - cmp ge dn #imm:6 op1 + ~op2 + 1 t=~n mul uu mul us mul su mul ss dn di op1<-{0,op1[7:0]} * {0,op2[7:0]} op1<-{0,op1[7:0]}*{op2[7],op2[7:0]} op1<-{op1[7],op1[7:0]}*{0,op2[7:0]} op1 <-{op1[7],op1[7:0]}* {op2[7],op2[7:0]} - pop rn rm op1<-@[sp+2], op2<-@[sp+4], sp<-sp+4 - excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 26 - mcu team lsi division system lsi business april 2000 push rn rm @[sp]<- op1,@[sp-2]<-op2,sp<-sp-4 - pop an am en<-@[sp+2], rn<-@[sp+4], em<- @[sp+6], rm<-@[sp+8], sp<-sp+8 - push an am @[sp]<-rn, @[sp-2]<-en, @[sp-4]<- rm, @[sp-6]<-em, sp<-sp-8 - bsrd eoffset:13 - a14 <- pc+2, pc <- pc + 2 + op1 - bra/brad ec:2 eoffset:8 if(ec:2 == 1) pc <- pc + 2 + op2 - bnzd r6 eoffset:8 if(z0 == 0) pc <- pc + 2 + op2 r6 <- r6 ? 1 z0 bnzd r7 eoffset:8 if(z1 == 0) pc <- pc + 2 + op2 r7 <- r7 ? 1 z1 bra/brad eoffset:11 - pc <- pc + 2 + op1 - brf/brfd eoffset:11 - if(t==0) pc <- pc + 2 + op1 - brt/brtd eoffset:11 - if(t==1) pc <- pc + 2+op1 - cld dn imm:5 op1 <- coprocessor[op2] - cld imm:5 di coprocessor[op1] <- op2 cop imm:13 - copir <- op2 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 27 - mcu team lsi division system lsi business april 2000 adc (1) adc rn, ri add with carry register description the adc (add with carry register) instruction is used to synthesize 32-bit addition. if register pairs r0, r1 and r2, r3 hold 32-bit values (r0 and r2 hold the least-significant word), the following instructions leave the 32-bit sum in r0, r1: add r0, r2 adc r1, r3 the instruction adc r0, r0 produces a single-bit rotate left with carry (17-bit rotate through the carry) on r0. adc adds the value of register rn, and the value of the carry flag (stored in the t bit), and the value of register ri, and stores the result in register rn. the t bit and the v flag are updated based on the result. 15 14 13 12 11 8 7 6 5 4 3 0 1 0 0 0 rn 0 0 1 0 ri operation rn := rn + ri + t bit t bit := carry from (rn + ri + t bit) v flag := overflow from (rn + ri + t bit) if(rn == r6/r7) z0/z1 flag := ((rn + ri + t) == 0) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 28 - mcu team lsi division system lsi business april 2000 adc (2) adc rn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 29 - mcu team lsi division system lsi business april 2000 add (1) add rn, ri add register description the add (add register) instruction is used to add two 16-bit values in registers. 32-bit addition can be achieved by executing adc instruction in pair with this instruction (see page 27). add adds the value of register rn, and the value of register ri, and stores the result in register rn. the t bit and the v flag are updated based on the result. 15 14 13 12 11 8 7 6 5 4 3 0 1 0 0 0 rn 0 0 0 0 ri operation rn := rn + ri t bit := carry from (rn + ri) v flag := overflow from (rn + ri) if(rn == r6/r7) z0/z1 flag := ((rn + ri) == 0) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 30 - mcu team lsi division system lsi business april 2000 add (2) add rn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 31 - mcu team lsi division system lsi business april 2000 add (3) add rn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 32 - mcu team lsi division system lsi business april 2000 add (4) add an, ri add extended register description the add (add extended register) instruction is used to add a 16-bit unsigned register value to a 22-bit register. this instruction adds the value of 16-bit register ri, and the value of 22-bit register an, and stores the result in register an. 15 14 13 12 11 10 8 7 6 5 4 3 0 1 0 1 0 0 an 1 1 0 0 ri operation an := an + ri exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 33 - mcu team lsi division system lsi business april 2000 add (5) add an, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 34 - mcu team lsi division system lsi business april 2000 add (6) add an, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 35 - mcu team lsi division system lsi business april 2000 and (1) and rn, ri and register description the and (and register) instruction is us ed to perform bitwise and operation on two values in registers, rn and ri. the result is stored in register rn. the t bit is updated based on the result. 15 14 13 12 11 8 7 6 5 4 3 0 1 0 0 0 rn 0 1 0 0 ri operation rn := rn & ri t bit := ((rn & ri) == 0) if(rn == r6/r7) z0/z1 flag := ((rn & ri) == 0) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 36 - mcu team lsi division system lsi business april 2000 and (2) and r0, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 37 - mcu team lsi division system lsi business april 2000 and (3) and rn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 38 - mcu team lsi division system lsi business april 2000 bitop bitop @[a8+r1], # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 39 - mcu team lsi division system lsi business april 2000 bnzd bnzd h, excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 40 - mcu team lsi division system lsi business april 2000 br brtype excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 41 - mcu team lsi division system lsi business april 2000 bra ec bra(d) ec:2 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 42 - mcu team lsi division system lsi business april 2000 break break break description the break instruction suspends the calm risc core for 1 cycle by keeping pc from increasing. processor resumes execution after 1 cycle. this instruction is used for debugging purposes only and thus should not be used in normal operating modes. a core signal nbrk is asserted low for the cycle. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 0 0 1 operation no operation with pc suspended for a single cycle. exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 43 - mcu team lsi division system lsi business april 2000 bsrd bsrd excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 44 - mcu team lsi division system lsi business april 2000 cld cld dn, excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 45 - mcu team lsi division system lsi business april 2000 clrsr clrsr bs:3 clear sr description the clrsr (clear sr) instruction is used to clear a specified bit in sr as follows: clrsr fe / ie / te / v / z0 / z1 / pm to clear the t bit, on e can do as follows: cmp gt, r0, r0 to turn on a specified bit in sr, the setsr instruction (in page 100 ) is used. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 0 1 0 0 1 1 1 1 0 1 0 0 0 0 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 46 - mcu team lsi division system lsi business april 2000 cmp (1) cmpmode rn, ri compare register description the cmp (compare register) instruction is used to compare two values in registers rn and ri. the allowed modes include ge (greater or equal), gt (greater than), uge (unsigned greater or equal), ugt (unsig ned greater than), and eq (equal). cmp subtracts the value of ri from the value of rn and performs comparison based on the result. the contents of rn an d ri are not changed after this operation. the t bit is updated for later reference. 15 14 13 12 11 8 7 6 5 4 3 0 1 0 0 0 rn 1 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 47 - mcu team lsi division system lsi business april 2000 cmp (2) cmpmode rn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 48 - mcu team lsi division system lsi business april 2000 cmp (3) cmp ge, dn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 49 - mcu team lsi division system lsi business april 2000 cmpeq (1) cmp eq, an, ai compare equal extended register description the cmp eq (compare equal extended register) instruction is used to compare two values in registers an and ai. this instruction is a restricted form of more general cmpmode instructions for a 22-bit equality comparison between register values. 15 14 13 12 11 10 8 7 6 5 4 3 2 0 1 0 1 0 1 an 0 0 0 1 0 ai operation t bit := (an == ai) an or ai refers to registers from a8 to a15 with their 6-bit extensions. exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 50 - mcu team lsi division system lsi business april 2000 cmpeq (2) cmp eq, dn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 51 - mcu team lsi division system lsi business april 2000 cmpeq (3) cmp eq an, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 52 - mcu team lsi division system lsi business april 2000 com commode rn complement description the com (complement) instruction is used to compute 1?s or 2?s complement of a register value rn. utilizing various modes, 32-bit complement operation can be done. if register pair r0, r1 holds a 32-bit value (r0 holds the least-significant word), the following instructions leave the 32-bit 2?s complement in r0, r1: com2 r0 // 2?s complement comc r1 // 2?s complement with carry com computes the 1?s complement of the value of register rn. com2 computes the 2?s complement, and comc computes the 2?s complement value when t bit has been set. if t bit is clear, com2 is equivalent to com. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 0 1 1 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 53 - mcu team lsi division system lsi business april 2000 cop cop excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 54 - mcu team lsi division system lsi business april 2000 decc decc rn decrement with carry description the decc (decrement with carry) instruction is used to synthesize 32-bit decrement. if register pa ir r0, r1 holds a 32-bit value (r0 holds the least- significant word), the following instructions leave the 32-bit decremented value in r0, r1: dec r0 // this is implemented by add r0, -1 decc r1 decc decrements the value of rn by 1 only if the carry flag (stored in the t bit) is clear, and stores the result back in register rn. the t bit and the v flag are updated based on the result. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 0 1 0 1 1 1 1 1 0 rn operation rn := rn - 1 + t bit t bit := carry from (rn - 1 + t bit) v flag := overflow from (rn -1 + t bit) if(rn == r6/r7) z0/z1 := ((rn ? 1 + t) == 0) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 55 - mcu team lsi division system lsi business april 2000 dt dt rn decrement and test description the dt (decrement and test) instruction is used to decrement the value of a specified register and test it. this inst ruction provides a compact way to control register indexing for loops. the t bit and the v flag are updated based on the result. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 0 1 0 0 1 1 1 1 0 rn operation rn := rn - 1 t bit := ((rn - 1) == 0) v flag := overflow from (rn - 1) if(rn == r6/r7) z0/z1 := ((rn ? 1) == 0) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 56 - mcu team lsi division system lsi business april 2000 ext ext rn sign-extend description the ext (sign extend) instruction is used to sign-extend an 8-bit value in rn. this instruction copies rn[7] to rn[15:8]. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 0 1 1 1 1 1 1 1 0 rn operation all bits from rn[15] to rn[8] := rn[7] if(rn == r6/r7) z0/z1 := (result == 0) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 57 - mcu team lsi division system lsi business april 2000 incc incc rn increment with carry description the incc (increment with carry) instruction is used to synthesize 32-bit increment. if register pair r0, r1 ho lds a 32-bit value (r0 holds the least- significant word), the following instructions leave the 32-bit incremented value in r0, r1: inc r0 // will be replaced by add r0, 1 incc r1 incc increments the value of rn by 1 only if the carry flag (stored in the t bit) is set, and stores the result back in register rn. the t bit and the v flag are updated based on the result. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 0 1 0 1 0 1 1 1 0 rn operation rn := rn + t bit t bit := carry from (rn + t bit) v flag := overflow from (rn + t bit) if(rn == r6/r7) z0/z1 := ((rn + t0) == 0) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 58 - mcu team lsi division system lsi business april 2000 jmp (1) jpf/jpt/jmp/jsr ai jump register description the jump register instructions change the program flow by assigning the value of register ai into pc. jpf and jpt are conditional jumps that check the t bit to determine whether or not to jump to the target address. jmp unconditionally jumps to the target. jsr is an unconditional jump but saves the return address (the immediately following instruction to jsr) in the link register, a14. at the end of each subroutine, jmp a14 will change the program flow back to the original call site. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 0 1 0 0 0 0 1 1 m [1] 1 1 1 0 m [0] ai operation (m == 00, jpf) if (t bit == false) pc := ai (m == 01, jpt) if (t bit == true) pc := ai (m == 10, jmp) pc := ai (m == 11, jsr) a14 := pc + 2 pc := ai exceptions none. notes there is no delay slot for these instruc tions. therefore, when conditional branch jpf or jpt is taken, the instruction in the pipeline which is fetched from pc+2 will be squashed. in case of jmp and jsr (a lways taken), the following instruction fetched will be always squashed. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 59 - mcu team lsi division system lsi business april 2000 jmp (2) jpf/jpt/jmp/jsr excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 60 - mcu team lsi division system lsi business april 2000 ld (1) ld rn, ri load register description the ld (load register) instruction is used to transfer a register value to a register. 15 14 13 12 11 8 7 6 5 4 3 0 1 0 0 0 rn 1 1 0 1 ri operation rn := ri if(rn == r6/r7) z0/z1 := (ri == 0) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 61 - mcu team lsi division system lsi business april 2000 ld (2) ld an, ai load extended register description this form of ld instruction (load extended register) is used to load a 22-bit register value to a 22-bit register. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 1 0 1 an 0 0 0 1 1 ai operation an := ai exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 62 - mcu team lsi division system lsi business april 2000 ld (3) ld rn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 63 - mcu team lsi division system lsi business april 2000 ld (4) ld rn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 64 - mcu team lsi division system lsi business april 2000 ld (5) ld an, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 65 - mcu team lsi division system lsi business april 2000 ld rext ld dn, ei / ld en, di load register extension description the ld rext (load register extension) inst ructions are used to transfer a register value to and from a 6-bit extension register. 15 14 13 12 11 8 7 6 5 4 3 2 0 1 0 1 0 0 dn(or di) 0 0 0 1 m ei (or en) operation (m == 0, ld dn, ei) dn := ei (zero-extended to 16 bits) (m == 1, ld en, di) en := di (lower 6 bits only) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 66 - mcu team lsi division system lsi business april 2000 ldb (1) ldb dn, @[ai+ excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 67 - mcu team lsi division system lsi business april 2000 ldb (2) ldb dn, @[ai+ excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 68 - mcu team lsi division system lsi business april 2000 ldb (3) ldb dn, @[ai+rj] / ldb @[an+rm], di load byte register indexed description the ldb (load byte register indexed) instruction is used to load a byte from or to data memory at the location specified by the register ai (or an) and the second register rj (or rm). 15 14 13 12 11 10 8 7 6 4 3 0 0 1 1 m 0 dn or di 1 ai or an rj or rm operation (m == 0, ldb dn, @[ai+rj]) dn := dm[(ai+rj] (m == 1, ldb @[an+rm], di) dm[(an+rm)] := di exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 69 - mcu team lsi division system lsi business april 2000 ldb (4) ldb r0, @[a8+ excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 70 - mcu team lsi division system lsi business april 2000 ldc ldc rn, @ai load code description the ldc instruction is used to transfer a register value from the program memory. the program memory address is specified by the 22-bit register an. ldc is useful to look up the data stored in program memory, such as the coefficient table for certain numerical algorithms. 15 14 13 12 11 8 7 6 5 4 3 2 0 1 0 1 0 rn 0 0 0 0 0 ai operation rn := pm[ai] exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 71 - mcu team lsi division system lsi business april 2000 ld pc ld an, pc load program counter description the ld pc (load program counter) instructio n is used to transfer the value of pc into a 22-bit register an. this instruction provides a way to implement position independent code (pic) on calmrisc16 even in the absence of general virtual memory support. after executing this instruction, an will be used to compute a pc-relative location of a data item or a code section. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 0 1 0 0 1 1 1 1 0 1 1 1 1 0 an operation an := pc + 4 exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 72 - mcu team lsi division system lsi business april 2000 ld svr (1) ld r0, spcl_* / ld r0, spch_* / ld r0, ssr_* load from saved register description the ld svr (load from saved register) instructions are used to transfer a value from the specified interrupt register, e.g., ssr_fiq. only r0 register is used for this data transfer. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 1 1 1 1 0 1 0 1 0 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 73 - mcu team lsi division system lsi business april 2000 ld svr (2) ld spcl_*, r0 / ld spch_*, r0 / ld ssr_*, r0 load to saved register description the ld svr (load to saved register) instru ctions are used to transfer a value to the specified interrupt regist er, e.g., ssr_fiq. only r0 register is used for this data transfer. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 1 1 1 1 0 1 0 1 1 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 74 - mcu team lsi division system lsi business april 2000 ld sr ld r0, sr / ld sr, r0 load status register description the ld sr (load status register) instruction is used to transfer a value to and from sr. only r0 register is used for this operation. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 0 1 m operation (m == 0, ld r0, sr) r0 := sr (m == 1, ld sr, r0) sr := r0 exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 75 - mcu team lsi division system lsi business april 2000 ldw (1) ldw rn, @[sp+ excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 76 - mcu team lsi division system lsi business april 2000 ldw (2) ldw rn, @[ai+ excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 77 - mcu team lsi division system lsi business april 2000 ldw (3) ldw rn, @[ai+ excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 78 - mcu team lsi division system lsi business april 2000 ldw (4) ldw rn, @[ai+rj] / ldw @[an+rm], ri load word register indexed description the ldw (load word register indexed) instruction is used to load a word from or to data memory at the location specified by the register ai (o r an) and the second register rj (or rm), which is an unsigned value. 15 14 13 12 11 8 7 6 4 3 0 0 1 0 m rn or ri 1 ai or an rj or rm operation (m == 0, ldw rn, @[ai+rj]) rn := dm[(ai+rj] (m == 1, ldw @[an+rm], ri) dm[(an+rm)] := ri exceptions none. notes for memory transfer per word, the (byte) address needs to be aligned to be even. thus, if (ai + rj) or (an + rm) is an odd number, it will be made even by clearing the least significant bit. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 79 - mcu team lsi division system lsi business april 2000 ldw (5) ldw an, @[ai+ excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 80 - mcu team lsi division system lsi business april 2000 ldw (6) ldw an, @[ai+ excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 81 - mcu team lsi division system lsi business april 2000 ldw (7) ldw an, @[ai+rj] / ldw @[ai+rj], an load word register indexed description the ldw (load word register indexed) instruction is used to load 2 word from or to data memory at the location specified by the register ai and the second register rj, which is an unsigned value. 15 14 13 12 11 8 7 6 4 3 0 0 1 1 m 1 an 1 ai rj operation (m == 0, ldw an, @[ai + rj]) en := dm[(ai + rj)] rn := dm[(ai + rj + 2)] (m == 1, ldw @[ai + rj], an) dm[(ai + rj)] := en dm[(ai + rj + 2)] := rn exceptions none. notes for memory transfer per word, the (byte) address needs to be aligned to be even. thus, if (ai + rj) is an odd number, it will be made even by clearing the least significant bit. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 82 - mcu team lsi division system lsi business april 2000 mul mul mode, dn, di multiplication description the instruction mul performs 8x8 multiplica tion of the least si gnificant byte of dn and the least significant byte of di. dn and di are registers from r0 to r7. the 16-bit multiplication result is written back to dn. the mode is one of uu, us, su, ss. the mode indicates each operand is signed value or unsigned value. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 1 0 m1 dn 1 1 0 1 m2 di operation if(m1 == 0 && m2 == 0) // mode = uu dn := lower 16 bits of ({0,dn[7:0]} * {0, di[7:0]}) else if(m1 == 0 && m2 == 1) // mode == us dn := lower 16 bits of ({0,dn[7:0]} * {di[7],di[7:0]}) else if(m1 == 1 && m2 == 0) // mode == su dn := lower 16 bits of ({dn[7],dn[7:0]} * {0,di[7:0]}) else // mode == ss dn := lower 16 bits of ({dn [7],dn[7:0]} * {di[7],di[7:0]}) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 83 - mcu team lsi division system lsi business april 2000 nop nop no operation description the nop (no operation) instruction does not perform any operation. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 0 1 1 1 1 0 1 0 0 1 0 0 0 0 operation none. exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 84 - mcu team lsi division system lsi business april 2000 or (1) or rn, ri or register description the or (or register) instruction is used to perform bitwise or operation on two values in registers, rn and ri. the result is stored in register rn. the t bit is updated based on the result. 15 14 13 12 11 8 7 6 5 4 3 0 1 0 0 0 rn 0 1 0 1 ri operation rn := rn | ri t bit := ((rn | ri) == 0) if(rn == r6/r7) z0/z1 := ((rn|ri) == 0) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 85 - mcu team lsi division system lsi business april 2000 or (2) or r0, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 86 - mcu team lsi division system lsi business april 2000 or (3) or rn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 87 - mcu team lsi division system lsi business april 2000 pop(1) pop rn, rm / pop rn load register from stack description the pop instruction load one or two 16-bit data from software stack to general registers. in the instruction of ?pop rn , rm?, there are some restrictions on rn and rm. - rn and rm should not be r15. - if rn is one of the 8 registers from r0 to r7, rm should also be one of them. if rn is one of the registers from r8 to r14, rm should also be one of them. for example, ?pop r7, r8? is illegal. - if rn is the same as rm, pop operation occurs only once. ?pop rn, rn? is equivalent to ?pop rn?. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 1 0 rm 1 1 1 0 0 rn operation if(rn == rm) { // pop rn rn := dm[sp + 2] sp := sp + 2 } else { rn := dm[sp + 2] rm := dm[sp + 4] sp := sp + 4 } exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 88 - mcu team lsi division system lsi business april 2000 pop(2) pop an, am / pop an load register from stack description the pop instruction load one or two 22- b it data from software stack to extended registers. in the instruction of ?pop an, am?, there are some restrictions on an and am. - an and am should not be a15. - if an is the same as am, pop operation occurs only once. ?pop an, an? is equivalent to ?pop an?. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 1 0 1 am 1 1 1 0 1 an operation if(an == am) { // pop an en := lower 6 bits of dm[sp + 2] rn := dm[sp + 4] sp := sp + 4 } else { en := lower 6 bits of dm[sp + 2] rn := dm[sp + 4] em := lower 6 bits of dm[sp + 6] rm := dm[sp + 8] sp := sp + 8 } exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 89 - mcu team lsi division system lsi business april 2000 push(1) push rn, rm / push rn load register to stack description the push instruction load one or two 16-bit data from general registers to software stack. in the instruction of ?push rn, rm?, there are some restrictions on rn and rm. - rn and rm should not be r15. - if rn is one of the 8 registers from r0 to r7, rm should also be one of them. if rn is one of the registers from r8 to r14, rm should also be one of them. for example, ?push r7, r8? is illegal. - if rn is the same as rm, push op eration occurs only once. ?push rn, rn? is equivalent to ?push rn?. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 1 0 rm 1 1 1 1 0 rn operation if(rn == rm) { // push rn dm[sp] := rn sp := sp ? 2 } else { dm[sp] := rn dm[sp ? 2] := rm sp := sp ? 4 } exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 90 - mcu team lsi division system lsi business april 2000 push(2) push an, am / push an load register to stack description the push instruction load one or two 22- b it data to software stack from extended registers. in the instructi on of ?push an, am?, there ar e some restrictions on an and am. - an and am should not be a15. - if an is the same as am, push operation occurs only once. ?push an, an? is equivalent to ?push an?. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 1 0 1 am 1 1 1 1 1 an operation if(an == am) { // push an dm[sp] := rn dm[sp ? 2] := {10?h000, en} sp := sp ? 4 } else { dm[sp] := rn dm[sp ? 2] := {10?h000, en} dm[sp ? 4] := rm dm[sp ? 6] := {10?h000, em} sp := sp ? 8 } exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 91 - mcu team lsi division system lsi business april 2000 retd retd ret. from subroutine with delay slot description the retd (return from subroutine with dela y slot) instruction is used to finish a subroutine and return by jumping to the address specified by the link register or a14. the difference between retd and jmp a14 is that retd has a delay slot, which allows efficient implem entation of small subroutines. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1 1 1 operation pc := a14 exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 92 - mcu team lsi division system lsi business april 2000 ret_fiq ret_fiq return from fast interrupt description the ret_fiq (return from fast interrupt) instruction is used to finish a fiq handler and resume the normal program execution. when this instruction is executed, ssr_fiq (saved sr) is restored into sr, and the program control transfers to (spch_fiq:spcl_fiq). 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1 0 0 operation sr := ssr_fiq pc := (spch_fiq:spcl_fiq) exceptions none. notes fast interrupt is requested through the core signal nfiq. when the request is acknowledged, sr and current pc are saved in the designated registers (namely ssr_fiq and spch_fiq:spcl_fiq) assigned for fiq processing. such bits in sr as fe, ie, and te are cleared, and pm is set. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 93 - mcu team lsi division system lsi business april 2000 ret_irq ret_irq return from interrupt description the ret_irq (return from interrupt) instruction is used to finish an irq handler and resume the normal program execution. when this instruction is executed, ssr_irq (saved sr) is restored into sr, and the program control transfers to (spch_irq:spcl_irq). 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1 0 1 operation sr := ssr_irq pc := (spch_irq:spcl_irq) exceptions none. notes interrupt is requested through the core signals nirq. when the request is acknowledged, sr and current pc are saved in the designated registers (namely ssr_irq and spch_fiq:spcl_irq) assigned for irq processing. such bits in sr as ie and te are cleared, and pm is set. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 94 - mcu team lsi division system lsi business april 2000 ret _ swi ret_swi return from software interrupt description the ret_swi (return from software interrupt) instruction is used to finish a swi handler and resume the normal program execution. when this instruction is executed, ssr_fiq (saved sr) is restored into sr, and the program control transfers to the address a14 (link register). 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 0 1 1 1 1 0 1 0 0 1 1 1 1 0 operation sr := ssr_swi pc := a14 exceptions none. notes software interrupt is initiated by execu ting a swi instruction from applications. when swi instruction is executed, sr and current pc are saved in the designated registers (namely ssr_swi and a14) assigned for swi processing. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 95 - mcu team lsi division system lsi business april 2000 rl rl rn rotate left description the rl (rotate left) instruction rotates the value of rn left by one bit and stores the result back in rn. t bit is upda ted as a result of this operation. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 0 0 0 0 1 1 1 1 0 rn operation rn := rn << 1, rn[0] = msb of rn before rotation t bit := msb of rn before rotation exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 96 - mcu team lsi division system lsi business april 2000 rr rr rn rotate right description the rr (rotate right) instruction rotates the value of rn right by one bit and stores the result back in rn. t bit is updated as a result of this operation. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 0 0 0 0 0 1 1 1 0 rn operation rn := rn >> 1, msb of rn = rn[0] before rotation t bit := rn[0] before rotation exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 97 - mcu team lsi division system lsi business april 2000 rrc rrc rn rotate right with carry description the rrc (rotate right with carry) instruction rotates the value of (rn:t bit) right by one bit and stores the result back in rn. t bit is updated as a result of this operation. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 0 0 0 1 0 1 1 1 0 rn operation rn := rn >> 1, msb of rn = t bit before rotation t bit := rn[0] before rotation exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 98 - mcu team lsi division system lsi business april 2000 sbc (1) sbc rn, ri subtract with carry register description the sbc (subtract with carry) instruction is used to synthesize 32-bit subtraction. if register pairs r0, r1 and r2, r3 hold 32-bit values (r0 and r2 hold the least- significant word), the following instructions leave the 32-bit result in r0, r1: sub r0, r2 sbc r1, r3 sbc subtracts the value of register ri, and the value of the carry flag (stored in the t bit), from the value of register rn, and stores the result in register rn. the t bit and the v flag are updated based on the result. 15 14 13 12 11 8 7 6 5 4 3 0 1 0 0 0 rn 0 0 1 1 ri operation rn := rn + ~ri + t bit t bit := carry from (rn + ~ri + t bit) v flag := overflow from (rn + ~ri + t bit) if(rn == r6/r7) z0/z1 := ((rn + ~ri + t) == 0) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 99 - mcu team lsi division system lsi business april 2000 sbc (2) sbc rn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 100 - mcu team lsi division system lsi business april 2000 setsr setsr bs:3 set sr description the setsr (set sr) instruction is used to set a specified bit in sr as follows: setsr fe / ie / te / v / z0 / z1 / pm to set the t bit, one can do as follows: cmp eq, r0, r0 to clear a specified bit in sr, the clrsr instruction (in page 45) is used. 15 14 13 12 11 10 9 8 7 6 5 4 3 2 0 1 0 0 1 1 1 1 0 1 0 0 0 1 excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 101 - mcu team lsi division system lsi business april 2000 sr sr rn shift right description the sr (shift right) instruction shifts the value of rn right by one bit and stores the result back in rn. t bit is upda ted as a result of this operation. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 0 0 1 0 0 1 1 1 0 rn operation rn := rn >> 1, with rn[15] set to 0 t bit := rn[0] before shifting exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 102 - mcu team lsi division system lsi business april 2000 sra sra rn shift right arithmetic description the sra (shift right arithmetic) instruction shifts the value of rn right by one bit and stores the result back in rn. while doing so, the original sign bit (most significant bit) is copied to the most signi ficant bit of the result. t bit is updated as a result of this operation. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 0 0 1 0 1 1 1 1 0 rn operation rn := rn >> 1, with rn[15] set to the original value t bit := rn[0] before shifting exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 103 - mcu team lsi division system lsi business april 2000 srb srb rn shift right byte description the srb (shift right byte) instruction shifts the value of rn right by 8 bit and stores the result back in rn. the high 8 bit positions are filled with 0?s. t bit is updated as a result of this operation. 15 14 13 12 11 10 9 8 7 6 5 4 3 0 1 0 0 0 0 0 1 1 1 1 1 0 rn operation rn[7:0] := rn[15:8] and rn[15:8] := 8?h00 t bit := rn[7] before shifting exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 104 - mcu team lsi division system lsi business april 2000 sub (1) sub rn, ri subtract register description the sub (subtract register) instruction is used to subtract a 16-bit register value from another 16-bit register value. 32-bit subtraction can be achieved by executing sbc instruction in pair with this instruction (see page 98). sub subtracts the value of register ri from the value of rn, and stores the result in register rn. the t bit and the v flag are updated based on the result. 15 14 13 12 11 8 7 6 5 4 3 0 1 0 0 0 rn 0 0 0 1 ri operation rn := rn - ri t bit := carry from (rn - ri) v flag := overflow from (rn - ri) if(rn == r6/r7) z0/z1 := ((rn ? ri) == 0) exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 105 - mcu team lsi division system lsi business april 2000 sub (2) sub rn, # excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 106 - mcu team lsi division system lsi business april 2000 sub (3) sub an, ri subtract extended register description this form of sub instruction (subtract extended register) is used to add a 16-bit unsigned register value from a 22-bit value in register. this instruction subtracts the value of 16-bit register ri from the value of 22-bit register an, and stores th e result in register an. 15 14 13 12 11 10 8 7 6 5 4 3 0 1 0 1 0 1 an 1 1 0 0 ri operation an := an - ri exceptions none. notes none. excellence in low-power the way mcu/dsp should be calmrisc16 reference manual - 107 - mcu team lsi division system lsi business april 2000 sub (4) sub an, # |