An interesting follow-up, provoked by an email I received
directly (shame on you, Sir, but I'm respecting your
privacy by not exposing your email address here...)
> CONSTANT version_number : std_logic_vector (7 downto 0) := X"0F";
> I have not succeeded to use this coding style with vectors
> that are not a multiple of 4.
> Lets say you have a 6-bit vector and want to set it to 3F.
> Any suggestions?
No, this works only for multiples of 4 bits. The reason is
that VHDL-93 handles the idiom X"0F" by literally substituting
the string "00001111" - in other words, each hex digit always
creates four one-bit literals.
Put eight bits into a constant and take a slice of it, or
better, repackage the numeric_std RESIZE function to do
the job for you:
function resize_slv( s: std_logic_vector; n: positive )
return std_logic_vector is
begin
return std_logic_vector(resize(unsigned(s), n));
end;
....
constant version6: std_logic_vector(5 downto 0)
:= resize_slv(X"3F", 6);
--
Jonathan Bromley, Consultant
DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services
Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:
Fax: +44 (0)1425 471573 Web:
http://www.doulos.com
The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.