cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Adventurer
Adventurer
602 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
Highlighted
Scholar
Scholar
503 Views
Registered: ‎08-01-2012

Re: initial value for constant declaration is not constant

Jump to solution

@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
Highlighted
Teacher
Teacher
593 Views
Registered: ‎07-09-2009

Re: initial value for constant declaration is not constant

Jump to solution
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
Highlighted
Adventurer
Adventurer
533 Views
Registered: ‎06-28-2016

Re: initial value for constant declaration is not constant

Jump to solution

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
Highlighted
Teacher
Teacher
517 Views
Registered: ‎07-09-2009

Re: initial value for constant declaration is not constant

Jump to solution
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
Highlighted
Scholar
Scholar
504 Views
Registered: ‎08-01-2012

Re: initial value for constant declaration is not constant

Jump to solution

@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)
Highlighted
Adventurer
Adventurer
475 Views
Registered: ‎06-28-2016

Re: initial value for constant declaration is not constant

Jump to solution

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
Highlighted
Visitor
Visitor
219 Views
Registered: ‎03-24-2020

Re: initial value for constant declaration is not constant

Jump to solution

Did you find a workaround?

Tags (1)
0 Kudos
Highlighted
Adventurer
Adventurer
202 Views
Registered: ‎06-28-2016

Re: initial value for constant declaration is not constant

Jump to solution

No, I'm afraid I haven't.

0 Kudos