hex constant

J

JohnSmith

Guest
What does the '_' char in the hexadecimal constant? Is it simply
ignored?

process
variable man_id : std_logic_vector(31 downto 0);
begin
man_id := X"1F_22_00_00";
end process;

Thanks
 
On Jan 13, 8:57 pm, JohnSmith <csnew...@gmail.com> wrote:
What does the '_' char in the hexadecimal constant? Is it simply
ignored?

process
 variable man_id : std_logic_vector(31 downto 0);
begin
 man_id := X"1F_22_00_00";
end process;

Thanks
You have it right. From the language manual: "An underline character
inserted between adjacent digits of a bit string literal does not
affect the value of this literal"

- Kenn
 
On Tue, 13 Jan 2009 18:21:45 -0800 (PST)
kennheinrich@sympatico.ca wrote:

On Jan 13, 8:57 pm, JohnSmith <csnew...@gmail.com> wrote:
What does the '_' char in the hexadecimal constant? Is it simply
ignored?

process
 variable man_id : std_logic_vector(31 downto 0);
begin
 man_id := X"1F_22_00_00";
end process;

Thanks

You have it right. From the language manual: "An underline character
inserted between adjacent digits of a bit string literal does not
affect the value of this literal"

- Kenn
Wait. So there's actually a mechanism in place to allow me to write
out long hex (or god forbid binary) constants with spacing? I _don't_
have to write long cryptic strings of ones and zeros, then use my text
editor's column position count to figure out where I am in a 19 bit
constant?

This is the sort of thing I should have known YEARS ago.

--
Rob Gaddi, Highland Technology
Email address is currently out of order
 
On Jan 14, 12:08 pm, Rob Gaddi <rga...@technologyhighland.com> wrote:
On Tue, 13 Jan 2009 18:21:45 -0800 (PST)



kennheinr...@sympatico.ca wrote:
On Jan 13, 8:57 pm, JohnSmith <csnew...@gmail.com> wrote:
What does the '_' char in the hexadecimal constant? Is it simply
ignored?

process
 variable man_id : std_logic_vector(31 downto 0);
begin
 man_id := X"1F_22_00_00";
end process;

Thanks

You have it right. From the language manual: "An underline character
inserted between adjacent digits of a bit string literal does not
affect the value of this literal"

 - Kenn

Wait.  So there's actually a mechanism in place to allow me to write
out long hex (or god forbid binary) constants with spacing?  I _don't_
have to write long cryptic strings of ones and zeros, then use my text
editor's column position count to figure out where I am in a 19 bit
constant?

This is the sort of thing I should have known YEARS ago.

--
Rob Gaddi, Highland Technology
Email address is currently out of order
You can also do this with regular numbers. The rules are: can't start
or end with underscore, and can't have more than one underscore in a
row. I like this for delimiting the thousands (1_000_000_000) when
doing unit conversions.

- Kenn
 
On Jan 14, 12:08 pm, Rob Gaddi <rga...@technologyhighland.com> wrote:
then use my text
editor's column position count to figure out where I am in a 19 bit
constant?
Better make it a 20 bit constant because each character in a hex
string will translate into 4 bits and you'll get compiler errors about
mismatched vector sizes. If you really do need some odd number like
19 though, string concatenation is a simple way to get there as well

Ex:
constant Some19bitConstant: std_ulogic_vector(18 downto 0) := "101" &
X"1F_22_00_00;

This is the sort of thing I should have known YEARS ago.

Must've missed the memo on that ;)

KJ
 
On Wed, 14 Jan 2009 09:08:02 -0800, Rob Gaddi
<rgaddi@technologyhighland.com> wrote:

On Tue, 13 Jan 2009 18:21:45 -0800 (PST)
kennheinrich@sympatico.ca wrote:

On Jan 13, 8:57 pm, JohnSmith <csnew...@gmail.com> wrote:
What does the '_' char in the hexadecimal constant? Is it simply
ignored?

process
 variable man_id : std_logic_vector(31 downto 0);
begin
 man_id := X"1F_22_00_00";
end process;

Thanks

You have it right. From the language manual: "An underline character
inserted between adjacent digits of a bit string literal does not
affect the value of this literal"

- Kenn

Wait. So there's actually a mechanism in place to allow me to write
out long hex (or god forbid binary) constants with spacing? I _don't_
have to write long cryptic strings of ones and zeros, then use my text
editor's column position count to figure out where I am in a 19 bit
constant?

This is the sort of thing I should have known YEARS ago.
This is a common problem with VHDL...

I think, when it was designed, people were being trained in fusty old
programming languages, with unfashionable things like abstraction
mechanisms, type safety, proper enumerations, parameter passing modes,
as well as the above, to make programs easier to read and understand.

So it simply borrowed a lot of dead guy stuff like that from Ada. And
nobody thought to point it out to the new guy on the block because it
was common knowledge...

<grouch=on>

Frankly it scares me to realise there are now CS graduates out there who
have never seen things like this; or a function declared local to a
procedure (a basic way to (a) abstract information out of the main code
and (b) hide it from everything else.)

But CS courses now typically cover C, Java and C++. Possibly Haskell or
Lisp to show there are other language paradigms; probably Python or
Smalltalk to show OO in a better light than C++. And I am led to
understand that VHDL is not often taught from the ground up, but as a
conversion course for C programmers...

But nothing to show there are better ways to write software, let alone
design hardware, than C-based languages.

To take one simple example from the software side...

Buffer overrun attacks were banished to history by Tony Hoare's Algol-60
compiler for the Elliott 804.

In 1964.

C - and its derivatives - are keeping us firmly entrenched in that
history.

We have to do better.

<grouch=off>
<soapbox=on>

I believe we can. I think C++ has given software development one
positive thing: nobody can complain that Ada is too large, complex,
cumbersome or inefficient!

Apart from that reputation, two real obstacles held it back: the
compilers were damned expensive, and they would bring a mid-80's
workstation to its knees. Now we have GNAT built into the gcc toolset,
using the same back end code generator (and because of its better
semantics, the Ada compiler can sometimes optimise better than C/C++).
Ada 1995 and now 2005 update the original with useful OO features;
(not like Smalltalk, but more like a sane version of C++).

And hands up anybody still developing on a mid-80's workstation...

I am just getting to grips with Ada 2005 with the GNAT 4.1 compiler* and
it's a refreshing change from catching obscure bugs in C++. And the
commonality with VHDL is making it a relatively smooth transition.
Well worth a look at if you like the strengths of VHDL.

* Get it from GCC not Adacore, unless you can afford their paid support
or ONLY want to write GPL code. The license is different...

<soapbox=off>

Thank you. I feel better now...

- Brian
 
On Thu, 15 Jan 2009 13:49:29 +0000, Brian Drummond wrote:

Thank you. I feel better now...
Don't worry, you're among friends.....

though I have to admit that I'm less enthusiastic
than you are about nested subprogram definitions;
that dratted static chain costs the compiler quite
a bit of extra effort, and burns up at least one
machine register that could be usefully deployed
on other things; and there are other ways to get
the syntactic/lexical hiding of stuff. And the
worst of it is that the nested subprogram, which
is likely to be quite long (elseways there's no
point in bothering to write it), is lexically in
a place where it tiresomely distracts attention
from the high-level business of its enclosing
procedure. Seems to me that classes do a better
job for you on that kind of thing.

_My_ favourite soapbox is the one about separation
of interface from implementation, something that
C++ and most of the rest of the OO zoo are pretty
bad at doing - for implementation-efficiency reasons
that seem spurious to me.

Anyway, Brian, I think we should both of us accept
that occam ain't coming back into the mainstream
any time soon, and just allow ourselves to be
assimilated and then fight the system from within.
How say we comrades found a Modula-2 cell some time?

[Editor's Note: Stop it, Bromley, it's just that
you are soured by a couple of weeks' immersion in
SystemVerilog...]
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services

Doulos Ltd., 22 Market Place, Ringwood, BH24 1AW, UK
jonathan.bromley@MYCOMPANY.com
http://www.MYCOMPANY.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 

Welcome to EDABoard.com

Sponsor

Back
Top