EmbDev.net

Forum: FPGA, VHDL & Verilog comparator in vhdl-ams


von sebgimi (Guest)


Rate this post
useful
not useful
Hi all! I would like to write a code for a comparator in vhdl-ams. Its 
the first time I use this langage so I'm totally lost... (by the way if 
you know a link with complet lesson on this langage it will be great).

Anyway, I find a simple code on the web, but when I run the entity only, 
the following error is occuring:

library ieee;
use ieee.std_logic_1164.all;
use ieee.electrical_systems.all;

entity comparator is

--generic (level : Real := 2.5); -- threshold

port(terminal a: electrical; -- analogic in
signal s : out std_logic); -- digital out

end comparator;

This is the error:

port(terminal a: electrical; -- analogic in
|
ncvhdl_p: *E,MISCOL (comparator_ent.vhdl,9|14): expecting a colon (':') 
87[4.3.3] 93[4.3.2].

That seem easy but I compare with others code on the web and I find no 
error. Furthermore I noted that the key word 'terminal' is not in color 
like the others key words. Maybe its a library issue, I don't know...

Can you help please ??

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
sebgimi wrote:
> Can you help please ??
Attach your VHDL file (as a *.vhd or a *.vhdl file).
It does not make sense to fiddle around with code snippets...

sebgimi wrote:
> Furthermore I noted that the key word 'terminal' is not in color like
> the others key words. Maybe its a library issue, I don't know...
Its a syntax-highlighting issue of your editor. What toolchain do you 
use?

von sebgimi (Guest)


Attached files:

Rate this post
useful
not useful
Thank you for your answer!

I know that just the code of the entity does not make sense, I did that 
to limit the number of errors and to make sure I use the right library 
and syntaxe of vhdl-ams.

The complet code is following:
1
entity comparator is 
2
3
generic (level : Real := 2.5); -- threshold
4
5
port( terminal a : in Electrical; -- analogic in
6
      signal s : out std_logic);       -- digital out
7
8
end entity comparator; 
9
10
architecture archi of comparator is 
11
12
quantity v across a;       -- across quantity to ground
13
14
begin 
15
16
     s <= `1' when v'Above(level) -- v > level 
17
     else `0';                    -- v < level
18
19
end architecture archi;

Now, when I compile the whole code 9 errors are occuring (in 
attachment)...

Do you know from where these errors come and how to fix them?

For information I use ncvhdl/ncsim toolchain.

Thank for your help!

von sebgimi (Guest)


Rate this post
useful
not useful
I forgot libraries declaration:

library ieee;
use ieee.std_logic_1164.all;
use ieee.electrical_systems.all;

Maybe I do not use the right libraries??

And I note that the word 'terminal' is not in color either in my last 
post so it is not an issue from the toolchain I guess.

von Alberto L. (Guest)


Rate this post
useful
not useful
Hello Sebastian,
To make an ideal comparator in vhdl-ams is a simple task...

I add here my VHDL-ams code. Then depending if you want to have 
threshold you can comment the last line or not.

You can find the full code on https://miscircuitos.com/ideal-comparator
1
library ieee, std;
2
use ieee.std_logic_1164.all;
3
use ieee.electrical_systems.all;
4
5
entity comparator is    
6
    GENERIC(
7
        Vthres : REAL := 0.1  --threshold
8
    );    
9
    PORT(
10
        TERMINAL Vin : ELECTRICAL;
11
        TERMINAL Vref : ELECTRICAL;
12
        result : out std_logic
13
    );
14
end entity comparator;
15
16
ARCHITECTURE vhdlams of comparator IS 
17
      QUANTITY Volt ACROSS Vin TO Vref;
18
BEGIN
19
    --result &lt;= '1' when (Vin &gt; Vref) else '0'; --without threshold
20
    result &lt;= '1' when Volt'above(Vthres) else '0'; --With threshold 
21
END vhdlams;
I hope it helps to anyone :)
Regards
Alberto

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.