Difference between revisions of "CasperTutorial01"

From AstroBaki
Jump to navigationJump to search
Line 436: Line 436:
 
\subsection{Programming the FPGA from BORPH}
 
\subsection{Programming the FPGA from BORPH}
  
To do so, simply execute it as you would any other linux program. Recall that
+
To program the ROACH FPGA, execute your *.bof file as you would any other Linux program.  
the filesystem is mapped from the server and the BORPH files were in
+
Change to the /boffiles directory and see which files are available:
/boffiles/.
 
 
 
Let's change to that directory now and see which files are available:
 
  
 
\begin{verbatim}
 
\begin{verbatim}
Line 450: Line 447:
 
-rwxr-xr-x  1 1000 1000 3894183 Aug 20  2009 das_blinken_lichte_2009_Feb_04_1837.bof
 
-rwxr-xr-x  1 1000 1000 3894183 Aug 20  2009 das_blinken_lichte_2009_Feb_04_1837.bof
 
-rw-r--r--  1 1001 1001 4468934 Aug 14  2009 tut1_2009_Aug_14_1140.bof
 
-rw-r--r--  1 1001 1001 4468934 Aug 14  2009 tut1_2009_Aug_14_1140.bof
root@roach020112:/boffiles#
 
 
\end{verbatim}
 
\end{verbatim}
  
  
We need to ensure that the file is marked as an executable, so that Linux is
+
If you haven't already, ensure that the file is marked as an executable, so that Linux is
able to run it. You will notice that our tut1 file is not executable (look at
+
able to run it:
the leftmost columns and see that there are no 'x's). Let's make it executable
 
now:
 
  
 
\begin{verbatim}
 
\begin{verbatim}
 
root@roach020112:/boffiles# chmod a+x tut1_2009_Aug_14_1140.bof  
 
root@roach020112:/boffiles# chmod a+x tut1_2009_Aug_14_1140.bof  
root@roach020112:/boffiles#
 
 
\end{verbatim}
 
\end{verbatim}
  
This will change permissions on the file, by adding executable permissions for
+
Now we are ready to execute it:
everybody. Rechecking:
 
 
 
\begin{verbatim}
 
root@roach020112:/boffiles# ls -al
 
total 8196
 
drwxrwxrwx  2 root root    4096 Aug 20  2009 .
 
drwxr-xr-x 23 root root    4096 Feb  2  2009 ..
 
-rwxr-xr-x  1 1000 1000 3894183 Aug 20  2009 das_blinken_lichte_2009_Feb_04_1837.bof
 
-rwxr-xr-x  1 1001 1001 4468934 Aug 14  2009 tut1_2009_Aug_14_1140.bof
 
root@roach020112:/boffiles#
 
\end{verbatim}
 
 
 
Now we are ready to execute it.
 
  
 
\begin{verbatim}
 
\begin{verbatim}
Line 483: Line 463:
 
\end{verbatim}
 
\end{verbatim}
  
This will go'n program the FPGA, and you should notice that LED0 on the ROACH
+
This will program the FPGA, and you should notice immediately that LED0 on the ROACH
hardware is now blinking. However, we've lost our terminal, because the process
+
hardware is blinking. However, we've lost control of our terminal because the *.bof file is
has captured it. To keep the process running, but return the prompt to us, we
+
continuing to execute. To keep the process running, but return the prompt to us, we
can now choose to background the task (ctrl-z), or we can kill it (ctrl-c) and
+
can now choose to background the task (ctrl-z, the "bg"), or we can kill it (ctrl-c) and
restart it with an amperstand, which will start it backgrounded.
+
restart it with an ampersand, which will start it in the background.
  
 
\begin{verbatim}
 
\begin{verbatim}
 
root@roach020112:/boffiles# ./tut1_2009_Aug_14_1140.bof &
 
root@roach020112:/boffiles# ./tut1_2009_Aug_14_1140.bof &
 
[1] 323
 
[1] 323
root@roach020112:/boffiles#
 
 
\end{verbatim}
 
\end{verbatim}
  
Our FPGA is now programmed (check for the flashing LED) and we have our prompt back!
+
Our FPGA is now programmed (check for the flashing LED) and we have our prompt back.
 
 
 
 
 
We can now see that a process in Linux has started...
 
We can now see that a process in Linux has started...
  
Line 515: Line 492:
 
root      328  0.8  0.3  3524  1800 pts/0    Ss  07:36  0:00 -bash
 
root      328  0.8  0.3  3524  1800 pts/0    Ss  07:36  0:00 -bash
 
root      332  0.0  0.1  2780  996 pts/0    R+  07:37  0:00 ps aux
 
root      332  0.0  0.1  2780  996 pts/0    R+  07:37  0:00 ps aux
root@roach020112:/boffiles#
 
 
\end{verbatim}
 
\end{verbatim}
  
Notice that PID 323 (yours may be different) is our process. We can now
+
Notice that PID 323 (yours may be different) is the *.bof file. We can now
navigate to the proc directory which contains our software registers.
+
navigate to a /proc directory that contains our software registers:
  
 
\begin{verbatim}
 
\begin{verbatim}
Line 537: Line 513:
 
-rw-rw-rw- 1 root root 4 Aug 21 08:00 sys_rev_rcs
 
-rw-rw-rw- 1 root root 4 Aug 21 08:00 sys_rev_rcs
 
-rw-rw-rw- 1 root root 4 Aug 21 08:00 sys_scratchpad
 
-rw-rw-rw- 1 root root 4 Aug 21 08:00 sys_scratchpad
root@roach020112:/proc/323/hw/ioreg#
 
 
\end{verbatim}
 
\end{verbatim}
  
Now you can see all our software registers. We have a, b, counter\_ctrl,
+
Now you can see all our software registers: a, b, counter\_ctrl,
counter\_value and sum\_a\_b as expect. However, in addition, the toolflow has
+
counter\_value and sum\_a\_b . In addition, the toolflow has
automatically added a few other registers.
+
automatically added a few other registers:
 
+
\begin{itemize}
sys\_board\_id is simply a constant which allows software to identify what
+
\item sys\_board\_id is simply a constant which allows software to identify what
 
hardware platform is running. For ROACH, this is a constant 0xb00b001.
 
hardware platform is running. For ROACH, this is a constant 0xb00b001.
  
sys\_clkcounter is a 32-bit counter that increments automatically on every FPGA
+
\item sys\_clkcounter is a 32-bit counter that increments automatically on every FPGA
 
clock tick. This allows software to estimate the FPGA's clock rate. Useful for
 
clock tick. This allows software to estimate the FPGA's clock rate. Useful for
 
debugging boards with bad clock inputs.
 
debugging boards with bad clock inputs.
  
sys\_rev is not yet implemented, but will eventually indicate the revision of
+
\item sys\_rev is not yet implemented, but will eventually indicate the revision of
 
the software toolchain that was used to compile the design
 
the software toolchain that was used to compile the design
  
sys\_rcs is also not yet implemented, but will eventually indicate the SVN revision of the CASPER library that was used to compile your design.
+
\item sys\_rcs is also not yet implemented, but will eventually indicate the SVN revision of the CASPER library that was used to compile your design.
  
sys\_scratchpad is simply a read/write software register where you can write a
+
\item sys\_scratchpad is simply a read/write software register where you can write a
 
register and read it back again as a sanity check.  Communicating with your
 
register and read it back again as a sanity check.  Communicating with your
 
FPGA process in BORPH The registers contain binary data. To read and represent
 
FPGA process in BORPH The registers contain binary data. To read and represent
Line 563: Line 538:
 
binary files. To write into these files, we'll use Linux's echo utility. Echo
 
binary files. To write into these files, we'll use Linux's echo utility. Echo
 
does not support writing hex values, but does support octal (base-8).  
 
does not support writing hex values, but does support octal (base-8).  
 +
\end{itemize}
  
Let's start by having a look at our counter value. Since we haven't started it
+
Start by having a look at our counter value. Since we haven't started it
 
yet, we expect it to be zero.  
 
yet, we expect it to be zero.  
  
Line 571: Line 547:
 
00000000  00 00 00 00                                      |....|
 
00000000  00 00 00 00                                      |....|
 
00000004
 
00000004
root@roach020112:/proc/323/hw/ioreg#
 
 
\end{verbatim}
 
\end{verbatim}
  
Line 588: Line 563:
  
 
Here we have told echo not to append a newline character to the end of the line
 
Here we have told echo not to append a newline character to the end of the line
(-n), and told it to interpret the incoming string's escape characters
+
(-n), and told it to interpret the incoming string's escape characters
(\verb=\=0 specifies octal values). Then we pipe it's output into
+
(\verb=\=0 specifies octal values). Then we pipe its output into
counter\_ctrl. Now let's relook at the counter value...
+
counter\_ctrl. Now when we look at the counter value...
  
 
\begin{verbatim}
 
\begin{verbatim}
Line 616: Line 591:
 
00000000  00 00 00 00                                      |....|
 
00000000  00 00 00 00                                      |....|
 
00000004
 
00000004
root@roach020112:/proc/323/hw/ioreg#
 
 
\end{verbatim}
 
\end{verbatim}
  

Revision as of 15:34, 26 March 2010