Forum Discussion
Altera_Forum
Honored Contributor
15 years agohelp in for loop
sir,here is my small code
library IEEE; use IEEE.STD_LOGIC_1164.ALL; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; -- Uncomment the following library declaration if using -- arithmetic functions with Signed or Unsigned values --use IEEE.NUMERIC_STD.ALL; -- Uncomment the following library declaration if instantiating -- any Xilinx primitives in this code. --library UNISIM; --use UNISIM.VComponents.all; entity nu is Port ( ---a : in STD_LOGIC_VECTOR (6 downto 0); b : out STD_LOGIC_VECTOR (6 downto 0)); end nu; architecture Behavioral of nu is constant f : std_logic_vector(7 downto 0) :="01011001"; signal result : integer; begin k1 : for i in 0 to 4 generate result <= conv_integer(signed(f))*i; b <= conv_std_logic_vector(result,7);<--- error in this line. end generate; end Behavioral; Analyzing Entity <nu> in library <work> (Architecture <Behavioral>). ERROR:Xst:800 - "C:/.Xilinx/gateor/float.vhd" line 44: Multi-source on Integers in Concurrent Assignment. plz fix my problem.4 Replies
- Altera_Forum
Honored Contributor
In that case at least you need input clock. Then run a counter from 0 to 4 (as integer) and multiply by your internal constant.
However, this will do as a crude exercise since you might just precompute result on paper and then don't need the design. - Altera_Forum
Honored Contributor
sir i want to multiply a 8 bit number with 0,1,2,3,4.but don't understand how to keep them in output using for loop.:(
- Altera_Forum
Honored Contributor
--- Quote Start --- k1 : for i in 0 to 4 generate result <= conv_integer(signed(f))*i; b <= conv_std_logic_vector(result,7);<--- error in this line. end generate; --- Quote End --- A common misunderstanding of HDL loops: Your loop is unrolled at compile time to: result <= conv_integer(signed(f))*0; b <= conv_std_logic_vector(result,7); result <= conv_integer(signed(f))*1; b <= conv_std_logic_vector(result,7); result <= conv_integer(signed(f))*2; b <= conv_std_logic_vector(result,7); result <= conv_integer(signed(f))*3; b <= conv_std_logic_vector(result,7); result <= conv_integer(signed(f))*4; b <= conv_std_logic_vector(result,7); so bothe result and b are driven by multiple statements. If loop was in a sequential body then last statement overrides and even then it becomes meaningless. You better tell us what do you want to do. - Altera_Forum
Honored Contributor
you have assigned to b 5 times.
secondly this is an altera forum, you are using xilinx tools