cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
skamat95
Newbie
Newbie
1,995 Views
Registered: ‎08-22-2017

array read vs single int read vivado hls

Jump to solution

Why does it take two clock cycles for an int array read as compared to one clock cycle to read an int. Also if the code consists of both array read and an int read, on what basis will it be prioritized while scheduling(In the following code, it always reads the array first. My doubt is why)? In my project I am using Zed Board to learn about the different directives present. The code without any directive is:

 

#include<stdio.h>
#include<math.h>
#include "trial.h"

void trial(int b,int a[10], int c[10])
{

for(int i=0;i<10;i++)
{
c[i] = a[i] + b +i;
}

}

 

The test bench is:

 

#include "trial.h"
#include <stdint.h>
#include <stdio.h>

int main(){

int a[10] = {0};
int b = 10;
int c[10] = {0};
for(int j = 0;j<10;j++)
{
a[j] = 1;
}
trial(b,a,c);
for(int j = 0;j<10;j++)
{
printf("%d\n",c[j]);
}

return 0;
}

 

Header file:

 

#include <stdint.h>
#include <stdio.h>
void trial(int b,int a[10], int c[10]);

 

 I am very new to this topic, any help is appreciated. Thank you in advance!

 

0 Kudos
1 Solution

Accepted Solutions
u4223374
Advisor
Advisor
3,210 Views
Registered: ‎04-26-2015

With no directives, it'll map "a" and "b" into LUT RAMs. For these it'll take one cycle to set the address, and then retrieve data on the next cycle. If you add a PIPELINE directive then it'll reorganize the accesses so it can get one per cycle.

 

Regarding which gets read first - the short answer is that in HLS, it doesn't matter. The whole point of HLS is that you don't need to pay attention to scheduling because that's all done automatically. HLS is generally very good at scheduling operations "adequately" (ie data gets where it needs to be when it needs to be, even if it's not the most elegant or efficient approach). If you want to have low-level control over scheduling, HLS is the wrong tool for the job.

 

 

View solution in original post

0 Kudos
2 Replies
florentw
Moderator
Moderator
1,983 Views
Registered: ‎11-09-2015

Hi @skamat95,

 

Why does it take two clock cycles for an int array read as compared to one clock cycle to read an int.

-> I guess this is because for an array you have to request a read at an address while a int is a value which is supposed to be available directly (sent directly by the upstream block)

 

Also if the code consists of both array read and an int read, on what basis will it be prioritized while scheduling(In the following code, it always reads the array first. My doubt is why)?

-> You are in HW, it should be done at the same time.

 

Hope that helps,

 

Regards,

 

Florent


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
u4223374
Advisor
Advisor
3,211 Views
Registered: ‎04-26-2015

With no directives, it'll map "a" and "b" into LUT RAMs. For these it'll take one cycle to set the address, and then retrieve data on the next cycle. If you add a PIPELINE directive then it'll reorganize the accesses so it can get one per cycle.

 

Regarding which gets read first - the short answer is that in HLS, it doesn't matter. The whole point of HLS is that you don't need to pay attention to scheduling because that's all done automatically. HLS is generally very good at scheduling operations "adequately" (ie data gets where it needs to be when it needs to be, even if it's not the most elegant or efficient approach). If you want to have low-level control over scheduling, HLS is the wrong tool for the job.

 

 

View solution in original post

0 Kudos