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 01-18-2007, 05:44 PM
news.sunrise
Guest
 
Posts: n/a
Default set different constants for simulation than for synthesis (preprocessor?)

Hi NG

Problem:
When simulating (Modelsim) one might want to set certain values differently
than for synthesis (Xilinx ISE).

Unfortunately it seems there's no possibility to have conditional code
blocks in vhdl depending on whether the code is read by a synthesizer or a
simulator.

Idea:
Tell Modelsim to call a preprocessor script that does some regexp on the
vhdl code before reading it. The value for simulation could be set in a
comment string.

This preprocessor could do the following:

change:
constant FOO : integer := 99999; --simValue(42)
to:
constant FOO : integer := 42;

I could write such a preprocessor, but how to integrate it?

Questions:
-How to tell Modelsim to call a script automatically and read the output of
the script?
-Is there a better solution?

Thanks for your help
Alain





Reply With Quote
  #2 (permalink)  
Old 01-18-2007, 06:40 PM
Arnim
Guest
 
Posts: n/a
Default Re: set different constants for simulation than for synthesis (preprocessor?)


> Problem: When simulating (Modelsim) one might want to set certain
> values differently than for synthesis (Xilinx ISE).


Why would one want to do this? Your synthesized design will be different
from what you simulate.

> Idea: Tell Modelsim to call a preprocessor script that does some
> regexp on the vhdl code before reading it. The value for simulation
> could be set in a comment string.
>
> -Is there a better solution?


I don't recommend to do this, but there is a better solution:

constant simulating_c : integer := 0
-- pragma translate_off
+ 1
-- pragma translate_on
;

A simulator will initialize the constant to 1. For the synthesizer the
+1 is eclipsed and the constant is 0. You could do this for all your
constants or simply use the trick once and derive all other differences
from this result.
Just ensure that the -- pragma <something> is recognized by your
synthesis tool.

Cheers

Arnim
Reply With Quote
  #3 (permalink)  
Old 01-18-2007, 08:01 PM
Duane Clark
Guest
 
Posts: n/a
Default Re: set different constants for simulation than for synthesis (preprocessor?)

news.sunrise wrote:
> Hi NG
>
> Problem:
> When simulating (Modelsim) one might want to set certain values differently
> than for synthesis (Xilinx ISE).


The caveat applies that doing this means your simulation doesn't match
the real hardware. That said...

One method I have used is to make the values I want to change into
generics, with the defaults being what I want to use for synthesis. Then
I put a configuration specification in surrounded by
translate_off/translate_on:

--synthesis translate_off;
for ctrl_d: CTRL
use entity work.CTRL
generic map (
SRCNT_START => X"28000",
SRCNT_END => X"280FF"
)
port map(
RESET => RESET,
CLK => CLK,
...
);
--synthesis translate_on;
Reply With Quote
  #4 (permalink)  
Old 01-19-2007, 04:34 PM
Andy
Guest
 
Posts: n/a
Default Re: set different constants for simulation than for synthesis (preprocessor?)

Indeed top level generics are probably the best way to go. I usually
set the default values to be appropriate for synthesis, although some
synthesis tools allow top level generics to be overridden as a
synthesis option (most simulators also allow this).

When simulating, you normally have higher level testbench that
instantiates the synthesizable design. In the instantiation, those
default generics can be overridden by a generic map in the
instantiation. Those generics can be set to values from other generics
passed down from the top level, which in turn can be set via simulator
options.

This can all be done without a configuration at all if you use direct
entity instantiation, and not have to mess with a component declaration
either (vhdl '93 feature)

DUT: entity work.CTRL(rtl) -- use architecture rtl of ctrl
generic map (
SRCNT_START => X"28000",
SRCNT_END => X"280FF"
)
port map(
RESET => RESET,
CLK => CLK,
...
);

Andy

Duane Clark wrote:
> news.sunrise wrote:
> > Hi NG
> >
> > Problem:
> > When simulating (Modelsim) one might want to set certain values differently
> > than for synthesis (Xilinx ISE).

>
> The caveat applies that doing this means your simulation doesn't match
> the real hardware. That said...
>
> One method I have used is to make the values I want to change into
> generics, with the defaults being what I want to use for synthesis. Then
> I put a configuration specification in surrounded by
> translate_off/translate_on:
>
> --synthesis translate_off;
> for ctrl_d: CTRL
> use entity work.CTRL
> generic map (
> SRCNT_START => X"28000",
> SRCNT_END => X"280FF"
> )
> port map(
> RESET => RESET,
> CLK => CLK,
> ...
> );
> --synthesis translate_on;


Reply With Quote
  #5 (permalink)  
Old 01-20-2007, 01:21 AM
Jim Lewis
Guest
 
Posts: n/a
Default Re: set different constants for simulation than for synthesis (preprocessor?)

You can avoid the "translate_off" ... by using
configuration declarations that are in a separate file.

>> Hi NG
>>
>> Problem:
>> When simulating (Modelsim) one might want to set certain values
>> differently than for synthesis (Xilinx ISE).

>
> The caveat applies that doing this means your simulation doesn't match
> the real hardware. That said...
>
> One method I have used is to make the values I want to change into
> generics, with the defaults being what I want to use for synthesis. Then
> I put a configuration specification in surrounded by
> translate_off/translate_on:
>
> --synthesis translate_off;
> for ctrl_d: CTRL
> use entity work.CTRL
> generic map (
> SRCNT_START => X"28000",
> SRCNT_END => X"280FF"
> )
> port map(
> RESET => RESET,
> CLK => CLK,
> ...
> );
> --synthesis translate_on;

Reply With Quote
  #6 (permalink)  
Old 01-20-2007, 03:20 AM
Gerhard Hoffmann
Guest
 
Posts: n/a
Default Re: set different constants for simulation than for synthesis (preprocessor?)

On Thu, 18 Jan 2007 19:40:29 +0100, Arnim <[email protected]> wrote:

>I don't recommend to do this, but there is a better solution:
>
> constant simulating_c : integer := 0
> -- pragma translate_off
> + 1
> -- pragma translate_on
> ...
>Just ensure that the -- pragma <something> is recognized by your
>synthesis tool.


and they tell us that the C preprocessor is ****.

But then, block comments are politically incorrect, too.

So, if we need to temporarily remove a block of statements, we have to
rely on emacs' or gvim's VHDL expertise.

regards, Gerhard


Reply With Quote
  #7 (permalink)  
Old 01-22-2007, 07:58 AM
Alain
Guest
 
Posts: n/a
Default Re: set different constants for simulation than for synthesis (preprocessor?)

> Why would one want to do this? Your synthesized design will be different
> from what you simulate.


Yes, but let's say I want to simulate a behaviour in millisecond
clk_en -range. I don't want to count every 50MHz clock until I've reached a
millisecond. So setting the masterclock to somewhat 10kHz for the simulation
is easier.



>
>> Idea: Tell Modelsim to call a preprocessor script that does some
>> regexp on the vhdl code before reading it. The value for simulation
>> could be set in a comment string.
>>
>> -Is there a better solution?

>
> I don't recommend to do this, but there is a better solution:
>
> constant simulating_c : integer := 0
> -- pragma translate_off
> + 1
> -- pragma translate_on
> ;


I'll check that out. thanks.

Alain

>
> A simulator will initialize the constant to 1. For the synthesizer the
> +1 is eclipsed and the constant is 0. You could do this for all your
> constants or simply use the trick once and derive all other differences
> from this result.
> Just ensure that the -- pragma <something> is recognized by your
> synthesis tool.
>
> Cheers
>
> Arnim



Reply With Quote
  #8 (permalink)  
Old 01-22-2007, 08:38 AM
Alain
Guest
 
Posts: n/a
Default Re: set different constants for simulation than for synthesis (preprocessor?)

This looks like a very correct way to do it.

The only problem is that you have to know from the beginning of coding what
values you will want to change for simulation. Ok, this is actually not so
bad, but I don't like the fact that you'll have to propagate these generics
through all layers.
This solution might result in a very long list of generics that doesn't help
code readability.

That's why I'd like a statement like
constant FOO : integer := 99999; --simValue(42)
even if I break with plain VHDL.

cheers
Alain

"Andy" <[email protected]> wrote in message
news:[email protected] oups.com...
> Indeed top level generics are probably the best way to go. I usually
> set the default values to be appropriate for synthesis, although some
> synthesis tools allow top level generics to be overridden as a
> synthesis option (most simulators also allow this).
>
> When simulating, you normally have higher level testbench that
> instantiates the synthesizable design. In the instantiation, those
> default generics can be overridden by a generic map in the
> instantiation. Those generics can be set to values from other generics
> passed down from the top level, which in turn can be set via simulator
> options.
>
> This can all be done without a configuration at all if you use direct
> entity instantiation, and not have to mess with a component declaration
> either (vhdl '93 feature)
>
> DUT: entity work.CTRL(rtl) -- use architecture rtl of ctrl
> generic map (
> SRCNT_START => X"28000",
> SRCNT_END => X"280FF"
> )
> port map(
> RESET => RESET,
> CLK => CLK,
> ...
> );
>
> Andy
>
> Duane Clark wrote:
>> news.sunrise wrote:
>> > Hi NG
>> >
>> > Problem:
>> > When simulating (Modelsim) one might want to set certain values
>> > differently
>> > than for synthesis (Xilinx ISE).

>>
>> The caveat applies that doing this means your simulation doesn't match
>> the real hardware. That said...
>>
>> One method I have used is to make the values I want to change into
>> generics, with the defaults being what I want to use for synthesis. Then
>> I put a configuration specification in surrounded by
>> translate_off/translate_on:
>>
>> --synthesis translate_off;
>> for ctrl_d: CTRL
>> use entity work.CTRL
>> generic map (
>> SRCNT_START => X"28000",
>> SRCNT_END => X"280FF"
>> )
>> port map(
>> RESET => RESET,
>> CLK => CLK,
>> ...
>> );
>> --synthesis translate_on;

>



Reply With Quote
Reply

Bookmarks


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
what is the difference between post-synthesis simulation and timing simulation? ikki FPGA 1 12-01-2008 06:50 AM
HDL - simulation vs synthesis [email protected] FPGA 4 05-29-2008 07:09 AM
Structured way of changing eg time constants for real world build / simulation? Nial Stewart FPGA 8 11-16-2007 09:12 AM
Simulation vs Synthesis [email protected] VHDL 14 02-21-2006 10:15 AM
what are the possible reasons that successful pre-synthesis simulation + successful synthesis = failed post-synthes walala VHDL 4 09-08-2003 02:51 PM


All times are GMT +1. The time now is 11:52 AM.


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