Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

altfp_add_sub

I work with floating point addition and I got a pb in the execution on the fpga when I want to execute my program on a fpga 2s60es, the result is zero Please please i want a solution it 's urgent

thanks a lot

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    And giving more details about what you did and how you got your results could help too.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    i'm so sorry for my poor english

    i use the method PIO to test the bloc altfp_add_sub in quartus all steps are al right in quatus when i want to execute this bloc altfp _add_sub in niosII with fpga 2S60ES

    the results in the console of niosII is 0.000 i don't khnow where is my pb

    the programme that i use is here:

    # include <math.h>

    # include <stdio.h>

    # include <string.h>

    # include <stdlib.h>

    # include "system.h"

    # include "alt_types.h"

    # include <time.h>

    # include <unistd.h>

    # include <sys/alt_timestamp.h>

    # include "sys/alt_irq.h"

    # include "altera_avalon_pio_regs.h"

    void main( void)

    {

    float val=1.1;

    int i;

    IOWR_ALTERA_AVALON_PIO_DATA(PIO_3_BASE, 0);// aclr pin

    IOWR_ALTERA_AVALON_PIO_DATA(PIO_3_BASE, 1);//aclr pin

    //

    IOWR_ALTERA_AVALON_PIO_DATA(PIO_2_BASE, 0);//clk-en

    IOWR_ALTERA_AVALON_PIO_DATA(PIO_0_BASE, 1.2);//

    IOWR_ALTERA_AVALON_PIO_DATA(PIO_1_BASE, 2.3);

    for(i=0;i<6400;i++)

    {

    val=IORD_ALTERA_AVALON_PIO_DATA(PIO_5_BASE);

    }

    }

    please help me and so sorry for my poor english
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    aclr and clken are both active high, so when you write 1 to aclr you keep the IP in constant reset. Similarly by writing 0 to clken you are disabling it.

    The second problem is that in C you can't directly write floating point values to a hardware register. The compiler will cast your floating point values to integer, i.e. it will write 0x00000001 to PIO_0 and 0x00000002 to PIO_1. You will have to generate the correct values in hexadecimal yourself or use a dirty C trick with pointers to avoid automatic casting.