As the main answer says, the recommended method is as follows:
use ieee.numeric_std.all;
...
my_slv <= std_logic_vector(to_unsigned(my_int, my_slv'length));
However, I would like to elaborate about why this is recommended, and why VHDL has such a seemingly convoluted way of converting integers into std_logic_vectors.
It comes down to how these types are viewed by the tools.
A standard_logic_vector is literally a bunch of 1s or 0s. I have 10001. What number is this? Well, it depends. Is it signed or unsigned? Ths SLV doesn't know or care. How many bits? Well, how long is your SLV?
An integer is signed, and usually 32 bits (if i remember correctly).
Stage 1:
Make my integer shorter, and unsigned. That's this part:
to_unsigned(my_int, my_slv'length));
"I have this integer, I want it to be unsigned, and I want it to fit
into the length of my SLV."
Stage 2: Then, take those bits and use them to drive the my_slv.
my_slv <= std_logic_vector(...)
"Take these bits, and use them to drive my slv"
(A note on terminology. A <= B
in VHDL is read out loud as "A is driven by B")
Combined, this gets you:
my_slv <= std_logic_vector(to_unsigned(my_int, my_slv'length));
When coming from a traditional programming background, it's very easy to get stuck in a programming way of thinking. But in VHDL the code you write has physical implications in hardware. Knowing why this method works and is recommended is one step closer to thinking about what you're writing in hardware terms.
Bonus tip: functions prefixed by to_ are ones that shorten/change the operands. They make them unsigned or a certain length or both. This is why to_unsigned requires you to specify the length. The functions without to_ (straight std_logic_vector(...) in this example) are used when types are directly compatible already. "Take these bits and stuff them in this type, no modifications required". These don't have a length argument because both sides are already the same. So when constructing things like this, I don't need to look it up, I just think about how I'm changing the data.