EE 475 XSDebug Documentation Page


The XSDebug tool was designed to assist students debug the inner workings of their designs for the Xess development boards with Xilinx XC4010XL FPGAs. The development boards only include a single 7-segment display and a parallel port connector for the input and output of information. To make the development boards more "user friendly" Ken Andrews developed a DOS version of XSDebug that uses a command line for the display of 4 8-bit numbers and input of a 16-bit number. The clock can be divided down from its standard 12MHz frequency to less than 1 Hz. or instructions can be single stepped. Unfortunately, due to restrictions with command line programs, the output of the FPGA would only update each time a new command was parsed. This made it difficult to determine exactly when problems occurred, as they would not be apparent to the user until the next update. The DOS version as many DOS programs are- was very user-unfriendly. As all of the machines that are available to the students were running Windows 95, it was decided that a windows version of the XSDebug would be a useful addition to the available tools.

Development Procedure

The first decision that was necessary for the development of the Windows version of XSDebug would be the programming environment. The first idea was a Java applet base program that could be run through the Internet browser available on each machine and based on the server. This would have been an ideal situation because updates of the software could be made to a single machine without requiring a reinstallment on every other machine in the lab. Unfortunately, Java's security features do not allow it to directly access hardware with out a special authorization process and thus it was decided that this would provide too much difficulty for the development and distribution of the software. The final tool used for development was Microsoft Visual C++ 5.0 as it allowed direct access to hardware, could be easily maintained by future professors, and was widely available in computer labs on campus.

Once the development environment had been chosen, the layout of the application became a focus. It was decided that both binary and hexadecimal displays should be used for outputs, but on the input bits, only the binary values could be changed. The "Set Din" button is automatically pushed when the user has entered information into either "Din Low" or "Din High" (These two values create the 16-bit input number- Din High being the higher 8-bits and Din Low being the lower 8-bits). The "Reset" button causes the lowest order bit of Din to be set to a '1', steps the clock, then returns the value to a '0'. This provided to be useful to students who needed a reset input for a project but did not want to have to go through the above process by hand. The "Single Step" button will cause the clock signal to produce first a high value followed by a low value. This button would be very useful for the debugging of instructions in student designed microprocessors. Three radio buttons also allow the user to manipulate the clock. The "Clock High" button allows the user to perform half of a single step, and the "Clock Low" (the default position) will perform the other half. The slider switch in conjunction with the "Run" radio button allows the student to reduce the clock speed by powers of 2 down to a value less than 1 Hz. Screen Shot of XSDebug Window

VHDL Shell Interface

The shell.txt interface allows a FPGA to communicate with the XSDebug program. This Shell is divided into three major parts:

The first part is the Port map that allows the user to send and receive values from their actual design. The next part describes the actual serial transmission interface. The last part is the Clock divider, which allows the program to control the clock speed to the FPGA design.

The XSDebug Code

All of the files for building the program in Microsoft C++ 5.0 can be found in The main code for XSDebug is divided between three sets of files:

The first files are XSDebug.cpp and XSDebug.h. These files contain the main code that defines the class behaviors for the application. This is the initialization code behind the window application and should not be modified for future versions of XSDebug.

The second set of files are XSDebug.rc and Resource.h. These contain the definition for the actual dialog box objects and their locations. It is best edited with Microsoft's visual editor.

The final set of files are XSDebugDlg.cpp and XSDebugDlg.h. These files contain the meat of the background code. This code contains 15 major code snippets and functions:

BOOL CXSDebugDlg::OnInitDialog(): In this function- the initialization of the dialog box takes place. Code sets the initial values for display and tells the program which parts of the screen are allowed to be modified. It also sets which radio button is selected, sets the default button to be the "Set Din" button (this was necessary because if not- it would default to the close button and anytime the users pressed enter, the application would close). Lastly, a timer is setup to execute the dialog Refresh() routine every half second. This was one of the advantages of using a windows based application rather than the DOS application.

void CALLBACK EXPORT TimerProc(HWND hWnd,UINT nMsg,UINT nIDEvent, DWORD dwTime ): All this function does is call the Refresh() routine which will cause the screen to update The input values are inserted by the SetTimer(ID, Time, function to call) function..

void CXSDebugDlg::OnSetDin(): This function is executed when the "Set Din" button is pushed. It takes the values from Din High and Din Low, checks to see if they are of length 8 (since each should be a 8 bit number), if they are- two global variables out1 and out2 are set (these variables are used by the transmit and receive functions to tell the sell what the value of Din is), then the values are converted to a hex value for display, and the Refresh() function is called.

void CXSDebugDlg::OnSingleStep(): This function is executed when the "Single Step" button is pushed. It first checks a global variable ClkState, which keeps track of which mode the clock, is in (High, Low, or Run). If the clock state is in Low, then it will allow the user to perform a single step by transmitting first a high clock instruction followed by the low clock instruction. The Refresh() function is then called to immediately show the result of the single step.

void CXSDebugDlg::OnClkHi(): This function is called when the "Clock High" radio button is pushed. If the clock in not already in the clock high state, the clock is set to high, the Refresh() routine is called, and the clock state is updated.

void CXSDebugDlg::OnClkLo(): This function is called when the "Clock Low" radio button is pushed. If the clock in not already in the clock low state, the clock is set to low, the Refresh() routine is called, and the clock state is updated.

void CXSDebugDlg::OnClkRun(): This function is called when the "Run" radio button is pushed. If the clock in not already in the clock run state, the clock is set to the value given by the slider control, the Refresh() routine is called, and the clock state is updated. To determine the value of the clock, the position of the slider is parsed into a 5-bit number that represents a clock divider factor that will be used to divide the clock down from 12Mhz to a slower running time.

void CXSDebugDlg::OnClose(): This function is called when the "Close" button is pushed. It explicitly terminates the program.

CString bin2hex(CString): This function takes a character string object (usually taken from the receive function or from the value of Din) and transforms it into a hexadecimal number.

void xmit(Cstring): This function is the transmit routine. it takes a string of 0's and 1's and performs a pseudo-serial transmission vial the parallel connection. The fact that this program makes use of direct access to the parallel port makes it unsuitable for use under Windows NT.

CString xmit(void): This is function returns a string that has been outputted from the FPGA. It also uses a pseudo-serial communication protocol receiving 8-bits at a time.

void error(CString temp): This function just provides an easy way to access a dialog box that displays the message contained in the string variable temp along with an "OK" button.

void CXSDebugDlg::Refresh(): This is the Refresh function that has been referred to in many of the previous functions. It explicitly performs four sets of transmit and receives to set the values of the four windows displaying output from the FPGA.

void CXSDebugDlg::OnReset(): This function is called when the "Reset" button is pushed. It will set the least significant bit of Din to high, step the clock, then set then least significant bit of Din to low. This is useful for a user who will need to perform a reset function, but does not want to have to change the value of Din, step the clock then reset the value of Din.

void CXSDebugDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar): This is the function that allows the user to move the horizontal scroll bar and view the corresponding clock divided value. When the scroll bar's position is modified, the 12MHz value is divided by 2 to the value of the position and then display in the corresponding box.

Written by Justin Backman
CS 490 Project
Spring 1998