Altera_Forum
Honored Contributor
12 years agoproblem with an addition in a vhdl code
Hello,
I have written the following code but I do not take the right results from the addition: met <=met+monada; I think that the problem is that I have the signal met twice. Specifically, I take that the output nn is equal to 1.. At first I had that my signals and the output are this type: "sfixed" beacause I wanted to add fixed point numbers but then the following error was appeared: expression has 7 elements, but must have 6 elements Then I increased the number of elements and it appeared this error: expression has 8 elements, but must have 7 elements LIBRARY ieee; USE ieee.std_logic_1164.all; library ieee_proposed; use ieee_proposed.fixed_pkg.all; use ieee.numeric_std.all; USE ieee.std_logic_signed.all; ENTITY adder IS PORT (z:IN SIGNED(2 DOWNTO 0) :="001"; nn:OUT signed (5 DOWNTO 0)); END adder; ARCHITECTURE behavior OF adder IS signal met:signed(5 DOWNTO 0); signal monada:signed(2 DOWNTO 0); signal meta:signed(5 DOWNTO 0); BEGIN PROCESS(met) -- variable count: integer range 26 downto 0; BEGIN --monada <= to_sfixed (1,monada); FOR i IN 1 TO 25 LOOP met <=met+1; -- met <=meta; END LOOP; FOR i IN 1 TO 5 LOOP IF(z=i) THEN nn<=met; END IF; END LOOP; END process; END behavior; What is my error?What I have to do?Please help me!!Thank you very much in advance..