Use of hex values for selected signal assignment 
Author Message
 Use of hex values for selected signal assignment

An associate of mine would like to use hex strings within a selected
signal assignment.  I understand there are constrants on the decoded
values which preclude function calls.  Any suggestions?  Here is the
standard syntax:

  with sig_sel select
    destin_sig  <= source_a when "1100",   -- Comment about value C
                   source_b when "1110",   -- Comment about value E
                   source_c when "1101",   -- Comment about value D
                   '0' when others ;

Can the values above be coded for better documentation as X'0C' or 16#C#
in some manner?  The above looks fine as 4 bits, but as the number of
bits increases, the engineer would find it much better to document with
hex numbers.


Core Development)



Sat, 26 Oct 2002 03:00:00 GMT  
 Use of hex values for selected signal assignment
I believe the following will work when signal 's0' is of type bit_vector:

with s0 select
 s9 <= s1 when "00000001",
       s2 when bit_vector'(B"0000_0010"),
       s3 when bit_vector'(X"03"),
       s4 when bit_vector'(X"04"),
       s5 when bit_vector'(X"05"),
       s6 when bit_vector'(X"06"),
       s7 when bit_vector'(X"07"),
       s8 when bit_vector'(X"08"),
       '0' WHEN OTHERS;

Any other suggestions?

Sincerely, Carl Ashley

Quote:

> An associate of mine would like to use hex strings within a selected
> signal assignment.  I understand there are constrants on the decoded
> values which preclude function calls.  Any suggestions?  Here is the
> standard syntax:

>   with sig_sel select
>     destin_sig  <= source_a when "1100",   -- Comment about value C
>                    source_b when "1110",   -- Comment about value E
>                    source_c when "1101",   -- Comment about value D
>                    '0' when others ;

> Can the values above be coded for better documentation as X'0C' or 16#C#
> in some manner?  The above looks fine as 4 bits, but as the number of
> bits increases, the engineer would find it much better to document with
> hex numbers.


> Core Development)



Sat, 26 Oct 2002 03:00:00 GMT  
 Use of hex values for selected signal assignment


Quote:
> An associate of mine would like to use hex strings within a selected
> signal assignment.  I understand there are constrants on the decoded
> values which preclude function calls.  Any suggestions?  Here is the
> standard syntax:

>   with sig_sel select
>     destin_sig  <= source_a when "1100",   -- Comment about value C
>                    source_b when "1110",   -- Comment about value E
>                    source_c when "1101",   -- Comment about value D
>                    '0' when others ;

> Can the values above be coded for better documentation as X'0C' or
16#C#
> in some manner?  The above looks fine as 4 bits, but as the number of
> bits increases, the engineer would find it much better to document
with
> hex numbers.


ASIC
> Core Development)

Carl,
To use an hexadecimal form such as X"0C", you have to have your sig_sel
declared as bit_vector. In that way you are using what is call "bit
strings". If you are going to use more bits you can write also
X"FA_C0_72" to do the literals more readable (depending of the synthesis
tool you are working with, you can declare also sig_sel as
std_logic_vector, but the portability it's not sure).
In the case of using 16#0C#, sig_sel has to be declared as integer.
Since, that is the one way of writing integer literals.

good luck,

Cristian Sisterna
National University of San Juan
Argentina

Sent via Deja.com http://www.deja.com/
Before you buy.



Sat, 26 Oct 2002 03:00:00 GMT  
 Use of hex values for selected signal assignment

Quote:

>An associate of mine would like to use hex strings within a selected
>signal assignment.  I understand there are constrants on the decoded
>values which preclude function calls.  Any suggestions?  Here is the
>standard syntax:

>  with sig_sel select
>    destin_sig  <= source_a when "1100",   -- Comment about value C
>                   source_b when "1110",   -- Comment about value E
>                   source_c when "1101",   -- Comment about value D
>                   '0' when others ;

>Can the values above be coded for better documentation as X'0C' or 16#C#
>in some manner?  The above looks fine as 4 bits, but as the number of
>bits increases, the engineer would find it much better to document with
>hex numbers.

Actually, you can do the following with VHDL'93.  sig_sel is a
std_logic_vector(3 downto 0) in this case.

    with sig_sel select
        destin_sig <= source_a when X"C",
                      source_b when X"E",
                      source_c when X"D",
                      '0' when others;

The caveat ("gotcha," in the vernacular) is that X"4" (for example) is a
four-bit item.  If you declared sig_sel as std_logic_vector(2 downto 0),
you'd get a compiler error complaining that the length of sig_sel doesn't
match the hex number.

-- a
-----------------------------------------
Andy Peters
Sr Electrical Engineer
National Optical Astronomy Observatories
950 N Cherry Ave
Tucson, AZ 85719
apeters (at) noao \dot\ edu

"A sufficiently advanced technology is indistinguishable from magic"
     --Arthur C. Clarke



Sun, 27 Oct 2002 03:00:00 GMT  
 Use of hex values for selected signal assignment
On Tue, 09 May 2000 16:03:18 -0400, Carl Ashley Work

Quote:

>An associate of mine would like to use hex strings within a selected
>signal assignment.  I understand there are constrants on the decoded
>values which preclude function calls.  Any suggestions?  Here is the
>standard syntax:

>  with sig_sel select
>    destin_sig  <= source_a when "1100",   -- Comment about value C
>                   source_b when "1110",   -- Comment about value E
>                   source_c when "1101",   -- Comment about value D
>                   '0' when others ;

>Can the values above be coded for better documentation as X'0C' or 16#C#
>in some manner?  The above looks fine as 4 bits, but as the number of
>bits increases, the engineer would find it much better to document with
>hex numbers.

How about this:

  with to_integer(unsigned(sig_sel)) select
    destin_sig  <=
      source_a when 12,
      source_b when 16#e#,
      source_c when 13,
      '0' when others ;

This gets around the annoying problem of not being able to specify a
hex choice when destin_sig isn't a multiple of 4 bits (or an octal
choice for a multiple of 3 bits).

You're right about the restriction on the use of function calls in the
choice (the decoded value, as you put it). Interestingly, though, the
analysers I've tried recently all allow conversion functions from
numeric_std, so this would (incorrectly, but usefully) compile without
an error:

  with sig_sel select
    destin_sig <= source_a when std_logic_vector(to_unsigned(12, 4)),
    etc.

(not that I'm suggesting this). I guess that they treat builtin's as
locally static.

Evan



Tue, 29 Oct 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. selected signal assignment question

2. Selecting certain signals in to a graph out of a possible 128 signals

3. Is There a Way to Output Signal Names and Enumerated Type Values Using Textio

4. Initial values of signals not used in Simulation

5. Hex to Bin, Bin to Hex, Hex to Dec, Dec to Hex

6. Decimal value in hex to hex value in hex. Help me out

7. CGI : getting selected values in a select-object

8. Clarion Browse using SQL doing a SELECT ASC and then SELECT DESC

9. Bugs from g77 - hex assignment and internal formats

10. Variable/Signal assigned by multiple non-blocking assignments

11. conditional signal assignment

12. Signal <=Variable assignment?

 

 
Powered by phpBB® Forum Software