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.

Standard log2 function for integers

Status
Not open for further replies.

shaiko

Advanced Member level 5
Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Visit site
Activity points
18,302
Hello,

I know that the log2 function of the math_real package works on type "real".
Is there a standard VHDL function that calculates log2 for integers?
 

No. But I think its one of the first functions most engineers add to their toolbox.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
I know. I have one myself...just a general question.

1. Can I cast a "positive" type into a real type in order to apply the log2 ?
2. If #1 is possible, can I recast the result back to a "positive" after applying the log2 function?
 

1. Yes, but I dont know what it would do if you tried to synthesise it into a non constant location (like assigning a signal), or slicing a signal.
2. Yes, but remember that casting a real to an integer will round the result.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
1. Yes, but I dont know what it would do if you tried to synthesise it into a non constant location (like assigning a signal), or slicing a signal.

You mean during runtime operation as part of my RTL (not compile time) ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top