--- Quote Start ---
What exactly is the problem, other than your VHDL being completly useless for hardware?
--- Quote End ---
Hiii ...
the problem is that I have errors and now I go confused
Im converting my game Sudoku that is in java to vhdl.
the method size is one of my methods.
you think that it is not needed?
here is my java code:
public class Sudoku {
static boolean empty = false;
//static int fullSet;
static int board;
static int allowedSets;
static boolean sudoku_array = new boolean ;
public static void main(String args)
{
initializeBoard();
readGame();
boolean solved = solveGame();
if(!solved)
printSets();
printGame();
}
/**
* Create board array and create and initialize sets for the
* board squares.
**/
public static void initializeBoard()
{
int counter = 0;
board = new int;
allowedSets = new int ;
// Since no moves have been made, any number can go anywhere.
// Start the sets out with all possibilities.
for(int i = 0; i < 9; i++){
for( int j = 0; j < 9; j++){
allowedSets = counter;
counter = counter + 9;
}
}
for (int i = 0; i < sudoku_array.length; i++){
sudoku_array = true;
}
}
/**
* Output the sets to the command line.
* Used when the solver fails to complete a game.
**/
public static void printSets()
{
for(int i = 0; i < 9; i++){
for( int j = 0; j < 9; j++){
for (int k = allowedSets; k < allowedSets + 9; k++ ) {
System.out.print("{");
if(sudoku_array)
System.out.print((k)+", ");
System.out.println("}");
}
}
}
}
/**
* Place val into the (x,y) position on the board and update sets
* to remove val as a possibility in row x, column y, and the box
* containing (x,y).
**/
public static void move(int x, int y, int val)
{
board = val;
if(val == 0) // handle 0 moves for readGame()
return;
// clear everything out of set (x,y)
for (int k = allowedSets; k < allowedSets + 9; k++ ) {
sudoku_array = sudoku_array && empty;
}
for (int i = 0; i < 9; i++){
sudoku_array+(val-1)] = false;
sudoku_array+(val-1)] = false;
}
int boxX = x/3;
int boxY = y/3;
// clear the box containing (x,y)
for(int i = 0; i < 3; i++)
for(int j = 0; j < 3; j++)
sudoku_array + (val-1)] = false;
}
/**
* Read in a game from the command line and put moves on the board
*
**/
public static void readGame()
{
try
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader stdin = new BufferedReader(isr);
String line = "";
for(int i = 0; i < 9; i++)
{
line = stdin.readLine();
for(int j = 0; j < 9; j++)
move(i,j,line.charAt(j)-'0');
}
}
catch(java.io.IOException e)
{
System.out.println(e);
}
}
/**
* Get the first element of a set.
* If the set has one element, return that element.
**/
public static int getElement(int index)
{
for(int i = index; i < index + 9; i++)
if(sudoku_array)
return i;
System.out.println("uh oh");
return 0;
}
public static boolean isEmpty(int index) {
boolean empty = true;
for(int i = index; i < index + 9; i++)
empty = empty && !sudoku_array;
return empty;
}
public static int size(int index) {
int size = 0;
for(int i = index; i < index + 9; i++)
if(sudoku_array)
size++;
return size;
}
/**
* Search the board for a space with only one possibility. If found,
* place that move on the board and update sets. Continue until
* either no move is made, or there are no possiblities in any squares.
**/
public static boolean solveGame()
{
boolean solved = false;
boolean moved = false;
int moves = 0;
while(!solved)
{
solved = true;
moved = false;
for(int i = 0; i < 9; i++)
{
for(int j = 0; j < 9; j++)
{
if(size(allowedSets) == 1)
{
move(i,j,getElement(allowedSets));
moved = true;
moves++;
}
else if(!isEmpty(allowedSets))
solved = false;
}
}
if(!moved) // Give up if no moves were found
break;
}
System.out.println("moves made: " + moves);
return solved;
}
/**
* Output the current board position.
*
**/
public static void printGame()
{
System.out.println();
for(int i = 0; i < 9; i++)
{
for(int j = 0; j < 9; j++)
System.out.print(board);
System.out.println();
}
}
}
I decided to convert each method in a separate vhdl file
and then one that have all the methods added as an component