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 divide a number by 1000 in FPGA

Status
Not open for further replies.

arash rezaee

Member level 5
Joined
Sep 10, 2009
Messages
87
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,952
Hi everyone

I have 16bit number which represent amplitude of my project and I want to divide it by 1000 and then multiply it with 0.16. How can I divide with a number which is not in the power of 2?

Please help me.

Regards
Arash
 

Literally, a divider can be used. But the "multiply it with 0.16" point suggests that you are not talking about integer numbers. Thus I think, you should clarify first about the involved number formats.

Multiply with 0.001 would be a correct answer as well ...
 

IN VHDL\Verilog is divisor allowed?....All I know is repeated subtraction for division in case of integers not in power of 2
 

Why not just multiply it with 160 instead of divide by 1000 then multiply by 0.16?
Anyway, I suppose divide can be done by using numeric_std library.
 

even better, use multiply from the fixed point library. divide is doable but needs a decent pipeline to workand you wont get that from a divide funtion. you need to use a divide ip block.

fixed divides are the same as a multiply
 

Thanks for reply
first of all I want to divide it by 1000. Then multiply it with 16 and at the end divide it by 100. How can I divide it? because when I divide it by 1000 the synthesiser got error and said it must be power of two.

any suggestion?

---------- Post added at 09:40 ---------- Previous post was at 09:37 ----------

Why not just multiply it with 160 instead of divide by 1000 then multiply by 0.16?
Anyway, I suppose divide can be done by using numeric_std library.

Do you really think 0.16 divide by 1000 is 160?? It is 0.00016 anyway
 

just muliply by 0.00016. look into fixed point notation. forget about divide.
vhdl has fixed point package to help with this.
 

just muliply by 0.00016. look into fixed point notation. forget about divide.
vhdl has fixed point package to help with this.

Would you mind explain more? I don`t know this package and also I don`t know how to use it.

Regards
 

Unless you divide by 2^x, It is not easy thing to do. In general, division is avoided. In your case, you can multiply by (0.16/1000). Then, it can be done by using a multiplier.
If your work allows you to divide by 1024 instead of 1000, it can be done without using any resource.
 

first of all, I suggest reading up on fixed point:
https://en.wikipedia.org/wiki/Fixed-point_arithmetic

then have a look at the fixed point package for VHDL (it became part of the VHDL 2008 standard)
you can get a user guide and 93 compatible versions here:
www.vhdl.org/fphdl

I am using ISE12.1 and I search in xilinx directory. I found that I have IEEE-PROPOSED in there. but when I write these two code ISE got error.
two lines are :
library ieee_proposed;
use IEEE_PROPOSED.FIXED_PKG_c.ALL;

what can I do now?
Regards
 

have you included the fixed package souce code in the project?
what exactly was the errror?
 

have you included the fixed package souce code in the project?
what exactly was the errror?

How can I include it? I really don`t know how to include package to library. will you please elaborate it for me.
 

just add the source files to your project file list.
 

I did it. but nothing changed. I have the error. Have you ever worked with divider ip core of ISE?
 

I wonder if it's of much use to discuss unsaid errors from unknown code?
 

I added to my project and when I run synthesis the same error I mention above appeared again.
 

the same error I mention above appeared again
May be it's my eyes. Can you please tell the post number where you reported the error message?

Did you mean post #11 "ISE got error!" :lol:
 

May be it's my eyes. Can you please tell the post number where you reported the error message?

Did you mean post #11 "ISE got error!" :lol:

:)):)):)):))
I thoutgh I mentioned about the error but I just mentioned about the library. you are right
this is code for using library:
library work;
use work.fixed_pkg_c.all;
this is the error :
ERROR:HDLParsers:3014 - "D:/Generator/i2stransmitter/AMPCONVERT.vhd" Line 28. Library unit fixed_pkg_c is not available in library work.
 

try
use work.fixed_pkg.all;

instead. The package name is not the file name.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top