comparator in vhdl-ams

Guest #3467264
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 ??
Moderator (Company: Titel) #3467294
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?
Guest #3467549
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!
Attached files:
Guest #3467561
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.
Guest #6220036
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

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.