Quick links: installation, usage example
lcc is a retargetable C compiler. The "target" of a C compiler is the processor for which it generates assembly instructions. The lcc compiler used in the download package is version 4.1 and has been ported to the mMIPS. A separate assembler (included with lcc) converts the mMIPS assembly to machine code that can be uploaded to the FPGA or fed to the hardware simulator. You need to rebuild it and set some environment settings before you can use the lcc compiler. See the paragraph installation below for an explanation of this procedure. See the usage example on how to use the compiler. The script dolcc included with the example applications gossip and multi-processor JPEG decoder invokes the lcc compiler. This script takes away the need to retype the compilation commands yourself (see the application design flow for more information).
Log on to an ICS server (e.g. co7.ics.ele.tue.nl). If you are using Windows you can use a SSH (Secure Shell) client such as SSH Secure Client to log on (instructions).
|Set the environment variable called
your logon script. The variable should contain the location of the folder
If you extracted the download package in your home directory then this
location should be ~/mmips_noc/lcc/lccdir (~
is a shorthand notation for /home/you_home_dir).
Which file is you logon script depends on the shell you get when you log on. You can
determine which logon shell you have by typing
ps (which gives a list of running
processes) directly after you have logged on to an Linux server:
|Now that you have set up the environment, you can rebuild
the lcc compiler:
The lcc compiler that comes with the package is configured for a mMIPS with 16 kilobytes for instructions and 16 kilobytes for data. The mMIPS page shows how to change these memory sizes, if desired.
Assume that we have a program which consists of 2 files foo1.cc and foo2.cc. Before we can make a binary of these files, we must first compile them. With lcc we use the following two commands:
lcc -c foo1.cc -o foo1.o
lcc -c foo2.cc -o foo2.o
The -c option tells the compiler that it should compile the source code file (e.g. foo1.cc and foo2.cc). After the -o option we put the name of the output file produced by the compiler.
After all source code files have been compiled, we can link them into one binary. In our example, we have two object files foo1.o and foo2.o. Using the following command, we link them into the binary foo.
lcc foo1.o foo2.o -o foo