How to Install the Bluespec SystemVerilog (BSV) Compiler

Last edited at 2025-04-27
65 Views

What is BSV?


BSV(Bluespec SystemVerilog) is one of HDLs(Hardware Description Languages). It enhances productivity in hardware design, as it supports high-level syntaxes and abstract data types compared to Verilog. This post briefly covers the installation procedure of the BSV compiler, and how to compile and simulate a BSV file. For more detailed explanation and examples, refer to the official user guide.


The last post on this blog(https://blog.yeonjun.kr/post/43) covers the same content in Korean.


The bsc(Bluespec Compiler) includes the simulator(Bluesim) and BSV/Verilog packages as well as the BSV language compiler.

My laptop is running on Windows 11, but bsc does not support Windows OS. So I used wsl to proceed in Ubuntu environment.



Bluespec Compiler (bsc) Installation


https://github.com/B-Lang-org/bsc/releases


First, let's download the most recent release, bsc-2025.01.1-ubuntu-24.04.tar.gz from the repository above.

$ wget https://github.com/B-Lang-org/bsc/releases/bsc-2025.01.1-ubuntu-24.04.tar.gz


After unzipping the tar file, we move the files into /opt/tools/bsc, as recommended in the README file.

$ tar -xvf bsc-2025.01.1-ubuntu-24.04.tar.gz
$ mkdir -p /opt/tools/bsc
$ mv bsc-2025.01.1-ubuntu-24.04 /opt/tools/bsc/bsc-2025.01.1-ubuntu-24.04


We shall install required packages for the compiler and the simulator as well.

$ apt-get install tcl-dev
$ apt-get install build-essential
$ apt-get install pkg-config


Next, create the link file of the release, and add it to PATH.

$ cd /opt/tools/bsc
$ ln -s bsc-2025.01.1-ubuntu-24.04 latest
$ export PATH=/opt/tools/bsc/latest/bin:$PATH


The installation is over. Now let's check the updated PATH.

If the link file was added properly, we may check the bsc version via bsc -v.

$ printenv
$ bsc -v



BSV Compilation & Simulation


Now we will compile a BSV source file and simulate it.

I made a project directory named /bsvtest, and wrote a simple BSV code as follows:


test.bsv

package test;
    String hello = "HelloWorld";

    (* synthesize *)
    module mkHelloWorld(Empty);
        rule say_hello;
            $display(hello);
            $finish;
        endrule
    endmodule
endpackage


The following shell script compiles the source code and links the object to Bluesim simulator.


build.sh

#!/bin/bash

base=./build
bdir=${base}/bdir
bindir=${base}/bin
simdir=${base}/simdir

mkdir -p ${bdir}
mkdir -p ${bindir}
mkdir -p ${simdir}

bsc -u -sim -simdir ${simdir} -bdir ${bdir} $1
bsc -u -sim -simdir ${simdir} -bdir ${bdir} -o ${bindir}/bsim -e mkHelloWorld


The script compiles the BSV file given as the first argument($1), and then links the object files to Bluesim simulator. The script creates Bluespec object files, and an executable file(./build/bin/bsim.o).


You can also compile the source into Verilog(.v) files using the -verilog flag. (For detail, refer to official user guide.)


The following command compiles and runs the simulator.

$ bash build.sh test.bsv
$ ./build/bin/bsim


(Output)

HelloWorld


And that's all for this installation guide!

Lastly, Let's install the Bluespec extension in VS Code to highlight our BSV codes.