JLS

Floating point math and rand() help

Recommended Posts

Hi all

 

ZPUino soft processor not support floating point math ? Please help me im testing simple code in AVR8 soft processor and floating math working fine but with ZPUino not working !

 

Many thanks info and example

Share this post


Link to post
Share on other sites

Many thanks info

 

Please do working fp math with ZPUino (this is very usefull - 90% my project require floating point math)

 

Thanks help

 

Kamil

Share this post


Link to post
Share on other sites

Why are you so dependant on fp math ? It will be very slow compared to integer-only and fixed point math.

 

Can you share your sketch ? I might be able to turn it into integer or fixed-point.

Share this post


Link to post
Share on other sites

My idea is studying chaotic attractors and fractals. FPGA and virtual processor is great for my chaotic and music experiments.

 

Some example my old codes for arduino platform is here http://jlswbs.blogspot.com

 

FPGA is better platform for interfacing devices this is very flexible.

 

Kamil

Share this post


Link to post
Share on other sites

Ok, here's a "libgcc.a" library fix for this.

 

http://alvie.com/zpuino/downloads/libgcc-fix-for-64bit-and-floatingpoint.zip

 

The zip file contains 4 libraries:

 

libgcc.a
fast/libgcc.a
small/libgcc.a
ludicrous/libgcc.a

 

Locate the "libgcc.a" installed in your system (should be four of them), they should be inside "hardware/tools/zpu/lib/gcc/zpu-elf/3.4.2/" for Windows and Mac. Make sure you don't overwrite AVR one instead.

Replace the four libraries in your system with the ones in the .zip file. If you're using linux, replace the ones in where you installed the toolchain.

 

If you only have one "libgcc.a", replace it with the fast version (fast/libgcc.a).

 

Let me know if this fixes all issues.

Share this post


Link to post
Share on other sites

Simple question. Im make chua oscillator sketch with deltasigma DAC. This working but dont understand how to write two independent DAC value. ( example DAC0 = x and DAC1 = y value )

 

 

#include <math.h>
      
  float x = 0.5;
  float y = 0.25;
  float z = 0.125;
  float oldx = 0;
  float oldy = 0;
  float oldz = 0;
  float h = 0;
  float dt = 0.005;
  float alpha = 15.6;
  float beta = 28.58;
  float a = -1.14286;
  float b = -0.714286;
  
  int outx,outy;
        
  int pindac0 = 0;
  int pindac1 = 1;
 
 
void setup() {
 
  pinMode(pindac0, OUTPUT);
  pinModePPS(pindac0, HIGH);
  outputPinForFunction(pindac0, 0);
  
  pinMode(pindac1, OUTPUT);
  pinModePPS(pindac1, HIGH);
  outputPinForFunction(pindac1, 0);
 
  
  SIGMADELTACTL = 0x03;
}
 
void loop(){
 
  oldx = x;
  oldy = y;
  oldz = z;
  
  h = (b * x) + (0.5 * ( a - b ) * (fabs(x+1) - fabs(x-1)));            
  x = oldx + dt * (alpha * (oldy - oldx - h));
  y = oldy + dt * (oldx - oldy + oldz);
  z = oldz + dt * (-beta * oldy);
        
  outx = 32768 + int(13500*x);
  outy = 32768 + 5 * int(13500*y);
   
  SIGMADELTADATA = outx;
 
 
 
Please help me with example two independent DAC.
 
Many thanks
 
Kamil

Share this post


Link to post
Share on other sites

It's a 32-bit register, with two 16-bit values for each channel.

 

So, doing:

 

SIGMADELTADATA = outy<<16 + outx&0xffff;

 

should do the job. The "&0xffff" is just to ensure you do not pass more "value" than it takes.

Share this post


Link to post
Share on other sites

sorry next few questions :-)

 

1. on your site is three different version bit file. Version with SID and VGA this two version not support deltasigma DAC ?

 

2. ZPUino support PWM on output PINs ? Please example thanks

 

3. Is possible make simple example how to basic run with SID POKEY and YM2149 ?

 

Many thanks help :-)

 

Kamil

Share this post


Link to post
Share on other sites
sorry next few questions :-)

 

1. on your site is three different version bit file. Version with SID and VGA this two version not support deltasigma DAC ?

 

2. ZPUino support PWM on output PINs ? Please example thanks

 

3. Is possible make simple example how to basic run with SID POKEY and YM2149 ?

Take a look at the RetroCade Sketch for examples and libraries for the SID and YM2149. POKEY to be added later, or maybe you might be interested in adding POKEY? Here is a RetroCade branch with POKEY.

 

 

Many thanks help :-)

 

Kamil

Share this post


Link to post
Share on other sites

Thanks info

 

Today im testing RetroCade :-)

 

Simple question do exist version bit file combined RetroCade and VGA output for Papilio One 500 ?

 

Thanks info about it.

 

Kamil

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now