Arm Cycle Model Studio (CMS) is a useful tool to create SystemC simulation models from Verilog RTL source code. SystemC models that are created with CMS run well with a variety of simulators and are easy to share with others inside and outside of a company. SystemC models are commonly used for architecture analysis, IP selection, and low-level early software development. The Accellera SystemC reference implementation is easy to build from source and runs on most any operating system.
The Cycle Model Studio Installation Guide calls for Red Hat Enterprise Linux 6.6 or CentOS 6.6. These Linux distributions may be found on some corporate networks, but many people have either upgraded to newer versions or are using a different Linux distribution such as Ubuntu. My current favorite desktop Linux distribution is Ubuntu Budgie, but I frequently try different distributions on various machines. Ubuntu is used for many types of software development and it is common to find scripts targeting Ubuntu for things like package management.
The requirement for Red Hat or CentOS makes it difficult to incorporate CMS into a project which is based on Ubuntu. Docker provides an easy solution to the problem and enables CMS to run on other operating systems, including Windows. For today, let us see how to use Docker to run CMS and create models on an Ubuntu machine.
For this exercise the following steps are demonstrated:
The CMS installation is easy on Linux, simply download the product from Arm IP Exchange using an Arm Developer account and untar the file.
$ mkdir cms; cd cms
$ tar xzf ~/Downloads/Arm-CycleModel-release-v11_0_4.tgz
Now CMS is ready to use. There is a setup file in the etc/ directory
For Bourne shell source <install-dir>/etc/setup.sh
For C-Shell source <install-dir>/etc/setup.csh
I am using bash so use the .sh file:
$ . ~/cms/etc/setup.sh
Try an example which comes with CMS.
$ cd ; cp -r $CARBON_HOME/examples/twocounter .
$ cd twocounter
/home/jasand01/cms/makefiles/Makefile.libs:25: *** Makefile.libs: 1 Unsupported Linux64 version - Ubuntu 18.04.2 LTS \n \l. Stop.
CMS runs this command to determine the Linux distribution:
Clearly, Ubuntu is not a supported OS so it is time to solve the problem with Docker.
The first step is to build a Docker image with a supported operating system. I will use CentOS 6.6 from Docker Hub. Make sure that Docker is installed. For this case Docker Community on Ubuntu is perfect. A Docker ID to access Docker Hub is also recommended to store your images. Visit Docker Hub and create a new account using the “Sign up for Docker Hub” link.
A quick way to install Docker and add your user to the docker group (so sudo is not required on any docker commands) is:
$ curl -fsSL get.docker.com -o get-docker.sh && sh get-docker.sh
$ sudo usermod -aG docker $USER
Below is a Dockerfile that is used to get the operating system, install extra packages required by CMS, setup a new user account called user1, and to add the CMS setup.sh information to the .bashrc for the new user.
Change the ARMLMD_LICENSE_FILE value to match the port and host of your license server.
RUN echo "root:docker" | chpasswd
RUN yum -y groupinstall "Additional Development" "Compatibility Libraries" "Development t
ools" "Perl Support" && yum clean all
RUN yum -y install gstreamer-plugins-base && yum clean all || true
RUN useradd --create-home -s /bin/bash -m user1 -u 1000 && echo "user1:docker" | chpasswd
# adjust the path to the CMS install and the license server as needed
RUN echo -e "source $HOME/cms/etc/setup.sh\nexport ARMLMD_LICENSE_FILE=7010@localhost" >> /home/user1/.bashrc
One trick that is used in the Dockerfile is to create the new user account (user1) with the same user id as the host user account. In my case, the user id is 1000. Change this to match your user id obtained from the id command or by running:
$ echo $UID
To create a docker image from the Docker file, run the build:
$ docker build -t jasonrandrews/centos6-cms -f Dockerfile .
I like to tag the image with my Docker ID so I can directly push it to the Docker Hub, but it is not necessary. Replace my ID (jasonrandrews) with yours or just remove it from the tag name.
You should see the image being built and after some time conclude with a success message similar to:
Successfully built 2b8526d5e084
Successfully tagged jasonrandrews/centos6-cms:latest
The image is now created on the local machine. If you want to save it in your account for use in the future or to use it on other machines run:
$ docker push jasonrandrews/centos6-cms
To use the new Docker image to run CMS a couple of tricks are used. Since we already have CMS installed on the Ubuntu host (from our first attempt), it can be accessed from the same place using a volume. The same is true for the example we tried to build, it can stay on the host machine and be accessed using a volume.
This is where the matching user id comes in. If you encounter write permission errors from the container to the volume, it means the user id probably does not match. There are other ways around it using chown and chmod, but I found the user id to be the cleanest way.
The FlexLM server is outside of the container so use host networking to find the license server on the local network VIA the ARMLM_LICENSE_FILE environment variable.
The run command is:
$ docker run -it –-rm --network host -v ~/cms:/home/user1/cms -v ~/twocounter:/home/user1/twocounter jasonrandrews/centos6-cms /bin/bash
A shell will start with the CentOS 6.6 container and I can build the example now. It is also possible to generate a SystemC wrapper for model.
[user1 ~]$ ls
[user1 ~]$ cd twocounter/
[user1 twocounter]$ make
/home/user1/cms/bin/cbuild twocounter.v -o libtwocounter.a
CBUILD, Arm Cycle Model Compiler, Version 11.0.4
All Rights Reserved. Use, disclosure or duplication without
prior written permission of Arm Inc. is prohibited.
Copyright (c) 2002-2019 by Arm Limited (or its affiliates). All Rights Reserved.
For technical support send email to email@example.com
# 1 Elapsed: 0:00:00 Complete: 0%
# 2 Elapsed: 0:00:00 Complete: 0%
<< some output omitted >>
#188 Elapsed: 0:00:01 Complete: 82%
Note 2039: Performing compile...
#189 Elapsed: 0:00:02 Complete: 100%
#189 Elapsed: 0:00:02 Complete: 100%
Note 111: Successfully created libtwocounter.a.
0 warnings, 0 errors, and 0 alerts detected.
env -i LANG=C COMPILER_PATH=/home/user1/cms/Linux64/bin HOME=/home/user1 LD_LIBRARY_PATH=/home/user1/cms/Linux64/gcc/lib64 /home/user1/cms/Linux64/gcc73/bin/gcc -I. -I/home/user1/cms/include -c twocounter.c -I/home/user1/cms/include
env -i LANG=C COMPILER_PATH=/home/user1/cms/Linux64/bin HOME=/home/user1 LD_LIBRARY_PATH=/home/user1/cms/Linux64/gcc/lib64 /home/user1/cms/Linux64/gcc73/bin/g++ -I. -I/home/user1/cms/include -L/home/user1/cms/Linux64/gcc73/lib64 -Wl,-rpath,/home/user1/cms/Linux64/gcc73/lib64 twocounter.o -o twocounter.exe libtwocounter.a -L/home/user1/cms/Linux64/lib -L/home/user1/cms/Linux64/lib/ES6 -L/home/user1/cms/Linux64/lib/gcc7/shared -L/home/user1/cms/Linux64/lib/gcc7 -Wl,-rpath,/home/user1/cms/Linux64/lib -Wl,-rpath,/home/user1/cms/Linux64/lib/ES6 -Wl,-rpath,/home/user1/cms/Linux64/lib/gcc7/shared -Wl,--enable-new-dtags -Wl,-dn -Wl,-dy -lcarbon5 -lnffw -lrt -ldl -lpthread
./twocounter.exe > twocounter.out
diff -b twocounter.out twocounter.gold
[user1 twocounter] $ carbon systemCWrapper libtwocounter.io.db Wrote: libtwocounter.gen.ccfg
The compiled model files are available on the host machine and can be used in a SystemC simulation project on Ubuntu or another Linux distribution.
Because there is nothing to save in the container, exit and automatically remove the container (with the --rm flag on the docker run command).
Cycle Model Studio has limited support for Linux distributions, but Docker is a very easy way to compile models using a container. The compiled models can be used in SystemC simulations running on Ubuntu or most any other 64-bit Linux distribution. Incorporating a Docker container into a modeling project makes it easy for model developers and platform creators to continue to work on the Linux distribution they have, such as Ubuntu, and avoid having to work on multiple machines and copy files back and forth. If you are involved with SystemC simulation for architecture analysis, IP selection, and low-level early software development and have existing RTL IP give Cycle Model Studio a try.
Try Cycle Model Studio
Yes, the same thing can be applied to Fast Models. There are some Docker files for Arm Fast Models and Development Studio at https://github.com/ARM-software/Tool-Solutions/tree/master/docker
Look in the arm-tool-base/ and the arm-tool-interactive/ directories.
Can a similar approach be applied to Fast Model tools?