Picoblaze Overview EENG 2910
Introduction 8-bit microcontroller for Xilinx devices Soft Core – Soft Processor 5% of the resources of spartan 3 (3S200 devicee) Compact, and Flexible Utilized for simple data processing and control
Introduction 8-bit data width 8-bit ALU with carry and zero flag 16 8-bit general-purpose registers 64-byte data memory 18 bit instruction width 10-bit instruction address (supports 1024 instr.) 256 input ports and 256 output ports 2 clock cycles per instruction
Instruction Set Logical Instructions Arithmetic Instruction Compare and test Instruction Shift and rotate Instruction Data Movement Instruction Program flow control Instructions Interrupt related Instruction
Programming Model (Notation) sX, sY : represents General Purpose Register Pc : Program Counter Tos : top-of-stack pointer of the call/return stack c, z, i: carry, zero, and interrupt flags Kk : 8 bit constant or port id Ss : 6-bit constant data memory address AAA: 10-bit constant instruction memory address.
Instruction Format op sX, sY : register-register format (sX, sY – operand, op – operation, sX – destination, sX sX op kk) op sX, kk: register-constant format (?) op sX: single – register format – used in shifting and rotating instructions with one operand. op AAA : single-address format. E.g jump and call instruction. AAA – address. Op - instruction without operand
Operations (Examples) Logical Operation (6 instructions) : and, or, xor Arithmetic operation (8): add, addcy or addc (addcy – add with carry flag), sub, subcy or subc. Compare and Test operation: compare sX, sY or comp sX, sY, compare sX, kk or comp sX, kk if sX=sY then z 1 else z 0; if sX>sY then c 1 else c 0; test sX, SY t s X and s Y ; if t = 0 then else z 0; C t(7) xor t(6) xor....xor t(0)
Operations Shift and Rotate Instruction sl0 sX – Shift a register left 1 bit and shift 0 into the LSB. sX sX(6…0) & 0; c sX(7) sl1 sX – shift a register left 1 bit and shift 1 into LSB. sX sX(6…0) & sX(0); c sX(7) slx sX – shift a register left 1 bit and shift sX(0) into the LSB. sla sX – shift left 1 bit and shift c into LSB similarly, sr0, sr1, srx, sra sX, rl sX, rr sX etc.
Data Movement Computation done via Registers and ALU Movement between - registers – load -Register and data RAM – Fetch and Store -Register and I/O port : input and output Load sX, sY; load sX, kk; - sX (sY or kk); fetch sX, (sY) or fetch (sX, sY);- sX RAM(sY); Fetch sX, SS, - sX RAM(sY); store sX, (sY) (or store sX, sY) –RAM[sX] sX; - move data from register to data RAM. Input sX, (sY), or in sX, sY –move data from input port to a register. sX in_port Output sX, (sY) (out sX, sY) move data from a register to the input port
Program Flow Jump, call, and return – load a value to the program counter and modify program flow. Unconditionally or conditionally based on zero and carry flags. Jump AAA – unconditional jump Jump c, AAA – jump if carry flag is set ( if c = 0 then pc AAA else pc = pc + 1) Jump nc, AAA; jump z, AAA; jump nz, AAA
Program flow - Call and Return Implementation of functions Call – loads a new value to the pc, saves it current value to a stack (special buffer). The routine contains a return( obtains the saved value from the stack and increment by 1) at the end. Picoblaze support nested function (LIFO). Picoblaze has 31-word stack.
Program flow Call AAA (unconditionally call subroutine) tos tos Stack [tos] pc; Pc AAA Call c, AAA (conditionally call subroutine) If (c = 1) tos tos Stack [tos] pc; Pc AAA Else Pc pc + 1 Return (ret) Return c, (ret c)