FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > VHDL

VHDL comp.lang.vhdl newsgroup / Usenet

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-06-2006, 01:27 PM
Weng Tianxiang
Guest
 
Posts: n/a
Default Global constants definition problem

Hi,
Help is needed.

I have some global constants shared among several modules, so I
set up a file to define a global package like the following:

Package MG_x_Constant is
constant DATA_BITS : integer := 16;
constant DATA_RANGE : real := (2.0**16);
-- constant DATA_BITS : integer := 64;
-- constant DATA_RANGE : real := (2.0**64);


-- used in all test bench
constant DATABITS : integer := DATA_BITS;

end MG_x_Constant;

Package body MG_x_Constant is
....
end MG_x_Constant;

In other modules, DATA_BITS, DATABITS are freely used.

This morning I found a problem:
when I changed DATA_BITS from 16 to 64, the ModelSim
sim window still shows constant DATABITS = 16 and it never changed,
even though I tried to delete the module from library and
re-compile it again. constant DATABITS = 16 doesn't change.

IN compilation order, the global package definition file is always the
first one.

I though if the global constant definition changes, all its appearance
should change, but it doesn't. Why?

What is wrong with the above statements?

Thank you.

Weng

Reply With Quote
  #2 (permalink)  
Old 09-06-2006, 02:10 PM
Jozsef
Guest
 
Posts: n/a
Default Re: Global constants definition problem

Hello,
Try to recompile ALL sources which references to this package. I think
about modelsim don't check & update referenced variables under
compilation process in other sources.

Best regards

Weng Tianxiang wrote:
> Hi,
> Help is needed.
>
> I have some global constants shared among several modules, so I
> set up a file to define a global package like the following:
>
> Package MG_x_Constant is
> constant DATA_BITS : integer := 16;
> constant DATA_RANGE : real := (2.0**16);
> -- constant DATA_BITS : integer := 64;
> -- constant DATA_RANGE : real := (2.0**64);
>
>
> -- used in all test bench
> constant DATABITS : integer := DATA_BITS;
>
> end MG_x_Constant;
>
> Package body MG_x_Constant is
> ...
> end MG_x_Constant;
>
> In other modules, DATA_BITS, DATABITS are freely used.
>
> This morning I found a problem:
> when I changed DATA_BITS from 16 to 64, the ModelSim
> sim window still shows constant DATABITS = 16 and it never changed,
> even though I tried to delete the module from library and
> re-compile it again. constant DATABITS = 16 doesn't change.
>
> IN compilation order, the global package definition file is always the
> first one.
>
> I though if the global constant definition changes, all its appearance
> should change, but it doesn't. Why?
>
> What is wrong with the above statements?
>
> Thank you.
>
> Weng


Reply With Quote
  #3 (permalink)  
Old 09-06-2006, 04:07 PM
Weng Tianxiang
Guest
 
Posts: n/a
Default Re: Global constants definition problem


Jozsef wrote:
> Hello,
> Try to recompile ALL sources which references to this package. I think
> about modelsim don't check & update referenced variables under
> compilation process in other sources.
>
> Best regards
>
> Weng Tianxiang wrote:
> > Hi,
> > Help is needed.
> >
> > I have some global constants shared among several modules, so I
> > set up a file to define a global package like the following:
> >
> > Package MG_x_Constant is
> > constant DATA_BITS : integer := 16;
> > constant DATA_RANGE : real := (2.0**16);
> > -- constant DATA_BITS : integer := 64;
> > -- constant DATA_RANGE : real := (2.0**64);
> >
> >
> > -- used in all test bench
> > constant DATABITS : integer := DATA_BITS;
> >
> > end MG_x_Constant;
> >
> > Package body MG_x_Constant is
> > ...
> > end MG_x_Constant;
> >
> > In other modules, DATA_BITS, DATABITS are freely used.
> >
> > This morning I found a problem:
> > when I changed DATA_BITS from 16 to 64, the ModelSim
> > sim window still shows constant DATABITS = 16 and it never changed,
> > even though I tried to delete the module from library and
> > re-compile it again. constant DATABITS = 16 doesn't change.
> >
> > IN compilation order, the global package definition file is always the
> > first one.
> >
> > I though if the global constant definition changes, all its appearance
> > should change, but it doesn't. Why?
> >
> > What is wrong with the above statements?
> >
> > Thank you.
> >
> > Weng


Hi Jozsef,
I re-compiled every modules, but the constants in global package don't
change as if they were compiled once and never re-compiled again.

I even deleted all work directory contents, recompile every modules,
but constants in the global package still don't change.

That is what I have experienced.

Any other ideas?

Weng

Reply With Quote
  #4 (permalink)  
Old 09-06-2006, 05:13 PM
Mike Treseler
Guest
 
Posts: n/a
Default Re: Global constants definition problem

Weng Tianxiang wrote:

> I even deleted all work directory contents, recompile every modules,
> but constants in the global package still don't change.


Maybe they are declared in more than one place.

-- Mike Treseler
Reply With Quote
  #5 (permalink)  
Old 09-06-2006, 06:27 PM
Weng Tianxiang
Guest
 
Posts: n/a
Default Re: Global constants definition problem


Mike Treseler wrote:
> Weng Tianxiang wrote:
>
> > I even deleted all work directory contents, recompile every modules,
> > but constants in the global package still don't change.

>
> Maybe they are declared in more than one place.
>
> -- Mike Treseler


Hi MIke,
Never!

I tried to move all constant definitions from package entity module to
package body module, all constants usage are errors.

Weng

Reply With Quote
  #6 (permalink)  
Old 09-06-2006, 06:33 PM
Weng Tianxiang
Guest
 
Posts: n/a
Default Re: Global constants definition problem


Weng Tianxiang wrote:
> Mike Treseler wrote:
> > Weng Tianxiang wrote:
> >
> > > I even deleted all work directory contents, recompile every modules,
> > > but constants in the global package still don't change.

> >
> > Maybe they are declared in more than one place.
> >
> > -- Mike Treseler

>
> Hi MIke,
> Never!
>
> I tried to move all constant definitions from package entity module to
> package body module, all constants usage are errors.
>
> Weng


Hi,
Is it possible that the error happens because I have used 2 levels of
constants:

constant DATA_BITS : integer := 16; <-- I change this value,
constant DATABITS : integer := DATA_BITS; <-- this value doesn't
change

Weng

Reply With Quote
  #7 (permalink)  
Old 09-07-2006, 12:42 PM
Brian Drummond
Guest
 
Posts: n/a
Default Re: Global constants definition problem

On 6 Sep 2006 08:07:21 -0700, "Weng Tianxiang" <[email protected]> wrote:

>
>Jozsef wrote:
>> Hello,
>> Try to recompile ALL sources which references to this package. I think
>> about modelsim don't check & update referenced variables under
>> compilation process in other sources.


>> > I have some global constants shared among several modules, so I
>> > set up a file to define a global package like the following:
>> >
>> > Package MG_x_Constant is

....
>> > end MG_x_Constant;


>> > This morning I found a problem:
>> > when I changed DATA_BITS from 16 to 64, the ModelSim
>> > sim window still shows constant DATABITS = 16 and it never changed,
>> > even though I tried to delete the module from library and
>> > re-compile it again.


>I re-compiled every modules, but the constants in global package don't
>change as if they were compiled once and never re-compiled again.
>
>I even deleted all work directory contents, recompile every modules,
>but constants in the global package still don't change.


I've just been through something similar. What happened in my case was:

the package was compiled into a library, and included in my desigh via
"Library/Use" statements.

The library was mapped into a particular Modelsim directory, and this
mapping was stored in modelsim.ini, in the directory where I was working
on the package.

Later, when I worked on the design, I found it using an OLD version of
the package - because its mapping for that library was in a DIFFERENT
modelsim.ini file (because the design was in a different place from the
package).

I got into this mess because this project was a combination of two older
ones, and not a fresh start.

This may not be your problem, but it's worth checking the library
mapping paths in ALL relevant versions of modelsim.ini are what you
expect.

- Brian

Reply With Quote
  #8 (permalink)  
Old 09-07-2006, 01:13 PM
Weng Tianxiang
Guest
 
Posts: n/a
Default Re: Global constants definition problem


Brian Drummond wrote:
> On 6 Sep 2006 08:07:21 -0700, "Weng Tianxiang" <[email protected]> wrote:
>
> >
> >Jozsef wrote:
> >> Hello,
> >> Try to recompile ALL sources which references to this package. I think
> >> about modelsim don't check & update referenced variables under
> >> compilation process in other sources.

>
> >> > I have some global constants shared among several modules, so I
> >> > set up a file to define a global package like the following:
> >> >
> >> > Package MG_x_Constant is

> ...
> >> > end MG_x_Constant;

>
> >> > This morning I found a problem:
> >> > when I changed DATA_BITS from 16 to 64, the ModelSim
> >> > sim window still shows constant DATABITS = 16 and it never changed,
> >> > even though I tried to delete the module from library and
> >> > re-compile it again.

>
> >I re-compiled every modules, but the constants in global package don't
> >change as if they were compiled once and never re-compiled again.
> >
> >I even deleted all work directory contents, recompile every modules,
> >but constants in the global package still don't change.

>
> I've just been through something similar. What happened in my case was:
>
> the package was compiled into a library, and included in my desigh via
> "Library/Use" statements.
>
> The library was mapped into a particular Modelsim directory, and this
> mapping was stored in modelsim.ini, in the directory where I was working
> on the package.
>
> Later, when I worked on the design, I found it using an OLD version of
> the package - because its mapping for that library was in a DIFFERENT
> modelsim.ini file (because the design was in a different place from the
> package).
>
> I got into this mess because this project was a combination of two older
> ones, and not a fresh start.
>
> This may not be your problem, but it's worth checking the library
> mapping paths in ALL relevant versions of modelsim.ini are what you
> expect.
>
> - Brian


Hi,
Thank you everyone who gave me an answer.

The problem is resolved, I would like to share the lesson
I learned from this experience.

1. Original code:
DATABITS_16_32_64 <= 64 when DATABITS = 64 else
32 when DATABITS = 32 else
16; -- for data bits between 4-16

BlockRAM_A: for I in 0 to 2 generate
BlockRAM_0: BlockRAM
generic map (
DATABITS => DATABITS_16_32_64,
DEPTH => LEVEL_X)
port map (
...
);
end generate;

The problem is the following statement:
DATABITS_16_32_64 <= 64 when DATABITS = 64 else
32 when DATABITS = 32 else
16; -- for data bits between 4-16

I thought DATABITS_16_32_64 was assigned value before it was used
in generic map, but it is wrong.

Because block BlockRAM_A and DATABITS_16_32_64 assignment statement
are in concurrent area, DATABITS_16_32_64 in generate map (...)
doesn't use the value it is assigned to in the above statement.
When loading, ModelSim immediately reports
error for situation of DATABITS = 16 so that it seems to me that
global variable DATABITS doesn't change.

1. The answers everyone gave show unanimously that
the grammar I used in global file is right;
2. So I abandoned my original idea to search for other clues.
3. Luckyly, I found the error after one day rest about the problem.

The following is the right coding for the segment:

BlockRAM_A: for I in 0 to 2 generate
BlockRAM_64 : if DATABITS = 64 generate
BlockRAM_0: BlockRAM
generic map (
DATABITS => 64,
DEPTH => LEVEL_X)
port map (
...
);
end generate;

BlockRAM_64 : if DATABITS = 32 generate
BlockRAM_0: BlockRAM
generic map (
DATABITS => 32,
DEPTH => LEVEL_X)
port map (
...
);
end generate;

BlockRAM_64 : if(DATABITS /= 64 and DATABITS /= 32) generate
BlockRAM_0: BlockRAM
generic map (
DATABITS => 16,
DEPTH => LEVEL_X)
port map (
...
);
end generate;
end generate;

Thank you.

Weng

Reply With Quote
  #9 (permalink)  
Old 09-07-2006, 01:56 PM
jr
Guest
 
Posts: n/a
Default Re: Global constants definition problem

Weng Tianxiang:


> 1. Original code:
> DATABITS_16_32_64 <= 64 when DATABITS = 64 else
> 32 when DATABITS = 32 else
> 16; -- for data bits between 4-16



Why do you make DATABITS_16_32_64 a signal? All your problems derive from
that. It looks like a constant to me.

Something like this would evaluate before the generic maps:
constant DATABITS_16_32_64: integer := (((DATABITS-1)/16)+1)*16;

DATABITS 4 to 16 : DATABITS_16_32_64 is 16
DATABITS 32 : DATABITS_16_32_64 is 32
DATABITS 64 : DATABITS_16_32_64 is 64.

Other cases irrelevant, I assume.

--
jr
Reply With Quote
  #10 (permalink)  
Old 09-07-2006, 02:34 PM
Weng Tianxiang
Guest
 
Posts: n/a
Default Re: Global constants definition problem


jr wrote:
> Weng Tianxiang:
>
>
> > 1. Original code:
> > DATABITS_16_32_64 <= 64 when DATABITS = 64 else
> > 32 when DATABITS = 32 else
> > 16; -- for data bits between 4-16

>
>
> Why do you make DATABITS_16_32_64 a signal? All your problems derive from
> that. It looks like a constant to me.
>
> Something like this would evaluate before the generic maps:
> constant DATABITS_16_32_64: integer := (((DATABITS-1)/16)+1)*16;
>
> DATABITS 4 to 16 : DATABITS_16_32_64 is 16
> DATABITS 32 : DATABITS_16_32_64 is 32
> DATABITS 64 : DATABITS_16_32_64 is 64.
>
> Other cases irrelevant, I assume.
>
> --
> jr


Hi Jr,
Wow! Wonderful !!!

Your answer is very clever and absolute better than mine. I will use
your code immediately without any conditions.

I learned a trick from you.

Thank you very much.

Weng

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Global Reset using Global Buffer [email protected] FPGA 18 11-30-2007 01:45 PM
Global ressource problem [email protected] FPGA 4 05-17-2007 02:18 AM
Global constants definition problem Weng Tianxiang FPGA 9 09-07-2006 02:34 PM
function definition [email protected] Verilog 0 09-06-2006 09:16 AM
Global Constants ed VHDL 3 02-08-2005 03:33 PM


All times are GMT +1. The time now is 03:10 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved