logical left shifter or latch ??

D

dangerlee

I try to establish a logical left shifter.
Synthesizer XST synthesizes a 32-bit latch.
I want to eliminate latch.
How can I do?
Thanks!!
-------------------------------------------------------------------
entity barrelshifter is
port(
BS_value :in std_logic_vector(31 downto 0);
BS_amount :in std_logic_vector(5 downto 0);
BS_operand2 :eek:ut std_logic_vector(31 downto 0)
);
end barrelshifter;

architecture Behavioral of barrelshifter is
constant cZeroSpace : std_logic_vector(31 downto 0) :=X"00000000";
signal sAmount : integer;
begin
sAmount <= conv_integer(BS_amount);
process(sAmount, BS_value)
begin
case sAmount is
when 0 =>
BS_operand2 <= BS_value;
when 1 to 31 =>
for i in 1 to 31 loop
if i = sAmount then
BS_operand2 <= BS_value((31-i) downto 0) & cZeroSpace((i-1) downto 0);
end if;
end loop;
when others =>
BS_operand2 <= cZeroSpace;
end case;
end process;
end Behavioral;
 
E

Egbert Molenkamp

Maybe the tool does not recognise that BS_operand2 always gets a value.
You can try to help the tool by adding an extra line; see below

begin
BS_operand2<=X"00000000"; -- ADDED
case sAmount is

Egbert Molenkamp
 
M

Mike Treseler

dangerlee said:
I try to establish a logical left shifter.
Synthesizer XST synthesizes a 32-bit latch.

There may be a logical error in your code.
I want to eliminate latch.
How can I do?

By writing and using a VHDL simulation testbench.
Run the testbench, watch the waveforms,
trace the code, edit, recompile, repeat.

-- Mike Treseler
 
E

Egbert Molenkamp

Check your code. You probably added the line at the wrong position!
The statement
BS_operand2<=X"00000000";
should be IN the process where you already assign to BS_operand2. So just
above the case statement.
This can never cause a multi-source problem.
In fact the external behaviour is the same assuming that you always assigned
a value to BS_operand2 in this process.

Does the tool inform you for wich object a latch is used? I assumed it is
for BS_operand2.
In the case statement you assign always a value to BS_operand2. But if a
tool can not detect it it will use a latch.
Therefore I suggested to add the additional statement at first statement in
the process. Now the tool recognise that it does not need a latch for
BS_operand2.

I'm curious to know if this helps.

Egbert Molenkamp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top