dpaul
Advanced Member level 5
The tx_data_length needs to be calc which is a signal of type unsigned. The parity_en_i and stop_bit_count_i are of types std_logic and can only be '0' or '1' (these two single bit inputs are outputs from a register in another module).
Unsigned addition needs to be performed for the tx_data_length. I am trying to maintain that the LHS and RHS signals must all of type unsigned.
Is this the best way to perform such an operation?
Update: More suitable header - Adding data-types std_logic and unsigned in VHDL
Unsigned addition needs to be performed for the tx_data_length. I am trying to maintain that the LHS and RHS signals must all of type unsigned.
Is this the best way to perform such an operation?
Code:
.
.
-- Ports declarations
parity_en_i : in std_logic;
.
.
stop_bit_count_i : in std_logic;
.
.
architecture arc of module_arch is
-- Signal declarations
.
.
signal tx_data_length : unsigned(3 downto 0);
signal data_length : unsigned(3 downto 0);
.
.
signal parity_en : integer range 0 to 1;
signal stop_bit_count : integer range 0 to 1;
begin
parity_en <= 1 when parity_en_i = '1' else 0;
stop_bit_count <= 1 when stop_bit_count_i = '1' else 0;
.
.
.
tx_data_length <= 1 + data_length + to_unsigned(parity_en, 1) + 1 + to_unsigned(stop_bit_count, 1);
.
.
Update: More suitable header - Adding data-types std_logic and unsigned in VHDL
Last edited: