Difference between revisions of "CasperTutorial01"
From AstroBaki
Jump to navigationJump to searchLine 436: | Line 436: | ||
\subsection{Programming the FPGA from BORPH} | \subsection{Programming the FPGA from BORPH} | ||
− | To | + | To program the ROACH FPGA, execute your *.bof file as you would any other Linux program. |
− | the | + | Change to the /boffiles directory and see which files are available: |
− | /boffiles | ||
− | |||
− | |||
\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 | ||
− | |||
\end{verbatim} | \end{verbatim} | ||
− | + | If you haven't already, ensure that the file is marked as an executable, so that Linux is | |
− | able to run it | + | able to run it: |
− | |||
− | |||
\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 | ||
− | |||
\end{verbatim} | \end{verbatim} | ||
− | + | Now we are ready to execute it: | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | Now we are ready to execute it | ||
\begin{verbatim} | \begin{verbatim} | ||
Line 483: | Line 463: | ||
\end{verbatim} | \end{verbatim} | ||
− | This will | + | This will program the FPGA, and you should notice immediately that LED0 on the ROACH |
− | hardware is | + | hardware is blinking. However, we've lost control of our terminal because the *.bof file is |
− | + | 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 | + | 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 | ||
− | |||
\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 | ||
− | |||
\end{verbatim} | \end{verbatim} | ||
− | Notice that PID 323 (yours may be different) is | + | Notice that PID 323 (yours may be different) is the *.bof file. We can now |
− | navigate to | + | 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 | ||
− | |||
\end{verbatim} | \end{verbatim} | ||
− | Now you can see all our software registers | + | Now you can see all our software registers: a, b, counter\_ctrl, |
− | counter\_value and sum\_a\_b | + | 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} | ||
− | + | 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 | ||
− | |||
\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 | + | (-n), and told it to interpret the incoming string's escape characters |
− | (\verb=\=0 specifies octal values). Then we pipe | + | (\verb=\=0 specifies octal values). Then we pipe its output into |
− | counter\_ctrl. Now | + | 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 | ||
− | |||
\end{verbatim} | \end{verbatim} | ||