cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
haggaie
Adventurer
Adventurer
837 Views
Registered: ‎06-28-2016

initial value for constant declaration is not constant

Jump to solution

Hi,

I've been trying to run xsim with vunit's library. One of the library files (logger_pkg-body.vhd) uses the following constant declaration:

constant p_default_logger : logger_t := get_logger("default");

where get_logger is an impure function defined in the same file. I get an error for this line saying that:

ERROR: [VRFC 10-932] initial value for constant declaration is not constant [/home/haggai/workspace/vunit/vunit/vhdl/logging/src/logger_pkg-body.vhd:1040]

I'm not sure whether that's legal VHDL in general, but I found this reference, which also used this pattern.

Is there maybe a command line argument that would cause xsim to accept this declaration?

0 Kudos
1 Solution

Accepted Solutions
richardhead
Scholar
Scholar
738 Views
Registered: ‎08-01-2012

@drjohnsmith 

impure functions are pretty common. They are required when you access an object declared external to the function. So if you want to write to the console using a function, you will need to declare it impure as OUTPUT is a file declared in the std.textio package. If you ever learn protected types, most of your functions inside them will be impure as you will be accessing variables local to the protected type.

They are used more in simulation, not so much (if at all) in synthesis (but I have seen it required).

VUNIT is a CI package. It is a library of functions that allow reporting with the controller and test definitions written in Python.

@haggaie 

XSIM has choked on vunit because xsim is pretty rubbish. It is a false error - there is nothing wrong with that constant declaration. It is xsim at fault.

I suggest using a simulator that has been updated in the last 10 years. Maybe the open source GHDL, or perhaps the free version of modelsim you can get from intel.

View solution in original post

Tags (1)
7 Replies
drjohnsmith
Teacher
Teacher
828 Views
Registered: ‎07-09-2009
I can safely say I have never used impure in VHDL,
( I normaly try to keep things simple, to help the tools )

but do you need to map the constant as impure as well ?

<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
haggaie
Adventurer
Adventurer
768 Views
Registered: ‎06-28-2016

You mean I should declare the constant as impure? I don't think that's supported in VHDL. Only functions can be declared pure/impure.

0 Kudos
drjohnsmith
Teacher
Teacher
752 Views
Registered: ‎07-09-2009
I did say I dont use impure,
never found a reason or it,
its use seems very much against the VHDL ethos,

hence the suggestion,

I'd love to know in more detail what are you trying to do that needs you to use an impure ?
<== If this was helpful, please feel free to give Kudos, and close if it answers your question ==>
0 Kudos
richardhead
Scholar
Scholar
739 Views
Registered: ‎08-01-2012

@drjohnsmith 

impure functions are pretty common. They are required when you access an object declared external to the function. So if you want to write to the console using a function, you will need to declare it impure as OUTPUT is a file declared in the std.textio package. If you ever learn protected types, most of your functions inside them will be impure as you will be accessing variables local to the protected type.

They are used more in simulation, not so much (if at all) in synthesis (but I have seen it required).

VUNIT is a CI package. It is a library of functions that allow reporting with the controller and test definitions written in Python.

@haggaie 

XSIM has choked on vunit because xsim is pretty rubbish. It is a false error - there is nothing wrong with that constant declaration. It is xsim at fault.

I suggest using a simulator that has been updated in the last 10 years. Maybe the open source GHDL, or perhaps the free version of modelsim you can get from intel.

View solution in original post

Tags (1)
haggaie
Adventurer
Adventurer
710 Views
Registered: ‎06-28-2016

Thanks, Richard.

I want to try other simulators eventually, but I have some existing code that is already  wanted working in xsim, which I wanted try using vunit's harness.

0 Kudos
fepires
Visitor
Visitor
454 Views
Registered: ‎03-24-2020

Did you find a workaround?

Tags (1)
0 Kudos
haggaie
Adventurer
Adventurer
437 Views
Registered: ‎06-28-2016

No, I'm afraid I haven't.

0 Kudos