This repository contains the installation procedure to setup the Bluespec Compiler (BSC) on Ubuntu 24.04. The latest version of the Ubuntu Linux Distribution can be installed from here Download Ubuntu Desktop | Ubuntu. This repository is work in progress.
Install the tape archive (TAR) of the Bluespec Compiler (BSC) here GitHub | BSC | Releases
Save the download in any one of the following locations: /opt
, ${HOME}/
or /usr/share
. If the file is downloaded to other locations, use the following command to move it to the suggested folders:
sudo mv filename /opt
Unpack the archive using the command:
sudo tar -xvzf filename
Further installation instructions to add the path can be found in the README.txt
. The same is explained here, create a directory named tools
using the command:
sudo mkdir -p /opt/tools/bsc
Move the unpacked BSC
file inside the directory using the command:
sudo mv filename /opt/tools/bsc/filename
Navigate to the directory in the terminal using the command:
cd /opt/tools/bsc
Create a symbolic link using the command:
sudo ln -s filename latest
To add the bin
subdirectory to the PATH
open the configuration file for the Bash shell environment using the command:
sudo gedit ~/.bashrc
Any one of the following text editor of choice can be used vim
and nano
. Before running the command make sure one of the text editor is installed in the system. sudo apt-get install gedit
, run this command to install gedit.
At the bottom of the configuration file, add the following path:
export PATH="/opt/tools/bsc/latest/bin:$PATH"
Save and exit the text editor. Use the command to restart.
sudo reboot
To check whether the PATH
has been added correctly, use the command
echo $PATH
Successful inclusion of the path will prompt the following output in the terminal window.
/opt/tools/bsc/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
Figure 1. Successful Installation |
It has been customary to start with a very simple example to introduce the working of any language. So, the first example program that is used to explain the flow of the BSC is a simple 'Hello World!' program.
Save the file as Testbench.bsv
.
module mkTestbench (Empty);
rule rl_print_answer;
$display ("Deep Thought says: Hello, World! The answer is 42.");
$finish;
endrule
endmodule
There are multiples methods to compile and run the BSV file. Here is the one of many methods to run and verify the design.
Put the .bsv
file in a directory called src/
. From outside src/
, run the following shell commands.
mkdir -p .bscdir
mkdir -p vlog
The mkdir -p .bscdir
creates a directory named .bscdir
in the current working directory. The -p
option ensures that intermediate directories are created if they do not exist already. If .bscdir
exists, mkdir
will not raise an error or overwrite it.
The mkdir -p vlog
creates a directory named vlog
in the current working directory. Similar to the first command, -p
ensures that vlog is created even if parent directories leading up to vlog
do not exist. This is run only at the initial setup phase.
Run the following to compile and elaborate the design
bsc -u -p "src:%/Libraries" -keep-fires -aggressive-conditions -show-schedule -show-range-conflict +RTS -K100M -RTS -bdir .bscdir -simdir .bscdir -info-dir .bscdir -vdir vlog -steps 10000000 -sim -g mkTestbench -o temp src/Testbench.bsv
To keep this succint explanations of the shell scripts are avoided. But the explanation of the shell command can be found on ChatGPT, just copy and paste.
Finally to generate the binary file for simulation, run the following script
bsc -e mkTestbench -o mkTestbench_bsim +RTS -K100M -RTS -bdir .bscdir -simdir .bscdir -info-dir .bscdir -vdir vlog -sim -keep-fires
To execute the binary for simulation run
./mkTestbench_bsim -V
The -V
tells Bluesim simulation to dump waveforms from the circuit into dump.vcd
file. Verilog simulators also have commands to capture VCDs. This program does not have any waveform, so run without -V
.
Figure 2. Hello World ! |
A BSV design can be converted to Verilog using the command:
bsc -verilog -g mkTestbench Testbench.bsv
Note that the waveforms from both Bluesim and Verilog simulation will be the same.
For futher information, visit Bluespec Compiler