A
Amal
In a design done by someone else I encountered a problem that I did
not expect. I don't usually compare vectors of different length, but
he was comparing a 10-bit vector with a bit string literal that is a
bit_vector. The base was hexadecimal and apparently he was comparing
the 10 bit vector (std_logic_vector). And did not get the correct
functionality. I am not sure if this is an inherent problem with VHDL
or it is Modelsim simulator problem.
In the following code, even if you change the comparison operator from
'<' (less than) to '<=' (less than or equal), you would get the same
result, which is very weird.
Please give me your input and tell me how VHDL treats bit-string
literals and bit_vector constants.
entity test is
end entity test;
architecture behav of test is
signal v : bit_vector(9 downto 0);
signal x1, x2, x3 : boolean;
begin
x1 <= (v < X"010");
x2 <= (v < b"0000_0001_0000");
x3 <= (v < "000000010000");
z1 <= (v < b"00_0001_0000");
z2 <= (v < "0000010000");
process
begin
v <= (others=>'0');
-- for i in 0 to 31 loop
-- v <= conv_std_logic_vector( i, v'length );
-- wait for 10 ns;
-- end loop;
wait for 10 ns;
v <= "0000000001";
wait for 10 ns;
v <= "0000000010";
wait for 10 ns;
v <= "0000000011";
wait for 10 ns;
v <= "0000000100";
wait for 10 ns;
v <= "0000000101";
wait for 10 ns;
v <= "0000000110";
wait for 10 ns;
v <= "0000000111";
wait for 10 ns;
v <= "0000001000";
wait for 10 ns;
v <= "0000001001";
wait for 10 ns;
v <= "0000001010";
wait for 10 ns;
v <= "0000001011";
wait for 10 ns;
v <= "0000001100";
wait for 10 ns;
v <= "0000001101";
wait for 10 ns;
v <= "0000001110";
wait for 10 ns;
v <= "0000001111";
wait for 10 ns;
v <= "0000010000";
wait for 10 ns;
v <= "0000010001";
wait for 50 ns;
wait;
end process;
end architecture behav;
-- Amal
not expect. I don't usually compare vectors of different length, but
he was comparing a 10-bit vector with a bit string literal that is a
bit_vector. The base was hexadecimal and apparently he was comparing
the 10 bit vector (std_logic_vector). And did not get the correct
functionality. I am not sure if this is an inherent problem with VHDL
or it is Modelsim simulator problem.
In the following code, even if you change the comparison operator from
'<' (less than) to '<=' (less than or equal), you would get the same
result, which is very weird.
Please give me your input and tell me how VHDL treats bit-string
literals and bit_vector constants.
entity test is
end entity test;
architecture behav of test is
signal v : bit_vector(9 downto 0);
signal x1, x2, x3 : boolean;
begin
x1 <= (v < X"010");
x2 <= (v < b"0000_0001_0000");
x3 <= (v < "000000010000");
z1 <= (v < b"00_0001_0000");
z2 <= (v < "0000010000");
process
begin
v <= (others=>'0');
-- for i in 0 to 31 loop
-- v <= conv_std_logic_vector( i, v'length );
-- wait for 10 ns;
-- end loop;
wait for 10 ns;
v <= "0000000001";
wait for 10 ns;
v <= "0000000010";
wait for 10 ns;
v <= "0000000011";
wait for 10 ns;
v <= "0000000100";
wait for 10 ns;
v <= "0000000101";
wait for 10 ns;
v <= "0000000110";
wait for 10 ns;
v <= "0000000111";
wait for 10 ns;
v <= "0000001000";
wait for 10 ns;
v <= "0000001001";
wait for 10 ns;
v <= "0000001010";
wait for 10 ns;
v <= "0000001011";
wait for 10 ns;
v <= "0000001100";
wait for 10 ns;
v <= "0000001101";
wait for 10 ns;
v <= "0000001110";
wait for 10 ns;
v <= "0000001111";
wait for 10 ns;
v <= "0000010000";
wait for 10 ns;
v <= "0000010001";
wait for 50 ns;
wait;
end process;
end architecture behav;
-- Amal