-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
>
> When i tried to analyse it using ghdl i'm getting the error msg like this
>
>
> [ejo...@linuxpoint ~]$ ghdl -a counter.vhdl
> counter.vhdl:29:27: no function declarations for operator "+"
> counter.vhdl:32:31: no function declarations for operator "+"
> ghdl: compilation error
> [ejo...@linuxpoint ~]$
>
> Please help me
>
> With regards
> Ejofti.
>
always use unsigned or signed type as internal signals when you need to
do arithmetic operations (CHANGE 1) , convert to/from std_logic_vector
to/from ports to be compliant with backend tools. (CHANGE 2)
On your code this give:
library ieee ;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity counter is
generic(n: natural :=2);
port( clock: in std_logic;
clear: in std_logic;
count: in std_logic;
Q: out std_logic_vector(n-1 downto 0)
);
end counter;
architecture behv of counter is
signal Pre_Q: unsigned(n-1 downto 0); -- <<<< CHANGE 1 HERE
begin
process(clock, count, clear)
begin
if clear = '1' then
Pre_Q <= Pre_Q + Pre_Q;
elsif (clock='1' and clock'event) then
if count = '1' then
Pre_Q <= Pre_Q + 1;
end if;
end if;
end process;
Q <= std_logic_vector(Pre_Q); -- <<<< CHANGE 2 HERE
end behv;
- ---------
This technique is more readable than
Pre_Q <= std_logic_vector(unsigned(Pre_Q) + 1);
but you can use this style when you work directly on input and output ports.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJMkdXqAAoJENlXRqSDmxB98OQH/ihOifiK3dWfg20nt20Eks1T
11LoPibIUuhDX2LZXs7KKHk4e4FqbecqwEAoCP4wDsoMnxjXS40LRKrR4PgaqAax
YfeOX9HQkmNChg5jRNhfTH7pGbP8tPEmRxOPxslDEmsHG9FqkKO/7GCjgt16yzoj
fcZLj0lFNxKmrO5ULrkI3nxJVICBzwKISeYkvEuFcBxq+D+nKyQHnh8WL1wwXUnU
ExZzDMiGqlCtTWTZhWJCpx8c1gZswiBRwSSR0vWhkmejkLc0z9X1LXUCBpVNdpmV
QQBgubaQkL9DQUUVEbOIrBkrDJo2DFGD1ODpDCXV4GDojUVDw0Qgpk9i+acMD0s=
=bLD3
-----END PGP SIGNATURE-----
_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss