UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Explorer
Explorer
2,946 Views
Registered: ‎03-29-2017

whether rand and srand library function will work or not in vivado HLS ?

Jump to solution

Hi,

 

I am using rand and srand library function to generate random bits. I have referred Xilinx forums in that mentioned only srand()/rand() requires about 256 Bytesof heap to work. But i seems that its work in hls. Not sure !

 

While synthesizing i am getting error "Please go through the attached screen shot"

 

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "ap_cint.h"

int SRAND(unsigned bit) {

#pragma HLS INTERFACE s_axilite port=bit bundle=a
#pragma HLS INTERFACE s_axilite port=return bundle=a

        int i;

        srand((unsigned) time(NULL));

        for (i = 0; i < 100; i++)
        {
#pragma HLS PIPELINE
            bit= rand() % 2;

        //    printf("%d", bit);

        }
return bit;
    }

Tags (2)
srand.PNG
0 Kudos
1 Solution

Accepted Solutions
Scholar u4223374
Scholar
5,320 Views
Registered: ‎04-26-2015

Re: whether rand and srand library function will work or not in vivado HLS ?

Jump to solution

No, they're not supported in HLS. You can write your own pseudo random number generator using a linear feedback shift register if you need to. Time.h is also not supported; the FPGA has no real concept of time.

0 Kudos
1 Reply
Scholar u4223374
Scholar
5,321 Views
Registered: ‎04-26-2015

Re: whether rand and srand library function will work or not in vivado HLS ?

Jump to solution

No, they're not supported in HLS. You can write your own pseudo random number generator using a linear feedback shift register if you need to. Time.h is also not supported; the FPGA has no real concept of time.

0 Kudos