Forum Discussion
Altera_Forum
Honored Contributor
14 years agomodelling interarrival times
Hello, I am interested to model inter arrival times for my design based on exponential distribution. I first tried to write a simple model which given below. I have two clarification...
Altera_Forum
Honored Contributor
14 years agoHello,
I have written a c program to generate interarrival times based on exponential distribution and store it as a .mif file. Here I am generating inter arrival time based on negative exponential distribution function. The packet last for 1.2 micro seconds and my clock is 6.4ns duration. So that it can used to initialize my RAM. Would like to know your feedback and if any improvements can be made. thanks
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# define rate 1
# define width 3
# define depth 64
int main()
{
double u,delta_t;
int i,delta;
FILE *fp = fopen("negexpdata.mif","w");
fprintf(fp,"WIDTH=%d;\n",width);
fprintf(fp,"DEPTH=%d;\n\n",depth);
fprintf(fp,"ADDRESS_RADIX=UNS;\n");
fprintf(fp,"DATA_RADIX=UNS;\n\n");
fprintf(fp,"CONTENT BEGIN\n");
for(i=0;i<depth;i++)
{
u = (double) rand()/ (double) RAND_MAX;
//delta_t = -log(u)/rate;
delta_t = -(1200 * log2(1-u))/6.4;
delta= (int)delta_t;
fprintf(fp,"\t%d\t:\t%d\n",i,delta);
}
fprintf(fp,"END;\n");
fclose(fp);
return(0);
}