Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] VHDL, which compare function is used?

Status
Not open for further replies.

std_match

Advanced Member level 4
Joined
Jul 9, 2010
Messages
1,304
Helped
463
Reputation
926
Reaction score
448
Trophy points
1,363
Location
Sweden
Activity points
10,167
I found a compare in old code, and I don't understand which function is used.
I can not find ">" for std_logic_vector.
VHDL has a built-in ">" for bit_vector, but it should not be used here?

I have created a small example. Look at line 21.
Tested with Modelsim 6.6d


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
library ieee;
   use ieee.std_logic_1164.all;
   use ieee.numeric_std.all;
 
entity std_logic_vector_compare is
  port(counter_vector_copy : out std_logic_vector(3 downto 0);
    greater_than_6 : out std_logic);
end entity std_logic_vector_compare;
 
architecture test of std_logic_vector_compare is
 
signal counter_vector   : std_logic_vector(3 downto 0);
signal counter : unsigned(3 downto 0) := "0000";
 
begin  -- architecture test
  counter_vector_copy <= counter_vector;
  counter_vector <= std_logic_vector(counter);
 
  process(counter_vector)
  begin
    if counter_vector > "0110" then     -- Which compare function ???
      greater_than_6 <= '1';
    else
      greater_than_6 <= '0';
    end if;
  end process;
 
  stimuli: process
  begin
    wait for 1 us;
    if counter = 15 then
      wait;
    end if;
    counter <= counter + 1;
  end process;
  
end architecture test;

 

hmm, bit of a head scratcher - even works when I only include std_logic_arith, so its not falling out of numeric_std.

- - - Updated - - -

Quartus compiles it without complaining either!
Might be worth posting on comp.lang.vhdl newsgroup
 

It is possible to use the predefined relational operators on all types and arrays of all types,
if the types are the same on both sides of the operator (the array sizes can be different).

The comparison is made element by element, and if one value is left of another in the definition, it is also "less than".

For std_logic_vector, this means that 'X' is less than '0' and 'Z' is greater than '1'.
 

It is possible to use the predefined relational operators on all types and arrays of all types
That's also my assumption. Specific functions and operators for std_logic_vector are required by the different result type.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top