2
LatticeMico
8
Microcontroller
Lattice Semiconductor
User’s Guide
Register File
The register file is implemented using dual ported distributed RAM. It contains 32 8-bit entries. Two values can be
simultaneously read from the register file.
Scratch Pad RAM (Internal)
The internal scratch pad memory has 32 entries. It can be addressed directly or indirectly (via a register). Indirect
addressing mode is not available if external scratch pad memory is attached.
Optional External Scratch Pad
The external scratch pad provides an additional 256 bytes of memory. It can be implemented using either distrib-
uted RAM or using an EBR. The external scratch pad memory can be addressed via indirect addressing only.
Hardware (Circular) Call Stack
When a
call
instruction is executed, the address of the next instruction is pushed into the call stack, a
ret
(return) instruction will pop the stack and continue execution from the location at the top of the stack.
An interrupt also causes the address of the instruction that would have executed next to be pushed into the call
stack. The
reti
(return from interrupt) instruction will pop the stack and continue from the location at the top of the
stack.
The stack is implemented as a circular buffer and any program execution will continue from an undefined location in
case of a stack overflow or underflow.
Interrupt Handling
The microcontroller has one interrupt source, which is level sensitive. The interrupt can be enabled or disabled by
software (
cli
= clear interrupt,
sti
= set interrupt). When an interrupt is received, the address of the next instruc-
tion is pushed into the call stack and the microcontroller continues execution from the interrupt vector (address 0).
The flags (carry and zero) are copied to shadow locations. The
interrupt ack
line is set high and the acknowl-
edge line is held high for the entire duration of interrupt handling. Once the interrupt has been acknowledged the
interrupt line should be set to 0.
A
reti
instruction will pop the call stack and transfer control to the address on top of the stack. The Flags (carry
and zero) are restored from the shadow locations. The interrupt acknowledge line is set to low.
The microcontroller cannot handle nested interrupts.
Input/Output
Input and output are done via “ports”. Up to 256 port numbers are allowed. The lower 32 ports can be addressed
directly (using the
import
and
export
instructions), or indirectly (using the
importi
and
exporti
instructions).
The upper 224 ports can be accessed by indirect addressing only (by the
importi
and
exporti
instructions).
The port number (0-31 of
import
,
export
and 0-255 for
importi
and
exporti
instructions) is presented at the
external interface for two cycles.
For
import
and
importi
instructions, the
ext_io_rd
signal is strobed in the same cycle as the input values are
sampled. The address signal is
ext_addr
and the input signals are
ext_io_din
. Both the address and the I/O
read strobe are driven in the second cycle. In the case of the
importi
instruction, the
ext_addr
signal is driven
from the register file; otherwise, for the
import
instruction, it is driven directly from the instruction. Figure 2 shows
the waveform corresponding to a read.