cmd_register: process (rst_n, clk)
begin
if (rst_n='0') then
cmd_r<= (others=>'0');
elsif (clk'event and clk='1') then
cmd_r<=...;
end if;
end process cmd_register;
I know "<=" specifies assignment but what is others
? And what does =>
do?
You use := to do variable assignment, which takes place immediately. So if you have a signal, you always use <= . If you have a variable, you always use := .
The VHDL keyword “std_logic_vector” defines a vector of elements of type std_logic. For example, std_logic_vector(0 to 2) represents a three-element vector of std_logic data type, with the index range extending from 0 to 2.
Assigning signals using Selected signal assignment Select statements are used to assign signals in VHDL. They can only be used in combinational code outside of a process. A selected signal assignment is a clear way of assigning a signal based on a specific list of combinations for one input signal.
cmd_r is defined as a std_logic_vector, or unsigned or signed signal. let's see how this signal type are defined:
type std_logic_vector is array (natural range <>) of std_logic;
type unsigned is array (natural range <>) of std_logic;
type signed is array (natural range <>) of std_logic;
Note that these 3 types have the same definition as an array of std_logic items.
The statement "Others => '0'" is a feature of the VHDL when the coder want to defined several items in an array with the same value.
In your example, all item std_logic in the array are set to '0'.
Another application of this statement is to set some items at a specific value and all others at a default value :
cmd_r <= (0 => '1',
4 => '1',
others => '0');
In this case, the bit 0 and 4 are set to '1' and all other bits are set to '0'.
One last thing, it's NOT possible to write something like this :
cmd_r <= (0 => '1',
4 downto 2 => "111", -- this line is wrong !!!
others => '0');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With