Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
public class Template extends Thread
{ // CONSTANTS
private static final int PARALLEL = 8;
private static final int WIDTH = 512;
private static final int HEIGHT = 512;
private static final int INT_SIZE = 4;
private static final int HEIGHT_PLUS_PARALLEL = 520;
private static final float PARALLEL_F = 8.0f;
// AXI IO
public int waddr;
public int wdata;
public int wburst;
public boolean wreq;
public boolean wbusy;
public int raddr;
public int rdata;
public boolean rreq;
public boolean rbusy;
// user IO
public int gpio0; // fb_addr
public int gpio1; // line_bytes
public int gpio2; // mode
public int gpio3; // param_addr
private int fb_addr;
private int line_bytes;
private int page0;
private int page1;
private float cx;
private float cy;
private float dx;
private float speed;
private int mode;
private int param_addr;
private Mandel mandel0 = new Mandel();
private Mandel mandel1 = new Mandel();
private Mandel mandel2 = new Mandel();
private Mandel mandel3 = new Mandel();
private Mandel mandel4 = new Mandel();
private Mandel mandel5 = new Mandel();
private Mandel mandel6 = new Mandel();
private Mandel mandel7 = new Mandel();
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
public class Mandel extends Thread
{
private static final float HALF_WIDTH = 256.0f;
private static final int WIDTH = 512;
private static final float MAX_C = 4.0f;
public float cx;
public float cy;
public float sy;
public float dx;
public int page;
public final int[] data = new int[1024 /*BUF_SIZE*/];
public boolean req;
public boolean ack;
public boolean enable;
public int mode;
public void run()
{
while (true)
{
while ((req == false) && (enable == true))
{
yield();
}
if (enable == false)
{
break;
}
float x, y, calc_size;
calc_size = dx * HALF_WIDTH;
x = cx - calc_size;
y = cy - calc_size + dx * sy;
int max_count = (mode >> 8) & 0xff;
for (int i = i_s; i < i_e; i++)
{
float a, b, a2, b2, c;
a = 0.0f;
b = 0.0f;
a2 = 0.0f;
b2 = 0.0f;
c = 0.0f;
int count = max_count;
while ((c < MAX_C) && (count > 0))
{
b = a * b * 2.0f - y;
a = a2 - b2 - x;
a2 = a * a;
b2 = b * b;
c = a2 + b2;
count--;
}
int color = 0;
color = 0xff000000 | ((count << 3) + (count << 10) + (count << 18));
data[i] = color;
x += dx;
}
ack = true;
while (req == true)
{
yield();
}
ack = false;
}
}
}
main.c : ドライバプログラム
/*
Copyright (c) 2015, miya
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/