Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > verifying UNIFORM using matlab

Reply
Thread Tools

verifying UNIFORM using matlab

 
 
FPGA
Guest
Posts: n/a
 
      03-03-2008
I have written a process to generate random numbers using UNIFORM. I
was trying to check the results using "rand" in matlab. How do i
initialise the seed values of both these functions to the same value.
I see that the random numbers generated by UNIFORM are different
compared to rand when the seed values are left uninitialised.
What do I need to change so that I get same output from both programs.

Thanks
 
Reply With Quote
 
 
 
 
Tricky
Guest
Posts: n/a
 
      03-04-2008
On Mar 3, 9:15 pm, FPGA <FPGA.unkn...@gmail.com> wrote:
> I have written a process to generate random numbers using UNIFORM. I
> was trying to check the results using "rand" in matlab. How do i
> initialise the seed values of both these functions to the same value.
> I see that the random numbers generated by UNIFORM are different
> compared to rand when the seed values are left uninitialised.
> What do I need to change so that I get same output from both programs.
>
> Thanks


Uninitilised positives (the seeds in this case) will take a value of 1
when they are put into the uniform function. Unitialised types when
used will take type'low as their value

positive'low = 1
std_logic'low = 'u'
etc.

so both of your first calls to uniform are seeding it with two 1s.

I dont know how the seeding works in matlab. It may not even use
positives, but the entire integer range. it is common in C to seed the
random number generator with the system time. Does matlab do something
similar? The C random function only has 1 seed, whereas uniform takes
2.
 
Reply With Quote
 
 
 
 
FPGA
Guest
Posts: n/a
 
      03-04-2008
On Mar 4, 4:26*am, Tricky <Trickyh...@gmail.com> wrote:
> On Mar 3, 9:15 pm, FPGA <FPGA.unkn...@gmail.com> wrote:
>
> > I have written a process to generate random numbers using UNIFORM. I
> > was trying to check the results using "rand" in matlab. How do i
> > initialise the seed values of both these functions to the same value.
> > I see that the random numbers generated by UNIFORM are different
> > compared to rand when the seed values are left uninitialised.
> > What do I need to change so that I get same output from both programs.

>
> > Thanks

>
> Uninitilised positives (the seeds in this case) will take a value of 1
> when they are put into the uniform function. Unitialised types when
> used will take type'low as their value
>
> positive'low = 1
> std_logic'low = 'u'
> etc.
>
> so both of your first calls to uniform are seeding it with two 1s.
>
> I dont know how the seeding works in matlab. It may not even use
> positives, but the entire integer range. it is common in C to seed the
> random number generator with the system time. Does matlab do something
> similar? The C random function only has 1 seed, whereas uniform takes
> 2.


I am not sure how the rand function in MATLAB works. I tried to search
if the code of the function was described anywhere but couldnt find.
I dont know if we can get MATLAB to generate results as UNIFORM does.
As you said, uniform has 2 seeds while rand has 1.
If anyone has an idea on how this can be done, please post your
comment.

 
Reply With Quote
 
Tricky
Guest
Posts: n/a
 
      03-04-2008
On Mar 4, 2:00 pm, FPGA <FPGA.unkn...@gmail.com> wrote:
> On Mar 4, 4:26 am, Tricky <Trickyh...@gmail.com> wrote:
>
>
>
> > On Mar 3, 9:15 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > I have written a process to generate random numbers using UNIFORM. I
> > > was trying to check the results using "rand" in matlab. How do i
> > > initialise the seed values of both these functions to the same value.
> > > I see that the random numbers generated by UNIFORM are different
> > > compared to rand when the seed values are left uninitialised.
> > > What do I need to change so that I get same output from both programs.

>
> > > Thanks

>
> > Uninitilised positives (the seeds in this case) will take a value of 1
> > when they are put into the uniform function. Unitialised types when
> > used will take type'low as their value

>
> > positive'low = 1
> > std_logic'low = 'u'
> > etc.

>
> > so both of your first calls to uniform are seeding it with two 1s.

>
> > I dont know how the seeding works in matlab. It may not even use
> > positives, but the entire integer range. it is common in C to seed the
> > random number generator with the system time. Does matlab do something
> > similar? The C random function only has 1 seed, whereas uniform takes
> > 2.

>
> I am not sure how the rand function in MATLAB works. I tried to search
> if the code of the function was described anywhere but couldnt find.
> I dont know if we can get MATLAB to generate results as UNIFORM does.
> As you said, uniform has 2 seeds while rand has 1.
> If anyone has an idea on how this can be done, please post your
> comment.


Why not generate a file containing all the stimulus for the vhdl and
matlab model in one or the other, instead of trying to recreate the
random sequence?
 
Reply With Quote
 
FPGA
Guest
Posts: n/a
 
      03-04-2008
On Mar 4, 9:12*am, Tricky <Trickyh...@gmail.com> wrote:
> On Mar 4, 2:00 pm, FPGA <FPGA.unkn...@gmail.com> wrote:
>
>
>
>
>
> > On Mar 4, 4:26 am, Tricky <Trickyh...@gmail.com> wrote:

>
> > > On Mar 3, 9:15 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > > I have written a process to generate random numbers using UNIFORM. I
> > > > was trying to check the results using "rand" in matlab. How do i
> > > > initialise the seed values of both these functions to the same value..
> > > > I see that the random numbers generated by UNIFORM are different
> > > > compared to rand when the seed values are left uninitialised.
> > > > What do I need to change so that I get same output from both programs.

>
> > > > Thanks

>
> > > Uninitilised positives (the seeds in this case) will take a value of 1
> > > when they are put into the uniform function. Unitialised types when
> > > used will take type'low as their value

>
> > > positive'low = 1
> > > std_logic'low = 'u'
> > > etc.

>
> > > so both of your first calls to uniform are seeding it with two 1s.

>
> > > I dont know how the seeding works in matlab. It may not even use
> > > positives, but the entire integer range. it is common in C to seed the
> > > random number generator with the system time. Does matlab do something
> > > similar? The C random function only has 1 seed, whereas uniform takes
> > > 2.

>
> > I am not sure how the rand function in MATLAB works. I tried to search
> > if the code of the function was described anywhere but couldnt find.
> > I dont know if we can get MATLAB to generate results as UNIFORM does.
> > As you said, uniform has 2 seeds while rand has 1.
> > If anyone has an idea on how this can be done, please post your
> > comment.

>
> Why not generate a file containing all the stimulus for the vhdl and
> matlab model in one or the other, instead of trying to recreate the
> random sequence?- Hide quoted text -
>
> - Show quoted text -


The goal is to check that the VHDL code generates results similar to
MATLAB . I have written the outputs of both in seperate text files. I
am not able to initialise the rand function to generate results
similar to MATLAB and vice versa. Called MATLAB today to get some more
information on how they have developed the rand function. They said
that this information is not available to the public.
I think one of the ways to do this would be, generating a pdf function
for both cases and showing that their random distriution is similar.

If any of you have other ideas please post them.
 
Reply With Quote
 
Tricky
Guest
Posts: n/a
 
      03-04-2008
On Mar 4, 3:23 pm, FPGA <FPGA.unkn...@gmail.com> wrote:
> On Mar 4, 9:12 am, Tricky <Trickyh...@gmail.com> wrote:
>
>
>
> > On Mar 4, 2:00 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > On Mar 4, 4:26 am, Tricky <Trickyh...@gmail.com> wrote:

>
> > > > On Mar 3, 9:15 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > > > I have written a process to generate random numbers using UNIFORM. I
> > > > > was trying to check the results using "rand" in matlab. How do i
> > > > > initialise the seed values of both these functions to the same value.
> > > > > I see that the random numbers generated by UNIFORM are different
> > > > > compared to rand when the seed values are left uninitialised.
> > > > > What do I need to change so that I get same output from both programs.

>
> > > > > Thanks

>
> > > > Uninitilised positives (the seeds in this case) will take a value of 1
> > > > when they are put into the uniform function. Unitialised types when
> > > > used will take type'low as their value

>
> > > > positive'low = 1
> > > > std_logic'low = 'u'
> > > > etc.

>
> > > > so both of your first calls to uniform are seeding it with two 1s.

>
> > > > I dont know how the seeding works in matlab. It may not even use
> > > > positives, but the entire integer range. it is common in C to seed the
> > > > random number generator with the system time. Does matlab do something
> > > > similar? The C random function only has 1 seed, whereas uniform takes
> > > > 2.

>
> > > I am not sure how the rand function in MATLAB works. I tried to search
> > > if the code of the function was described anywhere but couldnt find.
> > > I dont know if we can get MATLAB to generate results as UNIFORM does.
> > > As you said, uniform has 2 seeds while rand has 1.
> > > If anyone has an idea on how this can be done, please post your
> > > comment.

>
> > Why not generate a file containing all the stimulus for the vhdl and
> > matlab model in one or the other, instead of trying to recreate the
> > random sequence?- Hide quoted text -

>
> > - Show quoted text -

>
> The goal is to check that the VHDL code generates results similar to
> MATLAB . I have written the outputs of both in seperate text files. I
> am not able to initialise the rand function to generate results
> similar to MATLAB and vice versa. Called MATLAB today to get some more
> information on how they have developed the rand function. They said
> that this information is not available to the public.
> I think one of the ways to do this would be, generating a pdf function
> for both cases and showing that their random distriution is similar.
>
> If any of you have other ideas please post them.


In that case, why are you even trying to do this? generate a file from
matlab that is used as the stimulus for the VHDL testbench. Then you
do not need to use the uniform function at all, and then you are
testing that the results match.
 
Reply With Quote
 
FPGA
Guest
Posts: n/a
 
      03-04-2008
On Mar 4, 10:45*am, Tricky <Trickyh...@gmail.com> wrote:
> On Mar 4, 3:23 pm, FPGA <FPGA.unkn...@gmail.com> wrote:
>
>
>
>
>
> > On Mar 4, 9:12 am, Tricky <Trickyh...@gmail.com> wrote:

>
> > > On Mar 4, 2:00 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > > On Mar 4, 4:26 am, Tricky <Trickyh...@gmail.com> wrote:

>
> > > > > On Mar 3, 9:15 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > > > > I have written a process to generate random numbers using UNIFORM. I
> > > > > > was trying to check the results using "rand" in matlab. How do i
> > > > > > initialise the seed values of both these functions to the same value.
> > > > > > I see that the random numbers generated by UNIFORM are different
> > > > > > compared to rand when the seed values are left uninitialised.
> > > > > > What do I need to change so that I get same output from both programs.

>
> > > > > > Thanks

>
> > > > > Uninitilised positives (the seeds in this case) will take a value of 1
> > > > > when they are put into the uniform function. Unitialised types when
> > > > > used will take type'low as their value

>
> > > > > positive'low = 1
> > > > > std_logic'low = 'u'
> > > > > etc.

>
> > > > > so both of your first calls to uniform are seeding it with two 1s.

>
> > > > > I dont know how the seeding works in matlab. It may not even use
> > > > > positives, but the entire integer range. it is common in C to seed the
> > > > > random number generator with the system time. Does matlab do something
> > > > > similar? The C random function only has 1 seed, whereas uniform takes
> > > > > 2.

>
> > > > I am not sure how the rand function in MATLAB works. I tried to search
> > > > if the code of the function was described anywhere but couldnt find.
> > > > I dont know if we can get MATLAB to generate results as UNIFORM does..
> > > > As you said, uniform has 2 seeds while rand has 1.
> > > > If anyone has an idea on how this can be done, please post your
> > > > comment.

>
> > > Why not generate a file containing all the stimulus for the vhdl and
> > > matlab model in one or the other, instead of trying to recreate the
> > > random sequence?- Hide quoted text -

>
> > > - Show quoted text -

>
> > The goal is to check that the VHDL code generates results similar to
> > MATLAB . I have written the outputs of both in seperate text files. I
> > am not able to initialise the rand function to generate results
> > similar to MATLAB and vice versa. Called MATLAB today to get some more
> > information on how they have developed the rand function. They said
> > that this information is not available to the public.
> > I think one of the ways to do this would be, generating a pdf function
> > for both cases and showing that their random distriution is similar.

>
> > If any of you have other ideas please post them.

>
> In that case, why are you even trying to do this? generate a file from
> matlab that is used as the stimulus for the VHDL testbench. Then you
> do not need to use the uniform function at all, and then you are
> testing that the results match.- Hide quoted text -
>
> - Show quoted text -


I have to use the UNFORM function to check if it behaves in sync with
MATLAB. I have given up on getting the same results in matlab as in
VHDL. I am just trying to get a pdf plot of both results. No idea on
how to do this yet.
 
Reply With Quote
 
ajjc
Guest
Posts: n/a
 
      03-06-2008
On Mar 4, 12:10 pm, FPGA <FPGA.unkn...@gmail.com> wrote:
> On Mar 4, 10:45 am, Tricky <Trickyh...@gmail.com> wrote:
>
>
>
> > On Mar 4, 3:23 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > On Mar 4, 9:12 am, Tricky <Trickyh...@gmail.com> wrote:

>
> > > > On Mar 4, 2:00 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > > > On Mar 4, 4:26 am, Tricky <Trickyh...@gmail.com> wrote:

>
> > > > > > On Mar 3, 9:15 pm, FPGA <FPGA.unkn...@gmail.com> wrote:

>
> > > > > > > I have written a process to generate random numbers using UNIFORM. I
> > > > > > > was trying to check the results using "rand" in matlab. How do i
> > > > > > > initialise the seed values of both these functions to the same value.
> > > > > > > I see that the random numbers generated by UNIFORM are different
> > > > > > > compared to rand when the seed values are left uninitialised.
> > > > > > > What do I need to change so that I get same output from both programs.

>
> > > > > > > Thanks

>
> > > > > > Uninitilised positives (the seeds in this case) will take a value of 1
> > > > > > when they are put into the uniform function. Unitialised types when
> > > > > > used will take type'low as their value

>
> > > > > > positive'low = 1
> > > > > > std_logic'low = 'u'
> > > > > > etc.

>
> > > > > > so both of your first calls to uniform are seeding it with two 1s.

>
> > > > > > I dont know how the seeding works in matlab. It may not even use
> > > > > > positives, but the entire integer range. it is common in C to seed the
> > > > > > random number generator with the system time. Does matlab do something
> > > > > > similar? The C random function only has 1 seed, whereas uniform takes
> > > > > > 2.

>
> > > > > I am not sure how the rand function in MATLAB works. I tried to search
> > > > > if the code of the function was described anywhere but couldnt find.
> > > > > I dont know if we can get MATLAB to generate results as UNIFORM does.
> > > > > As you said, uniform has 2 seeds while rand has 1.
> > > > > If anyone has an idea on how this can be done, please post your
> > > > > comment.

>
> > > > Why not generate a file containing all the stimulus for the vhdl and
> > > > matlab model in one or the other, instead of trying to recreate the
> > > > random sequence?- Hide quoted text -

>
> > > > - Show quoted text -

>
> > > The goal is to check that the VHDL code generates results similar to
> > > MATLAB . I have written the outputs of both in seperate text files. I
> > > am not able to initialise the rand function to generate results
> > > similar to MATLAB and vice versa. Called MATLAB today to get some more
> > > information on how they have developed the rand function. They said
> > > that this information is not available to the public.
> > > I think one of the ways to do this would be, generating a pdf function
> > > for both cases and showing that their random distriution is similar.

>
> > > If any of you have other ideas please post them.

>
> > In that case, why are you even trying to do this? generate a file from
> > matlab that is used as the stimulus for the VHDL testbench. Then you
> > do not need to use the uniform function at all, and then you are
> > testing that the results match.- Hide quoted text -

>
> > - Show quoted text -

>
> I have to use the UNFORM function to check if it behaves in sync with
> MATLAB. I have given up on getting the same results in matlab as in
> VHDL. I am just trying to get a pdf plot of both results. No idea on
> how to do this yet.


Sounds like you have an ill-posed question here.

Mathworks won't tell you how it got it's pseudo-random stream...call
it rand(i), where rand(0)
is the seed.(In fact, you don't even know if there is a single seed or
any seed for that matter!)

You have created a pseudo-random stream fpga_rand(i), where the seed
is fpga_rand(0).
You are going to have to be satisfied with using statistical tests to
verify that
your function fpga_rand passes as many of the tests as you need, or at
least as many as the
matlab rand function passes. Look up http://en.wikipedia.org/wiki/Diehard_tests

alan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vectorized computation in C++ such as those in Matlab (Matlab toC++)? Luna Moon C++ 16 08-08-2008 04:27 PM
Eclipse RCP and MATLAB (calling MATLAB from JAVA) siki Java 0 01-16-2007 04:19 AM
Specify string with uniform indentation ignored tobiah Python 3 09-14-2006 10:15 PM
Re: Uniform "toolbar" on all machines. Evan Platt Computer Support 4 07-21-2005 12:59 PM
Newbie q: Parsing vendor-data into uniform XML Casper B XML 3 01-13-2005 01:20 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57