Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i try a verilog code for a 8-bit binary division it work good but the problem there is a reminder so how to get rid

i try a verilog code for a 8-bit binary division it work good but the problem there is a reminder so how to get rid of the reminder to make it exact division?

module division(A,B,Res);

//the size of input and output ports of the division module is generic. parameter WIDTH = 8; //input and output ports. input [WIDTH-1:0] A; input [WIDTH-1:0] B; output [WIDTH-1:0] Res; //internal variables reg [WIDTH-1:0] Res = 0; reg [WIDTH-1:0] a1,b1; reg [WIDTH:0] p1; integer i;

always@ (A or B) begin //initialize the variables. a1 = A; b1 = B; p1= 0; for(i=0;i < WIDTH;i=i+1) begin //start the for loop p1 = {p1[WIDTH-2:0],a1[WIDTH-1]}; a1[WIDTH-1:1] = a1[WIDTH-2:0]; p1 = p1-b1; if(p1[WIDTH-1] == 1) begin a1[0] = 0; p1 = p1 + b1; end else a1[0] = 1; end Res = a1; end

endmodule

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

Evaluate the expression. 8 P 0

Answered: 1 week ago

Question

=+Create an open dialogue among users?

Answered: 1 week ago