help needed for a non restoring division

OP (Company: nit warangal) #2392893
Rate this post
• ▲ 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
begin
process(a,b)
variable p,h :std_logic_vector(8 downto 0);
variable m :std_logic_vector(4 downto 0);
variable k:std_logic;


begin
m(4):='0';
m(3 downto 0):=b;
p(8):='0';
p(7 downto 0):=a;
p(8 downto 4):=p(8 downto 4)-m;
k:=p(8);
p(8 downto 1):=p(7 downto 0);
h:=p;
for i in 0 to 4 loop
if(k='0') then
h(0):='1';
h(8 downto 4):=h(8 downto 4)-m;
else
h(1):='0';
h(8 downto 4):=h(8 downto 4)+m;
end if;
k:=h(8);
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;

c=quotient
c=a/b



here i have written one program for non restoring division....but am 
getting the quotient as three....
Moderator (Company: Titel) #2393080
Rate this post
• ▲ 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 
result.
1
         a : IN  std_logic_vector(7 downto 0);
2
         b : IN  std_logic_vector(3 downto 0);
3
         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?

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.