Pico Blaze Intro

download Pico Blaze Intro

of 71

Transcript of Pico Blaze Intro

  • 8/17/2019 Pico Blaze Intro

    1/71

    Introducción al Picoblaze

  • 8/17/2019 Pico Blaze Intro

    2/71

    Por que un micro empotrado yno una FSM maquina de estados?

    Micropocessor (a “Programmable FSM”)Sequential execution

    SlowerBetter for complexflow diagramBetter for Large FSMEasier to make

    changes in algorithm

    “Regular” FSMParallel executionFaster

    Better for simpleflow diagram (butcan be used for

    everything)More difficult tomake changes in

    algorithm

  • 8/17/2019 Pico Blaze Intro

    3/71

    Introducción. Múltiplesaplicaciones

    There are literally dozens of 8-bit microcontrollerarchitectures and instruction sets. Modern FPGAs canefficiently implement practically any 8-bit microcontroller,and available FPGA soft cores support popular instructionsets such as the PIC, 8051, AVR, 6502, 8080, and Z80microcontrollers .

  • 8/17/2019 Pico Blaze Intro

    4/71

    Introducción. Múltiplesaplicaciones

    The Xilinx PicoBlaze microcontroller is specificallydesigned and optimized for the Virtex and Spartanseries of FPGAs.

  • 8/17/2019 Pico Blaze Intro

    5/71

    Introducción. Múltiplesaplicaciones

    The PicoBlaze solution consumes considerably lessresources than comparable 8-bit microcontrollerarchitectures.

  • 8/17/2019 Pico Blaze Intro

    6/71

  • 8/17/2019 Pico Blaze Intro

    7/71

    La solución paraprocesamiento sencillo

    PicoBlaze is a compact, capable, and cost-effectivefully embedded 8-bit RISC microcontroller coreoptimized for the Spartan™-3, Virtex™-II, Virtex-II

    Pro™ and Virtex-4 FPGAs and CoolRunner™-IICPLDs.

  • 8/17/2019 Pico Blaze Intro

    8/71

    La solución paraprocesamiento sencillo: te DA

    Free PicoBlaze Macro — The PicoBlazemicrocontroller is delivered as synthesizable VHDLsource code. As a result, the core is future-proof

    and can be migrated to future FPGA and CPLDarchitectures.

  • 8/17/2019 Pico Blaze Intro

    9/71

    La solución paraprocesamiento sencillo

    Ensamblador Facil de usar — The PicoBlazeassembler is provided as a simple DOS executable.The assembler will compile your program in less

    than 3 seconds and generate VHDL, Verilog and anM-file (for Xilinx System Generator) for defining theprogram within a block memory. Otherdevelopment tools include a graphical integrateddevelopment environment (IDE), a graphicalinstruction set simulator (ISS) and VHDL sourcecode and simulation models.

  • 8/17/2019 Pico Blaze Intro

    10/71

    La solución paraprocesamiento sencillo

    Alto rendimiento — PicoBlaze delivers 44 to 100million instructions per second (MIPS) dependingon the target FPGA family and speed grade – many

    times faster than commercially availablemicrocontroller devices..

  • 8/17/2019 Pico Blaze Intro

    11/71

    La solución para

    procesamiento sencillo

    Tamaño Lógico Minimo — PicoBlaze occupies192 logic cells, which represents just 5% of aSpartan-3 XC3S200 device. Because the core only

    consumes a small fraction of the FPGA and CPLDresources, many engineers can use multiplePicoBlaze devices for tackling larger tasks or simply

    keeping tasks isolated and predictable..

  • 8/17/2019 Pico Blaze Intro

    12/71

    La solución para

    procesamiento sencillo

    Empotrable al 100%— The PicoBlazemicrocontroller core is totally embedded within thetarget FPGA or CPLD and requires no external

    resources. Its basic functionality is easily extendedand enhanced by connecting additional logic to themicrocontroller’s input and output ports..

  • 8/17/2019 Pico Blaze Intro

    13/71

  • 8/17/2019 Pico Blaze Intro

    14/71

    CaracterísticasEs un 8-bit fully embedded microcontrollerTiene 16 8-bit general purpose registers,Tiene 8-bit ALU with the carry and zero flags64-byte data memory, scratch RAM

    10-bit instruction address, which supports aprogram up to 1024 instructions256 input ports and 256 output ports,

    Automatic 31-location CALL/RETURNstack

  • 8/17/2019 Pico Blaze Intro

    15/71

    Características (Cont.)Predictable performance, always two clockcycles per instruction, up to 200 MHz or 100MIPS in a Virtex-4™ FPGA and 88 MHz or 44MIPS in a Spartan-3 FPGA

    It also has facility for reset and interruptInstruction size is 16-bitsIt also has facility for reset and interrupt

    Fast interrupt response; worst-case 5 clockcycles

  • 8/17/2019 Pico Blaze Intro

    16/71

    Constant(k) Coded machineKCPSM3 es en muchas formas una maquina basada enconstantesConstant values are specified for use in the following aspects ofa program:

    Constant data value for use in an ALU operationConstant port address to access a specific piece of information orcontrol logic external to the PicoBlaze moduleConstant address values for controlling the execution sequence ofthe program

    Constant Cycles All instructions under all conditions execute over two clock cycles.

    Constant Program LengthThe program length is 256 instructions

  • 8/17/2019 Pico Blaze Intro

    17/71

    Estructura

    3 parts:

    • ALU• Reg file

    • Controlunit

  • 8/17/2019 Pico Blaze Intro

    18/71

    Estructura. DetallesRegisters

    16 8-bit registers labelled from s0 to sF ALU

    Takes two operands of 8-bits and returns theresult to the first register

    Add, Subtract with and without a carry aresupportedLOAD, AND, OR and XOR

    Flow ControlZero and Carry flags are set by the ALU operationsCALL/RETURN used for subroutine facilities

  • 8/17/2019 Pico Blaze Intro

    19/71

    Estructura. Detalles (cont.)

    ResetProcessor goes back to initial stateStarts executing from address 00Everything except the registers is reinitialized

    Input/OutputDuring an input the value on the indicated port istransferred to one of the registersDuring an output the value from one of theregisters is written on an output port

    Interrupt A single interrupt is allowed

  • 8/17/2019 Pico Blaze Intro

    20/71

    Porque uso un Microcontroladordentro de una FPGA?

    Aplicaciones de control y maquinas de

    estado son mas difícil de programarRecursos lógicos crece con el

    incremento de la complejidad

    Ejecución secuencial

    El rendimiento se degrada con el incrementode la complejidadLos requerimientos de memoria incrementa

    con la complejidadRespuesta lenta a estímulos simultáneos

    Debilidades

    Significativamente mucho masrendimientoExcelente para operaciones en

    paraleloSecuential vs. parallelo La

    implementación secuencial frente aparalela sacrifica rendimiento optimo ocosteRespuesta rápida a entradas

    simultaneas

    Fácil para programar aplicaciones de control ymaquinas de estadosLos requerimientos de recursos se mantienen

    constante dentro aún cuando incrementa lacomplejidadRe-uses recursos lógicos, excelente para

    funciones de baja rendimiento

    Fortalezas

    FPGA LogicPicoBlaze Microcontroller

  • 8/17/2019 Pico Blaze Intro

    21/71

    Usando el Microcontrolador

    PicoBlaze en una FPGA Flujo de diseño en VHDL

    El componente (macro o módulo ) es suministrado en VHDL(KCPSM3.vhd) y su declaración es la siguiente

    component KCPSM3port (

    address : out std_logic_vector( 9 downto 0);instruction : in std_logic_vector(17 downto 0);port_id : out std_logic_vector( 7 downto 0);write_strobe : out std_logic;out_port : out std_logic_vector( 7 downto 0);read_strobe : out std_logic;in_port : in std_logic_vector( 7 downto 0);interrupt : in std_logic;interrupt_ack : out std_logic;reset : in std_logic;clk : in std_logic );

    end component ;);

  • 8/17/2019 Pico Blaze Intro

    22/71

    Usando el Microcontrolador

    PicoBlaze en una FPGA Flujo de diseño en VHDL

    El componente (macro ) es suministrado en VHDL(KCPSM3.vhd) y su instanciación en un diseño es la siguiente

    processor: kcpsm3port map (address => address_signal,instruction => instruction_signal,port_id => port_id_signal,write_strobe => write_strobe_signal,out_port => out_port_signal,read_strobe => read_strobe_signal,in_port => in_port_signal,interrupt => interrupt_signal,interrupt_ack => interrupt_ack_signal,reset => reset_signal,clk => clk_signal );

  • 8/17/2019 Pico Blaze Intro

    23/71

    Usando el Microcontrolador

    PicoBlaze en una FPGA Flujo de diseño en VHDL

    La memoria de programa (ROM). ThePicoBlaze program ROM is used within a

    VHDL design flow.The PicoBlaze assembler generates a VHDLfile in which a block RAM and its initialcontents are defined. This VHDL file can be

    used for both logic synthesis andsimulation of the processor

  • 8/17/2019 Pico Blaze Intro

    24/71

    Usando el Microcontrolador

    PicoBlaze en una FPGA

    Flujo de diseño en VHDLDeclaración del componente (ROM).component prog_romport ( address : in std_logic_vector( 9 downto 0);

    instruction : out std_logic_vector(17 downto 0);clk : in std_logic);end component ;

    El nombre del componente deriva de nombre del

    fichero con el programa en ensamblador. Por ejemplosi tu programa se llama reloj.psm la memoria(componente) en vhdl se llama reloj.vhd . Esteproceso resulta de aplicar el compilador suministrado

  • 8/17/2019 Pico Blaze Intro

    25/71

  • 8/17/2019 Pico Blaze Intro

    26/71

    Diagrama de bloques del Micro +

    ROM. Poniendo todo junto

    signal instruction : std_logic_vector(17 downto 0);

    signal address : std_logic_vector(9 downto 0);

  • 8/17/2019 Pico Blaze Intro

    27/71

    PicoBlaze Herramientas de

    desarrollo Existen 3 herramientas de desarrollo

    Xilinx KCPSM3Mediatronix pBlazIDE

    Xilinx System Generator

  • 8/17/2019 Pico Blaze Intro

    28/71

    PicoBlaze Herramientas de

    desarrollo

    SiSiN/A Memory Viewer

    SiSiN/A Register Viewer

    SiSiN/A SimulatorBreakpoints

    Grafico/InteractivoGrafico/Interactivo VHDLInstruction Set Simulator

    KCPSM3PBlazIDEKCPSM3Sintaxisinstruciones

    Linea de comandodentro de

    System Generator

    GraficoLínea de comando enDos Wiindow

    Ensamblador

    Windows 2000 y XPWindows 98, 2000,NT, ME, XP

    WindowsPlataforma

    Xilinx System

    Generator

    Mediatronix

    pBlazIDE

    Xilinx KCPSM3

  • 8/17/2019 Pico Blaze Intro

    29/71

    PicoBlaze Herramientas de

    desarrollo Xilinx KCPSM3

    The KCPSM3 Assembler is provided as a simple DOSexecutable file together with three template files.Importante Crear un directorio de trabajo. Copy all thefiles KCPSM3.EXE, ROM_form.vhd, ROM_form.v, and ROM_form.coe dentro del directorio de trabajo.Los programas pueden ser escritos con el wordpad .Salvar con extensión psm

    Abre un cmd DOS.kcpsm3 [.psm]

    El ensamblador da salida de errores por pantalla (peor muyrápida) usar un fichero de salida para depurar errores:kcpsm3 [.psm] > screen_dump.txt

  • 8/17/2019 Pico Blaze Intro

    30/71

    PicoBlaze Herramientas de

    desarrollo Compilación. Ficheros de entrada y salida.

    l d l ll

  • 8/17/2019 Pico Blaze Intro

    31/71

    Ejemplo de una Plantilla

    de un programa ( KCPSM3 )

    NAMEREG sX, ; Rename register sX with CONSTANT , 00 ; Define constant , assign value

    ; ROM output file es siempre llamado ; .vhd

    ADDRESS 000 ; Programs always start at reset vector 0 ENABLE INTERRUPT ; If using interrupts, be sure to enable

    ; the INTERRUPT input BEGIN:

    ; > JUMP BEGIN ; Embedded applications never end

    ISR: ; An Interrupt Service Routine (ISR) is ; required if using interrupts ; Interrupts are automatically disabled ; when an interrupt is recognized ; Never re-enable interrupts during the ISR

    RETURNI ENABLE ; Return from interrupt service routine ; Use RETURNI DISABLE to leave interrupts ; disabled

    ADDRESS 3FF ; Interrupt vector is located at highest ; instruction address

    JUMP ISR ; Jump to interrupt service routine, IS

    Ej l d Pl ill d

  • 8/17/2019 Pico Blaze Intro

    32/71

    Ejemplo de una Plantilla de

    un programa ( pBlazIDE ) EQU sX ; Rename register sX with EQU $00 ; Define constant , assign value

    ; name ROM output file generated by pBlazIDE assembler VHDL “template.vhd”, “target.vhd”, “entity_name” DSIN ; Create input port, assign port address DSOUT ; Create output port, assign port address DSIO ; Create readable output port,

    ; assign port address ORG 0 ; Programs always start at reset vector 0

    EINT ; If using interrupts, be sure to enable the INTERRUPT input

    BEGIN: ; >

    JUMP BEGIN ; Embedded applications never end ISR: ; An Interrupt Service Routine (ISR) is

    ; required if using interrupts ; Interrupts are automatically disabled ; when an interrupt is recognized ; Never re-enable interrupts during the ISR RETI ENABLE ; Return from interrupt service routine

    ; Use RETURNI DISABLE to leave interrupts ; disabled

    ORG $3FF ; Interrupt vector is located at highest ; instruction address JUMP ISR ; Jump to interrupt service routine, ISR

  • 8/17/2019 Pico Blaze Intro

    33/71

    Conjunto de instruccionesProgram Control Group (jump, call y return)

    Jump Instruction – Both conditional andunconditional

  • 8/17/2019 Pico Blaze Intro

    34/71

  • 8/17/2019 Pico Blaze Intro

    35/71

    Conjunto de instruccionesProgram Control Group (jump, call y return)

    Return Instruction

  • 8/17/2019 Pico Blaze Intro

    36/71

  • 8/17/2019 Pico Blaze Intro

    37/71

  • 8/17/2019 Pico Blaze Intro

    38/71

    Logical Group (contd.)OR

    XOR

  • 8/17/2019 Pico Blaze Intro

    39/71

    Grupo aritmético ADD – without carry

    ADDC - with carry

  • 8/17/2019 Pico Blaze Intro

    40/71

    Arithmetic Group (contd.)SUB – without carry

    SUBC – with carry

  • 8/17/2019 Pico Blaze Intro

    41/71

    Shift and Rotate GroupShift right

    Shift left

  • 8/17/2019 Pico Blaze Intro

    42/71

    Shift right

  • 8/17/2019 Pico Blaze Intro

    43/71

    Shift left

  • 8/17/2019 Pico Blaze Intro

    44/71

    Input and Output GroupInput

    Output

  • 8/17/2019 Pico Blaze Intro

    45/71

  • 8/17/2019 Pico Blaze Intro

    46/71

    Individual ModulesOperand Select

    Arithmetic GroupLogic GroupShift and Rotate Group

    ALU Multiplexer ALU Control

    Program CounterStack Counter

  • 8/17/2019 Pico Blaze Intro

    47/71

    I di id l M d l

  • 8/17/2019 Pico Blaze Intro

    48/71

    Individual Modules

    CPU I t f

  • 8/17/2019 Pico Blaze Intro

    49/71

    CPU Interface

    CPU I t f

  • 8/17/2019 Pico Blaze Intro

    50/71

    CPU Interface

    Picoblaze no tiene Periféricos integradosestos se construyen si se necesitan …Se usan las instrucciones input y

    ouput para comunicase con ellos

    CPU I t f

  • 8/17/2019 Pico Blaze Intro

    51/71

    CPU Interface

    S

  • 8/17/2019 Pico Blaze Intro

    52/71

    System Architecture

    PicoBlaze

    Port ID

    In port

    Out port

    Read Strobe

    Write StrobeInterrupt

    Instruction

    Memory

    Device

    Address

    Instruction

    Reset

    Clock

    Data

  • 8/17/2019 Pico Blaze Intro

    53/71

    Data

    MovementInstruction

  • 8/17/2019 Pico Blaze Intro

    54/71

    Port Input

  • 8/17/2019 Pico Blaze Intro

    55/71

    Port Input

  • 8/17/2019 Pico Blaze Intro

    56/71

    Lectura de un puerto. Formas de

  • 8/17/2019 Pico Blaze Intro

    57/71

    ondas

    Port Output

  • 8/17/2019 Pico Blaze Intro

    58/71

    Port Output

    Clock of output Device is the same as CPU clock

  • 8/17/2019 Pico Blaze Intro

    59/71

    Write Enable

    D Q

    QEN

  • 8/17/2019 Pico Blaze Intro

    60/71

    Example

    Port Write Waveform

  • 8/17/2019 Pico Blaze Intro

    61/71

  • 8/17/2019 Pico Blaze Intro

    62/71

    Editing PSM file

  • 8/17/2019 Pico Blaze Intro

    63/71

    Compiling

  • 8/17/2019 Pico Blaze Intro

    64/71

    Verifying Compilation

  • 8/17/2019 Pico Blaze Intro

    65/71

    Verifying Compilation

  • 8/17/2019 Pico Blaze Intro

    66/71

    Identifying an error

  • 8/17/2019 Pico Blaze Intro

    67/71

    Verifying Everything is OK

  • 8/17/2019 Pico Blaze Intro

    68/71

    Copy generated verilog file

  • 8/17/2019 Pico Blaze Intro

    69/71

  • 8/17/2019 Pico Blaze Intro

    70/71

  • 8/17/2019 Pico Blaze Intro

    71/71