algoritmos fpga

7
Algoritmos Diseño de Sistemas con FPGA

Upload: carlos-damian-cofre-lara

Post on 01-Oct-2015

1 views

Category:

Documents


0 download

DESCRIPTION

algoritmo fpga

TRANSCRIPT

  • Algoritmos

    Diseo de Sistemas con FPGA

  • Cuenta Ceros, versin en C

    int cuentaceros(int a[8]) { int count,i; count=0; for(i=0;i

  • Cuenta Ceros, versin en C y en Verilog

    int cuentaceros(int a[8]) { int count,i; count=0; for(i=0;i

  • Cuenta Ceros

    Synthesizing Unit . Related source file is "cuentaceros.v". Found 3-bit adder for signal created at line 34. Found 3-bit adder for signal created at line 34. Found 3-bit adder for signal created at line 34. Found 3-bit adder for signal created at line 34. Found 3-bit adder for signal created at line 34. Found 3-bit adder for signal created at line 34. Found 3-bit adder for signal created at line 34. Summary: inferred 7 Adder/Subtractor(s). Unit synthesized.

    module cuentaceros ( int [7:0] a, output reg[2:0] Count ); integer i; always @* begin Count= 3'b0; for (i = 0; i < 8; i = i+1) begin if (!a[i])Count= Count+1; end end endmodule

  • Que pas?

    Que el for de C es secuencial en el tiempo, y el de Verilog es en rea!

    Es decir, la semntica es distinta!

    Lo mismo ocurre con las funciones que tambin existen en Verilog. Dos invocaciones significa dos reas ocupadas con la misma funcin.

    Ojo! XST infiere hardware para estas construcciones, pero tenemos que tener muy claro lo que queremos hacer.

  • Otra versin en Verilog module countzeros ( input [7:0] a, input clk, input reset, output reg[2:0] Count ); reg [2:0] count_reg, count_next; reg [7:0] a_reg,a_next always @(posedge clk) begin if (reset) begin a_reg
  • Otra versin en Verilog

    Hacer el cuentaceros con una mquina de estados.

    a

    clk

    start

    cuenta

    done