8 bit DIVISION PROBLEM

OP #4551669
Rate this post
• ▲ useful
▼ not useful
Hi guys,

I have a little problem with a division in VHDL. More exactly , my 
problem is that my first element which I want to be divided is not 
memorised and I really don`t know why because I have no problem with the 
second one.

Let me explain you :

I want to divide broj1 by broj2. Below is the code , please help me ! 
Thanks.


library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;



entity Multiplier is
port ( input : in std_logic_vector(7 downto 0);
            btn1,btn2,btn3 : in std_logic;
            output,remainder : out std_logic_vector(7 downto 0));

end Multiplier;

architecture Behavioral of Multiplier is
signal broj1:std_logic_vector (7 downto 0);
signal broj2:std_logic_vector (7 downto 0);
signal i:std_logic_vector (7 downto 0);
signal aux:std_logic_vector (7 downto 0);
begin

process (btn1, btn2)
begin

if (btn1'event and btn1='1') then
        broj1<=input;
end if;

if (btn2'event and btn2='1') then
        broj2<=input;
end if;
end process;

process (btn3)
begin

if (btn3'event and btn3='1') then
  --output <= broj1 / broj2;

  i<="00000000";


    while (broj1>= 0) loop
        i<=i+1;
    aux<=broj1;
    broj1<=broj1-broj2;
    end loop;
  i<=i-1;
  output<=i;
  remainder<=aux;



end if;
end process;

end Behavioral;
Moderator (Company: Titel) #4551712
Rate this post
• ▲ useful
▼ not useful
Marius P. wrote:
> Below is the code , please help me !
What did you expect it to do? And what does it instead?
How did you find that out?
You know in what a loop in VHDL results?

And the ABSOLUTE MAJOR HINT:
Forget that btn'event. Only a clock is worth of an 'event. And in a 
beginners design there MUST be only 1 clock throughout the WHOLE design.
To check a pressed button that buttons signal must be synchronized to 
the one and only clock. Then a debouncing should be used and an edge 
detection afterwards.
All in all that are a bunch of flipflops, also known as a shift 
register.
But that thing with those 'event on each input will run ONLY in 
simulation (if at all).
And one word more: VHDL is not a programming language. If it was then it 
would be called VH-P-L...

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.