modelsim dont work

Guest #6211995
Rate this post
• ▲ useful
▼ not useful
the program supposed to count the number of '1' in a given 32bit input

library IEEE;
use IEEE.std_logic_1164.all;

entity one_cnt is
port( serial_bit_input : in std_logic_vector (31 downto 0);
      result            : out  integer range 0 to 32) ;
end;

architecture behave of one_cnt is
signal cnt : integer range  0 to 32;
begin

process(serial_bit_input)
begin

cnt<=0;
  count_loop : for i in 31 downto 0 loop

    if serial_bit_input(i)='1' then
      cnt<=cnt+1;
    end if;

  end loop count_loop;

result<=cnt;
end process;
end architecture;



as you can see :

* Fatal: (vsim-3807) Types do not match between component and entity for 
port "result"

what sould i do?
Attached files:
Guest #6218207
Rate this post
• ▲ useful
▼ not useful
Hi,

I guess you accidentally compiled the Component template file *.vho 
instead of the source code (typically *.vhd oder *.vhdl).
Your code has only 27 lines of code, but the error was reported on line 
83.

Little hint:
Your design won't work this way. Try the code bellow...

process(serial_bit_input, cnt)
  variable cnt : integer range  0 to 32;
begin

  cnt := 0;
  count_loop : for i in 31 downto 0 loop
    if serial_bit_input(i)='1' then
      cnt := cnt + 1;
    end if;
  end loop count_loop;

  result<=cnt;

end process;

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.