EDAboard.com | EDAboard.eu | EDAboard.de | EDAboard.co.uk | RTV forum PL | NewsGroups PL

boolean operations on "integer" in VHDL'93

Ask a question - edaboard.com

elektroda.net NewsGroups Forum Index - VHDL Language - boolean operations on "integer" in VHDL'93

Goto page Previous  1, 2, 3

Andy
Guest

Fri Nov 12, 2010 9:46 pm   



On Nov 12, 9:58 am, rickman <gnu...@gmail.com> wrote:
Quote:
Yes, if the designer wants to consider SLV as a 2's complement vector,
there is nothing in the language to prevent that.  But there is
nothing in the language to promote it either.  Anyone is free to
create their own libraries or to use standard ones to add capabilities
to the language.  That is what is going on in both
numeric_std_unsigned and in numeric_std.  The utility of these data
types is being extended as the designer wishes.  It is not a default
part of the language.


The standard ("default part of the") language now includes the
packages. And by allowing the unsigned(my_slv) conversion, which does
not include any reforming of the elements within my_slv, and my_slv 10 (via numeric_std_unsigned), the language is ensuring that the
numeric interpretation is extended to slv. Whether you choose to
access that interpretation or not, the representation must be
consistent with the numeric interpretation.

Quote:
How do you expect a synthesis tool to handle this requirement?  If you
write VHDL code to increment a counter, what do you expect the
hardware to do when the counter reaches the max value?  Are you saying
you expect the synthesis tool to throw an error if the designer does
not indicate explicitly what will happen with an IF statement or a MOD
operator?

What does the synthesis tool do with integers in the case of a counter
that can overflow?

signal a : integer range 0 to 15;
-- clocked process wrapper...
  a <= a + 1;

What hardware should this produce?  Or how should I write this for a 4
bit counter?  How exactly should the synthesis tool "die trying"?

Your description did not legally tell the synthesis tool what to do
when a is 15, since storing the result of 15 + 1 in a would be illegal
(and in fact impossible in a four bit storage register). Therefore,
the synthesis tool is free to do anything it wants in that case.

So, one way to look at what really happens in synthesis is this:

signal a : integer range 0 to 15;
-- clocked process wrapper...
if a + 1 > 15 then -- implied by the range of a
a <= "don't care"; -- because assigning 16 to a is illegal anyway
else
a <= a + 1;
end if;

Lucky for us, it turns out that the most efficient implementation of
the above is to simply truncate the result of 15 + 1, which is a roll
over, or modulo counter.

I would prefer that it at least give me a warning that it was doing
this, but in reality, it could do anything it wants, because I did not
tell it what to do.

To keep simulation and synthesis on the same page, a better way to
write it in the first place would be:

signal a : integer range 0 to 15;
-- clocked process wrapper...
a <= (a + 1) mod 16;

This way, you are explicitly, legally telling the synthesis tool (and
the simulator) what you want to do when a is 15.

Andy

Brian Drummond
Guest

Sat Nov 13, 2010 12:11 am   



On Fri, 12 Nov 2010 06:38:15 -0800 (PST), Andy <jonesandy_at_comcast.net> wrote:

Quote:
On Nov 11, 3:33 pm, rickman <gnu...@gmail.com> wrote:
On Nov 8, 12:57 pm, Andy <jonesa...@comcast.net> wrote:

So maybe we limit the actions of overloaded assignment operators to
converting "closely related" types and resizing to this relatively
safe. If it works out, maybe we can extend overloaded assignments to
other areas, but I'd rather take baby steps and not break anything,
than take too big a step and cause bigger, unforseen problems.

Before you go too far with overloaded assignment operators,
you have to face another issue :

assignment is not an operator!

And changing that in VHDL would probably be difficult (for a mild
understatement). For better or worse, it's a 50-year old design decision in,
clearly not just VHDL, but back through Ada, and right back to Algol-60.

I don't see it happening.

- Brian

KJ
Guest

Sat Nov 13, 2010 3:32 am   



On Nov 12, 6:11 pm, Brian Drummond <brian_drumm...@btconnect.com>
wrote:
Quote:

Before you go too far with overloaded assignment operators,
you have to face another issue :

assignment is not an operator!

And changing that in VHDL would probably be difficult (for a mild
understatement). For better or worse, it's a 50-year old design decision in,
clearly not just VHDL, but back through Ada, and right back to Algol-60.

I don't see it happening.


Rather than overloading the assignment operator, my suggestion to the
(*1) VHDL pubas (two years ago) is to add a method to allow a function
to get access to the attributes associated with whatever the result of
the function will be assigned to. Adds to the language without
breaking anything existing and accomplishes the same goal.

Kevin Jennings

(*1) bug #240 https://bugzilla.mentor.com/show_bug.cgi?id=240

rickman
Guest

Sat Nov 13, 2010 4:35 am   



On Nov 12, 2:46 pm, Andy <jonesa...@comcast.net> wrote:
Quote:
On Nov 12, 9:58 am, rickman <gnu...@gmail.com> wrote:

Yes, if the designer wants to consider SLV as a 2's complement vector,
there is nothing in the language to prevent that. But there is
nothing in the language to promote it either. Anyone is free to
create their own libraries or to use standard ones to add capabilities
to the language. That is what is going on in both
numeric_std_unsigned and in numeric_std. The utility of these data
types is being extended as the designer wishes. It is not a default
part of the language.

The standard ("default part of the") language now includes the
packages. And by allowing the unsigned(my_slv) conversion, which does
not include any reforming of the elements within my_slv, and my_slv =
10 (via numeric_std_unsigned), the language is ensuring that the
numeric interpretation is extended to slv. Whether you choose to
access that interpretation or not, the representation must be
consistent with the numeric interpretation.



How do you expect a synthesis tool to handle this requirement? If you
write VHDL code to increment a counter, what do you expect the
hardware to do when the counter reaches the max value? Are you saying
you expect the synthesis tool to throw an error if the designer does
not indicate explicitly what will happen with an IF statement or a MOD
operator?

What does the synthesis tool do with integers in the case of a counter
that can overflow?

signal a : integer range 0 to 15;
-- clocked process wrapper...
a <= a + 1;

What hardware should this produce? Or how should I write this for a 4
bit counter? How exactly should the synthesis tool "die trying"?

Your description did not legally tell the synthesis tool what to do
when a is 15, since storing the result of 15 + 1 in a would be illegal
(and in fact impossible in a four bit storage register). Therefore,
the synthesis tool is free to do anything it wants in that case.

So, one way to look at what really happens in synthesis is this:

signal a : integer range 0 to 15;
-- clocked process wrapper...
if a + 1 > 15 then -- implied by the range of a
a <= "don't care"; -- because assigning 16 to a is illegal anyway
else
a <= a + 1;
end if;

Lucky for us, it turns out that the most efficient implementation of
the above is to simply truncate the result of 15 + 1, which is a roll
over, or modulo counter.

I would prefer that it at least give me a warning that it was doing
this, but in reality, it could do anything it wants, because I did not
tell it what to do.

To keep simulation and synthesis on the same page, a better way to
write it in the first place would be:

signal a : integer range 0 to 15;
-- clocked process wrapper...
a <= (a + 1) mod 16;

This way, you are explicitly, legally telling the synthesis tool (and
the simulator) what you want to do when a is 15.

Andy

As it turns out, that is exactly what I do because the simulation
doesn't work without it. It also solves your synthesis problem.

There are any number of things that a synthesis tool assumes if you
don't tell it. They think they are doing you a favor. But then these
are the same sorts of things that people complain about when using
VHDL. That is what VHDL is all about, telling the tools exactly what
you want rather than using default.

Rick

Jan Decaluwe
Guest

Sat Nov 13, 2010 9:02 am   



Brian Drummond wrote:
Quote:
On Fri, 12 Nov 2010 06:38:15 -0800 (PST), Andy <jonesandy_at_comcast.net> wrote:

On Nov 11, 3:33 pm, rickman <gnu...@gmail.com> wrote:
On Nov 8, 12:57 pm, Andy <jonesa...@comcast.net> wrote:

So maybe we limit the actions of overloaded assignment operators to
converting "closely related" types and resizing to this relatively
safe. If it works out, maybe we can extend overloaded assignments to
other areas, but I'd rather take baby steps and not break anything,
than take too big a step and cause bigger, unforseen problems.

Before you go too far with overloaded assignment operators,
you have to face another issue :

assignment is not an operator!

And changing that in VHDL would probably be difficult (for a mild
understatement). For better or worse, it's a 50-year old design decision in,
clearly not just VHDL, but back through Ada, and right back to Algol-60.

I don't see it happening.

Moreover, these proposals invariably seem to be inspired
by types that force us to deal with the representation to
get arithmetic right. For some reason, we seem to think
that we are better at that than synthesis tools. The
opposite is true of course.

For integer arithmetic, a more usable integer type would
address the issues in a much better way. I don't know
about fixed point, but probably the Ada example can be
enlightening.

Jan

--
Jan Decaluwe - Resources bvba - http://www.jandecaluwe.com
Python as a HDL: http://www.myhdl.org
VHDL development, the modern way: http://www.sigasi.com
Analog design automation: http://www.mephisto-da.com
World-class digital design: http://www.easics.com

Colin Paul Gloster
Guest

Tue Nov 16, 2010 8:40 pm   



Martin Thompson <martin.j.thompson_at_TRW.com> sent on November 12th, 2010:

|------------------------------------------------------------------|
|"[..] |
| |
|Maybe we should just quit VHDL and start synthesising Ada directly|
|[..]" |
|------------------------------------------------------------------|

People have claimed to have synthesized Ada to hardware.

|--------------------------------------------------------------------|
|"Maybe call it SystemAda Smile" |
|--------------------------------------------------------------------|

There was an article by Zainalabedin Navabi and others in "Ada
Letters" entitled "System level hardware design and simulation with
SystemAda" in 2009. It seems to me that they were trying to get an
easy publication instead of doing real work. They and the editor
showed unknowingly in the article that they did not know what they
were discussing.

Yours sincerely,
Paul Colin Gloster

Goto page Previous  1, 2, 3

elektroda.net NewsGroups Forum Index - VHDL Language - boolean operations on "integer" in VHDL'93

Ask a question - edaboard.com

Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
RTV map EDAboard.com map News map EDAboard.eu map EDAboard.de map EDAboard.co.uk map Opony