Nios Chess Game
Last Updated: 16-Nov-03

This page describes a port of the Faile chess engine to the Altera Embedded Nios processor. Tim Mann's WinBoard/XBoard is used as a graphical frontend. A simple serial driver (Linux/Cygwin) was developed to enables Faile to communicate with WinBoard/XBoard.
For this demo I used a Cyclone Nios development kit which can be purchased for less than $1000 from Altera. For this you get an excellent development board with a EP1C20 Cyclone FPGA, Ethernet adaptor, dual UART, LCD display, 8 leds, dual 7 segment display, 4 switches, Compact Flash Adaptor, 1MB of SRAM, 8MB of Flash and 16MB of SDRAM. On top of that you get a 16/32 bits configurable RISC processor (Nios) and ported GNU tools (gcc/as etc).
Porting of the Faile Chess engine was straitforward, the only problem I found was that the malloc function didn't seem to work. Given that I am using an old version of Nios (2.8) this might be fixed in the current release. I fixed the problem by pointing the large hash table (see hash.c) to the SDRAM memory. I also reduced the table to 1MByte, for improved performance the hash table should be corrected back to use the full 16Mbyte of SDRAM. Faile supports WinBoard/XBoard so the only piece of software I had to write was a serial port driver which redirected the stdin/stdout of the PC running Win/XBoard to the serial port.
To run the demo do the following:
- Download and Install Win/XBoard (Linux or Windows)
- Download the modified Faile source files [zipped, 48KByte]
- Download the Win/XBoard serial driver [zipped, 2KByte]
- For Windows you need to install Cygwin
- Compile the serial driver under Cygwin/Linux
gcc pipe232.c -o pipe232
- Under Nios SDK shell compile Faile by running make (note compiled
version is included in the zip file)
[SOPC Builder]$ make
#
2003.11.16.15:30:25 --- (Note: to make for Nios 16, try "make clean
all M=16")
# 2003.11.16.15:30:25 --- Compiling book.c
book.c:
In function `search_book':
book.c:999: warning: comparison of unsigned
expression >= 0 is always true
# 2003.11.16.15:30:27 --- Compiling
eval.c
# 2003.11.16.15:30:29 --- Compiling hash.c
# 2003.11.16.15:30:30
--- Compiling moves.c
# 2003.11.16.15:30:32 --- Compiling rand.c
#
2003.11.16.15:30:33 --- Compiling search.c
# 2003.11.16.15:30:34 ---
Compiling utils.c
utils.c: In function `_open':
utils.c:53: warning:
return makes integer from pointer without a cast
# 2003.11.16.15:30:36
--- Compiling faile.c
# 2003.11.16.15:30:37 --- Linking obj/faile.out
#
2003.11.16.15:30:38 --- Converting faile to S-Record
# 2003.11.16.15:30:38
--- . Built faile.srec
# 2003.11.16.15:30:38 --- . try make help for
more information
[SOPC Builder]$
- Download the Faile.srec file using:
nios-run faile.srec
- After downloading and executing Faile see if you can talk to it, try help, new, a2a3 (use the "nios-run -t" terminal program)
- If Faile is running OK, execute WinBoard under Cygwin using the following commands
winboard -fd "<path_to_pipe232>" -fcp "pipe232.exe /dev/ttyS0"
or using XBoard under Linux
/usr/local/bin/xboard.exe -fd "./" -fcp "./pipe232 /dev/ttyS0"
Note: you need to run Winboard under Cygwin because the pipe232 driver is written for Linux. The above examples uses COM1 (/dev/ttyS0).
- After a few second Win/XBoard is ready to play. Move one of the Pawn
and see if Faile responds, if not try ALT-1 in Win/XBoard and issue
the "new" command". If that still fails check the
serial connection. Use a communication program like TeraTerm
Pro/miniterm to talk to Win/XBoard and/or Faile.
Now if only I could play Chess.........:-)
