{"id":438,"date":"2023-01-27T07:31:28","date_gmt":"2023-01-27T07:31:28","guid":{"rendered":"https:\/\/thunder.snu.ac.kr\/wordpress\/?page_id=438"},"modified":"2023-04-03T15:24:10","modified_gmt":"2023-04-03T15:24:10","slug":"getting-started-with-facsim","status":"publish","type":"page","link":"https:\/\/thunder.snu.ac.kr\/?page_id=438","title":{"rendered":"Getting Started with FaCSim"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Download<\/h3>\n\n\n\n<p>You can download the gzipped tarball of the latest FaCSim distribution&nbsp;<a href=\"https:\/\/thunder.snu.ac.kr\/?page_id=64&amp;page=10\">here<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Build<\/h3>\n\n\n\n<p>Unzip the gzipped tarball as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">$ tar xvzf facsim-?.?.?.tar.gz<\/pre>\n\n\n\n<p>FaCSim distribution can be built for a single threaded version or for a parallel version. You can build each version of FaCSim as follows.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Single threaded version<\/strong><br>Run make without a target in the FaCSim distribution directory. It will generate an executable named facsim.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">$ make<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Parallel version<\/strong><br>Run make with the target named as &#8216;parallel&#8217; in the FaCSim distribution directory. It will generate an executable named facsim-par.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">$ make parallel<\/pre>\n\n\n\n<p>Note that if you want to build both versions of FaCSim in a distribution directory, the entire source files in src directory must be newly compiled to build the other version after building one version. In that case, you can remove all object files as well as executable files by running &#8216;make clean&#8217; in the src directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">$ make clean<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Run<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">3.1. Prepare an executable image for the ARM9 architecture<\/h4>\n\n\n\n<p>We use a simple &#8220;hello world&#8221; application to get you started with FaCSim. The following two links let you download the C source code as well as executable image file built with ARM ADS v1.2.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">hello.c\nhello.axf<\/pre>\n\n\n\n<p>hello.c simply prints the string &#8220;hello world!&#8221; and exits:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">#include &lt;stdio.h&gt;\nint main()\n{\n    printf( \"hello world!\\n\" );\n    return 0;\n}<\/pre>\n\n\n\n<p>If you have an ARM compiler (e.g., ADS, RVDS, or arm-elf-gcc), you can build the application by yourself. Depending on your ARM compiler, build hello.c with one of the following commands:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">ADS or RVDS\n$ armcc -o hello.axf -g -cpu ARM926EJ-S hello.c\n\narm-elf-gcc\n$ arm-elf-gcc -o hello.axf -g -mcpu=arm926ej-s hello.c<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3.2. Configure LD_LIBRARY_PATH<\/h4>\n\n\n\n<p>FaCSim requires several dynamic link libraries. Append FaCSim&#8217;s library path to your library path LD_LIBRARY_PATH as follows (we assume that you have built FaCSim in your home directory):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">bash\n$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME\/FaCSim\/lib\n\ncsh or tcsh\n$ setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH\\:$HOME\/FaCSim\/lib<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3.3. Run FaCSim<\/h4>\n\n\n\n<p>FaCSim requires a system configuration file. The configuration file can be specified with the &#8216;-c&#8217; option. If you do not specify one with the &#8216;-c&#8217; option, FaCSim expects the file &#8220;facsim.config&#8221; to exist in working directory. FaCSim terminates if it cannot read the system configuration file. After building FaCSim, you can find the FaCSim executable file as well as the configuration file facsim.config in the bin directory under the FaCSim distribution directory. You can run the single threaded version of FaCSim as follows (we assume that you have built FaCSim distribution in you home directory and that you have copied hello.axf to your home directory)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">$ cd $HOME\/FaCSim\/bin\n$ .\/facsim $HOME\/hello.axf\n\n$ cd $HOME\n$ $HOME\/FaCSim\/bin\/facsim -c $HOME\/FaCSim\/bin\/facsim.config hello.axf<\/pre>\n\n\n\n<p>Similarly, you can run the parallel version of FaCSim as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">$ cd $HOME\/FaCSim\/bin\n$ .\/facsim-par $HOME\/hello.axf\n\n$ cd $HOME\n$ $HOME\/FaCSim\/bin\/facsim-par -c $HOME\/FaCSim\/bin\/facsim.config hello.axf<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">3.4. Run the application with FaCSim<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">(FaCSim&gt;&gt; hide all\n(FaCSim&gt;&gt; run<\/pre>\n\n\n\n<p>When an application is terminated or reaches a break point, FaCSim displays detailed system statistics. Therefore, some output messages of the application can be missed if buffer of your terminal is too small. If you just want to confirm whether FaCSim distribution is working or not, you can hide all statistics messages of FaCSim by executing the hide all command. The run command will execute an application until it terminates. If you can see the string &#8220;Hello world!&#8221; in your terminal, your FaCSim distribution is working. Congratulations!<\/p>\n\n\n\n<p>You can see the description of a command by executing help &lt;command&gt; command. The following are a summary of the commands for the single threaded version of FaCSim.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">run [&lt;file&gt;]\ngo [&lt;file&gt;]\n  Run the executable image.\n  &lt;file&gt;: the name of the executable file to be executed.\n          If it is not supplied, the current file is executed.\n\nnext [&lt;number_of_instructions&gt;=1]\n  Execute a specified number of instructions.\n  &lt;number_of_instructions&gt;: the number of instructions to be executed.\n  Note that a function call is regarded as a single instruction.\n\nstep [&lt;number_of_instructions&gt;=1]\n  Execute a specified number of instructions.\n  &lt;number_of_instructions&gt;: the number of instructions to be executed.\n\nquit\n  Exit simulator.\n\nexamine &lt;address&gt; [&lt;size_in_bytes&gt;=0x10]\n  Examine memory contents in hexa-decimal and character format.\n  &lt;address&gt;:       a memory address.\n  &lt;size_in_bytes&gt;: the size of memory region.\n\nloadmemory &lt;start_address&gt; &lt;file&gt;\n  Read a file into memory.\n  &lt;start_address&gt;: the starting memory address.\n  &lt;file&gt;         : The name of the file to be read.\n\ncaching [{on|off}]\n  Turn on or off the decode cache.\n  If {on|off} is not supplied, the current status of the decode cache \n  is printed.\n\nbreak &lt;address&gt; [&lt;count&gt; [yes]]\n  Set a breakpoint at the specified address.\n  &lt;address&gt; : a memory address or a symbol at which the breakpoint is placed.\n  &lt;count&gt;   : the number of times the breakpoint must occur before execution \n              is stopped.\n  [yes]     : treats the specified address as a breakpoint only if the \n              instruction at the specified address is executed.\n\ndelete [&lt;address&gt; ...]\n  Delete one or more breakpoints.\n  If arguments are not supplied, delete all the breakpoints\n\nhelp [&lt;command&gt;]\n  Print the help message for the command.\n  If &lt;command&gt; is not supplied, the list of commands is printed.\n\nshow {all|register|pipeline|stats|debug_path|accpipeline|ipb}\n  Print the specified information each time the program stops.\n\nhide {all|register|pipeline|stats|debug_path|accpipeline|ipb}\n  Hide the specified information each time the program stops.\n\ninfo {config|register|memsystem|bus|pipeline|mmu|break|writebuffer}\n  Print the specified information.<\/pre>\n\n\n\n<p>A summary of commands for the parallel version of FaCSim is follows.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-tertiary-background-color has-background\">run [&lt;file&gt;]\ngo [&lt;file&gt;]\n  Run the executable image.\n  &lt;file&gt;: the name of the executable file to be executed.\n          If it is not supplied, the current file is executed.\n\nquit\n  Exit simulator.\n\nexamine &lt;address&gt; [&lt;size_in_bytes&gt;=0x10]\n  Examine memory contents in hexa-decimal and character format.\n  &lt;address&gt;:       a memory address.\n  &lt;size_in_bytes&gt;: the size of memory region.\n\nloadmemory &lt;start_address&gt; &lt;file&gt;\n  Read a file into memory.\n  &lt;start_address&gt;: the starting memory address.\n  &lt;file&gt;:          The name of the file to be read.\n\ncaching [{on|off}]\n  Turn on or off the decode cache.\n  If {on|off} is not supplied, the current status of the decode cache is printed.\n\nhelp [&lt;command&gt;]\n  Print the help message for the command.\n  If &lt;command&gt; is not supplied, the list of commands is printed.\n\nshow {all|register|pipeline|stats|debug_path|accpipeline|ipb}\n  Print the specified information each time the program stops.\n\nhide {all|register|pipeline|stats|debug_path|accpipeline|ipb}\n  Hide the specified information each time the program stops.\n\ninfo {config|register|memsystem|bus|pipeline|mmu|break|writebuffer}\n  Print the specified information.<\/pre>\n\n\n\n<p>Note that the parallel version of FaCSim does not support all the execution control commands but run that are available for the single threaded version (i.e., step, next, break, and delete).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Download You can download the gzipped tarball of the latest FaCSim distribution&nbsp;here. 2. Build Unzip the gzipped tarball as follows: $ tar xvzf facsim-?.?.?.tar.gz FaCSim distribution can be built for a single threaded version or for a parallel version. You can build each version of FaCSim as follows. $ make $ make parallel Note [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"footnotes":""},"class_list":["post-438","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/thunder.snu.ac.kr\/index.php?rest_route=\/wp\/v2\/pages\/438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thunder.snu.ac.kr\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/thunder.snu.ac.kr\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/thunder.snu.ac.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thunder.snu.ac.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=438"}],"version-history":[{"count":3,"href":"https:\/\/thunder.snu.ac.kr\/index.php?rest_route=\/wp\/v2\/pages\/438\/revisions"}],"predecessor-version":[{"id":1126,"href":"https:\/\/thunder.snu.ac.kr\/index.php?rest_route=\/wp\/v2\/pages\/438\/revisions\/1126"}],"wp:attachment":[{"href":"https:\/\/thunder.snu.ac.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}