Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
interfaceifc_name; methoddeclarations subinterfacedeclarations endinterface[:ifc_name] interfaceifc_name#({typeType_name}); methoddeclarations subinterfacedeclarations endinterface[:ifc_name] example: interfaceMyIfc#(t); methodActiontick(); interfaceFIFO#(t)inbuffer; endinterface:MyIfc
InterfaceDeclaration
ActionMethodDefinition
ActionValueMethodDefinition
Capitalization
Foo:Typenames,Typeclassnames,Interfacenames,Enumlabels, Taggedunionlabels,Packagenames foo:bit[..],int,modulenames,instancenames,allvariables, alltypevariables,rulenames packagePackage_name; typedefstatements importstatements interfacedeclarations moduledeclarations endpackage[:Package_name]
VariableDeclarationandInitialization
Type{variable_name[=expression]}; example: Integerx=16,y=32; inta[20],b[40]; Int#(5)xs[2][4]={{1,2,3,4}, {5,6,7,8}};
methodTypemethod_name[(Typeargument)];
MethodDeclaration ModuleDefinition
Package
VariableAssignment
variable_name=expression; example: x=23; b=foo.bar(x);
importPackage_name::*;
ImportStatement
ModuleInstantiation
Ifc_typeifc_name<module_name({parameter}); Ifc_typeifc_name<module_name([{parameter,} clocked_byclock_name, reset_byreset_name]); example: Reg#(Time32)state<mkReg(0);
ActionValueAssignmentStatement
Special<notationusedtoperformtheactionandreturnthe value typeidentifier<expression; identifier<expression;
Bit#(n) Int#(n) //signed Uint#(n) //unsigned Integer //staticelaborationonly Bool String Action ActionValue#(t) Rules Tuple2#(t1,t2)...Tuple7#(t1,...,t7) int //Int#(32) Nat //Bit#(32) Maybe#(t)
PredefinedDataTypes
Rules
letidentifier=expression;
ImplicitTypeDeclarationandInitialization
ifexpressionisactionvaluemethod
RegisterReadandWrite
register_name<=expression; example: state<=state+1;//sameas:state._write(state.read()+1)
Type_name Type_name#(type_variable)
TypeDefinition
//polymorphictype
ActionBlock
TypeSynonym
ValueMethodDefinition
Enumeration
(structvaluecontainsmember1andmember2,etc.) typedefstruct{Typemember1;...;TypememberN} Type_name[#{[numeric]typetype_variable}] [deriving(Typeclass)]; example: typedefstruct{Intx;Inty;}Coord deriving(Eq,Bits); Declarationandinitializationofastructurevariable Typevariable_name=Type{member:expression} Coordc1=Coord{x:1,y:foo}; Updateofastructurevariable c1.x=c1.x+5; Structurememberselection xposition=c1.x; TaggedUnion (unionvaluecontainsmember1ormember2) typedefuniontagged{typeMember1;...; typeMemberN;}Type_name[#...[numeric] typetype_variable]; example: typedefuniontagged{ voidInvalid; intValid;}MaybeInt;
Structure
(*{attribute[=expression]}*) synthesize RST_N=string CLK=string always_ready[=interface_method] always_enabled[=interface_method] descendingurgency={rule_names} preempts={rule_names,(list_rule_names)]} doc=string always_ready[=interface_method] always_enabled[=interface_method] ready=string enable=string result=string prefix=string port=string always_ready[=interface_method] always_enabled[=interface_method] noinline
Attributes
ModuleAttributes(toplevelonly)
MethodAttributes
InterfaceAttributes
Declarationandinitializationofataggedunion
FunctionAttributes(toplevelonly) RuleAttributes
parameterparameter_name=expression; portport_name=expression; default_clockclock_name [(port_name,port_name)][=expression]; input_clockclock_name[(port_name, port_name)]=expression; output_clockclock_name (port_name[,port_name]); no_reset; default_resetclock_name([port_name]) [=expression]; input_resetclock_name ([port_name])=expression; output_resetclock_name(port_name); ancestor(clock1,clock2); same_family(clock1,clock2); method[output_port]method_name ({input_ports})[enableenable_port] [readyready_port][clocked_by clock_name] [reset_byclock_name]; schedule({method_name})operator ({method_name}); operatorsareCF,SB,SBR,andC path(port_name1,port_name2);
importBVIStatements
Typevariable_name=Memberexpression; MaybeIntx=taggedValid5;
PatternMatching
taggedMember[pattern]
DefinedInterfaces
interfaceReg#(typea_type); methodAction_write(a_typex1); methoda_type_read(); endinterface:Reg interfacePulseWire; methodActionsend(); methodBool_read(); endinterface
Reg
taggedType[member:pattern] tagged{pattern,pattern}
Patternmatchinginacasestatement case(f(a))matches taggedValid.x:returnx; taggedInvalid:return0; endcase Patternmatchinginanifstatement if(xmatchestaggedValid.n&&&n>5...) matchpattern=expression; example: Tuple2#(Bits(32)x,Booly)a_tuple; match{.a,.b}=a_tuple;
PatternMatchingExamples
SystemTasksandFunctions
$finish $stop $dumpon $dumpoff $dumpvars $test$plusargs $time $stime
PulseWire
typedefReg#(a_type)Wire#(typea_type);
Wire
DefinedModules ImportingCFunctions
modulemkReg#(a_typeresetval) (Reg#(a_type)); modulemkRegU(Reg#(a_type)); modulemkRegA#(a_type resetval)(Reg#(a_type)); modulemkWire(Wire#(a_type)); modulemkBypassWire(Wire#(a_type)); modulemkDWire#(a_typedefaultval) (Wire#(a_type)); modulemkPulseWire(PulseWire);
Reg
PatternMatchingAssignmentStatement
ImportingVerilogModules
importBVI[verilog_module_name]= module[[Type]]module_name[#({parameter})] ({Ifc_typeifc_name})[provisos]; modulestatements importBVIstatements endmodule[:module_name]
Wire
BypassWire DWire
FunctionDefinition
PulseWire
FIFOFs(importFIFOF::*;)
seeLRMforadditionalFIFOs
LibraryPackages
BSVExample
packageCounter; interfaceCounter#(typecount_t); methodcount_tread(); methodActionload(count_tnewval); methodActionincrement(); methodActiondecrement(); endinterface modulemkCounter(Counter#(count_t)) provisos(Arith#(count_t),Bits#(count_t, count_t_sz)); Reg#(count_t)value<mkReg(0); PulseWireincrement_called<mkPulseWire(); PulseWiredecrement_called<mkPulseWire(); ruledo_increment(increment_called&&! decrement_called); value<=value+1; endrule ruledo_decrement(!increment_called&& decrement_called); value<=value1; endrule methodcount_tread(); returnvalue; endmethod methodActionload(count_tnewval); value<=newval; endmethod methodActionincrement(); increment_called.send(); endmethod methodActiondecrement(); decrement_called.send(); endmethod endmodule endpackage:Counter
Interface
Modules
Interfaces
Get/Put(importGetPut::*;)
Type
Connectable(importConnectable::*;) Typeclass
typeclassConnectable#(typea,typeb);
Module
mkConnection#(ax1,bx2);
Client/Server(importClientServer::*;) Interfaces
interfaceClient#(typereq_type,type resp_type); interfaceGet#(req_type)request; interfacePut#(resp_type)response; endinterface:Client interfaceServer#(typereq_type,type resp_type); interfacePut#(req_type)request; interfaceGet#(resp_type)response; endinterface:Server typedefTuple2#(Client#(req_type,resp_type), Server#(req_type,resp_type)) ClientServer#(typereq_type,typeresp_type);
Type