Created
November 13, 2023 04:09
-
-
Save myrfy001/f4621cba938fa8d9577181a0c06ac666 to your computer and use it in GitHub Desktop.
Bluespec SystemVerilog grammar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
intLiteral ::= ’0 | ’1 | |
| sizedIntLiteral | |
| unsizedIntLiteral | |
sizedIntLiteral ::= bitWidth baseLiteral | |
unsizedIntLiteral ::= [ sign ] baseLiteral | |
| [ sign ] decNum | |
baseLiteral ::= (’d | ’D) decDigitsUnderscore | |
| (’h | ’H) hexDigitsUnderscore | |
| (’o | ’O) octDigitsUnderscore | |
| (’b | ’B) binDigitsUnderscore | |
decNum ::= decDigits [ decDigitsUnderscore ] | |
bitWidth ::= decDigits | |
sign ::= + | - | |
decDigits ::= { 0...9 } | |
decDigitsUnderscore ::= { 0...9, _ } | |
hexDigitsUnderscore ::= { 0...9, a...f, A...F, _ } | |
octDigitsUnderscore ::= { 0...7, _ } | |
binDigitsUnderscore ::= { 0,1, _ } | |
realLiteral ::= decNum[ .decDigitsUnderscore ] exp [ sign ] decDigitsUnderscore | |
| decNum.decDigitsUnderscore | |
exp ::= e | E | |
stringLiteral ::= " · · · string characters · · · " | |
compilerDirective ::= ‘include "filename" | |
| ‘include <filename> | |
| ‘include macroInvocation | |
| ‘line lineNumber "filename" level | |
| ‘define macroName [ ( macroFormals ) ] | |
| macroInvocation | |
| ‘undef macroName | |
| ‘resetall | |
| ‘ifdef macroName | |
| ‘ifndef macroName | |
| ‘elsif macroName | |
| ‘else | |
| ‘endif | |
lineNumber ::= decLiteral | |
level ::= 0 | 1 | 2 | |
macroName ::= identifier | |
macroFormals ::= identifier { , identifier } | |
macroInvocation ::= ‘macroName [ ( macroActuals ) ] | |
macroActuals ::= substText { , substText } | |
package ::= package packageIde ; | |
{ exportDecl } | |
{ importDecl } | |
{ packageStmt } | |
endpackage [ : packageIde ] | |
exportDecl ::= export exportItem { , exportItem } ; | |
exportItem ::= identifier [ (..) ] | |
| Identifier [ (..) ] | |
| packageIde :: * | |
importDecl ::= import importItem { , importItem } ; | |
importItem ::= packageIde :: * | |
packageStmt ::= moduleDef | |
| interfaceDecl | |
| typeDef | |
| varDecl | varAssign | |
| functionDef | |
| typeclassDef | |
| typeclassInstanceDef | |
| externModuleImport | |
packageIde ::= Identifier | |
type ::= typePrimary | |
| typePrimary ( type { , type } ) Function type | |
typePrimary ::= typeIde [ # ( type { , type } ) ] | |
| typeNat | |
| bit [ typeNat : typeNat ] | |
typeIde ::= Identifier | |
typeNat ::= decDigits | |
exprPrimary ::= valueof ( type ) | |
| valueOf ( type ) | |
interfaceDecl ::= [ attributeInstances ] | |
interface typeDefType ; | |
{ interfaceMemberDecl } | |
endinterface [ : typeIde ] | |
typeDefType ::= typeIde [ typeFormals ] | |
typeFormals ::= # ( typeFormal { , typeFormal }) | |
typeFormal ::= [ numeric ] type typeIde | |
interfaceMemberDecl ::= methodProto | subinterfaceDecl | |
methodProto ::= [ attributeInstances ] | |
method type identifier ( [ methodProtoFormals ] ) ; | |
methodProtoFormals ::= methodProtoFormal { , methodProtoFormal } | |
methodProtoFormal ::= [ attributeInstances ] type identifier | |
subinterfaceDecl ::= [ attributeInstances ] | |
interface typeDefType; | |
moduleDef ::= [ attributeInstances ] | |
moduleProto | |
{ moduleStmt } | |
endmodule [ : identifier ] | |
moduleProto ::= module [ [ type ] ] identifier | |
[ moduleFormalParams ] ( [ moduleFormalArgs ] ) [ provisos ]; | |
moduleFormalParams ::= # (moduleFormalParam { , moduleFormalParam }) | |
moduleFormalParam ::= [ attributeInstances ] [ parameter ] type identifier | |
moduleFormalArgs ::= [ attributeInstances ] type | |
| [ attributeInstances ] type identifier | |
{ , [ attributeInstances ] type identifier } | |
moduleStmt ::= moduleInst | |
| methodDef | |
| subinterfaceDef | |
| rule | |
| varDo | varDeclDo | |
| functionCall | |
| systemTaskStmt | |
| ( expression ) | |
| returnStmt | |
| varDecl | varAssign | |
| functionDef | |
| moduleDef | |
| <module>BeginEndStmt | |
| <module>If | <module>Case | |
| <module>For | <module>While | |
moduleInst ::= [ attributeInstances ] | |
type identifier <- moduleApp ; | |
| [ attributeInstances ] | |
type identifier ( ) ; | |
moduleApp2 identifier( [ moduleActualArgs ] ) ; | |
moduleApp ::= identifier | |
( [ moduleActualParamArg { , moduleActualParamArg } ] ) | |
moduleActualParamArg ::= expression | |
| clocked_by expression | |
| reset_by expression | |
moduleApp2 ::= identifier [ # ( moduleActualParam { , moduleActualParam } ) ] | |
moduleActualParam ::= expression | |
moduleActualArgs ::= moduleActualArg { , moduleActualArg } | |
moduleActualArg ::= expression | |
| clocked_by expression | |
| reset_by expression | |
methodDef ::= method [ type ] identifier ( methodFormals ) [ implicitCond ] ; | |
functionBody | |
endmethod [ : identifier ] | |
| method Action identifier ( methodFormals ) [ implicitCond ] ; | |
{ actionStmt } | |
endmethod [ : identifier ] | |
| method ActionValue #( type ) identifier ( methodFormals ) [ implicitCond ; ] | |
{ actionValueStmt } | |
endmethod [ : identifier ] | |
| method [ type ] identifier ( methodFormals ) [ implicitCond ] = expression ; | |
methodFormals ::= methodFormal { , methodFormal } | |
methodFormal ::= [ type ] identifier | |
implicitCond ::= if ( condPredicate ) | |
condPredicate ::= exprOrCondPattern { &&& exprOrCondPattern } | |
exprOrCondPattern ::= expression | |
| expression matches pattern | |
subinterfaceDef ::= interface Identifier identifier ; | |
{ interfaceStmt } | |
endinterface [ : identifier ] | |
| interface [ type ] identifier = expression ; | |
interfaceStmt ::= methodDef | |
| subinterfaceDef | |
| expressionStmt | |
expressionStmt ::= varDecl | varAssign | |
| functionDef | |
| moduleDef | |
| <expression>BeginEndStmt | |
| <expression>If | <expression>Case | |
| <expression>For | <expression>While | |
rule ::= [ attributeInstances ] | |
rule identifier [ ruleCond ] ; | |
ruleBody | |
endrule [ : identifier ] | |
ruleCond ::= ( condPredicate ) | |
ruleBody ::= { actionStmt } | |
typeDef ::= typedefSynonym | |
| typedefEnum | |
| typedefStruct | |
| typedefTaggedUnion | |
typedefSynonym ::= typedef type typeDefType ; | |
typedefEnum ::= typedef enum { typedefEnumElements } Identifier [ derives ] ; | |
typedefEnumElements ::= typedefEnumElement { , typedefEnumElement } | |
typedefEnumElement ::= Identifier [ = intLiteral ] | |
| Identifier[intLiteral] [ = intLiteral ] | |
| Identifier[intLiteral:intLiteral] [ = intLiteral ] | |
typedefStruct ::= typedef struct { | |
{ structMember } | |
} typeDefType [ derives ] ; | |
typedefTaggedUnion ::= typedef union tagged { | |
{ unionMember } | |
} typeDefType [ derives ] ; | |
structMember ::= type identifier ; | |
| subUnion identifier ; | |
unionMember ::= type Identifier ; | |
| subStruct Identifier ; | |
| subUnion Identifier ; | |
| void Identifier ; | |
subStruct ::= struct { | |
{ structMember } | |
} | |
subUnion ::= union tagged { | |
{ unionMember } | |
} | |
provisos ::= provisos ( proviso { , proviso } ) | |
proviso ::= Identifier #(type { , type } ) | |
typeclassDef ::= typeclass typeclassIde typeFormals [ provisos ] | |
[ typedepends ] ; | |
{ overloadedDef } | |
endtypeclass [ : typeclassIde ] | |
typeclassIde ::= Identifier | |
typedepends ::= dependencies ( typedepend { , typedepend } ) | |
typedepend ::= typelist determines typelist | |
typelist ::= typeIde | |
| ( typeIde { , typeIde } ) | |
overloadedDef ::= functionProto | |
| varDecl | |
typeclassInstanceDef ::= instance typeclassIde # ( type { , type } ) [ provisos ] ; | |
{ varAssign ; | functionDef | moduleDef } | |
endinstance [ : typeclassIde ] | |
derives ::= deriving ( typeclassIde { , typeclassIde } ) | |
varDecl ::= type varInit { , varInit } ; | |
varInit ::= identifier [ arrayDims ] [ = expression ] | |
arrayDims ::= [ expression ] { [ expression ] } | |
varAssign ::= lValue = expression ; | |
| match pattern = expression ; | |
lValue ::= identifier | |
| lValue . identifier | |
| lValue [ expression ] | |
| lValue [ expression : expression ] | |
varDecl ::= let identifier = expression ; | |
| let identifier <- expression ; | |
regWrite ::= lValue <= expression | |
| ( expression ) <= expression | |
| lValue arrayIndexes <= expression | |
| lValue [ expression : expression ] <= expression | |
| lValue . identifier <= expression | |
arrayIndexes ::= [ expression ] { [ expression ] } | |
<ctxt>BeginEndStmt ::= begin [ : identifier ] | |
{ <ctxt>Stmt } | |
end [ : identifier ] | |
<ctxt>If ::= if ( condPredicate ) | |
<ctxt>Stmt | |
[ else | |
<ctxt>Stmt ] | |
<ctxt>Case ::= case ( expression ) | |
{ <ctxt>CaseItem } | |
[ <ctxt>DefaultItem ] | |
endcase | |
| case ( expression ) matches | |
{ <ctxt>CasePatItem } | |
[ <ctxt>DefaultItem ] | |
endcase | |
<ctxt>CaseItem ::= expression { , expression } : <ctxt>Stmt | |
<ctxt>DefaultItem ::= default [ : ] <ctxt>Stmt | |
<ctxt>While ::= while ( expression ) | |
<ctxt>Stmt | |
<ctxt>For ::= for ( forInit ; forTest ; forIncr ) | |
<ctxt>Stmt | |
forInit ::= forOldInit | forNewInit | |
forOldInit ::= simpleVarAssign { , simpleVarAssign } | |
simpleVarAssign ::= identifier = expression | |
forNewInit ::= type identifier = expression { , simpleVarDeclAssign } | |
simpleVarDeclAssign ::= [ type ] identifier = expression | |
forTest ::= expression | |
forIncr ::= varIncr { , varIncr } | |
varIncr ::= identifier = expression | |
functionDef ::= [ attributeInstances ] | |
functionProto | |
functionBody | |
endfunction [ : identifier ] | |
functionProto ::= function type identifier ( [ functionFormals ] ) [ provisos ] ; | |
| function type identifier ( [ functionFormals ] ) [ provisos ] = expression ; | |
functionFormals ::= functionFormal { , functionFormal } | |
functionFormal ::= type identifier | |
functionBody ::= actionBlock | |
| actionValueBlock | |
| { functionBodyStmt } | |
functionBodyStmt ::= returnStmt | |
| varDecl | varAssign | |
| functionDef | |
| moduleDef | |
| <functionBody>BeginEndStmt | |
| <functionBody>If | <functionBody>Case | |
| <functionBody>For | <functionBody>While | |
returnStmt ::= return expression ; | |
expression ::= condExpr | |
| operatorExpr | |
| exprPrimary | |
exprPrimary ::= identifier | |
| intLiteral | |
| realLiteral | |
| stringLiteral | |
| systemFunctionCall | |
| ( expression ) | |
| ? | |
| bitConcat | bitSelect | |
| beginEndExpr | |
| actionBlock | |
| actionValueBlock | |
| functionCall | |
| methodCall | |
| typeAssertion | |
| structExpr | |
| exprPrimary . identifier | |
| taggedUnionExpr | |
| interfaceExpr | |
| rulesExpr | |
| seqFsmStmt | parFsmStmt | |
condExpr ::= condPredicate ? expression : expression | |
operatorExpr ::= unop expression | |
| expression binop expression | |
bitConcat ::= { expression { , expression } } | |
bitSelect ::= exprPrimary [ expression [ : expression ] ] | |
beginEndExpr ::= begin [ : identifier ] | |
{ expressionStmt } | |
expression | |
end [ : identifier ] | |
actionBlock ::= action [ : identifier ] | |
{ actionStmt } | |
endaction [ : identifier ] | |
actionStmt ::= regWrite | |
| varDo | varDeclDo | |
| functionCall | |
| systemTaskStmt | |
| ( expression ) | |
| actionBlock | |
| varDecl | varAssign | |
| functionDef | |
| moduleDef | |
| <action>BeginEndStmt | |
| <action>If | <action>Case | |
| <action>For | <action>While | |
actionValueBlock ::= actionvalue [ : identifier ] | |
{ actionValueStmt } | |
endactionvalue [ : identifier ] | |
actionValueStmt ::= regWrite | |
| varDo | varDeclDo | |
| functionCall | |
| systemTaskStmt | |
| ( expression ) | |
| returnStmt | |
| varDecl | varAssign | |
| functionDef | |
| moduleDef | |
| <actionValue>BeginEndStmt | |
| <actionValue>If | <actionValue>Case | |
| <actionValue>For | <actionValue>While | |
varDeclDo ::= type identifier <- expression ; | |
varDo ::= identifier <- expression ; | |
functionCall ::= exprPrimary [ ( [ expression { , expression } ] ) ] | |
methodCall ::= exprPrimary . identifier [ ( [ expression { , expression } ] ) ] | |
typeAssertion ::= type ’ bitConcat | |
| type ’ ( expression ) | |
structExpr ::= Identifier { memberBind { , memberBind } } | |
memberBind ::= identifier : expression | |
taggedUnionExpr ::= tagged Identifier { memberBind { , memberBind } } | |
| tagged Identifier exprPrimary | |
interfaceExpr ::= interface Identifier ; | |
{ interfaceStmt } | |
endinterface [ : Identifier ] | |
rulesExpr ::= [ attributeInstances ] | |
rules [ : identifier ] | |
rulesStmt | |
endrules [ : identifier ] | |
rulesStmt ::= rule | expressionStmt | |
pattern ::= . identifier Pattern variable | |
| .* Wildcard | |
| constantPattern Constant | |
| taggedUnionPattern Tagged union | |
| structPattern Struct | |
| tuplePattern Tuple | |
constantPattern ::= intLiteral | |
| realLiteral | |
| stringLiteral | |
| Identifier Enum label | |
taggedUnionPattern ::= tagged Identifier [ pattern ] | |
structPattern ::= tagged Identifier { identifier : pattern { , identifier : pattern } } | |
tuplePattern ::= { pattern { , pattern } } | |
<ctxt>CasePatItem ::= pattern { &&& expression } : <ctxt>Stmt | |
caseExpr ::= case ( expression ) matches | |
{ caseExprItem } | |
endcase | |
caseExprItem ::= pattern [ &&& expression ] : expression | |
| default [ : ] expression | |
fsmStmt ::= exprFsmStmt | |
| seqFsmStmt | |
| parFsmStmt | |
| ifFsmStmt | |
| whileFsmStmt | |
| repeatFsmStmt | |
| forFsmStmt | |
| returnFsmStmt | |
exprFsmStmt ::= regWrite ; | |
| expression ; | |
seqFsmStmt ::= seq fsmStmt { fsmStmt } endseq | |
parFsmStmt ::= par fsmStmt { fsmStmt } endpar | |
ifFsmStmt ::= if expression fsmStmt | |
[ else fsmStmt ] | |
whileFsmStmt ::= while ( expression ) | |
loopBodyFsmStmt | |
forFsmStmt ::= for ( fsmStmt ; expression ; fsmStmt ) | |
loopBodyFsmStmt | |
returnFsmStmt ::= return ; | |
repeatFsmStmt ::= repeat ( expression ) | |
loopBodyFsmStmt | |
loopBodyFsmStmt ::= fsmStmt | |
| break ; | |
| continue ; | |
systemTaskStmt ::= systemTaskCall ; | |
| displayTaskName ( [ expression [ , expression ] ] ); | |
| $fclose ( fileIdentifier ) ; | |
| fileTaskName ( fileIdentifier , [ expression [ , expression ] ] ) ; | |
| stringTaskName ( ifcIdentifier , [ expression [ , expression ] ] ) ; | |
| $ungetc ( expression, fileIdentifier ) ; | |
| $fflush ( [ fileIdentifier ] ) ; | |
| $finish [ ( expression ) ] ; | |
| $stop [ ( expression ) ] ; | |
| $finish [ ( expression ) ] ; | |
| $stop [ ( expression ) ] ; | |
| $dumpvars | $dumpon | $dumpoff ; | |
displayTaskName ::= $display | $displayb | $displayo | $displayh | |
| $write | $writeb | $writeo | $writeh | |
systemTaskCall ::= $format ( [ expression [ , expression ] ] ) | |
| $fopen ( fileName [ , fileType ] ) | |
| stringAVTaskName ( [ expression [ , expression ] ] ) | |
| $fgetc ( fileIdentifier ) | |
| $realtobits ( expression ) | |
| $bitstoreal ( expression ) | |
| $test$plusargs ( expression ) | |
fileTaskName ::= $fdisplay | $fdisplayb | $fdisplayo | $fdisplayh | |
| $fwrite | $fwriteb | $fwriteo | $fwriteh | |
stringTaskName ::= $swrite | $swriteb | $swriteo | $swriteh | $sformat | |
stringAVTaskName ::= $swriteAV | $swritebAV | $swriteoAV | $swritehAV | $sformatAV | |
systemFunctionCall ::= $time | $stime | |
attributeInstances ::= attributeInstance | |
{ attributeInstance } | |
attributeInstance ::= (* attrSpec { , attrSpec } *) | |
attrSpec ::= attrName [ = expression ] | |
attrName ::= identifier |Identifier | |
externModuleImport ::= import "BVI" [ identifier = ] moduleProto | |
{ moduleStmt } | |
{ importBVIStmt } | |
endmodule [ : identifier ] | |
importBVIStmt ::= parameterBVIStmt | |
| methodBVIStmt | |
| portBVIStmt | |
| inputClockBVIStmt | |
| defaultClockBVIStmt | |
| outputClockBVIStmt | |
| inputResetBVIStmt | |
| defaultResetBVIStmt | |
| noResetBVIStmt | |
| outputResetBVIStmt | |
| ancestorBVIStmt | |
| sameFamilyBVIStmt | |
| scheduleBVIStmt | |
| pathBVIStmt | |
| interfaceBVIStmt | |
| inoutBVIStmt | |
parameterBVIStmt ::= parameter identifier = expression ; | |
methodBVIStmt ::= method [ portId ] identifer [ ( [ portId { , portId } ] ) ] | |
[ enable (portId ) ] [ ready ( portId) ] | |
[ clocked_by ( clockId) ] [ reset_by ( resetId) ] ; | |
portBVIStmt ::= port identifier [ clocked_by ( clockId ) ] | |
[ reset_by ( resetId ) ] = expression ; | |
inputClockBVIStmt ::= input_clock [ identifier ] ( [ portsDef ] ) = expression ; | |
| input_clock [ identifier ] ( [ portsDef ] ) <- expression ; | |
portsDef ::= portId [ , [ attributeInstances ] portId ] | |
portId ::= identifier | |
defaultClockBVIStmt ::= default_clock identifier ; | |
| default_clock [ identifier ] [ ( portsDef ) ] [ = expression ] ; | |
outputClockBVIStmt ::= output_clock identifier ( [ portsDef ] ) ; | |
inputResetBVIStmt ::= input_reset [ identifier ] [ ( portId ) ] [ clocked_by ( clockId ) ] = expression ; | |
| input_reset [ identifier ] [ ( portId ) ] [ clocked_by ( clockId ) ] <- expression ; | |
clockId ::= identifier | |
defaultResetBVIStmt ::= default_reset identifier ; | |
| default_reset [ identifier ] [ ( portId ) ] [ clocked_by ( clockId ) ] [ = expression ] ; | |
| default_reset [ identifier ] [ ( portId ) ] [ clocked_by ( clockId ) ] [ <- expression ] ; | |
outputResetBVIStmt ::= output_reset identifier [ ( portId ) ] [ clocked_by ( clockId ) ]; | |
ancestorBVIStmt ::= ancestor ( clockId , clockId ) ; | |
sameFamilyBVIStmt ::= same_family ( clockId , clockId ) ; | |
scheduleBVIStmt ::= schedule ( identifier { , identifier } ) operatorId | |
( identifier { , identifier } ); | |
operatorId ::= CF | |
| SB | |
| SBR | |
| C | |
pathBVIStmt ::= path ( portId, portId ) ; | |
interfaceBVIStmt ::= interface typeDefType ; | |
{ interfaceBVIMembDecl } | |
endinterface [ : typeIde ] | |
interfaceBVIMembDecl ::= methodBVIStmt | |
| interfaceBVIStmt ; | |
inoutBVIStmt ::= inout portId [ clocked_by ( clockId ) ] | |
[ reset_by ( resetId ) ] = expression ; | |
inoutBVIStmt ::= ifc_inout identifier (inoutId ) [ clocked_by ( clockId ) ] | |
[ reset_by ( resetId ) ] ; | |
externCImport ::= import "BDPI" [ identifier = ] function type | |
identifier ( [ CFuncArgs ] ) [ provisos ] ; | |
CFuncArgs ::= CFuncArg { , CFuncArg } | |
CFuncArg ::= type [ identifier ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment