


of bits needed for representing the actual result) at MSB.
Vhdl shift left how to#
You will have to compile in VHDL-2008 mode for this to work.SLL does multiplication operation by 2^(no.Shifts).In case of error in multiplication result add a correction bit of 2^(n-1) (where n is no. 2 Answers Sorted by: 1 Here is how to use the sll operator for you example. If R > 1 the single shift operation is repeated R times. The single shift operation replaces L with a value which is the result of concatenation whose left argument is the leftmost L'Length -1 elements of L and whose right argument is L'Right. This will automatically include all the relevant signals. In case when R is equal to 0 or L is the null array, the left operand L is returned. if you don't want to worry about signals missing from the sensitivity list, you can use the VHDL-2008 method process(all). And if you type if rst='1' then you never have to follow by elsif rst='0': of course rst='0' if it's not '1'.įinally, don't use the STD_LOGIC_unsigned package. signal result_int : unsigned(result'range) := (others => '0') In this case you can avoid the variables by detecting the zero and n-flag outside of the process statement. Try to avoid the use of variables anyhow. If alu_mode(2 downto 0)="111" you first set both flags, but immediately overwrite them if (temp = x"0000" ) or if (temp(15) = '1' ). Secondly, your flag setting is screwed up. This way it will no longer be a problem that signals are missing from the sensitivity list. Or -preferably- a synchronous process with synchronous reset main_proc: process(clk) You should either have a synchronous process with an asynchronous reset main_proc: process(rst, clk) First of all, even though you have a clock input port, your design is asynchronous. When "110" => temp := std_logic_vector(shift_right((unsigned(rd_data1)),to_integer(unsigned(shift))))

When "101" => temp := std_logic_vector(shift_left(unsigned(rd_data1),to_integer(unsigned(shift)))) When "100" => temp := rd_data1 NAND rd_data2 Variable m_temp : std_logic_vector(31 downto 0) Variable temp : STD_LOGIC_VECTOR(15 downto 0):=X"0000" Shift : in std_logic_vector (3 downto 0) Result : out STD_LOGIC_VECTOR (15 downto 0) Rd_data2 : in STD_LOGIC_VECTOR (15 downto 0) Īlu_mode : in STD_LOGIC_VECTOR (2 downto 0) Port ( rd_data1 : in STD_LOGIC_VECTOR (15 downto 0) Uncomment the following library declaration if instantiating arithmetic functions with Signed or Unsigned values Uncomment the following library declaration if using I can't figure out where I've gone wrong. However I've been forced to change that to a 4 bit std_logic_vector called 'shift' and now it won't shift anymore. I had this alu working with the shift left/right function when and the shift amount was being sent in on rd_data2, a 16 bit std_logic_vector.
