Computer Laboratory

Course pages 2015–16

Advanced Computer Design

Bluespec Walk-through

This walk-through is for the Bluespec tools installed on Computer Laboratory machines. See the bottom of this page for information on using the tools on the MCS Linux machines that are managed by Computing Service.

  • Bluespec documentation:
    see: /usr/groups/ecad/bluespec/current/doc/BSV/
     - reference.pdf
     - BSV_ref_card.pdf
     - Bluespec by Example book
    
    Also see the official [http://sites.google.com/a/bluespec.com/learning-bluespec/ Bluespec Wiki]
  • Initialise paths to the tools:
    source /usr/groups/ecad-labs/ACS-ACD/scripts/tools-setup.bash
    
  • If you like to use xemacs to edit your code then you might like to add the following to your
    ~/.xemacs/init.el
    to get syntax highlighting, etc.
    (setq load-path (cons (expand-file-name "/usr/groups/ecad/bluespec/current/util/emacs") load-path))
    
  • If you prefer emacs to edit your code then you might like to add the following to your
    ~/.emacs.d/init.el
    to get syntax highlighting, etc.
    (setq load-path (cons (expand-file-name
    "/usr/groups/ecad/bluespec/current/util/emacs") load-path))
    (autoload 'bsv-mode "bsv-mode" "BSV mode" t )
    (setq auto-mode-alist (cons  '("\\.bsv\\'" . bsv-mode) auto-mode-alist))
    
  • Create your first Bluespec program in a new directory and call it HelloWorld.bsv (note the case):
    module mkHelloWorld(Empty);
    
       Reg#(UInt#(4)) counter <- mkReg(10);
    
       rule loop (counter!=0);
          counter <= counter-1;
          $display("%05t: Hello World - loop counter = %d",$time,counter);
       endrule
    
       rule mark_ending (counter==0);
          $display("The End at time %05t",$time);
          $finish();
       endrule
    
    endmodule
    
  • Create yourself a makefile using Bluespec's script:
    makemakefile HelloWorld.bsv mkHelloWorld
    
    N.B. type "makemakefile" to see the options for this script.
  • Run the simulation using:
    make run
    
  • You might also like to try some Fibonacci function generation examples: FibSimple

Bluespec on MCS Linux machines

On MCS Linux (not Windows machines), Bluespec is installed in:

$CLTEACH/swm11/bluespec/current

To initialise environment variables including extending your PATH so that you can use the tools, enter the following at the command line:

source $CLTEACH/swm11/setup.bash

I hope that at this point you can follow the instructions, above but instead of looking in /usr/groups/ecad look in $CLTEACH/swm11.

I'll aim to put a copy of the ACS examples, etc., in $CLTEACH/swm11/ACS-ACD

You can get remote access, e.g. using ssh (secure shell) logging into linux.pwf.cam.ac.uk