Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to design 4bit divider circuit??

Status
Not open for further replies.

nanoYasser

Junior Member level 1
Joined
Mar 9, 2007
Messages
18
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,281
Location
I'm here sir!
Activity points
1,422
4 bit divider

Hi experts..
I have aproblem in designing an elementary calculator using logic gates IC's
There is no problem about addition,sub and multiplying
Can any one please tell me how to desing a circuit which can divid 4 bit on 4bit?

Thanks in advance..
Yassorty,
 

4-bit divider circuit

Hey
I think you can not divide a 4bit by 4bit without using a register. You will need one register to store the quotient value and other to store the remainder.
Ther are algorithmsfor doing so which use shifting of bits (you can find them in Computer system Organisation by Morris Mano)

Regards
tronix
 

divider circuits morris mano

If it is unsigned number, shift the dividend left by divider. something like this;

wire [4:0] results;
assign results = dividend << divider;

if it is signed number, then it is a bit more complicated. Do something like this;

module div(a,b,d);
input [3:0] a,b;
output [7:0] d;

reg [3:0] dvd,dvr,not_dvr;
reg [7:0] d;
reg [3:0] quo,rem;
reg sign;
integer i;

always @ ( * )
begin
if ( a[3] == 1'b1 ) // Changing the 4-bit signed to unsigned, for both, the divisor and the dividend.
dvd = ~a + 4'b1;
else
dvd = a;
if ( b[3] == 1'b1 )
dvr = ~b + 4'b1;
else
dvr = b;
not_dvr = ~dvr + 4'b1;
sign = a[3] ^ b[3]; // sign bit for the product.
if (b==4'b0) // For the case where the divisor is 0,
//we make the quo & rem both zero.
begin
quo = 1'b0;
rem = a;
end
else
begin
quo = 1'b0; // set the quotient to 0.
for ( i=1; i<=8; i=i+1) // actual division division algorithm.
if (dvd >= dvr)
begin
dvd = dvd + not_dvr;
quo = i;
end
rem = dvd;
end
if ( a[3] == 1'b1 ) // same signs
rem = ~rem + 4'b1;
if ( sign == 1'b1 ) // quotient is positive only if both the
//dividend & the divisor have the same sign.
quo = ~quo + 4'b1;
d = \{ quo, rem \}; // Concatenating to get the result.
end

endmodule
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top