Computer Laboratory

Course pages 2012–13

Advanced Computer Design

Bluespec Walkthrough

  • 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-1213/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