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.

Microblaze peripheral, float, OPB and C question.

Status
Not open for further replies.

kostbill

Full Member level 1
Joined
Dec 7, 2004
Messages
97
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
885
Hello. I am a newbie in FPGA and VHDL in general.

I am using microblaze in a spartan3e. I want to implement a peripheral with OPB (I am using OPB because I want to use DMA also). The microblaze will have a floating point unit. I don't know yet how efficient this is.

The peripheral will take a serial format (I2S) as an input from an external audio IC. The I2S will give me the values I need in a 16 bit signed number format.

I want to implement in the peripheral the functionality of converting this 16 bit signed value to a 32 bit floating point number.

So, my questions are these:

1. The "to_float" conversion will work on synthesis and will work on the FPGA? If not, can you guide me to a common way, used to do these things?

2. After the conversion, I will have a 32 bit number. Now, the way I understand it, I will have to pass the value to the OPB FIFO. But the FIFO can accept values declared as float? Or should I do something else? For example, is there a way to keep the same bits but make the floating point number appear as a "std_logic_vector(31 downto 0)" ? If I try to do it in the way of assigning each bit of my float in the std_logic_vector, will it work?

3. So, when this number finally goes into the memory, I will take it in C and write a simple union with a 32 bit integer and a float and read the float. Do you know if this works in the Xilinx compiler? If no, do you have any ideas that can help me?

Thank you very much for any help.
Bill.
 

keep in mind that "the peripheral" is a combination of hardware and software. You might find that the conversion to floating point works acceptably fast in software. in software, to_float might be in a library. for HW, you'd have to find IP for it, or write a fixed-floating converter. This makes sense as some algorithms might be able to trade area for speed, latency, ect...

for this reason, the data will never be of a true "float" type in the VHDL. you can define a type/subtype for "floats", eg a "subtype float is std_logic_vector(31 downto 0);" would allow you to know that a signal is a float, but the synthesizer would implement it using a SLV.
 
Thanks for the answer.

I will look for an IP for the converter, if I cannot find it I will try to write it. The problem is that I don't think (I am not sure yet) that my software will have time to convert the values.
 

Converting a number to a float in VHDL is not very hard. You need to compute a sign, mantissa and exponent:

  1. take absolute value of number, set the sign bit if it was negative
  2. left-justify the number; this is the mantissa
  3. the exponent is the distance shifted in step (2).
 

Thanks. First I will try the Xilinx ready IP for that purpose, if I see that it takes a lot of performance, I will try to do it myself, as you say.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top