Guest
Hi all,
I have a question I've been struggling with for a while. Suppose I
have a std_logic_vector named foo, 10 bits long:
signal foo : std_logic_vector(9 downto 0);
Assume foo is interpreted as an unsigned. If I want to check whether
the value of foo exceeds, say, 256, I could do
signal gt : std_logic;
gt <= '1' when unsigned(foo) > 256 else
'0';
Since I don't want to rely on synthesis tools to recognise the
possibility of doing a simple check of the 2 MSB's instead of
instantiating subtract unit and checking the sign bit, I do this:
gt <= '1' when (foo(9) or foo(8)) = '1' else
'0';
Which means I force the "2 MSB check".
This works of course, but is becomes a problem when the length of foo
is paramaterized:
signal foo : std_logic_vector(width-1 downto 0);
What I'm looking for is an elegant way of OR'ing a parameterized
number of bits in order to perform this check.
Thanks in advance for any help.
I have a question I've been struggling with for a while. Suppose I
have a std_logic_vector named foo, 10 bits long:
signal foo : std_logic_vector(9 downto 0);
Assume foo is interpreted as an unsigned. If I want to check whether
the value of foo exceeds, say, 256, I could do
signal gt : std_logic;
gt <= '1' when unsigned(foo) > 256 else
'0';
Since I don't want to rely on synthesis tools to recognise the
possibility of doing a simple check of the 2 MSB's instead of
instantiating subtract unit and checking the sign bit, I do this:
gt <= '1' when (foo(9) or foo(8)) = '1' else
'0';
Which means I force the "2 MSB check".
This works of course, but is becomes a problem when the length of foo
is paramaterized:
signal foo : std_logic_vector(width-1 downto 0);
What I'm looking for is an elegant way of OR'ing a parameterized
number of bits in order to perform this check.
Thanks in advance for any help.