Demonstration of Riviera-PRO and GitLab Integration in Docker Based Environment

This Application Note discusses the steps required to set up and run the demonstration design presenting how to put Riviera-PRO into a self-managed GitLab infrastructure using the Docker images. Riviera-PRO run within a GitLab job performs a simulation and collects the coverage statistics. The design used in this App Note is available on request. Please contact Aldec support to receive it.

Demo Prerequisites

Setup Demo Environment

Install required python packages:

python3 -m pip install -r requirements.txt

Execute the python script:

python3 gitlab_demo.py --create

The script pulls docker images for GitLab™ server instance (2.86GB) and gitlab-runner (760MB) so it may take some time. Then, it creates docker containers from images and configures them through API. Next, it will upload an open source based project containing two branches: main and coverage. The script will also create a modified docker image with Riviera-PRO (based on the original image aldec/riviera-pro:latest) and tags it as aldec/riviera-pro:demo. The modified image includes the make, python, and perl packages that are required by the example project.

Upon completion, the script displays the basic information about the access to the instance (the user is advised to write this information down):

GitLab URL: http://x.x.x.x:8880
GitLab initial root password: xxxxxxxxxxxxxxxxxxxxxxxxx
GitLab root personal API access token: xxxxxxxxxxxxxxxxxxxxxxxxx
GitLab user name: demo-user
GitLab user password: xxxxxxxxxxxxxxxxx

GitLab Overview

GitLab™ is a DevOps platform that supports every aspect of the software project management. Its main features include:

The above features are suited for software projects but can be successfully used in hardware designs. For example, artifacts can be used to send once compiled libraries to multiple simulation jobs or to collect *.acdb files from multiple jobs to merge them and generate reports. The concepts such as compilation, unit tests, code linting or code reviews are similar in both types of projects and only the applied tools are different.

GitLab Community Edition (self-hosted) is free even for commercial use and can be run as a docker container or installed from an Omnibus package. The official documentation contains the recommended architecture structure for three popular cloud services: AWS, Azure and GPC. Hosting GitLab in a cloud brings a big advantage as it allows us to use the autoscaling feature of the cloud. For example, GitLab can provision new EC2 instances or spawn jobs in AWS Fargate. Another option is using it as SaaS. In that case repository, artifacts and other data can be hosted on gitlab.com, but the user can provide gitlab-runners from his/her own infrastructure.

GitLab is not the only CI/CD platform that can be used in a workflow of a chip design project. Other worth mentioning platforms are:

Advantages of Using Docker

There are several GitLab runner executor types. The basic one is the shell executor which spawns new jobs directly in the host shell. Various software used in CI/CD jobs may have different dependencies. Upgrading the software version requires uninstalling old version and installing a new one with possibly new dependencies on all hosts. Maintaining infrastructure in such an approach may be a challenge for the IT departments. Using the network shares to host the software may not be a solution as EDA applications take hundreds of GBs of disk space and the network bandwidth may turn out to be a bottleneck.

The solution for the above issue can be docker containers. To change the CI/CD tool from shell to the docker executor, just add a line with a valid docker image name in the .gitlab-ci.yml Gitlab configuration file, for example:

image: "registry.example.com/my/image:latest"

A docker image contains software and its all dependencies. A docker container created from an image is fully separated from the host libraries so it solves the problems with compatibility and dependency conflicts. After upgrading software to a newer version, the user needs only to push a new image to the docker private repository. The versions of the local images are checked before every job. If the docker repository contains a new version then it is pulled and cached locally. What's more, docker images are built with layers. Only the modified layer and subsequent ones are downloaded. This allows minimizing the network traffic.

The following demo shows a configuration with a single gitlab-runner which can take up to two jobs at the same time, allowing us to demonstrate CI/CD main features on a single host. In a production environment the created structure is usually much more complex, but isolating software required by CI/CD in docker images allows the user to easily manage even large infrastructure. It is worth noting that a GitLab instance and runner almost never should be hosted on the same machine and such a configuration has been presented only for demonstration purposes.

Work pools can be controlled by GitLab itself or by Kubernetes. In the first case, adding new test machine requires only installation of gitlab-runner and its registration in the GitLab instance. The second approach assumes that control of spawning job containers will be passed to a Kubernetes cluster. Adding a new machine takes place through registering it as a Kubernetes cluster node.

Docker images are also a straightforward solution in case of cloud computing. GitLab supports solutions like autoscaling AWS EC2 instances, AWS Fargate (managed container service), AWS EKS (managed Kubernetes service) and similar. Cloud services may be integrated with on-premise infrastructure creating an entity called hybrid cloud. Cloud resources can be requested dynamically on demand extending local computing power when needed. For example, additional test instances may be spawned out of work hours to utilize free software licenses. Using docker images in such cases ensures that job environment will be the same no matter where the job is executed (in a cloud or on premise).

Demo Walkthrough

When creation of the environment is completed, open a web page pointed with the GitLab URL entry in the output of the script. It should look as follows:

Log in with the user name and password shown in the output of the script. The dashboard will contain a single example project:

The project is a modified version of the open source VeeR EH1 RISC-V Core design. The only difference is that the .gitlab-ci.yml file controlling CI/CD of the project in the GitLab environment has been included in this version. The file has the YAML format and is placed in the root directory:

The CI/CD YAML syntax reference can be found in the GitLab documentation.

The .gitlab-ci.yml file has the following major sections:

The pipeline for both branches (main and coverage) were triggered during configuration of the GitLab instance in a python script. To track the progress, pick the Build | Pipelines option from the Main menu and click the pipeline of the main branch:

The page displayed below shows the structure of the pipeline created from the .gitlab-ci.yml file. There are two stages (build and test) with assigned jobs. The build stage is already successfully completed and two jobs in the test stage are running in parallel:

Clicking on the job status shows console logs:

When the job is finished the page allows the user to download artifacts (simulation log in our case):

The aldec/riviera-pro:demo docker image created by the script does not contain the RISC-V GNU Compiler Toolchain since compilation from sources may take several hours. Instead of building test programs, Makefile uses the already created .hex binary files that will be loaded into memory. The files are listed in the job logs:

Building a custom docker image is shown in the Docker Application Note. It uses RISC-V GNU Compiler Toolchain as an example of the included tool and the image built with that example is compatible with this demo. The custom image may be built before (which results in using the modified image from the start) or after executing the python script. The second approach requires to re-run the jobs manually to see the effect:

Coverage Integration

GitLab uses specific code coverage format called Cobertura which is used among other things in code review. For better integration of the Aldec products with the CI/CD workflow, the script converting Aldec's implementation of UCDB (ACDB) to the Cobertura format is provided.

The demo-design project contains the coverage branch showing how CI/CD with coverage collecting could look like. Since the source project does not support coverage, the Makefile file needs to be modified as shown below:

The .gitlab-ci.yml file also needs to be modified. The required changes are listed below:

The coverage visualization is visible in pull requests. To present this feature, an example merge request was created during the demo project configuration. It can be accessed by selecting the Code | Merge requests option and choosing coverage feature in merge request. If pipeline status is still Running, please wait and refresh the page as the functionality requires the artifact from the last job in the stage. Exemplary changes in SystemVerilog source code can be viewed by clicking the Changes tab and selecting a SystemVerilog file:

The coverage visualization allows the user to see the lines covered and not covered by existing tests in the modified parts of code. The cover status is indicated by the vertical bars next to the line number. A green bar denotes that the line was executed at least once; a red bar in turn informs that the line was not executed. Such visualization provides information on how many changes and new code are covered by existing tests which is crucial when assigning tasks to QA teams.

The full version of the HTML coverage report can be downloaded with the Download button accessible from the artifacts of the merge_coverage job:



Printed version of site: www.aldec.com/en/support/resources/documentation/articles/2258