OpenCores
URL https://opencores.org/ocsvn/leros/leros/trunk

Subversion Repositories leros

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 5 to Rev 6
    Reverse comparison

Rev 5 → Rev 6

/leros/trunk/java/target/src/DrawLine.java
0,0 → 1,165
import com.muvium.leros.Native;
 
import com.muvium.MuviumRunnable;
 
/*
* Example program for Leros.
* Line drawing benchmark for the JTRES 2011 paper submisssion.
*
* Might in the meantime be broken, as this used a different IO class
*/
 
public class DrawLine extends MuviumRunnable {
 
static int Axv ;
static int Ayv ;
static int Bxv ;
static int Byv ;
static int Z ;
static int color ;
static int Ax = Axv;
static int Ay = Ayv;
static int Bx = Bxv;
static int By = Byv;
static int p ;
public void run(){
int dx = 0 ;
int dy = 0;
int Xincr = 0;
int Yincr = 0;
int dPr = 0;
int dPru = 0;
while( true ){
Axv = Native.rd(0);
Ayv = Native.rd(0);
Bxv = Native.rd(0);
Byv = Native.rd(0);
Z = Native.rd(0);
color = Native.rd(0);
Ax = Axv;
Ay = Ayv;
Bx = Bxv;
By = Byv;
//dx = Math.abs(Ax - Bx); //'; // store the change in X and Y of the line endpoints
if( Bx > Ax ){
dx = Bx - Ax;
}else{
dx = Ax - Bx;
}
//dY = Math.abs(AY - By); //'; // store the change in X and Y of the line endpoints
if( By > Ay ){
dy = By - Ay;
}else{
dy = Ay - By;
}
if( dy == 0){
//horizontalLine( Ax, Bx, AY ); //TODO Inline
}else{
if( dx == 0 ){
// verticalLine( AY, By, Ax );//TODO Inline
}else{
// 'diagonal line
//'If dX = 0 Then drawHorizontal
 
//'//------------------------------------------------------------------------
//'// DETERMINE "DIRECTIONS" TO INCREMENT X AND Y (REGARDLESS OF DECISION)
//'//------------------------------------------------------------------------
if( Ax > Bx ){ // '// which direction in X?
Xincr = -1;
}else{
Xincr = 1;
}
if( Ay > By) { // '// which direction in Y?
Yincr = -1;
}else{
Yincr = 1;
}
 
//'//------------------------------------------------------------------------
//'// DETERMINE INDEPENDENT VARIABLE (ONE THAT ALWAYS INCREMENTS BY 1 (OR -1) )
//'// AND INITIATE APPROPRIATE LINE DRAWING ROUTINE (BASED ON FIRST OCTANT
//'// ALWAYS). THE X AND Y'S MAY BE FLIPPED IF Y IS THE INDEPENDENT VARIABLE.
//'//------------------------------------------------------------------------
if (dx >= dy) { // '// if X is the independent variable
dPr = dy * 2; // '// amount to increment decision if right is chosen (always)
dPru = dPr - (dx * 2) ; // '// amount to increment decision if up is chosen
p = dPr - dx ; // '// decision variable start value
for(; dx >= 0; dx-- ){ //For dx = dx To 0 Step -1
// setPixel( Ax, AY, color );
Native.wr( Z , 0);
Native.wr( color, 0);
Native.wr( Ax, 0);
Native.wr( Ay, 0);
Ax = Ax + Xincr; // '// increment independent variable
if( p > 0 ){
Ay = Ay + Yincr;
}
if( p > 0 ){
p = p + dPru ; //'// increment decision (for up)
}else{
p = p + dPr;
}
}
}else{
dPr = dx * 2 ; // '// amount to increment decision if right is chosen (always)
dPru = dPr - (dy * 2) ;// '// amount to increment decision if up is chosen
p = dPr - dy ;// '// decision variable start value
 
for(; dy >= 0; dy--){ //For dY = dY To 0 Step -1 '// process each point in the line one at a time (just use dY)
// setPixel( Ax, AY, color );
Native.wr( Z , 0);
Native.wr( color, 0);
Native.wr( Ax, 0);
Native.wr( Ay, 0);
Ay = Ay + Yincr; // '// increment independent variable
if( p > 0 ){
Ax = Ax + Xincr;
}
if( p > 0 ){
p = p + dPru ; // '// increment decision (for up)
}else{
p = p + dPr;
}
}
}
}
}
Native.wr(0xFF, 0); //Done
}
 
} //Run()
}
leros/trunk/java/target/src/DrawLine.java Property changes : Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: leros/trunk/LerosMuviumSDK/LerosHello.java =================================================================== --- leros/trunk/LerosMuviumSDK/LerosHello.java (revision 5) +++ leros/trunk/LerosMuviumSDK/LerosHello.java (nonexistent) @@ -1,166 +0,0 @@ -import leros.Native; - -import com.muvium.MuviumRunnable; - -/* - * Example program for Leros. - * Line drawing benchmark for the JTRES 2011 paper submisssion. - * - */ - -public class LerosHello extends MuviumRunnable { - - static int Axv ; - static int Ayv ; - static int Bxv ; - static int Byv ; - static int Z ; - static int color ; - - static int Ax = Axv; - static int Ay = Ayv; - static int Bx = Bxv; - static int By = Byv; - - static int p ; - - public void run(){ - int dx = 0 ; - int dy = 0; - int Xincr = 0; - int Yincr = 0; - int dPr = 0; - int dPru = 0; - - while( true ){ - - Axv = Native.read(); - Ayv = Native.read(); - Bxv = Native.read(); - Byv = Native.read(); - Z = Native.read(); - color = Native.read(); - - Ax = Axv; - Ay = Ayv; - Bx = Bxv; - By = Byv; - - //dx = Math.abs(Ax - Bx); //'; // store the change in X and Y of the line endpoints - if( Bx > Ax ){ - dx = Bx - Ax; - }else{ - dx = Ax - Bx; - } - - - //dY = Math.abs(AY - By); //'; // store the change in X and Y of the line endpoints - if( By > Ay ){ - dy = By - Ay; - }else{ - dy = Ay - By; - } - - if( dy == 0){ - //horizontalLine( Ax, Bx, AY ); //TODO Inline - - }else{ - if( dx == 0 ){ - // verticalLine( AY, By, Ax );//TODO Inline - - }else{ - - // 'diagonal line - - //'If dX = 0 Then drawHorizontal - - //'//------------------------------------------------------------------------ - //'// DETERMINE "DIRECTIONS" TO INCREMENT X AND Y (REGARDLESS OF DECISION) - //'//------------------------------------------------------------------------ - if( Ax > Bx ){ // '// which direction in X? - Xincr = -1; - }else{ - Xincr = 1; - } - - if( Ay > By) { // '// which direction in Y? - Yincr = -1; - }else{ - Yincr = 1; - } - - - //'//------------------------------------------------------------------------ - //'// DETERMINE INDEPENDENT VARIABLE (ONE THAT ALWAYS INCREMENTS BY 1 (OR -1) ) - //'// AND INITIATE APPROPRIATE LINE DRAWING ROUTINE (BASED ON FIRST OCTANT - //'// ALWAYS). THE X AND Y'S MAY BE FLIPPED IF Y IS THE INDEPENDENT VARIABLE. - //'//------------------------------------------------------------------------ - if (dx >= dy) { // '// if X is the independent variable - - dPr = dy * 2; // '// amount to increment decision if right is chosen (always) - dPru = dPr - (dx * 2) ; // '// amount to increment decision if up is chosen - - p = dPr - dx ; // '// decision variable start value - - for(; dx >= 0; dx-- ){ //For dx = dx To 0 Step -1 - - // setPixel( Ax, AY, color ); - - Native.write( Z ); - Native.write( color ); - Native.write( Ax ); - Native.write( Ay ); - - - Ax = Ax + Xincr; // '// increment independent variable - if( p > 0 ){ - Ay = Ay + Yincr; - } - - - if( p > 0 ){ - p = p + dPru ; //'// increment decision (for up) - }else{ - p = p + dPr; - } - - } - - }else{ - - dPr = dx * 2 ; // '// amount to increment decision if right is chosen (always) - dPru = dPr - (dy * 2) ;// '// amount to increment decision if up is chosen - p = dPr - dy ;// '// decision variable start value - - for(; dy >= 0; dy--){ //For dY = dY To 0 Step -1 '// process each point in the line one at a time (just use dY) - - // setPixel( Ax, AY, color ); - Native.write( Z ); - Native.write( color ); - Native.write( Ax ); - Native.write( Ay ); - - Ay = Ay + Yincr; // '// increment independent variable - if( p > 0 ){ - Ax = Ax + Xincr; - } - - if( p > 0 ){ - p = p + dPru ; // '// increment decision (for up) - }else{ - p = p + dPr; - } - - } - } - - } - } - - Native.write( 0xFF ); //Done - } - - } //Run() -} - - \ No newline at end of file
leros/trunk/LerosMuviumSDK/LerosHello.java Property changes : Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.