EmbDev.net

Forum: FPGA, VHDL & Verilog 8 bit DIVISION PROBLEM


Author: Marius Pop (marius91000)
Posted on:

Rate this post
0 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;

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 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

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.