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.

Divider(4bit) verilog code for Spartan3E-XC3S100E

Status
Not open for further replies.

srinivasandelta

Newbie level 3
Joined
Jul 27, 2009
Messages
4
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Location
INDIA
Activity points
1,317
My 4 bit divider code is not working:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
`timescale 1ns / 1ps
 
module  divider4t4(clock, divisor, dividend,quotient,reminder);
 
input clock;
input [3:0] divisor;
input [3:0] dividend;
 
output [3:0]quotient;
output [3:0]reminder;
 
reg [3:0]quotient;
reg [3:0]reminder;
reg [3:0]temp;
 
always@(posedge clock)
begin
    reminder = dividend;
    if(reminder >= 0)
        begin 
            reminder=reminder-divisor;
            temp=reminder;
            quotient = quotient + 1;
        end
    else
        reminder = temp;
end
 
assign [3:0]reminder = [3:0]reminder;
assign [3:0]quotient = [3:0]quotient;
 
endmodule


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Thank you in advance,

With regards,
Srinivasan
 
Last edited by a moderator:

You apparently intend to write a sequential divider. But there's no sequence state machine in your code.
reminder is erroneously rewritten every cycle and quotient is never initialized.

Reconsider what you want to do, review examples from literature or try on your own.
 
First of all sorry for not posting the code under code tag.

I checked the forum for division program and help, but couldn't find any working code. All are incomplete and not executable.

While in the investigation, I got reminded about something I read about no solution for subtract operation through digital circuits of VLSI. I am not sure exactly where I read this.

But there is some basic point which illustrates the difficulty of implementing SUBTRACT function and not as straight forward way like addition.

Please can any one point out to any working code for Division/subtraction function/module in verilog syntax?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top