0% found this document useful (0 votes)
111 views3 pages

Bluespec Systemverilog Reference Card: Italic

This document provides a summary of Bluespec SystemVerilog syntax elements including interface and method declarations, module definitions, variable declarations, assignments, registers, rules, actions, value methods, enumerations, structures, attributes and importBVI statements. It defines syntax elements such as interfaces, modules, rules and actions and shows how variables, registers and methods are declared and used.

Uploaded by

Manoj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views3 pages

Bluespec Systemverilog Reference Card: Italic

This document provides a summary of Bluespec SystemVerilog syntax elements including interface and method declarations, module definitions, variable declarations, assignments, registers, rules, actions, value methods, enumerations, structures, attributes and importBVI statements. It defines syntax elements such as interfaces, modules, rules and actions and shows how variables, registers and methods are declared and used.

Uploaded by

Manoj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Interface Declaration Action Method Definition

interface ifc_name; method Action method_name ({parameter})
     method declarations    [if (method_predicate)];
     subinterface declarations method body statements
endinterface[:ifc_name] endmethod [:method_name]
interface ifc_name #({type Type_name}); 
Bluespec SystemVerilog Reference Card   method declarations ActionValue Method Definition
     subinterface declarations method ActionValue method_name({parameter})
Revision: 11/07 endinterface[:ifc_name]   [if (method_predicate)];
bold as is example: method body statements
italic user identifier being declared interface MyIfc#(t) ; return statement 
   method Action tick() ; endmethod [:method_name]
{ } repeated
   interface FIFO#(t) inbuffer ;
[ ] optional 
endinterface:MyIfc
Variable Declaration and Initialization
Capitalization Type {variable_name [= expression ]};
Foo: Type names, Typeclass names, Interface names, Enum labels, 
Method Declaration  example:
method Type method_name [(Type argument)] ;    Integer x = 16, y = 32;   
Tagged union labels, Package names
foo: bit[..], int, module names, instance names, all variables,     int a[20], b[40];      
all type variables, rule names Module Definition    Int#(5) xs[2][4] = {{1,2,3,4},          
module module_name [# ({parameter})]         {5,6,7,8}}; 
Package    ({Ifc_type ifc_name*})[provisos] ;  
package Package_name ; module instantiations Variable Assignment
  typedef statements variable declaration and initializations variable_name = expression ;
      import statements rules example:
      interface declarations interface/method definitions x = 23 ;
      module declarations endmodule [:module_name] b = foo.bar(x);
endpackage [: Package_name]   * ifc_name optional if only one ifc 
Module Instantiation ActionValue Assignment Statement
Import Statement Ifc_type ifc_name <­  module_name({parameter}); Special  <­ notation used to perform the action and return the 
import Package_name :: * ; Ifc_type ifc_name <­  module_name([{parameter,} value
clocked_by clock_name, 
type identifier <­ expression ;
Predefined Data Types reset_by reset_name]);
identifier <­ expression ;
Bit#(n) example:
Int#(n) // signed Reg#(Time32) state <­ mkReg(0);  
Uint#(n) // unsigned Implicit Type Declaration and Initialization
Integer // static elaboration only Rules let identifier = expression ;
Bool rule rule_name [rule_predicate] ; if expression is actionvalue method
String   action statements let identifier <­ expression ; 
Action endrule[: rule_name] example:
ActionValue#(t) rules [: rules_name] let n = valueof(Buffsize);
Rules   rule let z <­ rndm.get;        
Tuple2#(t1, t2) ... Tuple7#(t1,..., t7)
     variable declaration or variable assignment
int  // Int#(32) endrules[: rules_name]
Nat // Bit#(32) Register Read and Write
Maybe#(t)  register_name  <= expression ;
Action Block example:
Type Definition action [: action_name] ; state <= state + 1  ; // same as: state._write (state.read() + 1)
Type_name    action statements
Type_name#(type_variable) // polymorphic type endaction [:action_name]
Enumeration
Value Method Definition typedef enum {{Elements}} Type_name 
Type Synonym    [deriving (Typeclass)];
typedef type Type_name[#({type type_var})]; method Type method_name ({parameter})
  [if  (method_predicate)]; example:
example: typedef enum {Red, White, Blue} Color 
typedef Bit#(8) Byte; method body statements
deriving (Eq, Bits);
typedef Tuple3#(a, a, a) Triple#(type a); return statement   
endmethod [:method_name]
Structure Attributes importBVI Statements
(struct value contains member1 and member2, etc.) (* {attribute [= expression ]}*) parameter parameter_name = expression ; 
typedef struct {Type member1;...;Type memberN}  Module Attributes (top­level only) port port_name = expression ;  
Type_name [#{[numeric] type type_variable}] synthesize  default_clock clock_name
[deriving (Typeclass)]; RST_N = “string”   [(port_name, port_name)][= expression];
example: CLK = “string”  input_clock clock_name [(port_name, 
typedef struct {Int x; Int y;} Coord  always_ready [= “interface_method”]  port_name)] = expression;
deriving (Eq, Bits); always_enabled [= “interface_method”] output_clock clock_name 
Declaration and initialization of a structure variable descending urgency = “{rule_names}” (port_name [,port_name]);
Type variable_name = Type{member:expression}  preempts = “{rule_names, (list_rule_names)]}” no_reset;
Coord c1 =  Coord{x:1, y:foo}; doc = “string“ default_reset clock_name ([port_name])
Update of a structure variable     [= expression]; 
Method Attributes input_reset clock_name 
c1.x = c1.x + 5 ; always_ready [= “interface_method”]  ([port_name]) = expression; 
Structure member selection  always_enabled [= “interface_method”]  output_reset clock_name ( port_name );
xposition = c1.x ; ready = “string” ancestor ( clock1, clock2 ); 
Tagged Union  enable = “string”  same_family ( clock1, clock2 ); 
(union value contains member1 or member2)  result = “string” method [output_port] method_name 
typedef union tagged {type Member1; ... ;  prefix =  “string” ({input_ports}) [enable enable_port] 
   type MemberN;} Type_name [#...[numeric]  port = “string” [ready ready_port][clocked_by 
   type type_variable];  Interface Attributes clock_name]  [reset_by clock_name];
example: always_ready [= “interface_method”]  schedule ({method_name}) operator 
typedef union tagged { void Invalid;  always_enabled [= “interface_method”]  ({method_name});
int  Valid; } MaybeInt; Function Attributes (top­level only) operators are CF, SB, SBR, and C
Declaration and initialization of a tagged union noinline path (port_name1, port_name2) ;
Type variable_name = Member expression ;  Rule Attributes
MaybeInt x =  tagged Valid 5 ; fire_when_enabled Defined Interfaces
no_implicit_conditions Reg
descending_urgency = “{rule_names}” interface Reg #(type a_type);
Pattern Matching
preempts “{rule_names, [(list_rule_names)]}” method Action _write(a_type x1);
Tagged Union method a_type _read();
tagged Member [ pattern ]  System Tasks and Functions endinterface: Reg
Structure $display $finish PulseWire
tagged Type [ member:pattern ]  $write $stop interface PulseWire;
Tuple $fopen $dumpon      method Action send();
tagged {pattern, pattern} $fdisplay $dumpoff      method Bool _read();
Pattern Matching Examples $fwrite $dumpvars endinterface
Pattern matching in a case statement  $fgetc  $test$plusargs Wire
case (f(a)) matches $fflush $time typedef Reg#(a_type) Wire#(type a_type);
   tagged Valid .x : return x; $fclose  $stime
   tagged Invalid : return 0; $ungetc Defined Modules
endcase Reg
Pattern matching in an if statement  Importing C Functions module mkReg#(a_type resetval) 
if (x matches tagged Valid .n &&& n > 5...) import “BDPI” [c_function_name =] function (Reg#(a_type));
  Return_type function_name [{argument}]) module mkRegU(Reg#(a_type));
Pattern Matching Assignment Statement  module mkRegA#(a_type 
  [provisos] ; 
match pattern = expression ; resetval)(Reg#(a_type));
example: Wire
       Tuple2#(Bits(32) x, Bool y) a_tuple; Importing Verilog Modules  module mkWire(Wire#(a_type));
   match {.a, .b} = a_tuple ; import “BVI” [verilog_module_name] =   BypassWire
  module [[Type]] module_name [# ({parameter})] module mkBypassWire(Wire#(a_type)); 
Function Definition   ({Ifc_type ifc_name}) [provisos] ;
function type function_name ([{arguments}]) DWire
module statements
   [provisos]; module mkDWire#(a_type defaultval)
importBVI statements
(Wire#(a_type));
function body statements  endmodule [: module_name]
return statement  PulseWire
endfunction [: function_name] module mkPulseWire(PulseWire);
Library Packages BSV Example
FIFOFs (import FIFOF::*; )   package Counter ;
see LRM for additional FIFOs
interface Counter#(type count_t);
Interface     method count_t read();
interface FIFOF #(type a_type);     method Action load(count_t newval);
    method Action enq(a_type x1);     method Action increment();
    method Action deq();     method Action decrement();
    method a_type first(); endinterface
    method Bool notFull();
    method Bool notEmpty(); module mkCounter(Counter#(count_t))
    method Action clear();         provisos(Arith#(count_t), Bits#(count_t, 
endinterface: FIFOF count_t_sz));
Modules     Reg#(count_t) value <­ mkReg(0);
module mkFIFOF# (FIFO#(a_type)) ;     
module mkFIFOF1#(FIFO#(a_type));     PulseWire increment_called <­ mkPulseWire();
module mkSizedFIFOF#(Integer n)(FIFO#(a_type)) ;     PulseWire decrement_called <­ mkPulseWire();
module mkLFIFOF#(FIFO#(a_type));
    rule do_increment(increment_called && !
decrement_called);
Get/Put  (import GetPut::*;)         value <= value + 1;
Interfaces      endrule
interface Get#(type a_type);     rule do_decrement(!increment_called && 
    method ActionValue#(a_type) get(); decrement_called);
endinterface: Get         value <= value ­ 1;
interface Put#(type a_type);     endrule
    method Action put(a_type x1);
endinterface: Put     method count_t read();
Type         return value;
typedef Tuple2#( Get#(a_type), Put#(a_type) )      endmethod
  GetPut#(type a_type);     method Action load(count_t newval);
        value <= newval;
    endmethod
Connectable (import Connectable::*;)     method Action increment();
Typeclass         increment_called.send();
typeclass Connectable#(type a , type b) ;     endmethod
    method Action decrement();
Module
        decrement_called.send();
mkConnection#(a x1, b x2) ;     endmethod
endmodule
Client/Server (import ClientServer::*;) endpackage: Counter
Interfaces
interface Client#(type req_type, type 
resp_type);
    interface Get#(req_type)  request;
    interface Put#(resp_type) response;
endinterface: Client
interface Server#(type req_type, type 
resp_type);
    interface Put#(req_type)  request;
    interface Get#(resp_type) response;
endinterface: Server
Type
typedef Tuple2#(Client#(req_type, resp_type), 
Server#(req_type,resp_type)) 
                ClientServer#(type req_type, type resp_type);

You might also like