Forum: FPGA, VHDL & Verilog help needed for a non restoring division

von Aswin K. (Company: nit warangal) (aswinkavali)

Rate this post
0 useful
not useful
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity nam is
port (a : in std_logic_vector(7 downto 0);
    b : in std_logic_vector(3 downto 0);
    c : out std_logic_vector(3 downto 0));
end nam;

architecture ban of nam is
variable p,h :std_logic_vector(8 downto 0);
variable m :std_logic_vector(4 downto 0);
variable k:std_logic;

m(3 downto 0):=b;
p(7 downto 0):=a;
p(8 downto 4):=p(8 downto 4)-m;
p(8 downto 1):=p(7 downto 0);
for i in 0 to 4 loop
if(k='0') then
h(8 downto 4):=h(8 downto 4)-m;
h(8 downto 4):=h(8 downto 4)+m;
end if;
h(8 downto 1):=h(7 downto 0);

if (i=4) then
c<=h(3 downto 0);
end if;
end loop;

end process;

end ban;


here i have written one program for non restoring division....but am 
getting the quotient as three....

von Lothar M. (lkmiller) (Moderator)

Rate this post
0 useful
not useful
> here i have written one program for non restoring division...
You run a division of 8 bits by 4 bits and you return 4 bits as the 
         a : IN  std_logic_vector(7 downto 0);
         b : IN  std_logic_vector(3 downto 0);
         c : OUT  std_logic_vector(3 downto 0)
So one fairly simple question:
What would you expect as result when you calculate 16/1 or 32/2 or 33/2?
How will these results fit in 4 bit?

von Aswin K. (Company: nit warangal) (aswinkavali)

Rate this post
0 useful
not useful
that one is a limitation....but i have tried 32 by 4 and 32 by 8 the 
resuts were 3 in both cases.......what will be the problem...anybody 
having another program for this non restoring division please send 


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.