conversion variable to std_logic

D

Dr. Thomas Ansorg

Hello all
I need to convert a variable to a std_logic or std_logic_vector for
monitoring in the simulation. The variable is a natural range 0 to 39.

Tom
 
A

Andy

Hello all
I need to convert a variable to a std_logic or std_logic_vector for
monitoring in the simulation. The variable is a natural range 0 to 39.

Tom

use ieee.numeric_std.all;

....

sig <= std_logic_vector(to_unsigned(var, sig'length));

However, signals can be integer/natural types too, or
numeric_std.signed/unsigned. On device level ports, post-synthesis/P&R
gate level netlists will use SL/SLV datatypes on those ports no matter
what your RTL used (or you can build a type conversion wrapper for the
device when/if the gate level netlist is needed for simulation). For
internal signals & ports, use whatever makes the most sense.

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top