mirror of
https://github.com/nasa/fpp.git
synced 2025-12-11 03:05:32 -06:00
10611 lines
367 KiB
HTML
10611 lines
367 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="generator" content="Asciidoctor 2.0.20">
|
|
<title>The F Prime Prime (FPP) Language Specification, Unreleased, after v2.2.1</title>
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
|
|
<style>
|
|
/*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
|
|
/* Uncomment the following line when using as a custom stylesheet */
|
|
/* @import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"; */
|
|
html{font-family:sans-serif;-webkit-text-size-adjust:100%}
|
|
a{background:none}
|
|
a:focus{outline:thin dotted}
|
|
a:active,a:hover{outline:0}
|
|
h1{font-size:2em;margin:.67em 0}
|
|
b,strong{font-weight:bold}
|
|
abbr{font-size:.9em}
|
|
abbr[title]{cursor:help;border-bottom:1px dotted #dddddf;text-decoration:none}
|
|
dfn{font-style:italic}
|
|
hr{height:0}
|
|
mark{background:#ff0;color:#000}
|
|
code,kbd,pre,samp{font-family:monospace;font-size:1em}
|
|
pre{white-space:pre-wrap}
|
|
q{quotes:"\201C" "\201D" "\2018" "\2019"}
|
|
small{font-size:80%}
|
|
sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
|
|
sup{top:-.5em}
|
|
sub{bottom:-.25em}
|
|
img{border:0}
|
|
svg:not(:root){overflow:hidden}
|
|
figure{margin:0}
|
|
audio,video{display:inline-block}
|
|
audio:not([controls]){display:none;height:0}
|
|
fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
|
|
legend{border:0;padding:0}
|
|
button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
|
|
button,input{line-height:normal}
|
|
button,select{text-transform:none}
|
|
button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}
|
|
button[disabled],html input[disabled]{cursor:default}
|
|
input[type=checkbox],input[type=radio]{padding:0}
|
|
button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
|
|
textarea{overflow:auto;vertical-align:top}
|
|
table{border-collapse:collapse;border-spacing:0}
|
|
*,::before,::after{box-sizing:border-box}
|
|
html,body{font-size:100%}
|
|
body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;line-height:1;position:relative;cursor:auto;-moz-tab-size:4;-o-tab-size:4;tab-size:4;word-wrap:anywhere;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
|
|
a:hover{cursor:pointer}
|
|
img,object,embed{max-width:100%;height:auto}
|
|
object,embed{height:100%}
|
|
img{-ms-interpolation-mode:bicubic}
|
|
.left{float:left!important}
|
|
.right{float:right!important}
|
|
.text-left{text-align:left!important}
|
|
.text-right{text-align:right!important}
|
|
.text-center{text-align:center!important}
|
|
.text-justify{text-align:justify!important}
|
|
.hide{display:none}
|
|
img,object,svg{display:inline-block;vertical-align:middle}
|
|
textarea{height:auto;min-height:50px}
|
|
select{width:100%}
|
|
.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
|
|
div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0}
|
|
a{color:#2156a5;text-decoration:underline;line-height:inherit}
|
|
a:hover,a:focus{color:#1d4b8f}
|
|
a img{border:0}
|
|
p{line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
|
|
p aside{font-size:.875em;line-height:1.35;font-style:italic}
|
|
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
|
|
h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
|
|
h1{font-size:2.125em}
|
|
h2{font-size:1.6875em}
|
|
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
|
|
h4,h5{font-size:1.125em}
|
|
h6{font-size:1em}
|
|
hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em}
|
|
em,i{font-style:italic;line-height:inherit}
|
|
strong,b{font-weight:bold;line-height:inherit}
|
|
small{font-size:60%;line-height:inherit}
|
|
code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
|
|
ul,ol,dl{line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
|
|
ul,ol{margin-left:1.5em}
|
|
ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0}
|
|
ul.circle{list-style-type:circle}
|
|
ul.disc{list-style-type:disc}
|
|
ul.square{list-style-type:square}
|
|
ul.circle ul:not([class]),ul.disc ul:not([class]),ul.square ul:not([class]){list-style:inherit}
|
|
ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
|
|
dl dt{margin-bottom:.3125em;font-weight:bold}
|
|
dl dd{margin-bottom:1.25em}
|
|
blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
|
|
blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
|
|
@media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
|
|
h1{font-size:2.75em}
|
|
h2{font-size:2.3125em}
|
|
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
|
|
h4{font-size:1.4375em}}
|
|
table{background:#fff;margin-bottom:1.25em;border:1px solid #dedede;word-wrap:normal}
|
|
table thead,table tfoot{background:#f7f8f7}
|
|
table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
|
|
table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
|
|
table tr.even,table tr.alt{background:#f8f8f7}
|
|
table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{line-height:1.6}
|
|
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
|
|
h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
|
|
.center{margin-left:auto;margin-right:auto}
|
|
.stretch{width:100%}
|
|
.clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
|
|
.clearfix::after,.float-group::after{clear:both}
|
|
:not(pre).nobreak{word-wrap:normal}
|
|
:not(pre).nowrap{white-space:nowrap}
|
|
:not(pre).pre-wrap{white-space:pre-wrap}
|
|
:not(pre):not([class^=L])>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background:#f7f7f8;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed}
|
|
pre{color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;line-height:1.45;text-rendering:optimizeSpeed}
|
|
pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
|
|
pre>code{display:block}
|
|
pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
|
|
em em{font-style:normal}
|
|
strong strong{font-weight:400}
|
|
.keyseq{color:rgba(51,51,51,.8)}
|
|
kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background:#f7f7f7;border:1px solid #ccc;border-radius:3px;box-shadow:0 1px 0 rgba(0,0,0,.2),inset 0 0 0 .1em #fff;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
|
|
.keyseq kbd:first-child{margin-left:0}
|
|
.keyseq kbd:last-child{margin-right:0}
|
|
.menuseq,.menuref{color:#000}
|
|
.menuseq b:not(.caret),.menuref{font-weight:inherit}
|
|
.menuseq{word-spacing:-.02em}
|
|
.menuseq b.caret{font-size:1.25em;line-height:.8}
|
|
.menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
|
|
b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
|
|
b.button::before{content:"[";padding:0 3px 0 2px}
|
|
b.button::after{content:"]";padding:0 2px 0 3px}
|
|
p a>code:hover{color:rgba(0,0,0,.9)}
|
|
#header,#content,#footnotes,#footer{width:100%;margin:0 auto;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
|
|
#header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
|
|
#header::after,#content::after,#footnotes::after,#footer::after{clear:both}
|
|
#content{margin-top:1.25em}
|
|
#content::before{content:none}
|
|
#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
|
|
#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
|
|
#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
|
|
#header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:flex;flex-flow:row wrap}
|
|
#header .details span:first-child{margin-left:-.125em}
|
|
#header .details span.email a{color:rgba(0,0,0,.85)}
|
|
#header .details br{display:none}
|
|
#header .details br+span::before{content:"\00a0\2013\00a0"}
|
|
#header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
|
|
#header .details br+span#revremark::before{content:"\00a0|\00a0"}
|
|
#header #revnumber{text-transform:capitalize}
|
|
#header #revnumber::after{content:"\00a0"}
|
|
#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
|
|
#toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
|
|
#toc>ul{margin-left:.125em}
|
|
#toc ul.sectlevel0>li>a{font-style:italic}
|
|
#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
|
|
#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
|
|
#toc li{line-height:1.3334;margin-top:.3334em}
|
|
#toc a{text-decoration:none}
|
|
#toc a:active{text-decoration:underline}
|
|
#toctitle{color:#7a2518;font-size:1.2em}
|
|
@media screen and (min-width:768px){#toctitle{font-size:1.375em}
|
|
body.toc2{padding-left:15em;padding-right:0}
|
|
#toc.toc2{margin-top:0!important;background:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
|
|
#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
|
|
#toc.toc2>ul{font-size:.9em;margin-bottom:0}
|
|
#toc.toc2 ul ul{margin-left:0;padding-left:1em}
|
|
#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
|
|
body.toc2.toc-right{padding-left:0;padding-right:15em}
|
|
body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
|
|
@media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
|
|
#toc.toc2{width:20em}
|
|
#toc.toc2 #toctitle{font-size:1.375em}
|
|
#toc.toc2>ul{font-size:.95em}
|
|
#toc.toc2 ul ul{padding-left:1.25em}
|
|
body.toc2.toc-right{padding-left:0;padding-right:20em}}
|
|
#content #toc{border:1px solid #e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;border-radius:4px}
|
|
#content #toc>:first-child{margin-top:0}
|
|
#content #toc>:last-child{margin-bottom:0}
|
|
#footer{max-width:none;background:rgba(0,0,0,.8);padding:1.25em}
|
|
#footer-text{color:hsla(0,0%,100%,.8);line-height:1.44}
|
|
#content{margin-bottom:.625em}
|
|
.sect1{padding-bottom:.625em}
|
|
@media screen and (min-width:768px){#content{margin-bottom:1.25em}
|
|
.sect1{padding-bottom:1.25em}}
|
|
.sect1:last-child{padding-bottom:0}
|
|
.sect1+.sect1{border-top:1px solid #e7e7e9}
|
|
#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
|
|
#content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
|
|
#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
|
|
#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
|
|
#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
|
|
details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
|
|
details{margin-left:1.25rem}
|
|
details>summary{cursor:pointer;display:block;position:relative;line-height:1.6;margin-bottom:.625rem;outline:none;-webkit-tap-highlight-color:transparent}
|
|
details>summary::-webkit-details-marker{display:none}
|
|
details>summary::before{content:"";border:solid transparent;border-left:solid;border-width:.3em 0 .3em .5em;position:absolute;top:.5em;left:-1.25rem;transform:translateX(15%)}
|
|
details[open]>summary::before{border:solid transparent;border-top:solid;border-width:.5em .3em 0;transform:translateY(15%)}
|
|
details>summary::after{content:"";width:1.25rem;height:1em;position:absolute;top:.3em;left:-1.25rem}
|
|
.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
|
|
table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
|
|
.paragraph.lead>p,#preamble>.sectionbody>[class=paragraph]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
|
|
.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
|
|
.admonitionblock>table td.icon{text-align:center;width:80px}
|
|
.admonitionblock>table td.icon img{max-width:none}
|
|
.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
|
|
.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6);word-wrap:anywhere}
|
|
.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
|
|
.exampleblock>.content{border:1px solid #e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;border-radius:4px}
|
|
.sidebarblock{border:1px solid #dbdbd6;margin-bottom:1.25em;padding:1.25em;background:#f3f3f2;border-radius:4px}
|
|
.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
|
|
.exampleblock>.content>:first-child,.sidebarblock>.content>:first-child{margin-top:0}
|
|
.exampleblock>.content>:last-child,.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
|
|
.literalblock pre,.listingblock>.content>pre{border-radius:4px;overflow-x:auto;padding:1em;font-size:.8125em}
|
|
@media screen and (min-width:768px){.literalblock pre,.listingblock>.content>pre{font-size:.90625em}}
|
|
@media screen and (min-width:1280px){.literalblock pre,.listingblock>.content>pre{font-size:1em}}
|
|
.literalblock pre,.listingblock>.content>pre:not(.highlight),.listingblock>.content>pre[class=highlight],.listingblock>.content>pre[class^="highlight "]{background:#f7f7f8}
|
|
.literalblock.output pre{color:#f7f7f8;background:rgba(0,0,0,.9)}
|
|
.listingblock>.content{position:relative}
|
|
.listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:inherit;opacity:.5}
|
|
.listingblock:hover code[data-lang]::before{display:block}
|
|
.listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:inherit;opacity:.5}
|
|
.listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
|
|
.listingblock pre.highlightjs{padding:0}
|
|
.listingblock pre.highlightjs>code{padding:1em;border-radius:4px}
|
|
.listingblock pre.prettyprint{border-width:0}
|
|
.prettyprint{background:#f7f7f8}
|
|
pre.prettyprint .linenums{line-height:1.45;margin-left:2em}
|
|
pre.prettyprint li{background:none;list-style-type:inherit;padding-left:0}
|
|
pre.prettyprint li code[data-lang]::before{opacity:1}
|
|
pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
|
|
table.linenotable{border-collapse:separate;border:0;margin-bottom:0;background:none}
|
|
table.linenotable td[class]{color:inherit;vertical-align:top;padding:0;line-height:inherit;white-space:normal}
|
|
table.linenotable td.code{padding-left:.75em}
|
|
table.linenotable td.linenos,pre.pygments .linenos{border-right:1px solid;opacity:.35;padding-right:.5em;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
|
|
pre.pygments span.linenos{display:inline-block;margin-right:.75em}
|
|
.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
|
|
.quoteblock:not(.excerpt)>.title{margin-left:-1.5em;margin-bottom:.75em}
|
|
.quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
|
|
.quoteblock blockquote{margin:0;padding:0;border:0}
|
|
.quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
|
|
.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
|
|
.quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
|
|
.verseblock{margin:0 1em 1.25em}
|
|
.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans-serif;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
|
|
.verseblock pre strong{font-weight:400}
|
|
.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
|
|
.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
|
|
.quoteblock .attribution br,.verseblock .attribution br{display:none}
|
|
.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
|
|
.quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
|
|
.quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
|
|
.quoteblock.abstract{margin:0 1em 1.25em;display:block}
|
|
.quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
|
|
.quoteblock.excerpt>blockquote,.quoteblock .quoteblock{padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
|
|
.quoteblock.excerpt,.quoteblock .quoteblock{margin-left:0}
|
|
.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
|
|
.quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;font-size:.85rem;text-align:left;margin-right:0}
|
|
p.tableblock:last-child{margin-bottom:0}
|
|
td.tableblock>.content{margin-bottom:1.25em;word-wrap:anywhere}
|
|
td.tableblock>.content>:last-child{margin-bottom:-1.25em}
|
|
table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
|
|
table.grid-all>*>tr>*{border-width:1px}
|
|
table.grid-cols>*>tr>*{border-width:0 1px}
|
|
table.grid-rows>*>tr>*{border-width:1px 0}
|
|
table.frame-all{border-width:1px}
|
|
table.frame-ends{border-width:1px 0}
|
|
table.frame-sides{border-width:0 1px}
|
|
table.frame-none>colgroup+*>:first-child>*,table.frame-sides>colgroup+*>:first-child>*{border-top-width:0}
|
|
table.frame-none>:last-child>:last-child>*,table.frame-sides>:last-child>:last-child>*{border-bottom-width:0}
|
|
table.frame-none>*>tr>:first-child,table.frame-ends>*>tr>:first-child{border-left-width:0}
|
|
table.frame-none>*>tr>:last-child,table.frame-ends>*>tr>:last-child{border-right-width:0}
|
|
table.stripes-all>*>tr,table.stripes-odd>*>tr:nth-of-type(odd),table.stripes-even>*>tr:nth-of-type(even),table.stripes-hover>*>tr:hover{background:#f8f8f7}
|
|
th.halign-left,td.halign-left{text-align:left}
|
|
th.halign-right,td.halign-right{text-align:right}
|
|
th.halign-center,td.halign-center{text-align:center}
|
|
th.valign-top,td.valign-top{vertical-align:top}
|
|
th.valign-bottom,td.valign-bottom{vertical-align:bottom}
|
|
th.valign-middle,td.valign-middle{vertical-align:middle}
|
|
table thead th,table tfoot th{font-weight:bold}
|
|
tbody tr th{background:#f7f8f7}
|
|
tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
|
|
p.tableblock>code:only-child{background:none;padding:0}
|
|
p.tableblock{font-size:1em}
|
|
ol{margin-left:1.75em}
|
|
ul li ol{margin-left:1.5em}
|
|
dl dd{margin-left:1.125em}
|
|
dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
|
|
li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
|
|
ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
|
|
ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
|
|
ul.unstyled,ol.unstyled{margin-left:0}
|
|
li>p:empty:only-child::before{content:"";display:inline-block}
|
|
ul.checklist>li>p:first-child{margin-left:-1em}
|
|
ul.checklist>li>p:first-child>.fa-square-o:first-child,ul.checklist>li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
|
|
ul.checklist>li>p:first-child>input[type=checkbox]:first-child{margin-right:.25em}
|
|
ul.inline{display:flex;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
|
|
ul.inline>li{margin-left:1.25em}
|
|
.unstyled dl dt{font-weight:400;font-style:normal}
|
|
ol.arabic{list-style-type:decimal}
|
|
ol.decimal{list-style-type:decimal-leading-zero}
|
|
ol.loweralpha{list-style-type:lower-alpha}
|
|
ol.upperalpha{list-style-type:upper-alpha}
|
|
ol.lowerroman{list-style-type:lower-roman}
|
|
ol.upperroman{list-style-type:upper-roman}
|
|
ol.lowergreek{list-style-type:lower-greek}
|
|
.hdlist>table,.colist>table{border:0;background:none}
|
|
.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
|
|
td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
|
|
td.hdlist1{font-weight:bold;padding-bottom:1.25em}
|
|
td.hdlist2{word-wrap:anywhere}
|
|
.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
|
|
.colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
|
|
.colist td:not([class]):first-child img{max-width:none}
|
|
.colist td:not([class]):last-child{padding:.25em 0}
|
|
.thumb,.th{line-height:0;display:inline-block;border:4px solid #fff;box-shadow:0 0 0 1px #ddd}
|
|
.imageblock.left{margin:.25em .625em 1.25em 0}
|
|
.imageblock.right{margin:.25em 0 1.25em .625em}
|
|
.imageblock>.title{margin-bottom:0}
|
|
.imageblock.thumb,.imageblock.th{border-width:6px}
|
|
.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
|
|
.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
|
|
.image.left{margin-right:.625em}
|
|
.image.right{margin-left:.625em}
|
|
a.image{text-decoration:none;display:inline-block}
|
|
a.image object{pointer-events:none}
|
|
sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
|
|
sup.footnote a,sup.footnoteref a{text-decoration:none}
|
|
sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
|
|
#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
|
|
#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
|
|
#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
|
|
#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
|
|
#footnotes .footnote:last-of-type{margin-bottom:0}
|
|
#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
|
|
div.unbreakable{page-break-inside:avoid}
|
|
.big{font-size:larger}
|
|
.small{font-size:smaller}
|
|
.underline{text-decoration:underline}
|
|
.overline{text-decoration:overline}
|
|
.line-through{text-decoration:line-through}
|
|
.aqua{color:#00bfbf}
|
|
.aqua-background{background:#00fafa}
|
|
.black{color:#000}
|
|
.black-background{background:#000}
|
|
.blue{color:#0000bf}
|
|
.blue-background{background:#0000fa}
|
|
.fuchsia{color:#bf00bf}
|
|
.fuchsia-background{background:#fa00fa}
|
|
.gray{color:#606060}
|
|
.gray-background{background:#7d7d7d}
|
|
.green{color:#006000}
|
|
.green-background{background:#007d00}
|
|
.lime{color:#00bf00}
|
|
.lime-background{background:#00fa00}
|
|
.maroon{color:#600000}
|
|
.maroon-background{background:#7d0000}
|
|
.navy{color:#000060}
|
|
.navy-background{background:#00007d}
|
|
.olive{color:#606000}
|
|
.olive-background{background:#7d7d00}
|
|
.purple{color:#600060}
|
|
.purple-background{background:#7d007d}
|
|
.red{color:#bf0000}
|
|
.red-background{background:#fa0000}
|
|
.silver{color:#909090}
|
|
.silver-background{background:#bcbcbc}
|
|
.teal{color:#006060}
|
|
.teal-background{background:#007d7d}
|
|
.white{color:#bfbfbf}
|
|
.white-background{background:#fafafa}
|
|
.yellow{color:#bfbf00}
|
|
.yellow-background{background:#fafa00}
|
|
span.icon>.fa{cursor:default}
|
|
a span.icon>.fa{cursor:inherit}
|
|
.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
|
|
.admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
|
|
.admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
|
|
.admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
|
|
.admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
|
|
.admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
|
|
.conum[data-value]{display:inline-block;color:#fff!important;background:rgba(0,0,0,.8);border-radius:50%;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
|
|
.conum[data-value] *{color:#fff!important}
|
|
.conum[data-value]+b{display:none}
|
|
.conum[data-value]::after{content:attr(data-value)}
|
|
pre .conum[data-value]{position:relative;top:-.125em}
|
|
b.conum *{color:inherit!important}
|
|
.conum:not([data-value]):empty{display:none}
|
|
dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
|
|
h1,h2,p,td.content,span.alt,summary{letter-spacing:-.01em}
|
|
p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
|
|
p,blockquote,dt,td.content,td.hdlist1,span.alt,summary{font-size:1.0625rem}
|
|
p{margin-bottom:1.25rem}
|
|
.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
|
|
.exampleblock>.content{background:#fffef7;border-color:#e0e0dc;box-shadow:0 1px 4px #e0e0dc}
|
|
.print-only{display:none!important}
|
|
@page{margin:1.25cm .75cm}
|
|
@media print{*{box-shadow:none!important;text-shadow:none!important}
|
|
html{font-size:80%}
|
|
a{color:inherit!important;text-decoration:underline!important}
|
|
a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
|
|
a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
|
|
abbr[title]{border-bottom:1px dotted}
|
|
abbr[title]::after{content:" (" attr(title) ")"}
|
|
pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
|
|
thead{display:table-header-group}
|
|
svg{max-width:100%}
|
|
p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
|
|
h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
|
|
#header,#content,#footnotes,#footer{max-width:none}
|
|
#toc,.sidebarblock,.exampleblock>.content{background:none!important}
|
|
#toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
|
|
body.book #header{text-align:center}
|
|
body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
|
|
body.book #header .details{border:0!important;display:block;padding:0!important}
|
|
body.book #header .details span:first-child{margin-left:0!important}
|
|
body.book #header .details br{display:block}
|
|
body.book #header .details br+span::before{content:none!important}
|
|
body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
|
|
body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
|
|
.listingblock code[data-lang]::before{display:block}
|
|
#footer{padding:0 .9375em}
|
|
.hide-on-print{display:none!important}
|
|
.print-only{display:block!important}
|
|
.hide-for-print{display:none!important}
|
|
.show-for-print{display:inherit!important}}
|
|
@media amzn-kf8,print{#header>h1:first-child{margin-top:1.25rem}
|
|
.sect1{padding:0!important}
|
|
.sect1+.sect1{border:0}
|
|
#footer{background:none}
|
|
#footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
|
|
@media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
|
|
</style>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css">
|
|
</head>
|
|
<body class="article toc2 toc-left">
|
|
<div id="header">
|
|
<h1>The F Prime Prime (FPP) Language Specification, Unreleased, after v2.2.1</h1>
|
|
<div id="toc" class="toc2">
|
|
<div id="toctitle">Table of Contents</div>
|
|
<ul class="sectlevel1">
|
|
<li><a href="#Introduction">1. Introduction</a></li>
|
|
<li><a href="#Syntax-Notation">2. Syntax Notation</a></li>
|
|
<li><a href="#Lexical-Elements">3. Lexical Elements</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Lexical-Elements_Reserved-Words">3.1. Reserved Words</a></li>
|
|
<li><a href="#Lexical-Elements_Symbols">3.2. Symbols</a></li>
|
|
<li><a href="#Lexical-Elements_Identifiers">3.3. Identifiers</a></li>
|
|
<li><a href="#Lexical-Elements_End-of-Line-Tokens">3.4. End-of-Line Tokens</a></li>
|
|
<li><a href="#Lexical-Elements_Comments">3.5. Comments</a></li>
|
|
<li><a href="#Lexical-Elements_Whitespace-and-Non-Printable-Characters">3.6. Whitespace and Non-Printable Characters</a></li>
|
|
<li><a href="#Lexical-Elements_Explicit-Line-Continuations">3.7. Explicit Line Continuations</a></li>
|
|
<li><a href="#Lexical-Elements_Automatic-Suppression-of-Newlines">3.8. Automatic Suppression of Newlines</a></li>
|
|
<li><a href="#Lexical-Elements_Collapsing-of-Newlines">3.9. Collapsing of Newlines</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Element-Sequences">4. Element Sequences</a></li>
|
|
<li><a href="#Definitions">5. Definitions</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Definitions_Abstract-Type-Definitions">5.1. Abstract Type Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_Abstract-Type-Definitions_Syntax">5.1.1. Syntax</a></li>
|
|
<li><a href="#Definitions_Abstract-Type-Definitions_Semantics">5.1.2. Semantics</a></li>
|
|
<li><a href="#Definitions_Abstract-Type-Definitions_Examples">5.1.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions_Array-Definitions">5.2. Array Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_Array-Definitions_Syntax">5.2.1. Syntax</a></li>
|
|
<li><a href="#Definitions_Array-Definitions_Semantics">5.2.2. Semantics</a></li>
|
|
<li><a href="#Definitions_Array-Definitions_Examples">5.2.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions_Component-Definitions">5.3. Component Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_Component-Definitions_Syntax">5.3.1. Syntax</a></li>
|
|
<li><a href="#Definitions_Component-Definitions_Semantics">5.3.2. Semantics</a></li>
|
|
<li><a href="#Definitions_Component-Definitions_Examples">5.3.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions_Component-Instance-Definitions">5.4. Component Instance Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_Component-Instance-Definitions_Syntax">5.4.1. Syntax</a></li>
|
|
<li><a href="#Definitions_Component-Instance-Definitions_Semantics">5.4.2. Semantics</a></li>
|
|
<li><a href="#Definitions_Component-Instance-Definitions_Examples">5.4.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions_Constant-Definitions">5.5. Constant Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_Constant-Definitions_Syntax">5.5.1. Syntax</a></li>
|
|
<li><a href="#Definitions_Constant-Definitions_Semantics">5.5.2. Semantics</a></li>
|
|
<li><a href="#Definitions_Constant-Definitions_Examples">5.5.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions_Enum-Definitions">5.6. Enum Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_Enum-Definitions_Syntax">5.6.1. Syntax</a></li>
|
|
<li><a href="#Definitions_Enum-Definitions_Semantics">5.6.2. Semantics</a></li>
|
|
<li><a href="#Definitions_Enum-Definitions_Inferred-Representation-Type">5.6.3. Inferred Representation Type</a></li>
|
|
<li><a href="#Definitions_Enum-Definitions_Explicit-Representation-Type">5.6.4. Explicit Representation Type</a></li>
|
|
<li><a href="#Definitions_Enum-Definitions_Examples">5.6.5. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions_Enumerated-Constant-Definitions">5.7. Enumerated Constant Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_Enumerated-Constant-Definitions_Syntax">5.7.1. Syntax</a></li>
|
|
<li><a href="#Definitions_Enumerated-Constant-Definitions_Semantics">5.7.2. Semantics</a></li>
|
|
<li><a href="#Definitions_Enumerated-Constant-Definitions_Example">5.7.3. Example</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions_Module-Definitions">5.8. Module Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_Module-Definitions_Syntax">5.8.1. Syntax</a></li>
|
|
<li><a href="#Definitions_Module-Definitions_Semantics">5.8.2. Semantics</a></li>
|
|
<li><a href="#Definitions_Module-Definitions_Example">5.8.3. Example</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions_Port-Definitions">5.9. Port Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_Port-Definitions_Syntax">5.9.1. Syntax</a></li>
|
|
<li><a href="#Definitions_Port-Definitions_Semantics">5.9.2. Semantics</a></li>
|
|
<li><a href="#Definitions_Port-Definitions_Examples">5.9.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions_State-Machine-Definitions">5.10. State Machine Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_State-Machine-Definitions_Syntax">5.10.1. Syntax</a></li>
|
|
<li><a href="#Definitions_State-Machine-Definitions_Static-Semantics">5.10.2. Static Semantics</a></li>
|
|
<li><a href="#Definitions_State-Machine-Definitions_Dynamic-Semantics">5.10.3. Dynamic Semantics</a></li>
|
|
<li><a href="#Definitions_State-Machine-Definitions_Examples">5.10.4. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions_Struct-Definitions">5.11. Struct Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_Struct-Definitions_Syntax">5.11.1. Syntax</a></li>
|
|
<li><a href="#Definitions_Struct-Definitions_Semantics">5.11.2. Semantics</a></li>
|
|
<li><a href="#Definitions_Struct-Definitions_Examples">5.11.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions_Topology-Definitions">5.12. Topology Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Definitions_Topology-Definitions_Syntax">5.12.1. Syntax</a></li>
|
|
<li><a href="#Definitions_Topology-Definitions_Semantics">5.12.2. Semantics</a></li>
|
|
<li><a href="#Definitions_Topology-Definitions_Examples">5.12.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#State-Machine-Behavior-Elements">6. State Machine Behavior Elements</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#State-Machine-Behavior-Elements_Action-Definitions">6.1. Action Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#State-Machine-Behavior-Elements_Action-Definitions_Syntax">6.1.1. Syntax</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Action-Definitions_Semantics">6.1.2. Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Action-Definitions_Examples">6.1.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Choice-Definitions">6.2. Choice Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#State-Machine-Behavior-Elements_Choice-Definitions_Syntax">6.2.1. Syntax</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Choice-Definitions_Static-Semantics">6.2.2. Static Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Choice-Definitions_Dynamic-Semantics">6.2.3. Dynamic Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Choice-Definitions_Examples">6.2.4. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Do-Expressions">6.3. Do Expressions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#State-Machine-Behavior-Elements_Do-Expressions_Syntax">6.3.1. Syntax</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Do-Expressions_Semantics">6.3.2. Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Do-Expressions_Examples">6.3.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Guard-Definitions">6.4. Guard Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#State-Machine-Behavior-Elements_Guard-Definitions_Syntax">6.4.1. Syntax</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Guard-Definitions_Semantics">6.4.2. Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Guard-Definitions_Examples">6.4.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers">6.5. Initial Transition Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers_Syntax">6.5.1. Syntax</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers_Static-Semantics">6.5.2. Static Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers_Dynamic-Semantics">6.5.3. Dynamic Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers_Examples">6.5.4. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Signal-Definitions">6.6. Signal Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#State-Machine-Behavior-Elements_Signal-Definitions_Syntax">6.6.1. Syntax</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Signal-Definitions_Semantics">6.6.2. Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Signal-Definitions_Examples">6.6.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Definitions">6.7. State Definitions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Definitions_Syntax">6.7.1. Syntax</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Definitions_Static-Semantics">6.7.2. Static Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Definitions_Dynamic-Semantics">6.7.3. Dynamic Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Definitions_Examples">6.7.4. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Entry-Specifiers">6.8. State Entry Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Entry-Specifiers_Syntax">6.8.1. Syntax</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Entry-Specifiers_Semantics">6.8.2. Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Entry-Specifiers_Examples">6.8.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Exit-Specifiers">6.9. State Exit Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Exit-Specifiers_Syntax">6.9.1. Syntax</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Exit-Specifiers_Semantics">6.9.2. Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Exit-Specifiers_Examples">6.9.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers">6.10. State Transition Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers_Syntax">6.10.1. Syntax</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers_Static-Semantics">6.10.2. Static Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers_The-State-Transition-Map">6.10.3. The State Transition Map</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers_Dynamic-Semantics">6.10.4. Dynamic Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers_Examples">6.10.5. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Transition-Expressions">6.11. Transition Expressions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#State-Machine-Behavior-Elements_Transition-Expressions_Syntax">6.11.1. Syntax</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Transition-Expressions_Static-Semantics">6.11.2. Static Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Transition-Expressions_Dynamic-Semantics">6.11.3. Dynamic Semantics</a></li>
|
|
<li><a href="#State-Machine-Behavior-Elements_Transition-Expressions_Examples">6.11.4. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers">7. Specifiers</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Specifiers_Command-Specifiers">7.1. Command Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Command-Specifiers_Syntax">7.1.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Command-Specifiers_Semantics">7.1.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Command-Specifiers_Examples">7.1.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Component-Instance-Specifiers">7.2. Component Instance Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Component-Instance-Specifiers_Syntax">7.2.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Component-Instance-Specifiers_Semantics">7.2.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Component-Instance-Specifiers_Example">7.2.3. Example</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Connection-Graph-Specifiers">7.3. Connection Graph Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Connection-Graph-Specifiers_Syntax">7.3.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Connection-Graph-Specifiers_Semantics">7.3.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Connection-Graph-Specifiers_Example">7.3.3. Example</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Container-Specifiers">7.4. Container Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Container-Specifiers_Syntax">7.4.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Container-Specifiers_Semantics">7.4.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Container-Specifiers_Examples">7.4.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Event-Specifiers">7.5. Event Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Event-Specifiers_Syntax">7.5.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Event-Specifiers_Semantics">7.5.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Event-Specifiers_Examples">7.5.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Include-Specifiers">7.6. Include Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Include-Specifiers_Syntax">7.6.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Include-Specifiers_Semantics">7.6.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Include-Specifiers_Examples">7.6.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Init-Specifiers">7.7. Init Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Init-Specifiers_Syntax">7.7.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Init-Specifiers_Semantics">7.7.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Init-Specifiers_Example">7.7.3. Example</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Internal-Port-Specifiers">7.8. Internal Port Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Internal-Port-Specifiers_Syntax">7.8.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Internal-Port-Specifiers_Semantics">7.8.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Internal-Port-Specifiers_Examples">7.8.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Location-Specifiers">7.9. Location Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Location-Specifiers_Syntax">7.9.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Location-Specifiers_Semantics">7.9.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Location-Specifiers_Examples">7.9.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Parameter-Specifiers">7.10. Parameter Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Parameter-Specifiers_Syntax">7.10.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Parameter-Specifiers_Semantics">7.10.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Parameter-Specifiers_Examples">7.10.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Port-Instance-Specifiers">7.11. Port Instance Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Port-Instance-Specifiers_Syntax">7.11.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Port-Instance-Specifiers_Semantics">7.11.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Port-Instance-Specifiers_Examples">7.11.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Port-Matching-Specifiers">7.12. Port Matching Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Port-Matching-Specifiers_Syntax">7.12.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Port-Matching-Specifiers_Semantics">7.12.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Port-Matching-Specifiers_Example">7.12.3. Example</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Record-Specifiers">7.13. Record Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Record-Specifiers_Syntax">7.13.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Record-Specifiers_Semantics">7.13.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Record-Specifiers_Examples">7.13.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_State-Machine-Instance-Specifiers">7.14. State Machine Instance Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_State-Machine-Instance-Specifiers_Syntax">7.14.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_State-Machine-Instance-Specifiers_Static-Semantics">7.14.2. Static Semantics</a></li>
|
|
<li><a href="#Specifiers_State-Machine-Instance-Specifiers_Dynamic-Semantics">7.14.3. Dynamic Semantics</a></li>
|
|
<li><a href="#Specifiers_State-Machine-Instance-Specifiers_Examples">7.14.4. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Telemetry-Channel-Specifiers">7.15. Telemetry Channel Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Telemetry-Channel-Specifiers_Syntax">7.15.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Telemetry-Channel-Specifiers_Semantics">7.15.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Telemetry-Channel-Specifiers_Examples">7.15.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Specifiers_Topology-Import-Specifiers">7.16. Topology Import Specifiers</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Specifiers_Topology-Import-Specifiers_Syntax">7.16.1. Syntax</a></li>
|
|
<li><a href="#Specifiers_Topology-Import-Specifiers_Semantics">7.16.2. Semantics</a></li>
|
|
<li><a href="#Specifiers_Topology-Import-Specifiers_Example">7.16.3. Example</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Port-Instance-Identifiers">8. Port Instance Identifiers</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Port-Instance-Identifiers_Syntax">8.1. Syntax</a></li>
|
|
<li><a href="#Port-Instance-Identifiers_Semantics">8.2. Semantics</a></li>
|
|
<li><a href="#Port-Instance-Identifiers_Examples">8.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Type-Names">9. Type Names</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Type-Names_Primitive-Integer-Type-Names">9.1. Primitive Integer Type Names</a></li>
|
|
<li><a href="#Type-Names_Floating-Point-Type-Names">9.2. Floating-Point Type Names</a></li>
|
|
<li><a href="#Type-Names_The-Boolean-Type-Name">9.3. The Boolean Type Name</a></li>
|
|
<li><a href="#Type-Names_String-Type-Names">9.4. String Type Names</a></li>
|
|
<li><a href="#Type-Names_Qualified-Identifier-Type-Names">9.5. Qualified Identifier Type Names</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Expressions">10. Expressions</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Expressions_Arithmetic-Expressions">10.1. Arithmetic Expressions</a></li>
|
|
<li><a href="#Expressions_Array-Expressions">10.2. Array Expressions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Expressions_Array-Expressions_Syntax">10.2.1. Syntax</a></li>
|
|
<li><a href="#Expressions_Array-Expressions_Semantics">10.2.2. Semantics</a></li>
|
|
<li><a href="#Expressions_Array-Expressions_Example">10.2.3. Example</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Expressions_Boolean-Literals">10.3. Boolean Literals</a></li>
|
|
<li><a href="#Expressions_Dot-Expressions">10.4. Dot Expressions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Expressions_Dot-Expressions_Syntax">10.4.1. Syntax</a></li>
|
|
<li><a href="#Expressions_Dot-Expressions_Semantics">10.4.2. Semantics</a></li>
|
|
<li><a href="#Expressions_Dot-Expressions_Examples">10.4.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Expressions_Floating-Point-Literals">10.5. Floating-Point Literals</a></li>
|
|
<li><a href="#Expressions_Identifier-Expressions">10.6. Identifier Expressions</a></li>
|
|
<li><a href="#Expressions_Integer-Literals">10.7. Integer Literals</a></li>
|
|
<li><a href="#Expressions_Parenthesis-Expressions">10.8. Parenthesis Expressions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Expressions_Parenthesis-Expressions_Syntax">10.8.1. Syntax</a></li>
|
|
<li><a href="#Expressions_Parenthesis-Expressions_Semantics">10.8.2. Semantics</a></li>
|
|
<li><a href="#Expressions_Parenthesis-Expressions_Example">10.8.3. Example</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Expressions_String-Literals">10.9. String Literals</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Expressions_String-Literals_Single-Line-String-Literals">10.9.1. Single-Line String Literals</a></li>
|
|
<li><a href="#Expressions_String-Literals_Multiline-String-Literals">10.9.2. Multiline String Literals</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Expressions_Struct-Expressions">10.10. Struct Expressions</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Expressions_Struct-Expressions_Syntax">10.10.1. Syntax</a></li>
|
|
<li><a href="#Expressions_Struct-Expressions_Semantics">10.10.2. Semantics</a></li>
|
|
<li><a href="#Expressions_Struct-Expressions_Example">10.10.3. Example</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Expressions_Precedence-and-Associativity">10.11. Precedence and Associativity</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Formal-Parameter-Lists">11. Formal Parameter Lists</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Formal-Parameter-Lists_Syntax">11.1. Syntax</a></li>
|
|
<li><a href="#Formal-Parameter-Lists_Semantics">11.2. Semantics</a></li>
|
|
<li><a href="#Formal-Parameter-Lists_Examples">11.3. Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Format-Strings">12. Format Strings</a></li>
|
|
<li><a href="#Comments-and-Annotations">13. Comments and Annotations</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Comments-and-Annotations_Comments">13.1. Comments</a></li>
|
|
<li><a href="#Comments-and-Annotations_Annotations">13.2. Annotations</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Comments-and-Annotations_Annotations_Where-Annotations-Can-Occur">13.2.1. Where Annotations Can Occur</a></li>
|
|
<li><a href="#Comments-and-Annotations_Annotations_Kinds-of-Annotations">13.2.2. Kinds of Annotations</a></li>
|
|
<li><a href="#Comments-and-Annotations_Annotations_Multiline-Annotations">13.2.3. Multiline Annotations</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Translation-Units-and-Models">14. Translation Units and Models</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Translation-Units-and-Models_Translation-Units">14.1. Translation Units</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Translation-Units-and-Models_Translation-Units_Syntax">14.1.1. Syntax</a></li>
|
|
<li><a href="#Translation-Units-and-Models_Translation-Units_Example">14.1.2. Example</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Translation-Units-and-Models_Models">14.2. Models</a></li>
|
|
<li><a href="#Translation-Units-and-Models_Locations">14.3. Locations</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Scoping-of-Names">15. Scoping of Names</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Scoping-of-Names_Qualified-Identifiers">15.1. Qualified Identifiers</a></li>
|
|
<li><a href="#Scoping-of-Names_Names-of-Definitions">15.2. Names of Definitions</a></li>
|
|
<li><a href="#Scoping-of-Names_Name-Groups">15.3. Name Groups</a></li>
|
|
<li><a href="#Scoping-of-Names_Multiple-Definitions-with-the-Same-Qualified-Name">15.4. Multiple Definitions with the Same Qualified Name</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Scoping-of-Names_Multiple-Definitions-with-the-Same-Qualified-Name_Different-Name-Groups">15.4.1. Different Name Groups</a></li>
|
|
<li><a href="#Scoping-of-Names_Multiple-Definitions-with-the-Same-Qualified-Name_Module-Definitions">15.4.2. Module Definitions</a></li>
|
|
<li><a href="#Scoping-of-Names_Multiple-Definitions-with-the-Same-Qualified-Name_Conflicting-Definitions">15.4.3. Conflicting Definitions</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Scoping-of-Names_Resolution-of-Identifiers">15.5. Resolution of Identifiers</a></li>
|
|
<li><a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">15.6. Resolution of Qualified Identifiers</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Definitions-and-Uses">16. Definitions and Uses</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Definitions-and-Uses_Uses">16.1. Uses</a></li>
|
|
<li><a href="#Definitions-and-Uses_Use-Def-Graph">16.2. Use-Def Graph</a></li>
|
|
<li><a href="#Definitions-and-Uses_Order-of-Definitions-and-Uses">16.3. Order of Definitions and Uses</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Types">17. Types</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Types_Primitive-Integer-Types">17.1. Primitive Integer Types</a></li>
|
|
<li><a href="#Types_Floating-Point-Types">17.2. Floating-Point Types</a></li>
|
|
<li><a href="#Types_Primitive-Numeric-Types">17.3. Primitive Numeric Types</a></li>
|
|
<li><a href="#Types_The-Boolean-Type">17.4. The Boolean Type</a></li>
|
|
<li><a href="#Types_Primitive-Types">17.5. Primitive Types</a></li>
|
|
<li><a href="#Types_String-Types">17.6. String Types</a></li>
|
|
<li><a href="#Types_Array-Types">17.7. Array Types</a></li>
|
|
<li><a href="#Types_Enum-Types">17.8. Enum Types</a></li>
|
|
<li><a href="#Types_Struct-Types">17.9. Struct Types</a></li>
|
|
<li><a href="#Types_Abstract-Types">17.10. Abstract Types</a></li>
|
|
<li><a href="#Types_Internal-Types">17.11. Internal Types</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Types_Internal-Types_Integer">17.11.1. Integer</a></li>
|
|
<li><a href="#Types_Internal-Types_Integer-Types">17.11.2. Integer Types</a></li>
|
|
<li><a href="#Types_Internal-Types_Numeric-Types">17.11.3. Numeric Types</a></li>
|
|
<li><a href="#Types_Internal-Types_Anonymous-Array-Types">17.11.4. Anonymous Array Types</a></li>
|
|
<li><a href="#Types_Internal-Types_Anonymous-Struct-Types">17.11.5. Anonymous Struct Types</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Types_Displayable-Types">17.12. Displayable Types</a></li>
|
|
<li><a href="#Types_Types-with-Numeric-Members">17.13. Types with Numeric Members</a></li>
|
|
<li><a href="#Types_Default-Values">17.14. Default Values</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Type-Checking">18. Type Checking</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Type-Checking_Integer-Literals">18.1. Integer Literals</a></li>
|
|
<li><a href="#Type-Checking_Floating-Point-Literals">18.2. Floating-Point Literals</a></li>
|
|
<li><a href="#Type-Checking_Boolean-Literals">18.3. Boolean Literals</a></li>
|
|
<li><a href="#Type-Checking_String-Literals">18.4. String Literals</a></li>
|
|
<li><a href="#Type-Checking_Identifier-Expressions">18.5. Identifier Expressions</a></li>
|
|
<li><a href="#Type-Checking_Dot-Expressions">18.6. Dot Expressions</a></li>
|
|
<li><a href="#Type-Checking_Array-Expressions">18.7. Array Expressions</a></li>
|
|
<li><a href="#Type-Checking_Struct-Expressions">18.8. Struct Expressions</a></li>
|
|
<li><a href="#Type-Checking_Unary-Negation-Expressions">18.9. Unary Negation Expressions</a></li>
|
|
<li><a href="#Type-Checking_Binary-Arithmetic-Expressions">18.10. Binary Arithmetic Expressions</a></li>
|
|
<li><a href="#Type-Checking_Parenthesis-Expressions">18.11. Parenthesis Expressions</a></li>
|
|
<li><a href="#Type-Checking_Identical-Types">18.12. Identical Types</a></li>
|
|
<li><a href="#Type-Checking_Type-Conversion">18.13. Type Conversion</a></li>
|
|
<li><a href="#Type-Checking_Computing-a-Common-Type">18.14. Computing a Common Type</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Type-Checking_Computing-a-Common-Type_Pairs-of-Types">18.14.1. Pairs of Types</a></li>
|
|
<li><a href="#Type-Checking_Computing-a-Common-Type_Lists-of-Types">18.14.2. Lists of Types</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Type-Options">19. Type Options</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Type-Options_Conversion-of-Type-Options">19.1. Conversion of Type Options</a></li>
|
|
<li><a href="#Type-Options_Computing-a-Common-Type-Option">19.2. Computing a Common Type Option</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Type-Options_Computing-a-Common-Type-Option_Pairs-of-Type-Options">19.2.1. Pairs of Type Options</a></li>
|
|
<li><a href="#Type-Options_Computing-a-Common-Type-Option_Lists-of-Type-Options">19.2.2. Lists of Type Options</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Values">20. Values</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Values_Primitive-Integer-Values">20.1. Primitive Integer Values</a></li>
|
|
<li><a href="#Values_Integer-Values">20.2. Integer Values</a></li>
|
|
<li><a href="#Values_Floating-Point-Values">20.3. Floating-Point Values</a></li>
|
|
<li><a href="#Values_Boolean-Values">20.4. Boolean Values</a></li>
|
|
<li><a href="#Values_String-Values">20.5. String Values</a></li>
|
|
<li><a href="#Values_Abstract-Type-Values">20.6. Abstract Type Values</a></li>
|
|
<li><a href="#Values_Anonymous-Array-Values">20.7. Anonymous Array Values</a></li>
|
|
<li><a href="#Values_Array-Values">20.8. Array Values</a></li>
|
|
<li><a href="#Values_Enumeration-Values">20.9. Enumeration Values</a></li>
|
|
<li><a href="#Values_Anonymous-Struct-Values">20.10. Anonymous Struct Values</a></li>
|
|
<li><a href="#Values_Struct-Values">20.11. Struct Values</a></li>
|
|
<li><a href="#Values_Serialized-Sizes">20.12. Serialized Sizes</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Evaluation">21. Evaluation</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Evaluation_Evaluating-Expressions">21.1. Evaluating Expressions</a></li>
|
|
<li><a href="#Evaluation_Type-Conversion">21.2. Type Conversion</a>
|
|
<ul class="sectlevel3">
|
|
<li><a href="#Evaluation_Type-Conversion_Unsigned-Primitive-Integer-Values">21.2.1. Unsigned Primitive Integer Values</a></li>
|
|
<li><a href="#Evaluation_Type-Conversion_Signed-Primitive-Integer-Values">21.2.2. Signed Primitive Integer Values</a></li>
|
|
<li><a href="#Evaluation_Type-Conversion_Primitive-Integer-Values-of-Mixed-Sign">21.2.3. Primitive Integer Values of Mixed Sign</a></li>
|
|
<li><a href="#Evaluation_Type-Conversion_Primitive-and-Non-Primitive-Integer-Values">21.2.4. Primitive and Non-Primitive Integer Values</a></li>
|
|
<li><a href="#Evaluation_Type-Conversion_Floating-Point-Values">21.2.5. Floating-Point Values</a></li>
|
|
<li><a href="#Evaluation_Type-Conversion_Array-Values">21.2.6. Array Values</a></li>
|
|
<li><a href="#Evaluation_Type-Conversion_Structure-Values">21.2.7. Structure Values</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#Analysis-and-Translation">22. Analysis and Translation</a>
|
|
<ul class="sectlevel2">
|
|
<li><a href="#Analysis-and-Translation_Analysis">22.1. Analysis</a></li>
|
|
<li><a href="#Analysis-and-Translation_Analysis-Tools">22.2. Analysis Tools</a></li>
|
|
<li><a href="#Analysis-and-Translation_Translation">22.3. Translation</a></li>
|
|
<li><a href="#Analysis-and-Translation_Translation-Tools">22.4. Translation Tools</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div id="content">
|
|
<div class="sect1">
|
|
<h2 id="Introduction">1. Introduction</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>This document provides a detailed description of <strong>F Prime Prime</strong>, also known
|
|
as FPP or F Double Prime.
|
|
FPP is a modeling language for the
|
|
<a href="https://fprime.jpl.nasa.gov">F Prime flight software framework</a>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The goals of FPP are as follows:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>To provide a modeling language for F Prime that is simple, easy to use, and
|
|
well-tailored to the domain.</p>
|
|
</li>
|
|
<li>
|
|
<p>To provide semantic checking and error reporting for F Prime models.</p>
|
|
</li>
|
|
<li>
|
|
<p>To generate code in the various formats that F Prime uses, e.g.,
|
|
C++, Python, XML.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The purpose of this document is to describe FPP with enough precision and
|
|
detail to guide an implementation.
|
|
It is primarily aimed at language implementers, although FPP users may also
|
|
benefit from the level of precision and detail that it provides.
|
|
It is recommended that FPP users read
|
|
<a href="https://nasa.github.io/fpp/fpp-users-guide.html"><em>The FPP User’s Guide</em></a>
|
|
before consulting this document.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Syntax-Notation">2. Syntax Notation</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>Throughout this document, we use the following notation to describe
|
|
language syntax:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><code>fixed-width font</code> denotes literal model text.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>italics</em> denote grammar nonterminals.</p>
|
|
</li>
|
|
<li>
|
|
<p>Italicized brackets <em>[ ]</em> enclose optional elements.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Lexical-Elements">3. Lexical Elements</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>Before parsing an FPP model, the compiler converts the source
|
|
text into a list of <strong>tokens</strong>.
|
|
This process is called <strong>lexing</strong>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>A token is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A <a href="#Lexical-Elements_Reserved-Words">reserved word</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Lexical-Elements_Symbols">symbol</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Lexical-Elements_Identifiers">identifier</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Expressions_Integer-Literals">integer literal</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Expressions_Floating-Point-Literals">floating-point literal</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Expressions_String-Literals">string literal</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Lexical-Elements_End-of-Line-Tokens">end-of-line token</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A line of an <a href="#Comments-and-Annotations_Annotations">annotation</a>
|
|
beginning with <code>@</code> or <code>@<</code>.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Lexical-Elements_Reserved-Words">3.1. Reserved Words</h3>
|
|
<div class="paragraph">
|
|
<p>The following are reserved words in FPP.
|
|
They may not be used as identifiers, except
|
|
when preceded by the <code>$</code> character, as discussed below.</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">F32
|
|
F64
|
|
I16
|
|
I32
|
|
I64
|
|
I8
|
|
U16
|
|
U32
|
|
U64
|
|
U8
|
|
action
|
|
active
|
|
activity
|
|
always
|
|
array
|
|
assert
|
|
async
|
|
at
|
|
base
|
|
block
|
|
bool
|
|
change
|
|
choice
|
|
command
|
|
component
|
|
connections
|
|
constant
|
|
container
|
|
cpu
|
|
default
|
|
diagnostic
|
|
do
|
|
drop
|
|
else
|
|
entry
|
|
enum
|
|
enter
|
|
event
|
|
exit
|
|
false
|
|
fatal
|
|
format
|
|
get
|
|
guard
|
|
guarded
|
|
health
|
|
high
|
|
hook
|
|
id
|
|
if
|
|
import
|
|
include
|
|
initial
|
|
input
|
|
instance
|
|
internal
|
|
locate
|
|
low
|
|
machine
|
|
match
|
|
module
|
|
on
|
|
opcode
|
|
orange
|
|
output
|
|
param
|
|
passive
|
|
phase
|
|
port
|
|
priority
|
|
private
|
|
product
|
|
queue
|
|
queued
|
|
record
|
|
recv
|
|
red
|
|
ref
|
|
reg
|
|
request
|
|
resp
|
|
save
|
|
send
|
|
serial
|
|
set
|
|
severity
|
|
signal
|
|
size
|
|
stack
|
|
state
|
|
string
|
|
struct
|
|
sync
|
|
telemetry
|
|
text
|
|
throttle
|
|
time
|
|
topology
|
|
true
|
|
type
|
|
unmatched
|
|
update
|
|
warning
|
|
with
|
|
yellow</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Lexical-Elements_Symbols">3.2. Symbols</h3>
|
|
<div class="paragraph">
|
|
<p>The following sequences of characters are symbol tokens in FPP:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">(
|
|
)
|
|
*
|
|
+
|
|
,
|
|
-
|
|
->
|
|
.
|
|
/
|
|
:
|
|
;
|
|
=
|
|
[
|
|
]
|
|
{
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Lexical-Elements_Identifiers">3.3. Identifiers</h3>
|
|
<div class="paragraph">
|
|
<p><strong>Definition:</strong> An <strong>identifier</strong> is an unqualified name
|
|
consisting of one or more characters. The first character
|
|
must be a letter or an underscore. Characters after the first character
|
|
may be letters, digits, and underscores.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For example:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><code>identifier</code>, <code>identifier3</code>, and <code>__identifier3</code> are valid identifiers.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>3identifier</code> is not a valid identifier, because it starts with a digit.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>identifier%</code> is not a valid identifier, because it contains the character <code>%</code>.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Escaped keywords:</strong> Any identifier may be preceded by the character <code>$</code>, with
|
|
no intervening space.
|
|
An identifier <code>$</code> <em>I</em> has the same meaning as <em>I</em>, except that if <em>I</em> is a
|
|
<a href="#Lexical-Elements_Reserved-Words">reserved word</a>, then <em>I</em> is scanned
|
|
as an identifier and not as a reserved word.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For example:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><code>$identifier</code> is a valid identifier. It has the same meaning as <code>identifier</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>$time</code> is a valid identifier. It represents the character sequence <code>time</code>
|
|
treated as an identifier and not as a reserved word.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>time</code> is a reserved word. It may not be used as an identifier.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Lexical-Elements_End-of-Line-Tokens">3.4. End-of-Line Tokens</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>end-of-line token</strong> is a sequence of one or more <strong>newlines</strong>.
|
|
A newline (or line break) is the NL character (ASCII code 0x0A),
|
|
optionally preceded by a CR
|
|
character (ASCII code 0x0D). End-of-line tokens separate the elements of
|
|
<a href="#Element-Sequences">element sequences</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Lexical-Elements_Comments">3.5. Comments</h3>
|
|
<div class="paragraph">
|
|
<p>The lexer ignores <a href="#Comments-and-Annotations_Comments">comments</a>.
|
|
Specifically:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A comment followed by a <a href="#Lexical-Elements_End-of-Line-Tokens">newline</a> is treated as
|
|
a newline.</p>
|
|
</li>
|
|
<li>
|
|
<p>A comment at the end of a file, not followed by a newline, is
|
|
treated as no text.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Lexical-Elements_Whitespace-and-Non-Printable-Characters">3.6. Whitespace and Non-Printable Characters</h3>
|
|
<div class="paragraph">
|
|
<p>Apart from <a href="#Lexical-Elements_End-of-Line-Tokens">end-of-line tokens</a>, the
|
|
lexer treats whitespace as follows:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>Space characters are ignored, except to separate tokens.</p>
|
|
</li>
|
|
<li>
|
|
<p>No other whitespace or non-printable characters are allowed
|
|
outside of a string, comment, or annotation.
|
|
In particular, the tab character may not appear
|
|
in an FPP model outside of a string, comment, or annotation.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Lexical-Elements_Explicit-Line-Continuations">3.7. Explicit Line Continuations</h3>
|
|
<div class="paragraph">
|
|
<p>The character <code>\</code>, when appearing before a
|
|
<a href="#Lexical-Elements_End-of-Line-Tokens">newline</a>,
|
|
suppresses the newline.
|
|
Both the <code>\</code> and the following newline are ignored, and no
|
|
<a href="#Lexical-Elements_End-of-Line-Tokens">end-of-line token</a>,
|
|
is created.
|
|
For example, this</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a \
|
|
= 1</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>is equivalent to this:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 1</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Note that <code>\</code> is required in this case.
|
|
For example, the following is not syntactically correct:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a # Error
|
|
= 1</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The newline indicates the end of an element sequence, but
|
|
<code>constant a</code> is not a valid element sequence.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Lexical-Elements_Automatic-Suppression-of-Newlines">3.8. Automatic Suppression of Newlines</h3>
|
|
<div class="paragraph">
|
|
<p>The following symbols consume sequences of newlines that
|
|
follow them, without creating an
|
|
<a href="#Lexical-Elements_End-of-Line-Tokens">end-of-line token</a>:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">(
|
|
*
|
|
+
|
|
,
|
|
-
|
|
->
|
|
/
|
|
:
|
|
;
|
|
=
|
|
[
|
|
{</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For example, the following code is legal:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M {
|
|
constant a = 0
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>It is equivalent to this code:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M { constant a = 0 }</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The newline after the <code>{</code> symbol is consumed by the symbol.
|
|
The newline after the constant definition is consumed
|
|
by the element sequence member.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The following code is also legal, because the newline is
|
|
consumed by the <code>=</code> symbol:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a =
|
|
0</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Similarly, the following code is legal, because the newline
|
|
is consumed by the <code>+</code> symbol:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 1 +
|
|
2</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Lexical-Elements_Collapsing-of-Newlines">3.9. Collapsing of Newlines</h3>
|
|
<div class="paragraph">
|
|
<p>To simplify parsing, the lexer may collapse a sequence of one or more
|
|
<a href="#Lexical-Elements_End-of-Line-Tokens">end-of-line tokens</a>
|
|
into a single token, or into no token, if
|
|
the operation does not change the meaning of the result according
|
|
to the parse rules.
|
|
For example, the lexer may treat this code</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = [
|
|
1
|
|
2
|
|
3
|
|
|
|
]</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>as if it were this</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = [
|
|
1
|
|
2
|
|
3
|
|
]</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>or this</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = [
|
|
1
|
|
2
|
|
3 ]</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>According to the rules for
|
|
<a href="#Element-Sequences">parsing element sequences</a>,
|
|
all three code sections are equivalent.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Element-Sequences">4. Element Sequences</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>An <strong>element sequence</strong> is a sequence of similar elements, e.g., the
|
|
elements of a
|
|
<a href="#Translation-Units-and-Models_Translation-Units">translation
|
|
unit</a>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Each element of an element sequence has optional <strong>terminating
|
|
punctuation</strong>. The punctuation is either a comma or a semicolon,
|
|
depending on the kind of sequence.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For each element <em>e</em> in the sequence:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>You can always terminate <em>e</em> with a sequence of one or more newlines. In
|
|
this case no terminating punctuation is required.</p>
|
|
</li>
|
|
<li>
|
|
<p>You can omit the newline. In this case the terminating punctuation
|
|
is required, unless the element is last in the sequence or
|
|
the element is followed by a
|
|
<a href="#Comments-and-Annotations_Annotations">post-annotation</a>.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Examples:</strong></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>A
|
|
<a href="#Translation-Units-and-Models_Translation-Units">translation
|
|
unit</a> is a kind of element sequence. Here are some examples of element
|
|
sequences using
|
|
<a href="#Definitions_Constant-Definitions">constant
|
|
definitions</a> as the elements of a translation unit:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># No terminating punctuation
|
|
constant a = 0
|
|
constant b = 1</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># Optional terminating punctuation present
|
|
constant a = 0;
|
|
constant b = 1;</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># Terminating punctuation required after the first element but not the second
|
|
constant a = 0; constant b = 1</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># Error, because terminating punctuation is missing
|
|
constant a = 0 constant b = 1</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># No terminating punctuation required because of the post-annotation
|
|
constant a = 0 @< This is OK
|
|
constant b = 1</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>An
|
|
<a href="#Definitions_Enum-Definitions_Syntax">enum
|
|
constant sequence</a> is another example of an element sequence. Here are
|
|
some element sequences using
|
|
<a href="#Definitions_Enumerated-Constant-Definitions">enumerated
|
|
constant definitions</a> as elements of an enum constant sequence:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># No terminating punctuation
|
|
enum E {
|
|
X = 0
|
|
Y = 1
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># Optional terminating punctuation
|
|
enum E {
|
|
X = 0,
|
|
Y = 1,
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># Terminating punctuation required after the first element but not the second
|
|
enum E { X = 0, Y = 1 }</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Definitions">5. Definitions</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>A <strong>definition</strong> is a unit of syntax that introduces a name <em>N</em>
|
|
and associates some code with <em>N</em>.</p>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_Abstract-Type-Definitions">5.1. Abstract Type Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>abstract type definition</strong> associates a name with a type
|
|
without specifying the type.
|
|
In generated code, the type is specified externally (e.g., as a C++ class).</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Abstract-Type-Definitions_Syntax">5.1.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>type</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Abstract-Type-Definitions_Semantics">5.1.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The identifier is the name <em>N</em> of the type.
|
|
The definition associates the name <em>N</em> with an unspecified type <em>T'</em>.
|
|
The name <em>N</em> can be used as a type elsewhere in the model.
|
|
There are no explicit values associated with <em>N</em> in the model.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Abstract-Type-Definitions_Examples">5.1.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># Defines an abstract type A
|
|
type A
|
|
# Defines a struct type B whose member x has type A
|
|
struct B {
|
|
x: A
|
|
y: F32
|
|
} default { y = 1 }</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_Array-Definitions">5.2. Array Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>array definition</strong> defines a new array type and associates a name with
|
|
it.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Array-Definitions_Syntax">5.2.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>array</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a> <code>=</code>
|
|
<code>[</code> <a href="#Expressions"><em>expression</em></a> <code>]</code> <a href="#Type-Names"><em>type-name</em></a>
|
|
<em>[</em>
|
|
<code>default</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>format</code> <a href="#Expressions_String-Literals"><em>string-literal</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Array-Definitions_Semantics">5.2.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The identifier is the name <em>N</em> of the new type.
|
|
The first expression must evaluate to a compile-time constant numeric value <em>n</em>
|
|
whose value is greater than zero and less than or equal to 256.
|
|
<em>type-name</em> names the type <em>T</em> of each array element.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The definition associates the name <em>N</em> with a new type <em>T'</em>
|
|
that represents an array of <em>n</em> elements of type <em>T</em>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The expression following the keyword <code>default</code> is optional.
|
|
If present, it specifies the <a href="#Types_Default-Values">default value</a> associated
|
|
with the type.
|
|
The type of the expression must be
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a> <em>T'</em>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The optional format specifier specifies a <a href="#Format-Strings">format string</a>.
|
|
When displaying the array, the format is applied to each element of the array.
|
|
There is one argument to the format string, which is an array member.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Array-Definitions_Examples">5.2.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># Defines an array type A of 3 U8 elements with default value [ 0, 0, 0 ]
|
|
array A = [3] U8
|
|
|
|
# Defines an array type B of 2 A elements with default value
|
|
# [ [ 0, 0, 0 ], [ 0, 0, 0 ] ]
|
|
array B = [3] A
|
|
|
|
# Defines an array type C of 3 F32 elements with default value [ 1, 2, 3 ]
|
|
array C = [3] F32 default [ 1, 2, 3 ]
|
|
|
|
# Defines an array type C of 3 U32 values with default value
|
|
# [ 1, 1, 1 ] after promoting 1 to [ 1, 1, 1 ]
|
|
array D = [3] U32 default 1
|
|
|
|
# Defines an array type E of 3 U32 values with default value
|
|
# [ 1, 1, 1, ] and element format {.03f}
|
|
array E = [3] U32 default 1 format "{.03f}"</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_Component-Definitions">5.3. Component Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>component definition</strong> defines an F Prime component.
|
|
A component is a unit of function in the F Prime framework.
|
|
Component instances communicate with each other across
|
|
<a href="#Definitions_Port-Definitions">ports</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Component-Definitions_Syntax">5.3.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><em>component-kind</em> <code>component</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>{</code> <em>component-member-sequence</em> <code>}</code></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>component-kind</em> is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><code>active</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>passive</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>queued</code></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>component-member-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in
|
|
which each element is a <strong>component member</strong>,
|
|
and the terminating punctuation is a semicolon.
|
|
A component member is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A <a href="#Definitions_Constant-Definitions">constant definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Definitions_State-Machine-Definitions">state machine definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Definitions_Struct-Definitions">struct definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Specifiers_Command-Specifiers">command specifier</a>.
|
|
All commands specified in a component must have distinct names and opcodes.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Specifiers_Container-Specifiers">container specifier</a>.
|
|
All containers specified in a component must have distinct names and identifier
|
|
values.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Specifiers_Parameter-Specifiers">parameter specifier</a>.
|
|
All parameters specified in a component must have distinct names and identifier
|
|
values.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Specifiers_Port-Instance-Specifiers">port instance specifier</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Specifiers_Record-Specifiers">record specifier</a>.
|
|
All records specified in a component must have distinct names and identifier
|
|
values.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Specifiers_State-Machine-Instance-Specifiers">state machine instance specifier</a>.
|
|
All state machine instances specified in a component must have distinct names.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Specifiers_Telemetry-Channel-Specifiers">telemetry channel specifier</a>.
|
|
All telemetry channels specified in a component must have distinct names and
|
|
identifier values.</p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Definitions_Abstract-Type-Definitions">abstract type definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Definitions_Array-Definitions">array definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Definitions_Enum-Definitions">enum definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Specifiers_Event-Specifiers">event specifier</a>.
|
|
All events specified in a component must have distinct names and identifier
|
|
values.</p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Specifiers_Include-Specifiers">include specifier</a></p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Specifiers_Internal-Port-Specifiers">internal port specifier</a></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The command, event, parameter, telemetry, record, and container
|
|
specifiers are collectively referred to as <strong>dictionary specifiers</strong>.
|
|
The record and container specifiers are collectively referred to
|
|
as <strong>data product specifiers</strong>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Component-Definitions_Semantics">5.3.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The identifier is the name of the component.
|
|
The definitions inside the body of the component are
|
|
qualified with the component name, as for
|
|
<a href="#Definitions_Module-Definitions">module definitions</a>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The component members must satisfy the following rules:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>All names appearing in any general port specifiers, special port specifiers,
|
|
and internal port specifiers must be distinct.</p>
|
|
</li>
|
|
<li>
|
|
<p>All names appearing in any state machine instance specifier must
|
|
be distinct.</p>
|
|
</li>
|
|
<li>
|
|
<p>No passive component may have an <code>async</code> general or special
|
|
port specifier, an internal
|
|
port specifier, an <code>async</code> command specifier, or a state machine instance
|
|
specifier.</p>
|
|
</li>
|
|
<li>
|
|
<p>Each active or queued component must have at least one <code>async</code> general
|
|
or special port specifier, internal port specifier,
|
|
<code>async</code> command specifier, or state machine instance specifier.</p>
|
|
</li>
|
|
<li>
|
|
<p>Each component may have at most one of each special port kind.</p>
|
|
</li>
|
|
<li>
|
|
<p>Each component must provide ports as shown in the table below.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<table class="tableblock frame-all grid-all stretch">
|
|
<colgroup>
|
|
<col style="width: 50%;">
|
|
<col style="width: 50%;">
|
|
</colgroup>
|
|
<thead>
|
|
<tr>
|
|
<th class="tableblock halign-left valign-top">Condition</th>
|
|
<th class="tableblock halign-left valign-top">Requirement</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">If there are any command specifiers</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">There must be specifiers for ports <code>command recv</code>, <code>command reg</code>, and <code>command resp</code>.</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">If there are any event specifiers</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">There must be specifiers for ports <code>event</code>, <code>text event</code>, and <code>time get</code>.</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">If there are any parameter specifiers</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">There must be specifiers for ports <code>command recv</code>, <code>command reg</code>, <code>command resp</code>,
|
|
<code>param get</code>, and <code>param set</code>.</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">If there are any telemetry specifiers</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">There must be specifiers for ports <code>telemetry</code> and <code>time get</code>.</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">If there are any data product specifiers</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">There must be a specifier for either port <code>product</code> <code>get</code> or
|
|
port <code>product</code> <code>request</code>.
|
|
There must be specifiers for ports <code>product</code> <code>send</code> and <code>time</code> <code>get</code>.</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">If there is a specifier for <code>product</code> <code>request</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">There must be a specifier for port <code>product</code> <code>recv</code>.</p></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<div class="paragraph">
|
|
<p>The dictionary specifiers must satisfy the following rules:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>All commands must have distinct names and opcodes.</p>
|
|
</li>
|
|
<li>
|
|
<p>All events must have distinct names and identifier values.</p>
|
|
</li>
|
|
<li>
|
|
<p>All parameters must have distinct names and identifier values.</p>
|
|
</li>
|
|
<li>
|
|
<p>All telemetry channels must have distinct names and identifier values.</p>
|
|
</li>
|
|
<li>
|
|
<p>All records must have distinct names and identifier values.</p>
|
|
</li>
|
|
<li>
|
|
<p>All containers must have distinct names and identifier values.</p>
|
|
</li>
|
|
<li>
|
|
<p>If there are any container specifiers, then there must be at least one
|
|
record specifier, and vice versa.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Component-Definitions_Examples">5.3.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ Receives commands from the ground or from a sequencer
|
|
@ Dispatches commands to other components
|
|
active component CommandDispatcher {
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Constants
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ The number of com command input ports
|
|
constant numComCmdInPorts = 10
|
|
|
|
@ The number of command output ports
|
|
constant numCmdOutPorts = 20
|
|
|
|
# ----------------------------------------------------------------------
|
|
# General ports
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ Dispatches commands
|
|
output port cmdOut: [numCmdOutPorts] Fw.Cmd
|
|
|
|
@ Forwards received command responses
|
|
output port cmdResponseInOut: [numComCmdInPorts] Fw.CmdResponse
|
|
|
|
@ Receives com packets containing serialized commands
|
|
async input port comCmdIn: [numComCmdInPorts] Fw.Com
|
|
|
|
@ Receives command registration requests
|
|
guarded input port cmdRegIn: [numCmdOutPorts] Fw.CmdReg
|
|
|
|
@ Receives command responses
|
|
async input port cmdResponseIn: Fw.CmdResponse
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Special ports
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ Command receive port
|
|
command recv port cmdIn
|
|
|
|
@ Command registration port
|
|
command reg port cmdRegOut
|
|
|
|
@ Command response port
|
|
command resp cmdResponseOut
|
|
|
|
@ Event port
|
|
event port eventOut
|
|
|
|
@ Telemetry port
|
|
telemetry port tlmOut
|
|
|
|
@ Text event port
|
|
text event port textEventOut
|
|
|
|
@ Time get port
|
|
time get port timeGetOut
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Commands
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ No-op command
|
|
async command NO_OP
|
|
|
|
@ No-op string command
|
|
async command NO_OP_STRING(
|
|
arg1: string size 256 @< The string command argument
|
|
)
|
|
|
|
...
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Events
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ Opcode registered event
|
|
event OpcodeRegistered(
|
|
regOpcode: Opcode @< The opcode to register
|
|
regPort: U32 @< The registration port
|
|
dispatchSlot: U32 @< The dispatch slot
|
|
) severity diagnostic \
|
|
format "Opcode {} registered to port {} slot {}"
|
|
|
|
@ Opcode dispatched event
|
|
event OpcodeDispatched(
|
|
dispatchOpcode: Opcode @< The opcode dispatched
|
|
dispatchPort: U32 @< The dispatch port
|
|
) severity command \
|
|
format "Opcode {} dispatched to port {}"
|
|
|
|
...
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Telemetry
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ Number of commands dispatched
|
|
telemetry CommandsDispatched: U32 update on change
|
|
|
|
@ Number of command errors
|
|
telemetry CommandErrors: U32 update on change
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ Produces and sends images
|
|
active component Imager {
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Special ports
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ Command receive port
|
|
command recv port cmdIn
|
|
|
|
@ Command registration port
|
|
command reg port cmdRegOut
|
|
|
|
@ Command response port
|
|
command resp cmdResponseOut
|
|
|
|
@ Event port
|
|
event port eventOut
|
|
|
|
@ Telemetry port
|
|
telemetry port tlmOut
|
|
|
|
@ Text event port
|
|
text event port textEventOut
|
|
|
|
@ Time get port
|
|
time get port timeGetOut
|
|
|
|
@ Product request port
|
|
product request port productRequestOut
|
|
|
|
@ Product receive port
|
|
product recv port productRecvIn
|
|
|
|
@ Product send port
|
|
product send port productSendOut
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Commands
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ Take an image and send it as a data product
|
|
async command TAKE_IMAGE
|
|
|
|
...
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Events
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ Image taken
|
|
event ImageTaken severity activity low format "Image taken"
|
|
|
|
...
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Telemetry
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ Number of images taken
|
|
telemetry NumImagesTaken: U32 update on change
|
|
|
|
...
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Data products
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ A container for images
|
|
product container ImageContainer
|
|
|
|
@ A record for holding an image
|
|
product record ImageRecord: Image
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ A component with state machines
|
|
active component DeviceMgr {
|
|
|
|
# ----------------------------------------------------------------------
|
|
# State machines
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ A state machine representing a device
|
|
state machine Device {
|
|
|
|
@ Start the device
|
|
signal Start
|
|
|
|
@ Stop the device
|
|
signal Stop
|
|
|
|
@ Initial state is IDLE
|
|
initial enter IDLE
|
|
|
|
@ The IDLE state
|
|
state IDLE {
|
|
on Start enter RUNNING
|
|
}
|
|
|
|
@ The RUNNING state
|
|
state RUNNING {
|
|
on Stop enter IDLE
|
|
}
|
|
|
|
}
|
|
|
|
@ State machine instance for device 1
|
|
state machine instance device1: Device
|
|
|
|
@ State machine instance for device 2
|
|
state machine instance device2: Device
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Special ports
|
|
# ----------------------------------------------------------------------
|
|
|
|
...
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Commands
|
|
# ----------------------------------------------------------------------
|
|
|
|
@ Send a Start event to the specified device
|
|
async command START(
|
|
@ The device number
|
|
deviceNum: U8
|
|
)
|
|
|
|
@ Send a Stop event to the specified device
|
|
async command STOP(
|
|
@ The device number
|
|
deviceNum: U8
|
|
)
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_Component-Instance-Definitions">5.4. Component Instance Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>component instance definition</strong> defines an instance
|
|
of a
|
|
<a href="#Definitions_Component-Definitions">component</a>
|
|
that you can refer to in a
|
|
<a href="#Specifiers_Component-Instance-Specifiers">topology definition</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Component-Instance-Definitions_Syntax">5.4.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>instance</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>:</code>
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a>
|
|
<code>base</code> <code>id</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>[</em>
|
|
<code>type</code> <a href="#Expressions_String-Literals"><em>string-literal</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>at</code> <a href="#Expressions_String-Literals"><em>string-literal</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>queue</code> <code>size</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>stack</code> <code>size</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>priority</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>cpu</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>{</code> <em>init-specifier-sequence</em> <code>}</code>
|
|
<em>]</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>init-specifier-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in
|
|
which each element is an
|
|
<a href="#Specifiers_Init-Specifiers">init specifier</a>,
|
|
and the terminating punctuation is a semicolon.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Component-Instance-Definitions_Semantics">5.4.2. Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier names the component instance.</p>
|
|
</li>
|
|
<li>
|
|
<p>The qualified identifier must
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">refer to</a>
|
|
a
|
|
<a href="#Definitions_Component-Definitions">component definition <em>D</em></a>.
|
|
This component definition <em>D</em> is called the component definition
|
|
<strong>associated with</strong> the component instance <em>I</em>.
|
|
We also say that <em>I</em> is an instance of <em>D</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The expression following the keywords <code>base</code> <code>id</code> must have a
|
|
<a href="#Types_Internal-Types_Numeric-Types">numeric type</a>.
|
|
It associates a base identifier with the component instance.</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>The base identifier must evaluate to a nonnegative integer after
|
|
<a href="#Type-Checking_Type-Conversion">type conversion</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each component instance, for each
|
|
command, event, telemetry, or parameter identifier,
|
|
the identifier associated with the instance
|
|
is computed by adding the base identifier specified here to the relative
|
|
identifier specified in the component.
|
|
For this purpose, command opcodes are identifiers.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each instance, this procedure creates a range of identifiers,
|
|
from the base identifier to the largest identifier associated
|
|
with the instance.
|
|
If the component has no identifiers, then this range is empty.</p>
|
|
</li>
|
|
<li>
|
|
<p>No instance may have a base identifier that lies within
|
|
the identifier range of another instance.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>If present, the string literal following the keyword <code>type</code>
|
|
names the implementation type of the instance.
|
|
The type must be a valid type in the target language (e.g., a type name
|
|
in C++).
|
|
If the implementation type is not present, then the code generator
|
|
infers the name of the implementation type from the component name when
|
|
generating the constructor for the instance.
|
|
For example:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>Suppose an FPP model has a component <code>C</code> defined in module <code>M</code>.
|
|
Suppose <em>I</em> is an instance of component <code>M.C</code>.
|
|
By default, the implementation type associated with <em>I</em> is <code>M::C</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Specifying <code>type "M::D"</code> causes FPP to generate a
|
|
constructor for <em>I</em> with name <code>"M::D"</code> instead of <code>"M::C"</code>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Specifying an implementation type is useful in cases where the name
|
|
of the component implementation does not match the component
|
|
name, e.g., because there are several implementations of the
|
|
same FPP component.</p>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>If present, the string literal following the keyword <code>at</code>
|
|
must specify a file path, relative to the
|
|
<a href="#Translation-Units-and-Models_Locations">location</a>
|
|
of the component instance definition.
|
|
The file path must name a file in the target language (e.g., a C++
|
|
header file)
|
|
that provides the implementation associated with the instance.
|
|
If no such path is given, then the translator uses the location
|
|
of the component instance and the name of the component to generate
|
|
a default implementation path.</p>
|
|
</li>
|
|
<li>
|
|
<p>If present, the expression following the keywords <code>queue</code> <code>size</code> must
|
|
have a <a href="#Types_Internal-Types_Numeric-Types">numeric type</a>
|
|
and must evaluate to a nonnegative integer after
|
|
<a href="#Type-Checking_Type-Conversion">type conversion</a>.
|
|
It specifies the queue size for active and queued components.
|
|
The queue size is required for active and queued components
|
|
and is not allowed for passive components.</p>
|
|
</li>
|
|
<li>
|
|
<p>If present, the expression following the keywords <code>stack</code> <code>size</code> must
|
|
have a <a href="#Types_Internal-Types_Numeric-Types">numeric type</a>
|
|
and must evaluate to a nonnegative integer after
|
|
<a href="#Type-Checking_Type-Conversion">type conversion</a>.
|
|
It specifies the stack size in bytes for active components.
|
|
The stack size is optional for active components and is not allowed
|
|
for queued or passive components.</p>
|
|
</li>
|
|
<li>
|
|
<p>If present, the expression following the keyword <code>priority</code> must
|
|
have a <a href="#Types_Internal-Types_Numeric-Types">numeric type</a>.
|
|
It specifies the thread priority for active components.
|
|
The priority is optional for active components and is not allowed
|
|
for queued or passive components.</p>
|
|
</li>
|
|
<li>
|
|
<p>If present, the expression following the keyword <code>cpu</code> must
|
|
have a <a href="#Types_Internal-Types_Numeric-Types">numeric type</a>.
|
|
It specifies the CPU affinity for active components.
|
|
The CPU affinity is optional for active components and is not allowed
|
|
for queued or passive components.</p>
|
|
</li>
|
|
<li>
|
|
<p>If present, the init specifiers govern C++ code generation for
|
|
the component instance being defined.
|
|
See the section on
|
|
<a href="#Specifiers_Init-Specifiers">init specifiers</a>
|
|
for further information.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Component-Instance-Definitions_Examples">5.4.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">instance commandDispatcher: Svc.CommandDispatcher \
|
|
base id 0x100 \
|
|
queue size 10 \
|
|
stack size 4096 \
|
|
priority 30 \
|
|
cpu 0</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>This example defines an instance <code>commandDispatcher</code>
|
|
of component <code>Svc.CommandDispatcher</code>.
|
|
It specifies the base identifier, queue size, stack size,
|
|
priority, and CPU.</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">instance timer: Svc.Timer at "../../Timers/HardwareTimer.hpp"</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>This example defines an instance <code>timer</code> of component <code>Svc.Timer</code>.
|
|
It specifies that the component implementation is located at
|
|
path <code>../../Timers/HardwareTimer.hpp</code> instead of in the default location for the
|
|
component.
|
|
The path is resolved relative to the location of the instance definition.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_Constant-Definitions">5.5. Constant Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>constant definition</strong> associates a name with a compile-time constant
|
|
value. You can use the name in place of the value elsewhere in the
|
|
model.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Constant-Definitions_Syntax">5.5.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>constant</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>=</code>
|
|
<a href="#Expressions"><em>expression</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Constant-Definitions_Semantics">5.5.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p><em>expression</em> must
|
|
<a href="#Evaluation">evaluate</a>
|
|
to a compile-time constant value <em>v</em>. At any model point where the
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers">qualified identifier</a> <em>Q</em> refers to
|
|
the constant definition according to the
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">scoping
|
|
rules for names</a>, you can use <em>Q</em> as a name for <em>v</em>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Constant-Definitions_Examples">5.5.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 0 # a has value 0
|
|
constant b = 1.0 # b has value 1.0
|
|
constant c = a # c has value 0</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_Enum-Definitions">5.6. Enum Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>enum definition</strong> does two things:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>It defines a type \$T\$ and associates a name \$N\$ with \$T\$. Elsewhere
|
|
in the model, you can use \$N\$ to refer to \$T\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>It associates several named constants \$C_1, ..., C_n\$ with \$T\$.
|
|
These
|
|
constants, called the <strong>enumerated constants</strong> of \$T\$, are the values that
|
|
an expression of type \$T\$ may attain. Elsewhere in the model, you can
|
|
use the <a href="#Scoping-of-Names_Qualified-Identifiers">qualified
|
|
identifiers</a> \$N\$ <code>.</code> \$C_1, ..., N\$ <code>.</code> \$C_n\$
|
|
to refer to the enumerated
|
|
constants.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Enum-Definitions_Syntax">5.6.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>enum</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em> <code>:</code> <a href="#Type-Names"><em>type-name</em></a> <em>]</em>
|
|
<code>{</code> <em>enum-constant-sequence</em> <code>}</code>
|
|
<em>[</em>
|
|
<code>default</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>enum-constant-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in which the elements are
|
|
<a href="#Definitions_Enumerated-Constant-Definitions">enumerated
|
|
constant definitions</a>, and the terminating punctuation is a comma.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Enum-Definitions_Semantics">5.6.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The enumerated constants have the <a href="#Types_Enum-Types">enum type</a> defined in the
|
|
enum definition. During
|
|
<a href="#Analysis-and-Translation">analysis</a>, they are represented as values of
|
|
a primitive integer type, called the
|
|
<strong>representation type</strong>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>There must be at least one enumerated constant.
|
|
No two enumerated constants may have the same identifier.
|
|
Each enumerated constant must <a href="#Evaluation">evaluate</a> to
|
|
a compile-time constant whose type is
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a> the
|
|
representation type.
|
|
No two enumerated constants may have the same value after the conversion.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The expression following the keyword <code>default</code> is optional.
|
|
If present, it specifies the <a href="#Types_Default-Values">default value</a> associated
|
|
with the enum definition.
|
|
The type of the expression must be the type of the enum definition.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Enum-Definitions_Inferred-Representation-Type">5.6.3. Inferred Representation Type</h4>
|
|
<div class="paragraph">
|
|
<p>If <em>type-name</em> does not appear after the identifier, then
|
|
the implied representation type is <code>I32</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Enum-Definitions_Explicit-Representation-Type">5.6.4. Explicit Representation Type</h4>
|
|
<div class="paragraph">
|
|
<p>If <em>type-name</em> appears after the identifier, then the semantic
|
|
analyzer does the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Check that <em>type-name</em> names a <a href="#Types_Primitive-Integer-Types">primitive
|
|
integer type</a>.
|
|
If not, throw an error.</p>
|
|
</li>
|
|
<li>
|
|
<p>Use \$T\$ as the representation type.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Enum-Definitions_Examples">5.6.5. Examples</h4>
|
|
<div class="paragraph">
|
|
<p>The following example shows two definitions. In the first one, the implied
|
|
representation type is <code>I32</code>.
|
|
In the second one, the representation type is explicitly given as <code>U8</code>.</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">enum Gunfighters {
|
|
IL_BUONO
|
|
IL_BRUTTO
|
|
IL_CATTIVO
|
|
}
|
|
|
|
enum U8Gunfighters: U8 {
|
|
IL_BUONO
|
|
IL_BRUTTO
|
|
IL_CATTIVO
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The next example shows an enum definition with an explicit
|
|
default value.</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">enum Status {
|
|
YES
|
|
NO
|
|
MAYBE
|
|
} default MAYBE</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_Enumerated-Constant-Definitions">5.7. Enumerated Constant Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>enumerated constant definition</strong> is an element of an
|
|
<a href="#Definitions_Enum-Definitions">enum
|
|
definition</a>. Like a
|
|
<a href="#Definitions_Constant-Definitions">constant
|
|
definition</a>, it associates a value with a named constant. It also
|
|
establishes that the constant is one of the values of the type defined
|
|
in the enum definition.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Enumerated-Constant-Definitions_Syntax">5.7.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em>
|
|
<code>=</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Enumerated-Constant-Definitions_Semantics">5.7.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>If present, <em>expression</em> must
|
|
<a href="#Evaluation">evaluate</a>
|
|
to a compile-time constant value <em>v</em>. At any model point where the
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers">qualified identifier</a> <em>Q</em> refers to
|
|
the enumerated constant definition according to the
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">scoping
|
|
rules for names</a>, you can use <em>Q</em> as a name for the value that results
|
|
from converting <em>v</em> to the
|
|
<a href="#Definitions_Enum-Definitions_Semantics">type
|
|
of the enclosing enum definition</a>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The expression must be present or absent for all enumerated constant
|
|
definitions appearing in an
|
|
<a href="#Definitions_Enum-Definitions">enum definitions</a>.
|
|
If there are no expressions, then the enumerated constant definitions
|
|
are assigned increasing values starting with zero, as for
|
|
enumerations in C.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Note that the type of an enumerated constant value is the
|
|
<a href="#Types_Enum-Types">enum
|
|
type</a> defined by the enclosing enum definition. This may be
|
|
<a href="#Type-Checking_Type-Conversion">converted
|
|
to the representation type of the enum</a>. However, the reverse conversion
|
|
is not allowed: you can convert an enum type to a <code>U32</code> (for example),
|
|
but not a <code>U32</code> to an enum type. Nor can you convert one enum type to a
|
|
different one.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Enumerated-Constant-Definitions_Example">5.7.3. Example</h4>
|
|
<div class="paragraph">
|
|
<p>The
|
|
<a href="#Definitions_Enum-Definitions_Examples">examples
|
|
given for enum definitions</a> include enumerated constant definitions.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_Module-Definitions">5.8. Module Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>module definition</strong> provides a named scope that encloses and qualifies other
|
|
definitions, including other module definitions.
|
|
It is similar to a namespace in C++ or a package in Java or Scala.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Module-Definitions_Syntax">5.8.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>module</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>{</code> <em>module-member-sequence</em> <code>}</code></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>module-member-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in
|
|
which each element is a <strong>module member</strong>,
|
|
and the terminating punctuation is a semicolon.
|
|
A module member is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A <a href="#Definitions_Component-Definitions">component definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Definitions_Component-Instance-Definitions">component instance definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Definitions_Constant-Definitions">constant definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Definitions_Module-Definitions">module definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Definitions_Port-Definitions">port definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Definitions_Struct-Definitions">struct definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Definitions_Topology-Definitions">topology definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Specifiers_Location-Specifiers">location specifier</a></p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Definitions_Abstract-Type-Definitions">abstract type definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Definitions_Array-Definitions">array definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Definitions_Enum-Definitions">enum definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Specifiers_Include-Specifiers">include specifier</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Definitions_State-Machine-Definitions">state machine definition</a></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Module-Definitions_Semantics">5.8.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>A module definition <em>D</em> qualifies the names of all the definitions
|
|
inside it with its own name. Inside <em>D</em>, you can refer to definitions in
|
|
<em>D</em> by their unqualified name (the identifier appearing in the
|
|
definition) or by their qualified name. Outside <em>D</em>, you have to use the
|
|
qualified name. We say that the <strong>scope</strong> of the identifiers in the
|
|
definitions in <em>D</em> is limited to the inside of <em>D</em>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For further information about name scoping and qualification, see the
|
|
section on
|
|
<a href="#Scoping-of-Names">Scoping of Names</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Module-Definitions_Example">5.8.3. Example</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M {
|
|
constant a = 0
|
|
constant b = a # Inside M, we can refer to M.a as a
|
|
constant c = M.a # We can also say M.a here
|
|
}
|
|
constant d = M.a # Outside M, we have to say M.a
|
|
constant e = a # Error: a is not in scope here</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_Port-Definitions">5.9. Port Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>port definition</strong> defines an F Prime port.
|
|
A port is the endpoint of a connection between F Prime components.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Port-Definitions_Syntax">5.9.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>port</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em>
|
|
<code>(</code>
|
|
<a href="#Formal-Parameter-Lists"><em>param-list</em></a>
|
|
<code>)</code>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>-></code>
|
|
<a href="#Type-Names"><em>type-name</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Port-Definitions_Semantics">5.9.2. Semantics</h4>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>The identifier is the name of the port.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional parameter list specifies the formal parameters of the
|
|
port.
|
|
Each formal parameter is a piece of data carried on the port.
|
|
If there are no formal parameters, then the parameter list
|
|
may be omitted.</p>
|
|
</li>
|
|
<li>
|
|
<p>If the annotation <code>ref</code> appears in a formal parameter <em>P</em>,
|
|
then <em>P</em> is passed by reference in a synchronous port invocation
|
|
and by value in an asynchronous port invocation.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional type name appearing after the arrow specifies
|
|
an optional return type for the port.
|
|
If present, the return type is the type of the data returned
|
|
when the port is invoked in a synchronous context.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Port-Definitions_Examples">5.9.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ Port 1
|
|
port Port1(
|
|
a: U32 @< Parameter a
|
|
b: F64 @< Parameter b
|
|
)
|
|
|
|
@ Port 2
|
|
port Port2(
|
|
ref a: Fw.Com @< Ref parameter a
|
|
)
|
|
|
|
@ Port 3
|
|
port Port3(
|
|
a: U32 @< Parameter a
|
|
) -> U32</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_State-Machine-Definitions">5.10. State Machine Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>state machine definition</strong> defines a state machine.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>There are two kinds of state machine definitions:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>An <strong>external state machine definition</strong>
|
|
introduces a name and informs the FPP analyzer that
|
|
a state machine implementation with that name will be provided to the
|
|
FSW build.</p>
|
|
</li>
|
|
<li>
|
|
<p>An <strong>internal state machine definition</strong>
|
|
specifies the behavior of a state machine and
|
|
causes an implementation to be generated.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Implementation note:</strong>
|
|
As of FPP v2.2.1, only external state machine definitions are implemented.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_State-Machine-Definitions_Syntax">5.10.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>state machine</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em> <code>{</code> <em>state-machine-member-sequence</em> <code>}</code> <em>]</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>state-machine-member-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in
|
|
which each element is a <strong>state machine member</strong>,
|
|
and the terminating punctuation is a semicolon.
|
|
A state machine member is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A <a href="#State-Machine-Behavior-Elements_Choice-Definitions">choice definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#State-Machine-Behavior-Elements_Guard-Definitions">guard definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers">initial transition specifier</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#State-Machine-Behavior-Elements_Signal-Definitions">signal definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#State-Machine-Behavior-Elements_State-Definitions">state definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#State-Machine-Behavior-Elements_Action-Definitions">action definition</a></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The <strong>transitive members</strong> of a state machine definition <em>M</em> are
|
|
(1) the elements of <em>M</em> and (2)
|
|
the members of any state definition that is a transitive member of <em>M</em>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_State-Machine-Definitions_Static-Semantics">5.10.2. Static Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier is the name of the state machine.</p>
|
|
</li>
|
|
<li>
|
|
<p>If present, the optional state machine member sequence defines the
|
|
behavior of the state machine.
|
|
In this case, the state machine definition is internal.
|
|
If the state machine member sequence is absent, then the state machine
|
|
definition is external, i.e., the state machine
|
|
behavior is not specified in FPP.</p>
|
|
</li>
|
|
<li>
|
|
<p>If present, the optional state machine member sequence <em>M</em> must
|
|
satisfy the following rules:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p><em>M</em> must contain exactly one
|
|
<a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers">initial transition specifier</a>.
|
|
The initial transition occurs when the state machine starts up.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>M</em> must satisfy the rules described
|
|
<a href="#Definitions_State-Machine-Definitions_Static-Semantics_The-Transition-Graph">below</a>
|
|
for the induced transition graph.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>M</em> must satisfy the rules described
|
|
<a href="#Definitions_State-Machine-Definitions_Static-Semantics_Typed-Elements">below</a>
|
|
for typed elements.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="sect4">
|
|
<h5 id="Definitions_State-Machine-Definitions_Static-Semantics_The-Transition-Graph">The Transition Graph</h5>
|
|
<div class="paragraph">
|
|
<p>If present, the optional state machine member sequence <em>M</em>
|
|
induces a directed graph called the <strong>transition graph</strong>, defined as
|
|
follows:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The nodes of the transition graph are the state definitions and
|
|
choice definitions that are transitive members of <em>M</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The <strong>initial node</strong> of the transition graph is the state definition
|
|
or choice definition referred to in the unique initial transition specifier
|
|
that is an element of <em>M</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The arcs of the transition graph are given by the
|
|
<a href="#State-Machine-Behavior-Elements_Transition-Expressions">transition expressions</a> <em>e</em> that appear in (1) initial transition specifiers
|
|
that are members of states that are transitive members of <em>M</em> and (2)
|
|
state transition specifiers that are transitive members of <em>M</em> and (3)
|
|
choice definitions that are transitive members of <em>M</em>.
|
|
Each transition expression represents an arc from a <strong>start node</strong> to an
|
|
<strong>end node</strong>.
|
|
The start node is defined as follows:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>If <em>e</em> appears in an
|
|
<a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers">initial transition specifier</a> <em>I</em>, then the initial node is the
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions">state definition</a>
|
|
immediately enclosing <em>I</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>e</em> appears in a
|
|
<a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers">state transition specifier</a> <em>T</em>, then the initial
|
|
node is the
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions">state definition</a>
|
|
immediately enclosing <em>T</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>e</em> appears in a
|
|
<a href="#State-Machine-Behavior-Elements_Choice-Definitions">choice definition</a>
|
|
<em>J</em>, then the initial node is <em>J</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The terminal node is the state or choice definition
|
|
<a href="#Definitions_State-Machine-Definitions_Static-Semantics_Scoping-of-Names">referred to</a>
|
|
in <em>e</em>.</p>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>If the optional state machine member sequence is present, then
|
|
the transition graph <em>T</em> must satisfy the following rules:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Each state definition and each choice definition in
|
|
<em>T</em> must be reachable from the initial node of <em>T</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let <em>S</em> be the subgraph of <em>T</em> consisting of all
|
|
and only the choice definitions and the arcs whose start
|
|
and end nodes are choice definitions.
|
|
There must be no cycles in <em>S</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect4">
|
|
<h5 id="Definitions_State-Machine-Definitions_Static-Semantics_Typed-Elements">Typed Elements</h5>
|
|
<div class="paragraph">
|
|
<p>A <strong>typed element</strong> <em>e</em> is an
|
|
<a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers">initial transition specifier</a>,
|
|
a
|
|
<a href="#State-Machine-Behavior-Elements_State-Entry-Specifiers">state entry specifier</a>,
|
|
a
|
|
<a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers">state transition specifier</a>,
|
|
a
|
|
<a href="#State-Machine-Behavior-Elements_State-Exit-Specifiers">state exit specifier</a>,
|
|
or a
|
|
<a href="#State-Machine-Behavior-Elements_Choice-Definitions">choice definition</a>.
|
|
A typed element <em>e</em> <strong>points to</strong> a choice <em>J</em> if</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><em>e</em> is an initial transition specifier, and its transition expression
|
|
refers to <em>J</em>; or</p>
|
|
</li>
|
|
<li>
|
|
<p><em>e</em> is a state transition specifier with a transition expression that refers to
|
|
<em>J</em>; or</p>
|
|
</li>
|
|
<li>
|
|
<p><em>e</em> is a choice, and at least one of its transition expressions
|
|
refers to <em>J</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>It must be possible to assign <a href="#Type-Options">type options</a>
|
|
to all the typed elements in a state machine definition in
|
|
the following way.
|
|
If not, an error results.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The type option of each initial transition specifier, state entry
|
|
specifier, and state exit specifier is <em>None</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The type option of each state transition specifier <em>S</em> is the type
|
|
option specified in the definition of the signal specified in <em>S</em>
|
|
after the keyword <code>on</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The type option of a choice <em>J</em> is the
|
|
<a href="#Type-Options_Computing-a-Common-Type-Option_Lists-of-Type-Options">common type option</a> of the type options of the typed elements
|
|
that point to <em>J</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For each typed element <em>e</em></p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Let <em>O</em> be the type option assigned to <em>e</em> as described above.</p>
|
|
</li>
|
|
<li>
|
|
<p>For every action <em>A</em> appearing in the list of <code>do</code> actions specified in <em>e</em>,
|
|
<em>O</em> must be <a href="#Type-Options_Conversion-of-Type-Options">convertible to</a>
|
|
the type option specified in <em>A</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>For every guard <em>G</em> appearing in an <code>if</code> construct in <em>e</em>,
|
|
<em>O</em> must be <a href="#Type-Options_Conversion-of-Type-Options">convertible to</a>
|
|
the type option specified in <em>G</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect4">
|
|
<h5 id="Definitions_State-Machine-Definitions_Static-Semantics_Scoping-of-Names">Scoping of Names</h5>
|
|
<div class="paragraph">
|
|
<p>Inside the optional state machine member sequence, the following
|
|
rules govern the assignment of names to definitions and the resolution
|
|
of names in uses.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>State machine member definitions:</strong>
|
|
There are five kinds of <strong>state machine member definitions</strong>:
|
|
Action definitions, guard definitions, choice definitions, state
|
|
definitions, and state machine signal definitions.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Qualified names:</strong>
|
|
Each state machine member definition has an associated qualified
|
|
name.
|
|
Within a state machine member sequence,
|
|
the association of names to state machine member definitions is
|
|
the same as for <a href="#Scoping-of-Names_Names-of-Definitions">FPP definitions</a>,
|
|
after replacing “definition” with “state machine member definition.”</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For example:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">state machine S {
|
|
|
|
# Qualified name is A
|
|
action A
|
|
|
|
# Qualified name is S1
|
|
state S1 {
|
|
|
|
# Qualified name is S1.S2
|
|
state S2
|
|
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Conflicting names:</strong>
|
|
Each kind of definition resides in its own name group, except
|
|
that states and choices both reside in the state name group.
|
|
No two state machine definitions that reside in the same name group
|
|
may have the same qualified name.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Resolution of names:</strong>
|
|
Names are resolved in the ordinary way for
|
|
<a href="#Scoping-of-Names_Resolution-of-Identifiers">identifiers</a>
|
|
and
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">qualified identifiers</a> in FPP,
|
|
with the following modifications:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The top level is the state machine member sequence.</p>
|
|
</li>
|
|
<li>
|
|
<p>The definitions are the state machine member definitions.</p>
|
|
</li>
|
|
<li>
|
|
<p>Each kind of definition resides in its own name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>The brace-delimited definitions are state definitions.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_State-Machine-Definitions_Dynamic-Semantics">5.10.3. Dynamic Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>An internal state machine <em>M</em> has the following runtime behavior:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><em>M</em> maintains a current state <em>S</em>.
|
|
The current state is undefined until initialization occurs.
|
|
From that point on, the current state is always a leaf state.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>M</em> provides a function for initializing the state machine.
|
|
It runs the
|
|
<a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers_Dynamic-Semantics">behavior associated with the initial transition specifier of <em>M</em></a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each signal <em>s</em>, <em>M</em> provides a function for sending <em>s</em>.
|
|
This function has a typed argument with type <em>T</em> if and only if
|
|
the <a href="#State-Machine-Behavior-Elements_Signal-Definitions">definition of signal <em>s</em></a>
|
|
has type <em>T</em>.
|
|
It runs the
|
|
<a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers_Dynamic-Semantics">behavior associated with <em>s</em> in the current state <em>S</em></a>.
|
|
This behavior may cause one or more actions to be performed,
|
|
and it may cause the current state to change.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The functions are called by the code that is generated when a
|
|
state machine is <a href="#Specifiers_State-Machine-Instance-Specifiers">instantiated</a>
|
|
as part of an active or queued component.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_State-Machine-Definitions_Examples">5.10.4. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">state machine MonitorSm {
|
|
|
|
action doCalibrate
|
|
action init2
|
|
action motorControl
|
|
action reportFault
|
|
|
|
guard calibrateReady
|
|
|
|
signal Calibrate
|
|
signal Complete
|
|
signal Drive
|
|
signal Fault
|
|
signal RTI
|
|
signal Stop
|
|
|
|
initial enter DeviceOn
|
|
|
|
state DeviceOn {
|
|
|
|
initial do { init2 } enter Initializing
|
|
|
|
state Initializing {
|
|
on Complete enter Idle
|
|
}
|
|
|
|
state Idle {
|
|
on Drive enter Driving
|
|
on Calibrate if calibrateReady enter Calibrating
|
|
}
|
|
|
|
state Calibrating {
|
|
on RTI do { doCalibrate }
|
|
on Fault do { reportFault } enter Idle
|
|
on Complete enter Idle
|
|
}
|
|
|
|
state Driving {
|
|
on RTI do { motorControl }
|
|
on Stop enter Idle
|
|
}
|
|
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_Struct-Definitions">5.11. Struct Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>struct definition</strong> defines a new structure type and associates a name
|
|
with it.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Struct-Definitions_Syntax">5.11.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>struct</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>{</code> <em>struct-type-member-sequence</em> <code>}</code>
|
|
<em>[</em> <code>default</code> <a href="#Expressions"><em>expression</em></a> <em>]</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>struct-type-member-sequence</em> is an <a href="#Element-Sequences">element sequence</a>
|
|
in which the elements are struct type members, and the terminating
|
|
punctuation is a comma.
|
|
A <strong>struct type member</strong> has the following syntax:</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><a href="#Lexical-Elements_Identifiers"><em>identifier</em></a> <code>:</code>
|
|
<em>[</em>
|
|
<code>[</code> <a href="#Expressions"><em>expression</em></a> <code>]</code>
|
|
<em>]</em>
|
|
<a href="#Type-Names"><em>type-name</em></a>
|
|
<em>[</em>
|
|
<code>format</code> <a href="#Expressions_String-Literals"><em>string-literal</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Struct-Definitions_Semantics">5.11.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The identifier is the name <em>N</em> of the type. The definition associates the name
|
|
<em>N</em> with a
|
|
<a href="#Types_Struct-Types">struct type</a> <em>T</em> representing a structure with named members, each
|
|
of the specified type. Each
|
|
identifier appearing in the struct type member sequence must be distinct.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The optional expression <code>[</code> <em>e</em> <code>]</code> for a struct member specifies the
|
|
<strong>size</strong> of the member, i.e., the number of elements stored in the member.
|
|
If present, <em>e</em> must have a
|
|
<a href="#Types_Internal-Types_Numeric-Types">numeric type</a>, and it must
|
|
evaluate to a value greater than zero after conversion to
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>.
|
|
If <em>e</em> is not present, then default size is one.
|
|
If a member <em>m</em> has size greater than one, then <em>m</em>
|
|
is translated to an array in the implementation language.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The optional format specifier for a struct member specifies a
|
|
<a href="#Format-Strings">format string</a>.
|
|
The format is applied when displaying the struct member.
|
|
There is one argument to the format string, which is the member value.
|
|
If the size of the member is greater than one, then the
|
|
translator applies the format to each element.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The expression following the keyword <code>default</code> is optional.
|
|
If present, it specifies the <a href="#Types_Default-Values">default value</a>
|
|
associated with the type.
|
|
The type of the expression must be
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a> <em>T</em>.
|
|
If the expression specifies a value for a member with size
|
|
greater than one, then the value is applied to each element.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Struct-Definitions_Examples">5.11.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># Defines a struct type A with members x and y
|
|
# and default value { x = 0, y = 0 }
|
|
struct A {
|
|
x: U32
|
|
y: F32
|
|
}
|
|
|
|
# Defines a struct type B with members x and y
|
|
# and default value { x = 0, y = 1 }
|
|
struct B {
|
|
x: U32
|
|
y: F32
|
|
} default { y = 1 }
|
|
|
|
# Defines a struct type C with format specifiers
|
|
struct C {
|
|
x: U32 format "{} counts"
|
|
y: F32 format "{} m/s"
|
|
}
|
|
|
|
# Defines a struct type D with member x
|
|
# After translation, x is an array of 3 U32 elements
|
|
# The associated FPP struct type is { x: U32 }
|
|
# The default value of D stores 1 into each of the 3 elements of x
|
|
struct D {
|
|
x: [3] U32
|
|
} default { x = 1 }</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions_Topology-Definitions">5.12. Topology Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>topology definition</strong> defines an F Prime topology,
|
|
that is, a set of component instances and the connections
|
|
between their ports.
|
|
The connections are divided into named <strong>connection graphs</strong>.
|
|
The different graphs capture different aspects of FSW
|
|
function, such as commanding and telemetry.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>One topology can be imported into another one.
|
|
The connections are merged graph by graph.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Topology-Definitions_Syntax">5.12.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>topology</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>{</code> <em>topology-member-sequence</em> <code>}</code></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>topology-member-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in
|
|
which each element is a <strong>topology member</strong>,
|
|
and the terminating punctuation is a semicolon.
|
|
A topology member is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A <a href="#Specifiers_Component-Instance-Specifiers">component
|
|
instance specifier</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Specifiers_Connection-Graph-Specifiers">connection graph specifier</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Specifiers_Topology-Import-Specifiers">topology import specifier</a></p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Specifiers_Include-Specifiers">include specifier</a></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Topology-Definitions_Semantics">5.12.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>A topology definition <em>D</em> must be resolvable to a topology <em>T</em>,
|
|
according to the following algorithm:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Resolve <em>D</em> to a
|
|
<a href="#Definitions_Topology-Definitions_Semantics_Resolving-to-a-Partially-Numbered-Topology">partially numbered topology</a> <em>T'</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Apply
|
|
<a href="#Definitions_Topology-Definitions_Semantics_Automatic-Numbering-of-Ports">automatic numbering of ports</a>
|
|
to <em>T'</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="sect4">
|
|
<h5 id="Definitions_Topology-Definitions_Semantics_Resolving-to-a-Partially-Numbered-Topology">Resolving to a Partially Numbered Topology</h5>
|
|
<div class="paragraph">
|
|
<p>A <strong>partially numbered topology</strong> is a topology in which port number
|
|
assignments may or may not exist for each connection.
|
|
A port number assignment exists if
|
|
it is specified in the model source.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>For each endpoint <em>E</em> (output or input) in each connection <em>C</em>
|
|
appearing in <em>D</em>,
|
|
if <em>E</em> has a port number expression <em>e</em> in the FPP source, then
|
|
<a href="#Evaluation">evaluate</a> <em>e</em>,
|
|
<a href="#Type-Checking_Type-Conversion">convert</a> the result to a value <em>n</em> of type
|
|
<em>Integer</em>, and assign the port number <em>n</em> at that position.
|
|
Check that <em>n</em> is in bounds for the port instance being numbered.</p>
|
|
</li>
|
|
<li>
|
|
<p>Recursively resolve all the topologies directly imported into <em>D</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Construct the connection graphs of <em>T</em> given by the
|
|
<a href="#Specifiers_Connection-Graph-Specifiers">direct connection graphs</a>
|
|
appearing in
|
|
<em>D</em>, after merging each set of connection graphs with the same name into
|
|
a single graph.
|
|
For example, the two connection graphs</p>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">connections C { a.b -> c.d }</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>and</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">connections C { e.f -> g.h }</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>are treated as the single graph</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">connections C { a.b -> c.d, e.f -> g.h }</code></pre>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>Compute the set <em>S</em> of topologies transitively imported into <em>T</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each topology <em>T'</em> in <em>S</em>,
|
|
<a href="#Specifiers_Topology-Import-Specifiers">import the instances</a>
|
|
of <em>T'</em> into <em>T</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Check that the connections discovered in step 3 are between port
|
|
instances present in <em>T</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each topology <em>T'</em> in <em>S</em>,
|
|
<a href="#Specifiers_Topology-Import-Specifiers">import the connections</a>
|
|
of <em>T'</em> into <em>T</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Resolve
|
|
<a href="#Specifiers_Connection-Graph-Specifiers">graph pattern specifiers</a>,
|
|
adding connections to <em>T</em>.
|
|
Add only connections that are not already present in <em>T</em>.
|
|
For example, if a command pattern indicates a command
|
|
registration connection between two ports, and there is already
|
|
a command registration connection between those ports, then
|
|
do not add the connection.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect4">
|
|
<h5 id="Definitions_Topology-Definitions_Semantics_Automatic-Numbering-of-Ports">Automatic Numbering of Ports</h5>
|
|
<div class="paragraph">
|
|
<p>FPP automatically assigns port numbers as follows.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Check output port numbers:</strong>
|
|
At each output port <em>p</em> of each component instance <em>I</em>, check that</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The number of connections is in bounds for the
|
|
size of <em>I</em> <code>.</code> <em>p</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>There is no pair of connections \$c_1\$ and \$c_2\$
|
|
at the same port number of <em>I</em> <code>.</code> <em>p</em>.
|
|
For example, the following pair of connections is not allowed:</p>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">a.p[0] -> b.p
|
|
a.p[0] -> c.p</code></pre>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Apply matched numbering:</strong>
|
|
Assign matching numbers to matched pairs of ports.
|
|
For each instance <em>I</em> in the topology:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Let <em>C</em> be the component type of <em>I</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each
|
|
<a href="#Specifiers_Port-Matching-Specifiers">port matching specifier</a>
|
|
<code>match</code> \$p_1\$ <code>with</code> \$p_2\$ appearing in the definition of <em>C</em>:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>For each of <em>i</em> = 1 and <em>i</em> = 2, check that no two distinct connections
|
|
at <em>I</em> <code>.</code> \$p_i\$ have the same port number assigned to them.</p>
|
|
</li>
|
|
<li>
|
|
<p>Any connection that names <em>I</em> <code>.</code> \$p_1\$ or <em>I</em> <code>.</code> \$p_2\$
|
|
is <strong>match constrained</strong>. If a match constrained connection is marked
|
|
<code>unmatched</code> then it is <strong>unmatched</strong>; otherwise it is <strong>matched</strong>.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each matched connection \$c_1\$ with an endpoint at <em>I</em> <code>.</code> \$p_1\$:</p>
|
|
<div class="olist lowerroman">
|
|
<ol class="lowerroman" type="i">
|
|
<li>
|
|
<p>Let <em>I'</em> be the component instance at the other endpoint
|
|
of \$c_1\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Check that there is one and only one matched connection
|
|
\$c_2\$ between <em>I'</em> and <em>I</em> <code>.</code> \$p_2\$.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>Check that the connections \$c_2\$ computed in the previous
|
|
step are all the matched connections at <em>I</em> <code>.</code> \$p_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each pair \$(c_1,c_2)\$ computed in step c:</p>
|
|
<div class="olist lowerroman">
|
|
<ol class="lowerroman" type="i">
|
|
<li>
|
|
<p>If \$c_1\$ has a port number \$n_1\$ assigned at <em>I</em> <code>.</code> \$p_1\$ and
|
|
\$c_2\$ has a port number \$n_2\$ assigned at
|
|
<em>I</em> <code>.</code> \$p_2\$, then check that \$n_1 = n_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$c_1\$ has a port number <em>n</em> assigned at <em>I</em> <code>.</code> \$p_1\$,</p>
|
|
<div class="olist upperalpha">
|
|
<ol class="upperalpha" type="A">
|
|
<li>
|
|
<p>If no connection at <em>I</em> <code>.</code> \$p_2\$ has port number <em>n</em> assigned to it,
|
|
then assign <em>n</em> to \$c_2\$ at <em>I</em> <code>.</code> \$p_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise an error occurs.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$c_2\$ has a port number <em>n</em> assigned at <em>I</em> <code>.</code> \$p_2\$,</p>
|
|
<div class="olist upperalpha">
|
|
<ol class="upperalpha" type="A">
|
|
<li>
|
|
<p>If no connection at <em>I</em> <code>.</code> \$p_1\$ has port number <em>n</em> assigned to it,
|
|
then assign <em>n</em> to \$c_1\$ at <em>I</em> <code>.</code> \$p_1\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise an error occurs.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>Traverse the pairs \$(c_1,c_2)\$ computed in step c according to the
|
|
<a href="#Definitions_Topology-Definitions_Semantics_Ordering-of-Connections">order</a> of the connections \$c_1\$, least to greatest.
|
|
For each pair \$(c_1,c_2)\$ that does not yet have assigned
|
|
port numbers, find the lowest available port number
|
|
and assign it at <em>I</em> <code>.</code> \$p_1\$ and <em>I</em> <code>.</code> \$p_2\$.
|
|
A port number <em>n</em> is available if (a) <em>n</em> is in bounds for <em>I</em> <code>.</code> \$p_1\$
|
|
and <em>I</em> <code>.</code> \$p_2\$; and (b)
|
|
<em>n</em> is not already assigned to a connection at <em>I</em> <code>.</code> \$p_1\$; and (c)
|
|
<em>n</em> is not already assigned to a connection at <em>I</em> <code>.</code> \$p_2\$.
|
|
If no port number is available, then an error occurs.
|
|
Note that \$p_1\$ and \$p_2\$
|
|
<a href="#Specifiers_Port-Matching-Specifiers_Semantics">are required to have the
|
|
same size for their port arrays</a>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Apply general numbering:</strong>
|
|
Fill in any remaining port numbers.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Traverse the connections
|
|
<a href="#Definitions_Topology-Definitions_Semantics_Ordering-of-Connections">in order</a>, least to greatest.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each output endpoint <em>P</em> in each connection <em>C</em>,
|
|
if no port number is already assigned, then assign the lowest available port
|
|
number at position <em>P</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each input endpoint <em>P</em> in each connection <em>C</em>, if no port number is
|
|
already assigned, then assign the port number zero.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>See Example 4 in the <a href="#Definitions_Topology-Definitions_Examples">Examples section</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect4">
|
|
<h5 id="Definitions_Topology-Definitions_Semantics_Ordering-of-Connections">Ordering of Connections</h5>
|
|
<div class="paragraph">
|
|
<p>For purposes of port numbering, FPP orders connections as follows.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Connection endpoints:</strong>
|
|
A <strong>connection endpoint</strong> is <em>I</em> <code>.</code> <em>p</em> or <em>I</em> <code>.</code> <em>p</em> <code>[</code> <em>n</em> <code>]</code>, where</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><em>I</em> refers to a
|
|
<a href="#Definitions_Component-Instance-Definitions">component instance</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>p</em> is an identifier that names a port instance specified in
|
|
the component definition associated with <em>I</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>n</em> is an optional port number that is present if and only
|
|
if it appears in the model source.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>When a connection endpoint <em>e</em> has the form <em>I</em> <code>.</code> <em>p</em> <code>[</code> <em>n</em> <code>]</code>,
|
|
we say that the endpoint <strong>has source port number</strong> <em>n</em>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Each connection endpoint has a <strong>fully qualified name</strong>.
|
|
The fully qualified name is <em>Q</em> <code>.</code> <em>p</em>, where <em>Q</em> is the
|
|
<a href="#Scoping-of-Names_Names-of-Definitions">fully qualified name</a>
|
|
of the instance <em>I</em>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>FPP orders connection endpoints \$e_1\$ and \$e_2\$ as follows:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>If the fully qualified name of \$e_1\$ is lexically less
|
|
than (respectively greater than) the fully qualified name of
|
|
\$e_2\$, then \$e_1\$ is less than (respectively greater than) \$e_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$e_1\$ and \$e_2\$ have source port numbers
|
|
port numbers \$n_1\$ and \$n_2\$,
|
|
then the ordering of \$e_1\$
|
|
and \$e_2\$ is the same as the numerical ordering of \$n_1\$
|
|
and \$n_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise \$e_1\$ and \$e_2\$ are equal in the ordering.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Connections:</strong> A <strong>connection</strong> is \$e_1\$ <code>-></code>
|
|
\$e_2\$,
|
|
where \$e_1\$ and \$e_2\$ are the connection endpoints.
|
|
FPP orders connections \$c_1\$ and \$c_2\$ as follows:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Let connection \$c_1\$ be \$e_1\$ <code>-></code>
|
|
\$e'_1\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let connection \$c_2\$ be \$e_2\$ <code>-></code>
|
|
\$e'_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>If \$e_1\$ is less than (respectively greater than)
|
|
\$e_2\$,
|
|
then \$c_1\$ is less than (respectively greater than) \$c_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$e'_1\$ is less than (respectively greater than)
|
|
\$e'_2\$, then \$c_1\$ is less than (respectively greater than)
|
|
\$c_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise \$c_1\$ and \$c_2\$ are equal in the ordering.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Definitions_Topology-Definitions_Examples">5.12.3. Examples</h4>
|
|
<div class="paragraph">
|
|
<p><strong>Example 1.</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ Command and data handling topology
|
|
topology CDH {
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Public instances
|
|
# ----------------------------------------------------------------------
|
|
|
|
instance commandDispatcher
|
|
instance commandSequencer
|
|
instance engineeringRateGroup
|
|
instance engineeringTelemetryLogger
|
|
instance engineeringTelemetryConverter
|
|
instance engineeringTelemetrySplitter
|
|
instance eventLogger
|
|
instance rateGroupDriver
|
|
instance telemetryDatabase
|
|
instance timeSource
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Private instances
|
|
# ----------------------------------------------------------------------
|
|
|
|
private instance socketGroundInterface
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Connection patterns
|
|
# ----------------------------------------------------------------------
|
|
|
|
command connections instance commandDispatcher
|
|
event connections instance eventLogger
|
|
time connections instance timeSource
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Connection graphs
|
|
# ----------------------------------------------------------------------
|
|
|
|
connections CommandSequences {
|
|
commandSequencer.comCmdOut -> commandDispatcher.comCmdIn
|
|
}
|
|
|
|
connections Downlink {
|
|
eventLogger.comOut -> socketGroundInterface.comEventIn
|
|
telemetryDatabase.comOut -> socketGroundInterface.comTlmIn
|
|
}
|
|
|
|
connections EngineeringTelemetry {
|
|
commandDispatcher.tlmOut -> engineeringTelemetrySplitter.tlmIn
|
|
commandSequencer.tlmOut -> telemetryDatabase.tlmIn
|
|
engineeringRateGroup.tlmOut -> engineeringTelemetrySplitter.tlmIn
|
|
engineeringTelmetryConverter.comTlmOut -> engineeringTelemetryLogger.comTlmIn
|
|
engineeringTelemetrySplitter.tlmOut -> engineeringTelemetryConverter.tlmIn
|
|
engineeringTelemetrySplitter.tlmOut -> telemetryDatabase.tlmIn
|
|
}
|
|
|
|
connections RateGroups {
|
|
engineeringRateGroup.schedOut -> commandSequencer.schedIn
|
|
engineeringRateGroup.schedOut -> telemetryDatabase.schedIn
|
|
rateGroupDriver.cycleOut -> engineeringRateGroup.cycleIn
|
|
}
|
|
|
|
connections Uplink {
|
|
socketGroundInterface.comCmdOut -> commandDispatcher.comCmdIn
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example 2.</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ Attitude control topology
|
|
topology AttitudeControl {
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Imported topologies
|
|
# ----------------------------------------------------------------------
|
|
|
|
import CDH
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Public instances
|
|
# ----------------------------------------------------------------------
|
|
|
|
instance acsRateGroup
|
|
instance attitudeControl
|
|
...
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Private instances
|
|
# ----------------------------------------------------------------------
|
|
|
|
instance socketGroundInterface
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Connection patterns
|
|
# ----------------------------------------------------------------------
|
|
|
|
command connections instance commandDispatcher
|
|
event connections instance eventLogger
|
|
time connections instance timeSource
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Connection graphs
|
|
# ----------------------------------------------------------------------
|
|
|
|
connections AttitudeTelemetry {
|
|
...
|
|
}
|
|
|
|
connections Downlink {
|
|
eventLogger.comOut -> socketGroundInterface.comEventIn
|
|
telemetryDatabase.comOut -> socketGroundInterface.comTlmIn
|
|
}
|
|
|
|
connections EngineeringTelemetry {
|
|
acsRateGroup.tlmOut -> engineeringTelemetrySplitter.tlmIn
|
|
...
|
|
}
|
|
|
|
connections RateGroups {
|
|
acsRateGroup.schedOut -> attitudeControl.schedIn
|
|
}
|
|
|
|
connections Uplink {
|
|
socketGroundInterface.comCmdOut -> commandDispatcher.comCmdIn
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example 3.</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ Release topology
|
|
topology Release {
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Imported topologies
|
|
# ----------------------------------------------------------------------
|
|
|
|
import AttitudeControl
|
|
import CDH
|
|
import Communication
|
|
...
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example 4.</strong></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Here is the topology that results from automatic numbering of ports
|
|
applied to topology <code>B</code> in the
|
|
<a href="#Specifiers_Topology-Import-Specifiers_Example">example for topology import
|
|
specifiers</a>:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">topology B {
|
|
|
|
instance a
|
|
instance c
|
|
instance d
|
|
instance e
|
|
instance f
|
|
|
|
connections C1 {
|
|
a.p1[0] -> c.p[0]
|
|
a.p1[1] -> d.p[0]
|
|
}
|
|
|
|
connections C2 {
|
|
a.p2[0] -> e.p[0]
|
|
}
|
|
|
|
connections C3 {
|
|
a.p3[0] -> f.p[0]
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="State-Machine-Behavior-Elements">6. State Machine Behavior Elements</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>A <strong>state machine behavior element</strong> specifies an element of the behavior
|
|
associated with a
|
|
<a href="#Definitions_State-Machine-Definitions">state machine definition</a>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Implementation note:</strong>
|
|
As of FPP v2.2.1, state machine behavior elements are not implemented.</p>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="State-Machine-Behavior-Elements_Action-Definitions">6.1. Action Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>action definition</strong> is part of a
|
|
<a href="#Definitions_State-Machine-Definitions">state machine definition</a>.
|
|
It defines an action, i.e., a function that is called when
|
|
the enclosing state machine performs a
|
|
<a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers">transition from a state</a>
|
|
or passes through a
|
|
<a href="#State-Machine-Behavior-Elements_Choice-Definitions">choice</a>.
|
|
Actions may carry data.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Action-Definitions_Syntax">6.1.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>action</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em>
|
|
<code>:</code>
|
|
<a href="#Type-Names"><em>type-name</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Action-Definitions_Semantics">6.1.2. Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier specifies the name of the action.</p>
|
|
</li>
|
|
<li>
|
|
<p>If present, the optional type name specifies the type <em>T</em> associated
|
|
with the action.
|
|
A value of type <em>T</em> will be passed into the function associated with
|
|
the action when it is called.
|
|
If <em>type-name</em> is not present, then there is no data associated with the
|
|
action.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Action-Definitions_Examples">6.1.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">struct FaultData {
|
|
$id: U32
|
|
data: U32
|
|
}
|
|
|
|
@ A state machine with action definitions
|
|
state machine ActionDefs {
|
|
|
|
@ An action without data
|
|
action initPower
|
|
|
|
@ An action with data
|
|
action reportFault: FaultData
|
|
|
|
...
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="State-Machine-Behavior-Elements_Choice-Definitions">6.2. Choice Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>choice definition</strong> specifies a choice as part of a
|
|
<a href="#Definitions_State-Machine-Definitions">state machine definition</a>
|
|
or
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions">state definition</a>.
|
|
A choice is a branch point controlled by a
|
|
<a href="#State-Machine-Behavior-Elements_Guard-Definitions">guard</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Choice-Definitions_Syntax">6.2.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>choice</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>{</code>
|
|
<code>if</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a> <a href="#State-Machine-Behavior-Elements_Transition-Expressions"><em>transition-expression</em></a>
|
|
<code>else</code> <a href="#State-Machine-Behavior-Elements_Transition-Expressions"><em>transition-expression</em></a>
|
|
<code>}</code></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Choice-Definitions_Static-Semantics">6.2.2. Static Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier after the keyword <code>choice</code> is the name of the choice.</p>
|
|
</li>
|
|
<li>
|
|
<p>The identifier after the keyword <code>if</code> must
|
|
<a href="#Definitions_State-Machine-Definitions_Static-Semantics_Scoping-of-Names">refer</a>
|
|
to a
|
|
<a href="#State-Machine-Behavior-Elements_Guard-Definitions">guard definition</a>.
|
|
It specifies the guard that controls the branch.</p>
|
|
</li>
|
|
<li>
|
|
<p>Each of the transition expressions must be valid.
|
|
The first transition expression is run if the guard evaluates to <code>true</code>;
|
|
otherwise the second transition expression is run.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Choice-Definitions_Dynamic-Semantics">6.2.3. Dynamic Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>Each choice <em>J</em> has the following <strong>entry behavior</strong>:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Evaluate the guard of <em>J</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>J</em> evaluates to <code>true</code>, then
|
|
<a href="#State-Machine-Behavior-Elements_Transition-Expressions_Dynamic-Semantics">run the <code>if</code> transition expression in the context of <em>J</em></a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise run the <code>else</code> transition expression in the context of <em>J</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>If any of the guard or the transition expressions requires a typed argument
|
|
<em>v</em>, then according to the static semantics, <em>v</em> must be available,
|
|
and it must have a compatible type.
|
|
Use <em>v</em> to evaluate the guard or run the transition expression.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Choice-Definitions_Examples">6.2.4. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">state machine Device {
|
|
|
|
action initPower
|
|
guard coldStart
|
|
|
|
initial enter J1
|
|
|
|
choice J1 {
|
|
if coldStart enter OFF \
|
|
else do { initPower } enter ON
|
|
}
|
|
|
|
state OFF
|
|
|
|
state ON
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="State-Machine-Behavior-Elements_Do-Expressions">6.3. Do Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>do expression</strong> specifies a list of actions as part of an
|
|
<a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers">initial transition specifier</a>,
|
|
a <a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers">state transition specifier</a>,
|
|
a <a href="#State-Machine-Behavior-Elements_State-Entry-Specifiers">state entry specifier</a>,
|
|
a <a href="#State-Machine-Behavior-Elements_State-Exit-Specifiers">state exit specifier</a>,
|
|
or
|
|
a <a href="#State-Machine-Behavior-Elements_Choice-Definitions">choice definition</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Do-Expressions_Syntax">6.3.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>do</code> <code>{</code> <em>action-sequence</em> <code>}</code></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>action-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in
|
|
which each element is an <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
and the terminating punctuation is a comma.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Do-Expressions_Semantics">6.3.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>Each identifier in the action sequence must
|
|
<a href="#Definitions_State-Machine-Definitions_Static-Semantics_Scoping-of-Names">refer</a>
|
|
to an
|
|
<a href="#State-Machine-Behavior-Elements_Action-Definitions">action definition</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Do-Expressions_Examples">6.3.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">state machine Device {
|
|
|
|
action powerActuator
|
|
action powerGyro
|
|
action powerGimbal
|
|
|
|
state ON {
|
|
entry do {
|
|
powerActuator
|
|
powerGyro
|
|
powerGimbal
|
|
}
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="State-Machine-Behavior-Elements_Guard-Definitions">6.4. Guard Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>guard definition</strong> is part of a
|
|
<a href="#Definitions_State-Machine-Definitions">state machine definition</a>.
|
|
It defines a guard, i.e., a function that returns a Boolean value.
|
|
Guards are associated with
|
|
<a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers">state transitions</a>
|
|
and
|
|
<a href="#State-Machine-Behavior-Elements_Choice-Definitions">choices</a>.
|
|
If the guard evaluates to <code>true</code>, then the state transition occurs
|
|
or the branch of the choice is taken.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Guard-Definitions_Syntax">6.4.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>guard</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em>
|
|
<code>:</code>
|
|
<a href="#Type-Names"><em>type-name</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Guard-Definitions_Semantics">6.4.2. Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier specifies the name of the guard.</p>
|
|
</li>
|
|
<li>
|
|
<p>If present, the optional type name specifies the type <em>T</em> associated
|
|
with the guard.
|
|
A value of type <em>T</em> will be passed into the guard function when it is called.
|
|
If <em>type-name</em> is not present, then there is no data associated with the
|
|
guard.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Guard-Definitions_Examples">6.4.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">enum EnabledStatus { ENABLED, DISABLED }
|
|
|
|
struct FaultData {
|
|
status: EnabledStatus
|
|
$id: U32
|
|
data: U32
|
|
}
|
|
|
|
@ A state machine with guard definitions
|
|
state machine GuardDefs {
|
|
|
|
@ A guard without data
|
|
guard powerIsEnabled
|
|
|
|
@ A guard with data
|
|
guard faultProtectionIsEnabled: FaultData
|
|
|
|
...
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="State-Machine-Behavior-Elements_Initial-Transition-Specifiers">6.5. Initial Transition Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>initial transition specifier</strong> is part of a
|
|
<a href="#Definitions_State-Machine-Definitions">state machine definition</a>
|
|
or a
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions">state definition</a>.
|
|
It specifies an initial transition, i.e., a transition taken
|
|
when starting up a state machine or entering a state with
|
|
substates.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Initial-Transition-Specifiers_Syntax">6.5.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>initial</code>
|
|
<a href="#State-Machine-Behavior-Elements_Transition-Expressions"><em>transition-expression</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Initial-Transition-Specifiers_Static-Semantics">6.5.2. Static Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The state definition or choice definition referred to in the
|
|
transition expression must <strong>lead to a member</strong> of the same
|
|
state machine definition or state definition in which the initial
|
|
transition specifier appears.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>A state definition <em>D</em> leads to a member of a state machine definition <em>M</em>
|
|
(respectively a state <em>S</em>) if <em>D</em> is a member of <em>M</em> (respectively <em>S</em>).</p>
|
|
</li>
|
|
<li>
|
|
<p>A choice definition <em>D</em> leads to a member of a state machine definition <em>M</em>
|
|
(respectively as state <em>S</em>) if it is a member of <em>M</em> (respectively <em>S</em>)
|
|
and the state or choice definitions referred to in <em>D</em> lead to members of
|
|
<em>M</em> (respectively <em>S</em>).</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Initial-Transition-Specifiers_Dynamic-Semantics">6.5.3. Dynamic Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>To run an initial transition specifier <em>I</em> with transition expression <em>E</em>,
|
|
we <a href="#State-Machine-Behavior-Elements_Transition-Expressions_Dynamic-Semantics">run <em>E</em> in the context of <em>I</em></a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Initial-Transition-Specifiers_Examples">6.5.4. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">state machine Device {
|
|
|
|
action initDev1
|
|
action initDev2
|
|
|
|
# When the state machine starts up, enter the ON state
|
|
initial enter ON
|
|
|
|
state ON {
|
|
|
|
# When entering the ON state, enter the POWERING_UP substate
|
|
initial do {
|
|
initDev1
|
|
initDev2
|
|
} \
|
|
enter POWERING_UP
|
|
|
|
state POWERING_UP
|
|
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="State-Machine-Behavior-Elements_Signal-Definitions">6.6. Signal Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>signal definition</strong> is part of a
|
|
<a href="#Definitions_State-Machine-Definitions">state machine definition</a>.
|
|
It defines a signal that may be sent to the enclosing state machine.
|
|
Signals are inputs to state machines that cause state transitions
|
|
to occur.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Signals can be external or internal.
|
|
An external signal is sent to the state machine from outside,
|
|
e.g., by a command to an F Prime component.
|
|
An internal signal is sent by the state machine implementation
|
|
to itself.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>All signals sent to a state machine (internal and external)
|
|
are placed on a first-in first-out (FIFO) queue.
|
|
The state machine dequeues and processes signals when it is
|
|
entering a state, and after it has run the entry function
|
|
for that state.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Signal-Definitions_Syntax">6.6.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>signal</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em>
|
|
<code>:</code>
|
|
<a href="#Type-Names"><em>type-name</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Signal-Definitions_Semantics">6.6.2. Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier specifies the signal name.</p>
|
|
</li>
|
|
<li>
|
|
<p>If present, the optional type name specifies the type of the
|
|
data carried by the signal.
|
|
If <em>type-name</em> is not present, then the signal carries no data.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Signal-Definitions_Examples">6.6.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">struct FaultData {
|
|
$id: U32
|
|
data: U32
|
|
}
|
|
|
|
@ A state machine with signal definitions
|
|
state machine SignalDefs {
|
|
|
|
@ A signal without data
|
|
signal RTI
|
|
|
|
@ A signal with data
|
|
signal Fault: FaultData
|
|
|
|
...
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="State-Machine-Behavior-Elements_State-Definitions">6.7. State Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>state definition</strong> is part of a
|
|
<a href="#Definitions_State-Machine-Definitions">state machine definition</a>
|
|
or
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions">state definition</a>.
|
|
It defines a state of a state machine.
|
|
A state <em>S'</em> defined inside a state <em>S</em> expresses a hierarchy
|
|
of states: <em>S'</em> is a substate of <em>S</em>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Definitions_Syntax">6.7.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>state</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em> <code>{</code> <em>state-definition-member-sequence</em> <code>}</code> <em>]</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>state-definition-member-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in
|
|
which each element is a <strong>state definition member</strong>,
|
|
and the terminating punctuation is a semicolon.
|
|
A state definition member is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>An <a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers">initial transition specifier</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#State-Machine-Behavior-Elements_Choice-Definitions">choice definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#State-Machine-Behavior-Elements_State-Definitions">state definition</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers">state transition specifier</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#State-Machine-Behavior-Elements_State-Entry-Specifiers">state entry specifier</a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#State-Machine-Behavior-Elements_State-Exit-Specifiers">state exit specifier</a></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Definitions_Static-Semantics">6.7.2. Static Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier is the name of the state.</p>
|
|
</li>
|
|
<li>
|
|
<p>If the state definition member sequence <em>M</em> is present,
|
|
then it must obey the following rules:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>If <em>M</em> contains at least one state definition, then <em>M</em> must contain exactly
|
|
one initial transition specifier <em>I</em>.
|
|
<em>I</em> specifies the sub-state to enter on entry to the outer state.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>M</em> may not contain more than one state entry specifier.
|
|
If <em>M</em> has a state entry specifier <em>S</em>, then the <strong>entry actions</strong> of
|
|
<em>M</em> are the actions specified in <em>S</em>, in the order specified.
|
|
Otherwise <em>M</em> has no entry actions.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>M</em> may not contain more than one state exit specifier.
|
|
If <em>M</em> has a state exit specifier <em>S</em>, then the <strong>exit actions</strong> of
|
|
<em>M</em> are the actions specified in <em>S</em>, in the order specified.
|
|
Otherwise <em>M</em> has no exit actions.</p>
|
|
</li>
|
|
<li>
|
|
<p>No two <a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers">state
|
|
transition specifiers</a> that are members of <em>M</em> may
|
|
<a href="#Definitions_State-Machine-Definitions_Static-Semantics_Scoping-of-Names">refer</a> to the same
|
|
signal definition.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>If the state definition member sequence <em>M</em> is present and <em>M</em>
|
|
contains at least one state definition, then the
|
|
state definition is called an <strong>inner state definition</strong>.
|
|
Otherwise it is called a <strong>leaf state definition</strong>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Definitions_Dynamic-Semantics">6.7.3. Dynamic Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>Each state definition <em>S</em> has the following <strong>entry behavior</strong>:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Run the entry actions, if any, of <em>S</em>.
|
|
According to the static semantics, the entry actions must
|
|
not require a typed argument.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>S</em> is an inner state, then run the
|
|
<a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers_Dynamic-Semantics">behavior</a> of the initial transition of <em>S</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise set the current state of the state machine to <em>S</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Definitions_Examples">6.7.4. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">state machine MonitorSm {
|
|
|
|
action doCalibrate
|
|
action heaterOff
|
|
action heaterOn
|
|
action init1
|
|
action init2
|
|
action monitorOff
|
|
action monitorOn
|
|
action motorControl
|
|
action reportFault
|
|
action stopMotor
|
|
|
|
guard calibrateReady
|
|
|
|
signal Calibrate
|
|
signal Complete
|
|
signal Drive
|
|
signal Fault
|
|
signal RTI
|
|
signal Stop
|
|
|
|
initial enter DEVICE_ON
|
|
|
|
state DEVICE_ON {
|
|
|
|
initial do {
|
|
init1
|
|
init2
|
|
} \
|
|
enter INITIALIZING
|
|
|
|
state INITIALIZING {
|
|
on Complete enter IDLE
|
|
}
|
|
|
|
state IDLE {
|
|
entry do {
|
|
heaterOff
|
|
monitorOff
|
|
}
|
|
exit do {
|
|
heaterOn
|
|
monitorOn
|
|
}
|
|
on Drive enter DRIVING
|
|
on Calibrate if calibrateReady enter CALIBRATING
|
|
}
|
|
|
|
state CALIBRATING {
|
|
on RTI do { doCalibrate }
|
|
on Fault do { reportFault } enter Idle
|
|
on Complete enter IDLE
|
|
}
|
|
|
|
state DRIVING {
|
|
on RTI do { motorControl }
|
|
on Stop do { stopMotor } enter IDLE
|
|
}
|
|
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="State-Machine-Behavior-Elements_State-Entry-Specifiers">6.8. State Entry Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>state entry specifier</strong> is part of a
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions">state definition</a>.
|
|
It specifies the actions to take when entering the state.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Entry-Specifiers_Syntax">6.8.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>entry</code> <a href="#State-Machine-Behavior-Elements_Do-Expressions"><em>do-expression</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Entry-Specifiers_Semantics">6.8.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The do expression must be valid.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Entry-Specifiers_Examples">6.8.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">state machine Device {
|
|
|
|
action heaterOn
|
|
action monitorOn
|
|
|
|
state RUNNING {
|
|
entry do {
|
|
heaterOn
|
|
monitorOn
|
|
}
|
|
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="State-Machine-Behavior-Elements_State-Exit-Specifiers">6.9. State Exit Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>state exit specifier</strong> is part of a
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions">state definition</a>.
|
|
It specifies the actions to take when exiting the state.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Exit-Specifiers_Syntax">6.9.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>exit</code> <a href="#State-Machine-Behavior-Elements_Do-Expressions"><em>do-expression</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Exit-Specifiers_Semantics">6.9.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The do expression must be valid.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Exit-Specifiers_Examples">6.9.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">state machine Device {
|
|
|
|
action heaterOff
|
|
action monitorOff
|
|
|
|
state RUNNING {
|
|
exit do {
|
|
heaterOff
|
|
monitorOff
|
|
}
|
|
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="State-Machine-Behavior-Elements_State-Transition-Specifiers">6.10. State Transition Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>state transition specifier</strong> is part of a
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions">state definition</a>.
|
|
It specifies a transition from the state in which it appears.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Transition-Specifiers_Syntax">6.10.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>on</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em>
|
|
<code>if</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>]</em>
|
|
<em>transition-or-do</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>transition-or-do</em> is one of the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><a href="#State-Machine-Behavior-Elements_Transition-Expressions"><em>transition-expression</em></a></p>
|
|
</li>
|
|
<li>
|
|
<p><a href="#State-Machine-Behavior-Elements_Do-Expressions"><em>do-expression</em></a></p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Transition-Specifiers_Static-Semantics">6.10.2. Static Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier after the keyword <code>on</code> must
|
|
<a href="#Definitions_State-Machine-Definitions_Static-Semantics_Scoping-of-Names">refer</a>
|
|
to a
|
|
<a href="#State-Machine-Behavior-Elements_Signal-Definitions">signal definition</a>.
|
|
It names the signal that causes the transition to occur.</p>
|
|
</li>
|
|
<li>
|
|
<p>If present, the optional identifier after the keyword <code>if</code> must
|
|
<a href="#Definitions_State-Machine-Definitions_Static-Semantics_Scoping-of-Names">refer</a>
|
|
to a
|
|
<a href="#State-Machine-Behavior-Elements_Guard-Definitions">guard definition</a>.
|
|
It specifies a guard for the transition.</p>
|
|
</li>
|
|
<li>
|
|
<p>The first form of the <em>transition-or-do</em> syntax specifies an <strong>external
|
|
transition</strong>, i.e., an optional list of actions and a target state or choice.</p>
|
|
</li>
|
|
<li>
|
|
<p>The second form of the <em>transition-or-do</em> syntax specifies an
|
|
<strong>internal transition</strong>, i.e., a list of actions to take while remaining
|
|
in the same state.
|
|
The do expression must be valid.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Transition-Specifiers_The-State-Transition-Map">6.10.3. The State Transition Map</h4>
|
|
<div class="paragraph">
|
|
<p>The set of all state transition specifiers in a state machine
|
|
induces a <strong>state transition map</strong> <em>m: Signal x State → GuardedTransition</em>,
|
|
where a guarded transition is a pair consisting of an optional guard
|
|
and a transition or do expression.
|
|
The map <em>m</em> is constructed as follows.
|
|
Let <em>T</em> be a state transition specifier with signal <em>s</em>, optional guard <em>g</em>,
|
|
and transition or do expression <em>t</em>, defined in state <em>S</em>.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>If <em>S</em> is a leaf state, then <em>m</em> maps <em>(s, S)</em> to <em>(g, t)</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise, for each leaf state <em>S<sub>i</sub></em> that is transitively
|
|
contained in <em>S</em>, <em>m</em> maps <em>(s, S<sub>i</sub>)</em> to <em>(g, t)</em>, unless
|
|
the mapping is overridden.
|
|
Overriding occurs when another state <em>S'</em> that is transitively contained in <em>S</em>
|
|
maps <em>(s, S<sub>i</sub>)</em> to <em>(g',t')</em> according to items (1) or (2).
|
|
In that case, the mapping lower in the hierarchy takes precedence.
|
|
This overriding behavior is called <strong>behavioral polymorphism</strong>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Transition-Specifiers_Dynamic-Semantics">6.10.4. Dynamic Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>Let <em>M</em> be a state machine.
|
|
Suppose <em>M</em> is in state <em>S</em>.
|
|
Let <em>m</em> be the state transition map of <em>M</em>, defined in the previous section.
|
|
Let <em>s</em> be a signal of <em>M</em>.
|
|
<strong>Sending</strong> signal <em>s</em> to <em>M</em> results in the following behavior:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>If <em>(s,S)</em> is not in the domain of <em>m</em>, then do nothing.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>Let <em>(g,t) = m(s,S)</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Evaluate the guard <em>g</em>.
|
|
If the result is <code>false</code>, then do nothing.
|
|
Otherwise</p>
|
|
<div class="olist lowerroman">
|
|
<ol class="lowerroman" type="i">
|
|
<li>
|
|
<p>If <em>t</em> is a do expression <em>E</em>, then perform the actions
|
|
listed in <em>E</em>, if any, in the order listed.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise <em>t</em> is a transition expression <em>E</em>.
|
|
<a href="#State-Machine-Behavior-Elements_Transition-Expressions_Dynamic-Semantics">Run <em>E</em> in the context of <em>S</em></a>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>If any of the guard, do expression, or transition expression requires a
|
|
typed argument <em>v</em>, then according to the static semantics, <em>v</em> must
|
|
be available, and it must have a compatible type.
|
|
Use <em>v</em> to evaluate the guard, run the do expression, or run
|
|
the transition expression.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_State-Transition-Specifiers_Examples">6.10.5. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">state machine Device {
|
|
|
|
action performStuff
|
|
action powerHeater
|
|
action powerSensor
|
|
|
|
guard initComplete
|
|
|
|
signal PowerOn
|
|
signal RTI
|
|
|
|
initial enter OFF
|
|
|
|
state OFF {
|
|
on PowerOn if initComplete do {
|
|
powerHeater
|
|
powerSensor
|
|
} \
|
|
enter ON
|
|
}
|
|
|
|
state ON {
|
|
on RTI do { performStuff }
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="State-Machine-Behavior-Elements_Transition-Expressions">6.11. Transition Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>transition expression</strong> specifies a transition as part of an
|
|
<a href="#State-Machine-Behavior-Elements_Initial-Transition-Specifiers">initial transition</a>,
|
|
a <a href="#State-Machine-Behavior-Elements_State-Transition-Specifiers">state transition</a>,
|
|
or
|
|
a <a href="#State-Machine-Behavior-Elements_Choice-Definitions">choice</a>.
|
|
The transition performs zero or more actions and then
|
|
enters a state or choice.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Transition-Expressions_Syntax">6.11.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><em>[</em>
|
|
<a href="#State-Machine-Behavior-Elements_Do-Expressions"><em>do-expression</em></a>
|
|
<em>]</em>
|
|
<code>enter</code> <a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Transition-Expressions_Static-Semantics">6.11.2. Static Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The do expression specifies the list of actions to be
|
|
performed when making the transition.
|
|
If there are no actions, the do expression may be omitted.</p>
|
|
</li>
|
|
<li>
|
|
<p>The qualified identifier after the keyword <code>enter</code> must
|
|
<a href="#Definitions_State-Machine-Definitions_Static-Semantics_Scoping-of-Names">refer</a>
|
|
to a
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions">state definition</a>
|
|
or a
|
|
<a href="#State-Machine-Behavior-Elements_Choice-Definitions">choice definition</a>
|
|
It is the state or choice that is entered in the transition.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Transition-Expressions_Dynamic-Semantics">6.11.3. Dynamic Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>A transition expression <em>E</em> is run in the context of an
|
|
initial transition specifier, a leaf state definition,
|
|
or a choice definition.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>To run <em>E</em> in the context of an initial transition specifier
|
|
<em>I</em>, do the following:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>Perform the actions, if any, specified in <em>E</em>, in the order specified.</p>
|
|
</li>
|
|
<li>
|
|
<p>Run the entry behavior of the
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions_Dynamic-Semantics">state</a>
|
|
or
|
|
<a href="#State-Machine-Behavior-Elements_Choice-Definitions_Dynamic-Semantics">choice</a>
|
|
referred to in <em>E</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>According to the static semantics, actions and the entry behavior must not require
|
|
a typed argument.</p>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>To run <em>E</em> in the context of a leaf state definition or choice definition <em>D</em>,
|
|
do the following:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>Let <em>T</em> be the state or choice which is the target of <em>E</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let <em>P</em> be the <strong>lowest common ancestor</strong> of <em>D</em> and <em>T</em>.
|
|
The lowest common ancestor is defined as follows:</p>
|
|
<div class="olist lowerroman">
|
|
<ol class="lowerroman" type="i">
|
|
<li>
|
|
<p>A <strong>point in the state hierarchy</strong> is either the entire state machine
|
|
or a state definition.</p>
|
|
</li>
|
|
<li>
|
|
<p>The lowest common ancestor of <em>D</em> and <em>T</em> is the lowest
|
|
point in the state hierarchy such that (A)
|
|
by descending from <em>P</em> at least once it is possible to reach <em>D</em> and (B)
|
|
by descending from <em>P</em> at least once it is possible to reach <em>T</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>Ascend through the state hierarchy from <em>D</em> to <em>P</em>.
|
|
When passing out of a state <em>S</em>, perform the
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions_Static-Semantics">exit actions</a> of <em>S</em>, in the order specified.</p>
|
|
</li>
|
|
<li>
|
|
<p>Perform the actions, if any, specified in <em>E</em>, in the order specified.</p>
|
|
</li>
|
|
<li>
|
|
<p>Descend through the state hierarchy from <em>P</em> to the point just above <em>T</em>.
|
|
When passing into a state <em>S</em>, perform the
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions_Static-Semantics">entry actions</a> of <em>S</em>, in the order specified.</p>
|
|
</li>
|
|
<li>
|
|
<p>Run the entry behavior of the
|
|
<a href="#State-Machine-Behavior-Elements_State-Definitions_Dynamic-Semantics">state</a>
|
|
or
|
|
<a href="#State-Machine-Behavior-Elements_Choice-Definitions_Dynamic-Semantics">choice</a>
|
|
<em>T</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>According to the static semantics, if any of the actions or the
|
|
entry behavior requires a typed argument <em>v</em>, then <em>v</em> must
|
|
be available, and it must have a compatible type.
|
|
Use <em>v</em> to call the action or run the behavior.</p>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="State-Machine-Behavior-Elements_Transition-Expressions_Examples">6.11.4. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">state machine Device {
|
|
|
|
action initDev1
|
|
action initDev2
|
|
|
|
initial do {
|
|
initDev1
|
|
initDev2
|
|
} \
|
|
enter OFF
|
|
|
|
state OFF
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Specifiers">7. Specifiers</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>A <strong>specifier</strong> is a unit of syntax that specifies some information
|
|
about an FPP model.
|
|
It may associate a local name with the specification.
|
|
However, unlike a <a href="#Definitions">definition</a>, it does not
|
|
create a
|
|
<a href="#Scoping-of-Names_Names-of-Definitions">globally unique qualified name</a>.</p>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Command-Specifiers">7.1. Command Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>command specifier</strong> specifies a command as part of a
|
|
<a href="#Definitions_Component-Definitions">component definition</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Command-Specifiers_Syntax">7.1.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><em>command-kind</em> <code>command</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em>
|
|
<code>(</code> <a href="#Formal-Parameter-Lists"><em>param-list</em></a> <code>)</code>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>opcode</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>priority</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<em>queue-full-behavior</em>
|
|
<em>]</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>command-kind</em> is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><code>async</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>guarded</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>sync</code></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>queue-full-behavior</em> is as for
|
|
<a href="#Specifiers_Port-Instance-Specifiers">port instance specifiers</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Command-Specifiers_Semantics">7.1.2. Semantics</h4>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>The command kind specifies the kind of the command.
|
|
It is similar to the kind of a <a href="#Specifiers_Port-Instance-Specifiers">port instance specifier</a>, except that different commands
|
|
on the same port can have different kinds.</p>
|
|
</li>
|
|
<li>
|
|
<p>The identifier names the command.</p>
|
|
</li>
|
|
<li>
|
|
<p>The parameter list specifies the command parameters.
|
|
If there are command parameters, each parameter must be
|
|
a <a href="#Types_Displayable-Types">displayable type</a>.
|
|
If there are no parameters, the list may be omitted.
|
|
<code>ref</code> may not appear in any of the parameters.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> following <code>opcode</code> specifies the numeric
|
|
opcode for the command.
|
|
If <em>e</em> is present, its type must be convertible to
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>, and <em>e</em> must evaluate
|
|
to a nonnegative integer.
|
|
If <em>e</em> is not present, then the default opcode is either zero (for the first
|
|
opcode appearing in a component) or the previous opcode plus one.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> appearing after the keyword <code>priority</code> specifies
|
|
a priority for the command on the input queue.
|
|
The type of <em>e</em> must be <a href="#Type-Checking_Type-Conversion">convertible to</a>
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>.
|
|
The priority expression is valid only if the kind of the command is <code>async</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional <em>queue-full-behavior</em> specifies the behavior of the command
|
|
when the input full is queue.
|
|
This specifier is valid only if the kind of the command is <code>async</code>.
|
|
If no specifier appears, then the default behavior is <code>assert</code>.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Command-Specifiers_Examples">7.1.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ A sync command with no parameters
|
|
sync command SyncNoParams opcode 0x00
|
|
|
|
@ An async command with no parameters
|
|
async command AsyncNoParams opcode 0x01
|
|
|
|
@ A sync command with parameters
|
|
sync command SyncParams(
|
|
param1: U32 @< Param 1
|
|
param2: string @< Param 2
|
|
) opcode 0x02
|
|
|
|
@ An async command with parameters
|
|
async command AsyncParams(
|
|
param1: U32 @< Param 1
|
|
param2: string @< Param 2
|
|
) opcode 0x03
|
|
|
|
@ An async command with priority
|
|
async command AsyncPriority(
|
|
param1: U32 @< Param 1
|
|
param2: string @< Param 2
|
|
) opcode 0x04 priority 10
|
|
|
|
@ An async command with priority and drop on queue full
|
|
async command AsyncPriorityDrop(
|
|
param1: U32 @< Param 1
|
|
param2: string @< Param 2
|
|
) opcode 0x05 priority 10 drop</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Component-Instance-Specifiers">7.2. Component Instance Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>component instance specifier</strong>
|
|
specifies that a
|
|
<a href="#Definitions_Component-Instance-Definitions">component instance</a>
|
|
is part of a
|
|
<a href="#Definitions_Topology-Definitions">topology</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Component-Instance-Specifiers_Syntax">7.2.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><em>[</em> <code>private</code> <em>]</em>
|
|
<code>instance</code>
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Component-Instance-Specifiers_Semantics">7.2.2. Semantics</h4>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>The qualified identifier must
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">refer to</a>
|
|
a
|
|
<a href="#Definitions_Component-Instance-Definitions">component instance</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional keyword <code>private</code>, if present, specifies
|
|
a <strong>private instance</strong> of a topology.
|
|
This means that
|
|
the instance is private to the topology <em>T</em> in which
|
|
the specifier appears.
|
|
A private instance appears only in <em>T</em>; it does not appear
|
|
in any topology <em>T'</em> into which <em>T</em> is
|
|
<a href="#Specifiers_Topology-Import-Specifiers">imported</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If an instance is not declared private, then it is implicitly
|
|
a <strong>public instance</strong>. This means the instance
|
|
appears in each topology <em>T'</em> into which <em>T</em> is
|
|
<a href="#Specifiers_Topology-Import-Specifiers">imported</a>.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Component-Instance-Specifiers_Example">7.2.3. Example</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">component A { ... }
|
|
component B { ... }
|
|
component C { ... }
|
|
|
|
instance a: A base id 0x100 ...
|
|
instance b: B base id 0x200 ...
|
|
instance c: B base id 0x300 ...
|
|
|
|
Topology T {
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Public instances
|
|
# ----------------------------------------------------------------------
|
|
|
|
instance a
|
|
instance b
|
|
|
|
# ----------------------------------------------------------------------
|
|
# Private instances
|
|
# ----------------------------------------------------------------------
|
|
|
|
private instance c
|
|
|
|
...
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Connection-Graph-Specifiers">7.3. Connection Graph Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>connection graph specifier</strong> specifies one or more <strong>connection graphs</strong>
|
|
as part of a
|
|
<a href="#Definitions_Topology-Definitions">topology definition</a>.
|
|
A connection graph is a named set of <strong>connections</strong>.
|
|
A connection connects an <a href="#Specifiers_Port-Instance-Specifiers">output port
|
|
instance</a> of one
|
|
<a href="#Specifiers_Component-Instance-Specifiers">component instance</a>
|
|
to an
|
|
<a href="#Specifiers_Port-Instance-Specifiers">input port instance</a> of
|
|
another.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Connection-Graph-Specifiers_Syntax">7.3.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p>A connection graph specifier is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A <strong>direct graph specifier:</strong>
|
|
<code>connections</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>{</code> <em>connection-sequence</em> <code>}</code></p>
|
|
</li>
|
|
<li>
|
|
<p>A <strong>pattern graph specifier:</strong>
|
|
<em>pattern-kind</em>
|
|
<code>connections</code>
|
|
<code>instance</code> <a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a>
|
|
<em>[</em>
|
|
<code>{</code> <em>instance-sequence</em> <code>}</code>
|
|
<em>]</em></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>connection-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in
|
|
which each element is a <strong>connection</strong>,
|
|
and the terminating punctuation is a comma.
|
|
A connection is the following:</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>[</em>
|
|
<code>unmatched</code>
|
|
<em>]</em>
|
|
<a href="#Port-Instance-Identifiers"><em>port-instance-id</em></a>
|
|
<em>[</em>
|
|
<code>[</code>
|
|
<a href="#Expressions"><em>expression</em></a>
|
|
<code>]</code>
|
|
<em>]</em>
|
|
<code>-></code>
|
|
<a href="#Port-Instance-Identifiers"><em>port-instance-id</em></a>
|
|
<em>[</em>
|
|
<code>[</code>
|
|
<a href="#Expressions"><em>expression</em></a>
|
|
<code>]</code>
|
|
<em>]</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>pattern-kind</em> is one of the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><code>command</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>event</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>health</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>param</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>telemetry</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>text</code> <code>event</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>time</code></p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>instance-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in
|
|
which each element is a
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers">qualified identifier</a>,
|
|
and the terminating punctuation is a comma.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Connection-Graph-Specifiers_Semantics">7.3.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p><strong>Direct graph specifiers.</strong>
|
|
A direct graph specifier directly specifies a named connection graph.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier following the keyword <code>connections</code> names
|
|
the connection graph.</p>
|
|
</li>
|
|
<li>
|
|
<p>The connection sequence specifies the set of connections in the graph.
|
|
For each connection <em>C</em>:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>The optional keyword <code>unmatched</code> is allowed only if <em>C</em> is
|
|
<a href="#Definitions_Topology-Definitions_Semantics_Automatic-Numbering-of-Ports">match constrained</a>.
|
|
In this case, if the keyword <code>unmatched</code> is present, then <em>C</em> is
|
|
unmatched.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each of the two port instance identifiers <em>I</em> appearing in <em>C</em>:</p>
|
|
<div class="olist lowerroman">
|
|
<ol class="lowerroman" type="i">
|
|
<li>
|
|
<p>The component instance named in <em>I</em>
|
|
must be available in the enclosing topology,
|
|
either through
|
|
<a href="#Specifiers_Component-Instance-Specifiers">direct specification</a>
|
|
or through
|
|
<a href="#Specifiers_Topology-Import-Specifiers">import</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> following the identifier, if it is present,
|
|
represents a port number, i.e., an index into an
|
|
array of port instances.
|
|
The type of <em>e</em> must be a
|
|
<a href="#Types_Internal-Types_Numeric-Types">numeric type</a>, and
|
|
<em>e</em> must
|
|
<a href="#Evaluation">evaluate</a> to a compile-time constant
|
|
that becomes a non-negative integer <em>n</em> when
|
|
<a href="#Evaluation_Type-Conversion">converted to</a> type <em>Integer</em>.
|
|
<em>n</em> must lie in the range [0,2<sup>31</sup>) and must be in bounds for the
|
|
array size of the port instance specifier named in <em>I</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>The arrow represents the direction of the connection (left to right).</p>
|
|
</li>
|
|
<li>
|
|
<p>The connection must go from an
|
|
<a href="#Specifiers_Port-Instance-Specifiers">output port instance</a>
|
|
to an
|
|
<a href="#Specifiers_Port-Instance-Specifiers">input port instance</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The <a href="#Specifiers_Port-Instance-Specifiers">port instance types</a>
|
|
specified in the two port instances must match,
|
|
except that a <code>serial</code> port at either end can be connected
|
|
to any port at the other end.</p>
|
|
</li>
|
|
<li>
|
|
<p>If a <code>serial</code> port instance <em>S</em> is connected to a typed port
|
|
instance <em>T</em>, then the <a href="#Definitions_Port-Definitions">port type</a>
|
|
specified in <em>T</em> may not have a return type.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Pattern graph specifiers.</strong>
|
|
A pattern graph specifier indirectly specifies one or more named connection
|
|
graphs
|
|
by specifying a source component instance, a set of target component
|
|
instances, and a pattern for connecting the source instance to each of the
|
|
target instances.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Each topology may contain at most one of each kind of graph pattern.</p>
|
|
</li>
|
|
<li>
|
|
<p>The qualified identifier following the keyword <code>instance</code> must
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">refer to</a>
|
|
a component instance that is available in the enclosing topology,
|
|
either through
|
|
<a href="#Specifiers_Component-Instance-Specifiers">direct specification</a>
|
|
or through
|
|
<a href="#Specifiers_Topology-Import-Specifiers">import</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If the instance sequence <em>I</em> appears, then each qualified identifier
|
|
<em>Q</em> appearing in <em>I</em> must refer to a component instance that is available
|
|
in the enclosing topology, and each instance must be valid for the pattern
|
|
(i.e., must have a port of the type required for the pattern).
|
|
The instances in the sequence name the target instances for the
|
|
pattern. If no instance sequence appears, then the target instances are
|
|
all instances specified directly in the enclosing topology (not via import)
|
|
that are valid for the pattern.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The meaning of specifier depends on the pattern kind, as follows:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><code>command</code>: The source instance <em>I</em> is a command dispatcher.
|
|
The following connection graphs are generated:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>A connection graph named <code>Command</code> consisting of all connections
|
|
from the output port of type <code>Fw::Cmd</code> of <em>I</em> to the command input port
|
|
of each target component.</p>
|
|
</li>
|
|
<li>
|
|
<p>A connection graph named <code>CommandRegistration</code> consisting of all
|
|
connections from the command registration output port of
|
|
each target component
|
|
to the command registration input port of <em>I</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A connection graph named <code>CommandResponse</code> consisting of all connections
|
|
from the command response output port of each target component
|
|
to the command response input port of <em>I</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p><code>event</code>: The source instance <em>I</em> is an event logger
|
|
with an input port of type <code>Fw.Log</code>.
|
|
The generated connection graph has name <code>Events</code> and contains
|
|
all connections for sending events to <em>I</em> through an event
|
|
output port.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>health</code>: The source instance <em>I</em> is a health component.
|
|
The generated connection graph has name <code>Health</code> and contains
|
|
all connections between the health component and ping
|
|
ports of the target components of type <code>Svc.Ping</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>param</code>: The source instance <em>I</em> is a parameter database
|
|
component.
|
|
The generate connection graph has name <code>Parameters</code>
|
|
and contains all connections for (a) getting
|
|
parameters from the database and (b) saving
|
|
parameters to the database.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>telemetry</code>: The source instance <em>I</em> is a telemetry database
|
|
with an input port of type <code>Fw.Tlm</code>.
|
|
The generated connection graph has name <code>Telemetry</code>
|
|
and contains all connections for sending telemetry to <em>I</em>
|
|
through a telemetry output port.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>text event</code>: The source instance <em>I</em> is a text event
|
|
logger with an input port of type <code>Fw.LogText</code>.
|
|
The generated connection graph has name <code>TextEvents</code> and contains
|
|
all connections for sending events to <em>I</em> through an event
|
|
output port.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>time</code>: The source instance <em>I</em> is a time component.
|
|
The generated connection graph has name <code>Time</code> and contains
|
|
all connections for getting the time from <em>I</em> through
|
|
a time get output port.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Connection-Graph-Specifiers_Example">7.3.3. Example</h4>
|
|
<div class="paragraph">
|
|
<p>Assume the following instances are available in the enclosing topology,
|
|
and all have command ports:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">commandDispatcher
|
|
commandSequencer
|
|
engineeringTelemetryLogger
|
|
eventLogger
|
|
telemetryDatabase
|
|
timeSource</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Here is a pattern graph specifier:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">command connections instance commandDispatcher</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>It is equivalent to the following direct graph specifiers:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">connections CommandRegistration {
|
|
commandDispatcher.cmdRegOut -> commandDispatcher.cmdRegIn
|
|
commandSequencer.cmdRegOut -> commandDispatcher.cmdRegIn
|
|
engineeringTelemetryLogger.cmdRegOut -> commandDispatcher.cmdRegIn
|
|
eventLogger.cmdRegOut -> commandDispatcher.cmdRegIn
|
|
telemetryDatabase.cmdRegOut -> commandDispatcher.cmdRegIn
|
|
timeSource.cmdRegOut -> commandDispatcher.cmdRegIn
|
|
}
|
|
|
|
connections Command {
|
|
commandDispatcher.cmdOut -> commandDispatcher.cmdIn
|
|
commandDispatcher.cmdOut -> commandSequencer.cmdIn
|
|
commandDispatcher.cmdOut -> engineeringTelemetryLogger.cmdIn
|
|
commandDispatcher.cmdOut -> eventLogger.cmdIn
|
|
commandDispatcher.cmdOut -> telemetryDatabase.cmdIn
|
|
commandDispatcher.cmdOut -> timeSource.cmdIn
|
|
}
|
|
|
|
connections CommandResponse {
|
|
commandDispatcher.cmdRespOut -> commandDispatcher.cmdRespIn
|
|
commandSequencer.cmdRespOut -> commandDispatcher.cmdRespIn
|
|
engineeringTelemetryLogger.cmdRespOut -> commandDispatcher.cmdRespIn
|
|
eventLogger.cmdRespOut -> commandDispatcher.cmdRespIn
|
|
telemetryDatabase.cmdRespOut -> commandDispatcher.cmdRespIn
|
|
timeSource.cmdRespOut -> commandDispatcher.cmdRespIn
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>See also the <a href="#Definitions_Topology-Definitions_Examples">examples for topology
|
|
definitions</a>.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Container-Specifiers">7.4. Container Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>container specifier</strong> specifies a data product container as part of a
|
|
<a href="#Definitions_Component-Definitions">component definition</a>.
|
|
Containers are units of data that can be downlinked and then deleted.
|
|
They hold <a href="#Specifiers_Record-Specifiers">data product records</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Container-Specifiers_Syntax">7.4.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>product</code> <code>container</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em>
|
|
<code>id</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>default</code> <code>priority</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Container-Specifiers_Semantics">7.4.2. Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier names the container.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> after the keyword <code>id</code> specifies the
|
|
numeric identifier for the container.
|
|
If <em>e</em> is present, then the type of <em>e</em> must be
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a>
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>, and <em>e</em> must evaluate
|
|
to a nonnegative integer.
|
|
If <em>e</em> is not present, then the
|
|
default identifier is either zero (for the first container appearing in a
|
|
component) or the previous container identifier plus one.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> after the keywords <code>default</code> <code>priority</code>
|
|
specifies a downlink priority for the container.
|
|
This priority can be overridden by the command that downlinks the data.
|
|
If <em>e</em> is present, then the type of <em>e</em> must be
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a>
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>, and <em>e</em> must evaluate
|
|
to a nonnegative integer.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Container-Specifiers_Examples">7.4.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ Container 0
|
|
@ Implied id is 0x00
|
|
product container Container0
|
|
|
|
@ Container 1
|
|
product container Container1 id 0x02
|
|
|
|
@ Container 2
|
|
@ Implied id is 0x03
|
|
product container Container2 default priority 10</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Event-Specifiers">7.5. Event Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>event specifier</strong> specifies an event report as part of a
|
|
<a href="#Definitions_Component-Definitions">component definition</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Event-Specifiers_Syntax">7.5.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>event</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em>
|
|
<code>(</code> <a href="#Formal-Parameter-Lists"><em>param-list</em></a> <code>)</code>
|
|
<em>]</em>
|
|
<code>severity</code> <em>severity</em>
|
|
<em>[</em>
|
|
<code>id</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<code>format</code> <a href="#Expressions_String-Literals"><em>string-literal</em></a>
|
|
<em>[</em>
|
|
<code>throttle</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>severity</em> is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><code>activity</code> <code>high</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>activity</code> <code>low</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>command</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>diagnostic</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>fatal</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>warning</code> <code>high</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>warning</code> <code>low</code></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Event-Specifiers_Semantics">7.5.2. Semantics</h4>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>The identifier names the event.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>severity</em> specifies the severity of the event.</p>
|
|
</li>
|
|
<li>
|
|
<p>The parameter list specifies the event parameters.
|
|
If there are event parameters, each parameter must be
|
|
a <a href="#Types_Displayable-Types">displayable type</a>.
|
|
If there are no parameters, the list may be omitted.
|
|
<code>ref</code> may not appear in any of the parameters.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> following <code>id</code> specifies the numeric
|
|
identifier for the event.
|
|
If <em>e</em> is present, then the type of <em>e</em> must be convertible to
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>, and <em>e</em> must evaluate
|
|
to a nonnegative integer.
|
|
If <em>e</em> is not present, then the default identifier is either zero (for the
|
|
first
|
|
event appearing in a component) or the previous event identifier plus one.</p>
|
|
</li>
|
|
<li>
|
|
<p>The string following <code>format</code> is a
|
|
<a href="#Format-Strings">format string</a> that formats the event for display on the
|
|
ground. The arguments to the format string are the values bound to the event
|
|
parameters. A numeric format is allowed for any
|
|
argument whose type is a <a href="#Types_Internal-Types_Numeric-Types">numeric type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> following <code>throttle</code> specifies the maximum number
|
|
of times to emit the event before throttling it.
|
|
The type of <em>e</em> must be convertible to
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a> and must evaluate to an integer
|
|
in the range [0,2<sup>31</sup>).</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Event-Specifiers_Examples">7.5.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ An array of 3 F64 values
|
|
array F64x3 = [3] F64
|
|
|
|
@ An enumeration of cases
|
|
enum Case { A, B, C }
|
|
|
|
@ Event 0
|
|
event Event0 \
|
|
severity activity low \
|
|
id 0x00 \
|
|
format "Event 0 occurred"
|
|
|
|
@ Event 1
|
|
@ Sample output: "Event 1 occurred with argument 42"
|
|
event Event1(
|
|
arg1: U32 @< Argument 1
|
|
) \
|
|
severity activity high \
|
|
id 0x01 \
|
|
format "Event 1 occurred with argument {}"
|
|
|
|
@ Event 2
|
|
@ Sample output: "Saw value [ 0.001, 0.002, 0.003 ] for case A"
|
|
event Event2(
|
|
case: Case @< The case
|
|
value: F64x3 @< The value
|
|
) \
|
|
severity warning low \
|
|
id 0x02 \
|
|
format "Saw value {} for case {}" \
|
|
throttle 10</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Include-Specifiers">7.6. Include Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>include specifier</strong> specifies that a file
|
|
should be included in a
|
|
<a href="#Translation-Units-and-Models_Translation-Units">translation unit</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Include-Specifiers_Syntax">7.6.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>include</code> <a href="#Expressions_String-Literals"><em>string-literal</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Include-Specifiers_Semantics">7.6.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The string literal specifies a file path relative to the
|
|
<a href="#Translation-Units-and-Models_Locations">location</a> of the include specifier.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>During parsing, the translator does the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Resolve the path to an absolute file name that refers to a file <em>F</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Parse <em>F</em>, recursively resolving any include specifiers that appear in <em>F</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Include its parsed elements as if they appeared
|
|
in the enclosing translation unit at the point where the include
|
|
specifier appears.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The suffix <code>.fppi</code> is conventional for included files, to distinguish them
|
|
from files presented directly for analysis or translation.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Include-Specifiers_Examples">7.6.3. Examples</h4>
|
|
<div class="paragraph">
|
|
<p><strong>Example 1.</strong></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>File <code>a.fppi</code> contains the following:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 1</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>File <code>b.fpp</code> contains the following:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">include "a.fppi"
|
|
constant b = a</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>File <code>b.fpp</code> is translated identically to this translation unit:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 1
|
|
constant b = a</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example 2.</strong></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>File <code>a.fppi</code> contains the following:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 1</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>File <code>b.fpp</code> contains the following:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M { include "a.fppi" }
|
|
b = M.a</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>File <code>b.fpp</code> is translated identically to this translation unit:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M { constant a = 1 }
|
|
b = M.a</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Init-Specifiers">7.7. Init Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>init specifier</strong> associates some code with a
|
|
<a href="#Definitions_Component-Instance-Definitions">component instance</a>.
|
|
Usually this is initialization code, hence the name.
|
|
It may also serve another purpose (e.g., teardown).</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Init-Specifiers_Syntax">7.7.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>phase</code> <a href="#Expressions"><em>expression</em></a>
|
|
<a href="#Expressions_String-Literals"><em>string-literal</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Init-Specifiers_Semantics">7.7.2. Semantics</h4>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>The expression following the keyword <code>phase</code> must have
|
|
a <a href="#Types_Internal-Types_Numeric-Types">numeric type</a>.
|
|
It provides an integer identifier for an initialization phase.</p>
|
|
</li>
|
|
<li>
|
|
<p>Each component instance may have at most one init specifier
|
|
for each distinct numeric phase.</p>
|
|
</li>
|
|
<li>
|
|
<p>The code string specifies some code in a target language
|
|
that is associated with the instance.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The meaning of the initialization phase and the code depends
|
|
on the translation context.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Init-Specifiers_Example">7.7.3. Example</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ Phases of initialization
|
|
enum Phases {
|
|
@ When components are constructed
|
|
CONSTRUCTION
|
|
@ After components are constructed, and before connections are established
|
|
BEFORE_CONNECTIONS
|
|
@ After connections are established
|
|
AFTER_CONNECTIONS
|
|
@ When components are deallocated
|
|
TEARDOWN
|
|
}
|
|
|
|
instance commandDispatcher: Svc.CommandDispatcher \
|
|
base id 0x100 \
|
|
queue size 10 \
|
|
stack size 4096 \
|
|
priority 30 \
|
|
{
|
|
|
|
phase BEFORE_CONNECTIONS """
|
|
commandDispatcher.init(QueueDepth::commandDispatcher);
|
|
"""
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>In this example, the code generator provides three phases,
|
|
<code>CONSTRUCTION</code>, <code>BEFORE_CONNECTIONS</code>, <code>AFTER_CONNECTIONS</code>,
|
|
and <code>TEARDOWN</code>.
|
|
In the <code>CONSTRUCTION</code> phase, the code generator generates
|
|
a default constructor invocation that looks like this:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">Svc::CommandDispatcher commandDispatcher("commandDispatcher");</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>By default, the code generator might generate this code
|
|
to run before connections are established:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="c++">commandDispatcher.init(
|
|
QueueDepth::commandDispatcher,
|
|
InstanceID::commandDispatcher
|
|
);</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The code shown above overrides the code generated for the second
|
|
phase to remove the instance ID from the arguments of the <code>init</code> method.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Internal-Port-Specifiers">7.8. Internal Port Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>internal port specifier</strong> specifies
|
|
a single-use port for use in handlers of the enclosing
|
|
<a href="#Definitions_Component-Definitions">component</a>.
|
|
A component can use an internal port to send a message
|
|
to itself.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Internal-Port-Specifiers_Syntax">7.8.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>internal</code> <code>port</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em>
|
|
<code>(</code>
|
|
<a href="#Formal-Parameter-Lists"><em>param-list</em></a>
|
|
<code>)</code>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>priority</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<em>queue-full-behavior</em>
|
|
<em>]</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>queue-full-behavior</em> has the same syntax as for
|
|
<a href="#Specifiers_Port-Instance-Specifiers_Syntax">port instance specifiers</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Internal-Port-Specifiers_Semantics">7.8.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The identifier is the name of the port.
|
|
The parameter list specifies the formal parameters of the
|
|
port.
|
|
Each formal parameter is a piece of data carried on the port.
|
|
The names of the formal parameters must be distinct.
|
|
No formal parameter may be a <code>ref</code> parameter.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The optional priority and queue full behavior have the same semantics as in
|
|
<a href="#Specifiers_Port-Instance-Specifiers_Semantics">async input port instance
|
|
specifiers</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Internal-Port-Specifiers_Examples">7.8.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ Port 1
|
|
internal port Port1(
|
|
a: U32 @< Parameter a
|
|
b: F64 @< Parameter b
|
|
)
|
|
|
|
@ Port 2
|
|
internal port Port2(
|
|
a: U8 @< Parameter a
|
|
b: I32 @< Parameter b
|
|
) priority 10 drop</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Location-Specifiers">7.9. Location Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>location specifier</strong> specifies the
|
|
<a href="#Translation-Units-and-Models_Locations">location</a>
|
|
of a <a href="#Definitions">definition</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Location-Specifiers_Syntax">7.9.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p>A location specifier is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A <strong>component instance location specifier</strong> <code>locate</code> <code>instance</code>
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a> <code>at</code>
|
|
<a href="#Expressions_String-Literals"><em>string-literal</em></a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <strong>component location specifier</strong> <code>locate</code> <code>component</code>
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a> <code>at</code>
|
|
<a href="#Expressions_String-Literals"><em>string-literal</em></a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <strong>constant location specifier</strong> <code>locate</code> <code>constant</code>
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a> <code>at</code>
|
|
<a href="#Expressions_String-Literals"><em>string-literal</em></a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <strong>port location specifier</strong> <code>locate</code> <code>port</code>
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a> <code>at</code>
|
|
<a href="#Expressions_String-Literals"><em>string-literal</em></a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <strong>state machine location specifier</strong> <code>locate</code> <code>state</code> <code>machine</code>
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a> <code>at</code>
|
|
<a href="#Expressions_String-Literals"><em>string-literal</em></a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <strong>topology location specifier</strong> <code>locate</code> <code>topology</code>
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a> <code>at</code>
|
|
<a href="#Expressions_String-Literals"><em>string-literal</em></a></p>
|
|
</li>
|
|
<li>
|
|
<p>A <strong>type location specifier</strong> <code>locate</code> <code>type</code>
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a> <code>at</code>
|
|
<a href="#Expressions_String-Literals"><em>string-literal</em></a></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Location-Specifiers_Semantics">7.9.2. Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The qualified identifier <em>Q</em> is resolved like a
|
|
<a href="#Definitions-and-Uses_Uses">use</a> that refers to a <a href="#Definitions">definition</a>
|
|
as follows:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>A constant location specifier refers to a
|
|
<a href="#Definitions_Constant-Definitions">constant definition</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A type location specifier refers to an
|
|
<a href="#Definitions_Array-Definitions">array definition</a>,
|
|
<a href="#Definitions_Enum-Definitions">enum definition</a>,
|
|
<a href="#Definitions_Struct-Definitions">struct definition</a>, or
|
|
<a href="#Definitions_Abstract-Type-Definitions">abstract type definition</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A port location specifier refers to a
|
|
<a href="#Definitions_Port-Definitions">port definition</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A component location specifier refers to a
|
|
<a href="#Definitions_Component-Definitions">component definition</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A component instance location specifier refers to a
|
|
<a href="#Definitions_Component-Instance-Definitions">component instance definition</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A topology location specifier refers to a
|
|
<a href="#Definitions_Topology-Definitions">topology definition</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A state machine location specifier refers to a
|
|
<a href="#Definitions_State-Machine-Definitions">state machine definition</a>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>When a location specifier appears inside a
|
|
<a href="#Definitions_Module-Definitions">module definition <em>M</em></a>,
|
|
<em>Q</em> is implicitly qualified by the
|
|
<a href="#Scoping-of-Names_Names-of-Definitions">qualified name</a>
|
|
of <em>M</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>Q</em> need not actually refer to any definition.
|
|
This rule allows the specification of dependencies for a larger set
|
|
of files than the ones involved in a particular analysis
|
|
or translation.</p>
|
|
</li>
|
|
<li>
|
|
<p>The string literal must specify the path of an FPP source file, relative to the
|
|
<a href="#Translation-Units-and-Models_Locations">location</a>
|
|
of the specifier.
|
|
The file must exist.
|
|
After resolving
|
|
<a href="#Specifiers_Include-Specifiers">include specifiers</a>,
|
|
the file must contain the definition referred to in the
|
|
location specifier.</p>
|
|
</li>
|
|
<li>
|
|
<p>Multiple location specifiers for the same definition are allowed in a single
|
|
<a href="#Translation-Units-and-Models_Models">model</a>, so long as the locations are all
|
|
consistent.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Location-Specifiers_Examples">7.9.3. Examples</h4>
|
|
<div class="paragraph">
|
|
<p><strong>Example 1:</strong></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>File <code>a.fpp</code> contains the following:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 1</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>File <code>b.fpp</code> contains the following:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">locate constant a at "a.fpp"
|
|
constant b = a</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>When analyzing <code>b.fpp</code>, the analyzer knows that the definition of constant
|
|
<code>a</code> is available in <code>a.fpp</code>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example 2:</strong></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>File <code>a.fpp</code> is as in the previous example.
|
|
File <code>b.fpp</code> contains the following:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M { constant b = 0 }</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>File <code>c.fpp</code> contains the following:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">locate constant a at "a.fpp"
|
|
module M { locate constant b at "b.fpp" }</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The first location specifier refers to the constant <code>a</code>.
|
|
The second location specifier refers to the constant <code>M.b</code>.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Parameter-Specifiers">7.10. Parameter Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>parameter specifier</strong> specifies a parameter as part of a
|
|
<a href="#Definitions_Component-Definitions">component definition</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Parameter-Specifiers_Syntax">7.10.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>param</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>:</code> <a href="#Type-Names"><em>type-name</em></a>
|
|
<em>[</em>
|
|
<code>default</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>id</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>set</code> <code>opcode</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>save</code> <code>opcode</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Parameter-Specifiers_Semantics">7.10.2. Semantics</h4>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>The identifier names the parameter.</p>
|
|
</li>
|
|
<li>
|
|
<p>The type name specifies the type <em>T</em> of the parameter.
|
|
<em>T</em> must be a <a href="#Types_Displayable-Types">displayable type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> following the keyword <code>default</code>
|
|
specifies a default value for the parameter.
|
|
If <em>e</em> is present, then the type of <em>e</em> must be
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a> <em>T</em>.
|
|
If <em>e</em> is not present, then there is no default value for
|
|
the parameter:
|
|
When the parameter is used, then either (1) a value is
|
|
available in the parameter database or (2) the use is
|
|
invalid.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> after the keyword <code>id</code> specifies the
|
|
numeric identifier for the parameter.
|
|
If <em>e</em> is present, then the type of <em>e</em> must be
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a>
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>, and <em>e</em> must evaluate
|
|
to a nonnegative integer.
|
|
If <em>e</em> is not present, then the
|
|
default identifier is either zero (for the first parameter appearing in a
|
|
component) or the previous parameter identifier plus one.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> after the keywords <code>set</code> <code>opcode</code> specifies the
|
|
opcode of the command for setting the parameter.
|
|
If <em>e</em> is present, then the type of <em>e</em> must be
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a>
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>.
|
|
If <em>e</em> is not present, then the default value is either zero (for
|
|
the first command appearing in a component) or the previous opcode
|
|
plus one.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> after the keywords <code>save</code> <code>opcode</code> specifies
|
|
the opcode of the command for saving the parameter.
|
|
If <em>e</em> is present, then the type of <em>e</em> must be
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a>
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>.
|
|
If <em>e</em> is not present, then the default value is either zero (for
|
|
the first command appearing in a component) or the previous opcode
|
|
plus one.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Parameter-Specifiers_Examples">7.10.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ Parameter 1
|
|
param Parameter1: U32 \
|
|
id 0x00 \
|
|
set opcode 0x80 \
|
|
save opcode 0x81
|
|
|
|
@ Parameter 2
|
|
param Parameter2: F64 \
|
|
default 1.0 \
|
|
id 0x01 \
|
|
set opcode 0x82 \
|
|
save opcode 0x83</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Port-Instance-Specifiers">7.11. Port Instance Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>port instance specifier</strong> specifies an instantiated
|
|
<a href="#Definitions_Port-Definitions">port</a> as part
|
|
of a
|
|
<a href="#Definitions_Component-Definitions">component definition</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Port-Instance-Specifiers_Syntax">7.11.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p>A port instance specifier is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><em>general-port-kind</em> <code>port</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a> <code>:</code>
|
|
<em>[</em>
|
|
<code>[</code> <a href="#Expressions"><em>expression</em></a> <code>]</code>
|
|
<em>]</em>
|
|
<em>port-instance-type</em>
|
|
<em>[</em>
|
|
<code>priority</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<em>queue-full-behavior</em>
|
|
<em>]</em></p>
|
|
</li>
|
|
<li>
|
|
<p><em>[</em> <em>special-port-input-kind</em> <em>]</em>
|
|
<em>special-port-kind</em> <code>port</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<em>[</em>
|
|
<code>priority</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<em>queue-full-behavior</em>
|
|
<em>]</em></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>general-port-kind</em> is one of the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><code>async</code> <code>input</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>guarded</code> <code>input</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>output</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>sync</code> <code>input</code></p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>port-instance-type</em> is one of the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a></p>
|
|
</li>
|
|
<li>
|
|
<p><code>serial</code></p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>queue-full-behavior</em> is one of the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><code>assert</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>block</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>drop</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>hook</code></p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>special-port-input-kind</em> is one of the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><code>async</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>guarded</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>sync</code></p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>special-port-kind</em> is one of the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><code>command</code> <code>recv</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>command</code> <code>reg</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>command</code> <code>resp</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>event</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>param</code> <code>get</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>param</code> <code>set</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>product</code> <code>get</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>product</code> <code>recv</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>product</code> <code>request</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>product</code> <code>send</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>telemetry</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>text</code> <code>event</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>time</code> <code>get</code></p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The following port instances are <strong>input port instances</strong>:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>Any general port with <code>input</code> in its name.</p>
|
|
</li>
|
|
<li>
|
|
<p>Special ports <code>command recv</code> and <code>product recv</code>.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The others are <strong>output port instances</strong>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Port-Instance-Specifiers_Semantics">7.11.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p><strong>General port instances:</strong></p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The kind specifies the kind of the port instance.</p>
|
|
</li>
|
|
<li>
|
|
<p>The identifier specifies the name of the port instance.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> enclosed in brackets specifies the
|
|
number of port instances in the port instance array.
|
|
If no such expression appears, the default value is 1.
|
|
The type of <em>e</em> must be <a href="#Type-Checking_Type-Conversion">convertible to</a>
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>.
|
|
<em>e</em> must
|
|
<a href="#Evaluation">evaluate</a> to a value <em>n</em> after
|
|
<a href="#Evaluation_Type-Conversion">conversion</a> to <em>Integer</em>.
|
|
<em>n</em> must be greater than zero.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>port-instance-type</em> specifies the type of the port instance.</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>If the type is a qualified identifier <em>q</em>, then <em>q</em> must
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">refer</a> to a
|
|
<a href="#Definitions_Port-Definitions">port definition <em>D</em></a>.
|
|
If the kind is <code>async input</code>, then <em>D</em>
|
|
may not specify a return type.</p>
|
|
</li>
|
|
<li>
|
|
<p>If the type is <code>serial</code>, then the port instance is a <strong>serial
|
|
port instance</strong>.
|
|
A serial port instance does not specify a type.
|
|
It may be connected to a port of any type.
|
|
Serial data passes through the port.
|
|
The data may be converted to or
|
|
from a specific type at the other end of the connection.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> appearing after the keyword
|
|
<code>priority</code> specifies a priority for the port instance.
|
|
The type of <em>e</em> must be <a href="#Type-Checking_Type-Conversion">convertible to</a>
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>.
|
|
The priority applies to the component’s message queue and may appear only for
|
|
<code>async input</code> ports.
|
|
The meaning of the priority value is operating system-dependent.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional <em>queue-full-behavior</em> specifies the behavior when a
|
|
message is received and the queue is full:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p><code>assert</code> means that an assertion fails, terminating FSW.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>block</code> means that the sender is blocked until there is
|
|
space on the queue for the message.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>drop</code> means that the message is dropped.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>hook</code> means that the message is passed to a user-supplied hook function.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>This specifier is valid only for <code>async input</code> ports.
|
|
If no specifier appears, then the default behavior is <code>assert</code>.</p>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Special port instances:</strong>
|
|
The special port instance have special functions in the code generated
|
|
from an FPP model.
|
|
The types and other attributes of the special ports are specified by F Prime.
|
|
The identifier specifies the name of the port.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>There must be at most one of each kind of special port instance.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The optional input kind must be present for <code>product</code> <code>recv</code> ports
|
|
and may not be present for other ports.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> appearing after the keyword
|
|
<code>priority</code> and the optional <em>queue-full-behavior</em> behavior have
|
|
the same meaning as described above for general ports.
|
|
These elements are valid only for <code>async</code> <code>product</code> <code>recv</code> ports.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Each special port instance represents an implied use of a port
|
|
as shown in the table below.
|
|
These ports are defined by the F Prime framework.</p>
|
|
</div>
|
|
<table class="tableblock frame-all grid-all stretch">
|
|
<colgroup>
|
|
<col style="width: 50%;">
|
|
<col style="width: 50%;">
|
|
</colgroup>
|
|
<thead>
|
|
<tr>
|
|
<th class="tableblock halign-left valign-top">Special port kind</th>
|
|
<th class="tableblock halign-left valign-top">Implied port use</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>command</code> <code>recv</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.Cmd</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>command</code> <code>reg</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.CmdReg</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>command</code> <code>resp</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.CmdResponse</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>event</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.Log</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>param</code> <code>get</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.PrmGet</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>param</code> <code>set</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.PrmSet</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>product</code> <code>get</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.DpGet</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>product</code> <code>recv</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.DpResponse</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>product</code> <code>request</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.DpRequest</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>product</code> <code>send</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.DpSend</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>telemetry</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.Tlm</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>text</code> <code>event</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.LogText</code></p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>time</code> <code>get</code></p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>Fw.Time</code></p></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Port-Instance-Specifiers_Examples">7.11.3. Examples</h4>
|
|
<div class="paragraph">
|
|
<p><strong>General ports:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ Async input port of type Fw.Com
|
|
@ It has priority 10.
|
|
@ It drops input received when the queue is full.
|
|
async input port asyncComIn: Fw.Com priority 10 drop
|
|
|
|
@ Async input serial port
|
|
async input port serialIn: serial
|
|
|
|
@ Guarded input port of type Fw.Com
|
|
guarded input port guardedComIn: Fw.Com
|
|
|
|
@ Output port array of 10 Fw.Com ports
|
|
output port comOut: [10] Fw.Com
|
|
|
|
@ Sync input port of type Fw.Com
|
|
sync input port syncComIn: Fw.Com</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Special ports:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ A port for receiving commands from the command dispatcher
|
|
command recv port cmdIn
|
|
|
|
@ A port for sending command registration requests to the command dispatcher
|
|
command reg port cmdRegOut
|
|
|
|
@ A port for sending responses to the command dispatcher
|
|
command resp port cmdRespOut
|
|
|
|
@ A port for emitting events
|
|
event port eventOut
|
|
|
|
@ A port for emitting text events
|
|
text event port textEventOut
|
|
|
|
@ A port for getting parameter values from the parameter database
|
|
param get port paramGetOut
|
|
|
|
@ A port for sending parameter values to the parameter database
|
|
param set port paramSetOut
|
|
|
|
@ A port for emitting telemetry channels
|
|
telemetry port tlmOut
|
|
|
|
@ A port for getting the current time
|
|
time get port timeGetOut
|
|
|
|
@ An async port for receiving requested data product buffers
|
|
async product recv port productRecvIn
|
|
|
|
@ A port for requesting data product buffers
|
|
product request port productRequestOut
|
|
|
|
@ A port for sending data products
|
|
product send port productSendOut</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Port-Matching-Specifiers">7.12. Port Matching Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>port matching specifier</strong> is part of a
|
|
<a href="#Definitions_Component-Definitions">component definition</a>.
|
|
It specifies that when the component is instantiated and
|
|
connected into a topology, the corresponding port numbers
|
|
of two of its port instances should match.
|
|
For example, a port matching specifier could specify that
|
|
for a health monitoring component, any component connected
|
|
to its ping output port at port number <em>n</em> should also be connected
|
|
to its ping input port at the same port number <em>n</em>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Port-Matching-Specifiers_Syntax">7.12.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>match</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>with</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Port-Matching-Specifiers_Semantics">7.12.2. Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Each of the identifiers must name a
|
|
<a href="#Specifiers_Port-Instance-Specifiers">general port instance</a>
|
|
specified in the enclosing component.</p>
|
|
</li>
|
|
<li>
|
|
<p>The two port instances must be distinct and must have the same
|
|
array size.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Port-Matching-Specifiers_Example">7.12.3. Example</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">queued component Health {
|
|
|
|
@ Number of ping ports
|
|
constant numPingPorts = 10
|
|
|
|
@ Ping output port
|
|
output port pingOut: [numPingPorts] Svc.Ping
|
|
|
|
@ Ping input port
|
|
async input port pingIn: [numPingPorts] Svc.Ping
|
|
|
|
@ Corresponding port numbers of pingOut and pingIn must match
|
|
match pingOut with pingIn
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Record-Specifiers">7.13. Record Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>record specifier</strong> specifies a data product record as part of a
|
|
<a href="#Definitions_Component-Definitions">component definition</a>.
|
|
A record is a unit of data that is stored in a
|
|
<a href="#Specifiers_Container-Specifiers">container</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Record-Specifiers_Syntax">7.13.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>product</code> <code>record</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>:</code> <a href="#Type-Names"><em>type-name</em></a>
|
|
<em>[</em>
|
|
<code>array</code>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>id</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Record-Specifiers_Semantics">7.13.2. Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier names the record.</p>
|
|
</li>
|
|
<li>
|
|
<p>The type name <em>T</em> following the identifier specifies the type of the data stored
|
|
in the record.</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>If the keyword <code>array</code> appears after the type name, then the record stores
|
|
a variable number of elements of type <em>T</em>.
|
|
In this case the record consists of a size <em>s</em> followed by a data payload
|
|
consisting of <em>s</em> elements of type <em>T</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise the record stores a single value of type <em>T</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> after the keyword <code>id</code> specifies the
|
|
numeric identifier for the record.
|
|
If <em>e</em> is present, then the type of <em>e</em> must be
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a>
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>, and <em>e</em> must evaluate
|
|
to a nonnegative integer.
|
|
If <em>e</em> is not present, then the
|
|
default identifier is either zero (for the first record appearing in a
|
|
component) or the previous record identifier plus one.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Record-Specifiers_Examples">7.13.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ An array of 3 F64 values
|
|
array F64x3 = [3] F64
|
|
|
|
@ Record 0: A variable number of F32 values
|
|
@ Implied id is 0x00
|
|
product record Record0: F32 array
|
|
|
|
@ Record 1: A single U32 value
|
|
product record Record1: U32 id 0x02
|
|
|
|
@ Record 2: A single F64x3 value
|
|
@ Implied id is 0x03
|
|
product record Record2: F64x3</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_State-Machine-Instance-Specifiers">7.14. State Machine Instance Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>state machine instance specifier</strong> specifies an instantiated
|
|
<a href="#Definitions_State-Machine-Definitions">state machine</a> as part
|
|
of a
|
|
<a href="#Definitions_Component-Definitions">component definition</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_State-Machine-Instance-Specifiers_Syntax">7.14.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>state machine instance</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>:</code>
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a>
|
|
<em>[</em>
|
|
<code>priority</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<em>queue-full-behavior</em>
|
|
<em>]</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>queue-full-behavior</em> has the same syntax as for
|
|
<a href="#Specifiers_Port-Instance-Specifiers_Syntax">port instance specifiers</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_State-Machine-Instance-Specifiers_Static-Semantics">7.14.2. Static Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier names the state machine instance.</p>
|
|
</li>
|
|
<li>
|
|
<p>The qualified identifier must
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">refer to</a>
|
|
a
|
|
<a href="#Definitions_State-Machine-Definitions">state machine definition</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional priority and queue full behavior have the same semantics as in
|
|
<a href="#Specifiers_Port-Instance-Specifiers_Semantics">async input port instance
|
|
specifiers</a>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_State-Machine-Instance-Specifiers_Dynamic-Semantics">7.14.3. Dynamic Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Specifying one or more instances of a state machine <em>M</em> in a component <em>C</em>
|
|
causes the following code to be generated as part of <em>C</em>:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>Pure virtual functions corresponding to the actions and guards of <em>M</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each signal <em>s</em> of <em>M</em>, a function for sending <em>s</em> to <em>M</em>.
|
|
The signal function may or may not have a typed argument, depending
|
|
on the definition of <em>s</em>.
|
|
The signal and the argument, if any, are serialized on the component
|
|
queue and dispatched from the queue in the ordinary way for
|
|
an F Prime active or queued component.
|
|
Upon dispatching a signal, the signal and argument, if any,
|
|
are used to call the <a href="#Definitions_State-Machine-Definitions_Dynamic-Semantics">function for sending <em>s</em> to <em>M</em></a>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_State-Machine-Instance-Specifiers_Examples">7.14.4. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">state machine M {
|
|
initial S
|
|
state S
|
|
}
|
|
|
|
passive component C {
|
|
|
|
@ m1 is an instance of state machine M
|
|
state machine instance m1: M
|
|
|
|
@ m2 is an instance of state machine M
|
|
state machine instance m2: M priority 10 drop
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Telemetry-Channel-Specifiers">7.15. Telemetry Channel Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>telemetry channel definition</strong> defines a telemetry channel as part of a
|
|
<a href="#Definitions_Component-Definitions">component definition</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Telemetry-Channel-Specifiers_Syntax">7.15.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>telemetry</code> <a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>:</code> <a href="#Type-Names"><em>type-name</em></a>
|
|
<em>[</em>
|
|
<code>id</code> <a href="#Expressions"><em>expression</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>update</code> <em>telemetry-update</em>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>format</code> <a href="#Expressions_String-Literals"><em>string-literal</em></a>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>low</code> <code>{</code> <em>telemetry-limit-sequence</em> <code>}</code>
|
|
<em>]</em>
|
|
<em>[</em>
|
|
<code>high</code> <code>{</code> <em>telemetry-limit-sequence</em> <code>}</code>
|
|
<em>]</em></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>telemetry-update</em> is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><code>always</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>on</code> <code>change</code></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>telemetry-limit-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a>
|
|
in which the elements are <strong>telemetry limits</strong>,
|
|
and the terminating punctuation is a comma.
|
|
A telemetry limit is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><code>red</code> <a href="#Expressions"><em>expression</em></a></p>
|
|
</li>
|
|
<li>
|
|
<p><code>orange</code> <a href="#Expressions"><em>expression</em></a></p>
|
|
</li>
|
|
<li>
|
|
<p><code>yellow</code> <a href="#Expressions"><em>expression</em></a></p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Telemetry-Channel-Specifiers_Semantics">7.15.2. Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The identifier names the telemetry channel.</p>
|
|
</li>
|
|
<li>
|
|
<p>The type name specifies the type <em>T</em> of the telemetry channel.
|
|
<em>T</em> must be a <a href="#Types_Displayable-Types">displayable type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional expression <em>e</em> after the keyword <code>id</code> specifies the
|
|
numeric identifier for the channel.
|
|
If <em>e</em> is present, then the type of <em>e</em> must be
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a>
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>, and <em>e</em> must evaluate
|
|
to a nonnegative integer.
|
|
If <em>e</em> is not present, then the
|
|
default identifier is either zero (for the first channel appearing in a
|
|
component) or the previous channel identifier plus one.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional update specifier specifies whether the telemetry channel
|
|
is emitted always or on change.
|
|
If the specifier is not present, the default behavior is always.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional format specifier specifies a <a href="#Format-Strings">format string</a>.
|
|
There is one argument to the format string, which is the channel value.</p>
|
|
</li>
|
|
<li>
|
|
<p>The optional high and low limit specifiers specify the high and low limits
|
|
for the channel.
|
|
The following rules apply:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>At most one of each kind of limit (red, orange, yellow) may appear
|
|
in each specifier.</p>
|
|
</li>
|
|
<li>
|
|
<p>The type of the expression in each limit must be a
|
|
<a href="#Types_Internal-Types_Numeric-Types">numeric type</a> and must be
|
|
<a href="#Type-Checking_Type-Conversion">convertible to</a>
|
|
the type of the channel.</p>
|
|
</li>
|
|
<li>
|
|
<p>The limit is applied to each telemetry channel with type <em>T</em> and value <em>v</em>
|
|
as follows:</p>
|
|
<div class="olist lowerroman">
|
|
<ol class="lowerroman" type="i">
|
|
<li>
|
|
<p>If <em>T</em> is a
|
|
<a href="#Types_Internal-Types_Numeric-Types">numeric type</a>, then the
|
|
limit is applied directly to <em>v</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>T</em> is not itself a numeric type
|
|
(e.g., it is an array), then the limit is applied recursively to each member
|
|
value of <em>v</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Telemetry-Channel-Specifiers_Examples">7.15.3. Examples</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ An array of 3 F64 values
|
|
array F64x3 = [3] F64
|
|
|
|
@ Telemetry channel 0
|
|
telemetry Channel0: U32 id 0x00
|
|
|
|
@ Telemetry channel 1
|
|
telemetry Channel1: U32 \
|
|
id 0x01 \
|
|
update on change
|
|
|
|
@ Telemetry channel 2
|
|
telemetry Channel2: F64 \
|
|
id 0x02 \
|
|
format "{.3f}"
|
|
|
|
@ Telemetry channel 3
|
|
telemetry Channel3: F64x3 \
|
|
id 0x03 \
|
|
low { yellow -1, orange -2, red -3 } \
|
|
high { yellow 1, orange 2, red 3 }</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Specifiers_Topology-Import-Specifiers">7.16. Topology Import Specifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>topology import specifier</strong> imports one topology into another one.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Topology-Import-Specifiers_Syntax">7.16.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>import</code> <a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Topology-Import-Specifiers_Semantics">7.16.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The qualified identifier must
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">refer to</a>
|
|
a
|
|
<a href="#Definitions_Topology-Definitions">topology definition</a>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Importing instances:</strong>
|
|
FPP uses the following algorithm to import the instances
|
|
of topology <em>T'</em> into topology <em>T</em>:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Let <em>I</em> be the set of
|
|
<a href="#Specifiers_Component-Instance-Specifiers">instances</a>
|
|
of <em>T</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let <em>I'</em> be the set of
|
|
<a href="#Specifiers_Component-Instance-Specifiers">public instances</a>
|
|
of <em>T'</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let <em>I''</em> be the set union of <em>I</em> and <em>I'</em>.
|
|
That means that if either or both of <em>I</em> and <em>I'</em> contain the instance <em>S</em>,
|
|
then <em>I''</em> contains the instance <em>S</em> once.
|
|
Each instance in <em>I''</em> has private visibility if it is private
|
|
in either <em>I</em> or <em>I'</em>, otherwise public visibility.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Importing connections:</strong>
|
|
FPP uses the following algorithm to import the connections
|
|
of topology <em>T'</em> into topology <em>T</em>.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>For each
|
|
<a href="#Specifiers_Connection-Graph-Specifiers">connection graph name</a> \$N_i\$
|
|
that appears in either <em>T</em> or <em>T'</em>:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>Let \$G_i\$ be the connection graph named \$N_i\$ in <em>T</em>.
|
|
If no such graph exists, then let \$G_i\$ be the empty connection graph
|
|
with name \$N_i\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let \$G'_i\$ be the connection graph named \$N_i\$ in <em>T'</em>.
|
|
If no such graph exists, then let \$G'_i\$ be the empty connection graph
|
|
with name \$N_i\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let \$C_i\$ be the set of
|
|
<a href="#Specifiers_Connection-Graph-Specifiers">connections</a>
|
|
of \$G_i\$ such that each of the two instances at
|
|
the ends of the connection is in <em>I''</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let \$C'_i\$ be the set of
|
|
<a href="#Specifiers_Connection-Graph-Specifiers">connections</a>
|
|
of \$G'_i\$ such that each of the two the instances at
|
|
the ends of the connection is in <em>I''</em>, and the connection
|
|
is defined by a direct or pattern specifier in <em>T'</em>
|
|
(i.e., not imported into <em>T'</em> from another topology).</p>
|
|
</li>
|
|
<li>
|
|
<p>Let \$C''_i\$ be the disjoint union of \$C_i\$ and \$C'_i\$.
|
|
That means that if \$C_i\$ contains <em>n</em> connections between port
|
|
<em>p</em> and port <em>p'</em>, and \$C'_i\$ contains <em>m</em> connections between
|
|
port <em>p</em> and port <em>p'</em>, then \$C_i\$ contains <em>n + m</em> connections
|
|
between port <em>p</em> and port <em>p'</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let \$G''_i\$ be the connection graph with name \$N_i\$
|
|
and connections \$C''_i\$.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>Return the connection graphs \$G''_i\$.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Specifiers_Topology-Import-Specifiers_Example">7.16.3. Example</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">topology A {
|
|
|
|
instance a
|
|
private instance b
|
|
instance c
|
|
|
|
connections C1 {
|
|
a.p1 -> c.p
|
|
}
|
|
|
|
connections C2 {
|
|
b.p -> c.p
|
|
}
|
|
|
|
}
|
|
|
|
topology B {
|
|
|
|
import A
|
|
|
|
instance d
|
|
instance e
|
|
instance f
|
|
|
|
connections C1 {
|
|
a.p1 -> d.p
|
|
}
|
|
|
|
connections C2 {
|
|
a.p2 -> e.p
|
|
}
|
|
|
|
connections C3 {
|
|
a.p3 -> f.p
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>After importing, topology <code>B</code> is equivalent to this topology:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">topology B {
|
|
|
|
instance a
|
|
instance c
|
|
instance d
|
|
instance e
|
|
instance f
|
|
|
|
connections C1 {
|
|
a.p1 -> c.p
|
|
a.p2 -> d.p
|
|
}
|
|
|
|
connections C2 {
|
|
a.p2 -> e.p
|
|
}
|
|
|
|
connections C3 {
|
|
a.p3 -> f.p
|
|
}
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Note the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>The connections from topologies <code>A</code> and <code>B</code> are merged graph by graph.</p>
|
|
</li>
|
|
<li>
|
|
<p>Because instance b is private to topology <code>A</code>, neither it nor any
|
|
of its connections appear in topology <code>B</code>.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Port-Instance-Identifiers">8. Port Instance Identifiers</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>A <strong>port instance identifier</strong> identifies a port instance
|
|
that is part of a component instance.
|
|
Port instance identifiers appear in
|
|
<a href="#Specifiers_Connection-Graph-Specifiers">connection graph specifiers</a>.</p>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Port-Instance-Identifiers_Syntax">8.1. Syntax</h3>
|
|
<div class="paragraph">
|
|
<p><a href="#Scoping-of-Names_Qualified-Identifiers"><em>qual-ident</em></a>
|
|
<code>.</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Port-Instance-Identifiers_Semantics">8.2. Semantics</h3>
|
|
<div class="paragraph">
|
|
<p>For each port instance identifier <em>Q</em> <code>.</code> <em>P</em>:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The qualified identifier <em>Q</em> must
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">refer to</a>
|
|
a component instance <em>I</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>I</em> must refer to a <a href="#Definitions_Component-Instance-Definitions">component
|
|
instance definition <em>I'</em></a>.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>I'</em> must refer to a <a href="#Definitions_Component-Definitions">component
|
|
definition <em>C</em></a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The identifier <em>P</em>
|
|
must refer to a
|
|
<a href="#Specifiers_Port-Instance-Specifiers">port instance specifier</a>
|
|
of <em>C</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Port-Instance-Identifiers_Examples">8.3. Examples</h3>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">a.b
|
|
A.b.c</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>In the first example, <code>a</code> names a component instance, and <code>b</code> names a port
|
|
instance.
|
|
In the second example, <code>A.b</code> names a component instance, and <code>c</code> names a
|
|
port instance.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Type-Names">9. Type Names</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p><strong>Type names</strong> are the syntactic names of
|
|
<a href="#Types">types</a>.
|
|
In some cases, e.g., <code>U32</code>, there is a one-to-one correspondence
|
|
between type names and types.
|
|
In other cases, e.g., array types, there is no one-to-one correspondence.
|
|
For example, depending on the enclosing scope, the name
|
|
<code>a.b</code> and the name <code>b</code> may refer to the same array type.</p>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Names_Primitive-Integer-Type-Names">9.1. Primitive Integer Type Names</h3>
|
|
<div class="paragraph">
|
|
<p><strong>Primitive integer type names</strong> are the names of the
|
|
<a href="#Types_Primitive-Integer-Types">primitive integer types</a>.
|
|
There are two kinds of primitive
|
|
integer types: unsigned integer types and signed integer types.</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>The names of the unsigned integer types are <code>U8</code>, <code>U16</code>, <code>U32</code>, and <code>U64</code>.
|
|
The <code>U</code> stands for “unsigned.” The number after the U is the width of the
|
|
representation in bits, using the standard binary representation of an
|
|
unsigned integer.</p>
|
|
</li>
|
|
<li>
|
|
<p>The names of the signed integer types are <code>I8</code>, <code>I16</code>, <code>I32</code>, and <code>I64</code>. The
|
|
<code>I</code> stands for “[signed] integer.” The number after the I is the width of
|
|
the representation in bits, using the standard binary two’s complement
|
|
representation of a signed integer.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Names_Floating-Point-Type-Names">9.2. Floating-Point Type Names</h3>
|
|
<div class="paragraph">
|
|
<p>The <strong>floating-point type names</strong> are <code>F32</code> and <code>F64</code>. These refer to the types
|
|
of IEEE
|
|
floating-point values of width 32 and 64 bits, respectively.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Names_The-Boolean-Type-Name">9.3. The Boolean Type Name</h3>
|
|
<div class="paragraph">
|
|
<p>The type name <code>bool</code> represents the type of the two Boolean values <code>true</code> and
|
|
<code>false</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Names_String-Type-Names">9.4. String Type Names</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>string type name</strong> consists of the keyword <code>string</code> optionally
|
|
followed by the keyword <code>size</code> and an
|
|
<a href="#Expressions"><em>expression</em></a>. For example:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">string
|
|
string size 256</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The optional expression following the keyword <code>size</code> is called the <strong>size
|
|
expression</strong> of the string type name. If present, it must have a
|
|
<a href="#Types_Internal-Types_Numeric-Types">numeric type</a>, and it must
|
|
evaluate to a value in the range [0,2<sup>31</sup>) after conversion to
|
|
<a href="#Types_Internal-Types_Integer"><em>Integer</em></a>.
|
|
The size expression specifies the maximum
|
|
length of a string value represented by the type. If the size expression is
|
|
not present, then the translator uses a default maximum string length.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Names_Qualified-Identifier-Type-Names">9.5. Qualified Identifier Type Names</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>qualified identifier type name</strong> is a
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers">qualified
|
|
identifier</a> that refers to an
|
|
<a href="#Definitions_Abstract-Type-Definitions">abstract type definition</a>,
|
|
<a href="#Definitions_Array-Definitions">array definition</a>,
|
|
<a href="#Definitions_Enum-Definitions">enum definition</a>, or
|
|
<a href="#Definitions_Struct-Definitions">struct definition</a>
|
|
via the
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">rules
|
|
for name scoping</a>.
|
|
It names the
|
|
<a href="#Types">type</a> defined in the definition to which it refers.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For example:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M {
|
|
type T
|
|
array A = [3] T # T is a qualified identifier t type name. It names the type M.T.
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M {
|
|
array A = [3] U8
|
|
array B = [3] A # A is an array type name. It names the type M.A.
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M {
|
|
enum E { X = 0, Y = 1 }
|
|
array A = [3] E # E is a qualified identifier type name. It names the type M.E.
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M {
|
|
struct S {
|
|
x: U32
|
|
y: F32
|
|
}
|
|
struct T {
|
|
s: S # S is a qualified identifier type name. It names the type M.S.
|
|
}
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Expressions">10. Expressions</h2>
|
|
<div class="sectionbody">
|
|
<div class="sect2">
|
|
<h3 id="Expressions_Arithmetic-Expressions">10.1. Arithmetic Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>FPP includes the following <strong>arithmetic expressions</strong>:</p>
|
|
</div>
|
|
<table class="tableblock frame-all grid-all stretch">
|
|
<colgroup>
|
|
<col style="width: 50%;">
|
|
<col style="width: 50%;">
|
|
</colgroup>
|
|
<thead>
|
|
<tr>
|
|
<th class="tableblock halign-left valign-top">Syntax</th>
|
|
<th class="tableblock halign-left valign-top">Meaning</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>-</code> \$e\$</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">Negate \$e\$</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">\$e_1\$ <code>+</code> \$e_2\$</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">Add \$e_1\$ and \$e_2\$</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">\$e_1\$ <code>-</code> \$e_2\$</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">Subtract \$e_2\$ from \$e_1\$</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">\$e_1\$ <code>*</code> \$e_2\$</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">Multiply \$e_1\$ by \$e_2\$</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">\$e_1\$ <code>/</code> \$e_2\$</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">Divide \$e_1\$ by \$e_2\$</p></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<div class="paragraph">
|
|
<p>Each subexpression of an arithmetic expression must have
|
|
<a href="#Types_Internal-Types_Numeric-Types">numeric type</a>. Evaluation is by either
|
|
standard integer arithmetic or standard floating-point arithmetic, depending on
|
|
the <a href="#Type-Checking">type of the expression</a>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = -1
|
|
constant b = 2 + 3
|
|
constant c = a * b</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Expressions_Array-Expressions">10.2. Array Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>array expression</strong> is an expression that represents an array value.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Array-Expressions_Syntax">10.2.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>[</code> <em>array-element-sequence</em> <code>]</code></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>array-element-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in which the elements
|
|
are
|
|
<a href="#Expressions">expressions</a>, and the terminating punctuation
|
|
is a comma.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Array-Expressions_Semantics">10.2.2. Semantics</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The sequence must have at least one element.</p>
|
|
</li>
|
|
<li>
|
|
<p>The types of the expressions in the sequence must be
|
|
<a href="#Type-Checking_Computing-a-Common-Type_Lists-of-Types">convertible to a common type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The value of the expression is formed by computing
|
|
the value of each element and then converting all the
|
|
elements to the common type.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Array-Expressions_Example">10.2.3. Example</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = [ 0, 1, 2 ] # a is an array value with elements 0, 1, 2</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Expressions_Boolean-Literals">10.3. Boolean Literals</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>Boolean literal expression</strong> is one of the values <code>true</code> and <code>false</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Expressions_Dot-Expressions">10.4. Dot Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>dot expression</strong> is a
|
|
<a href="#Definitions-and-Uses_Uses">use</a>
|
|
that refers to a
|
|
<a href="#Definitions_Constant-Definitions">constant definition</a>
|
|
or
|
|
<a href="#Definitions_Constant-Definitions">enumerated constant definition</a>.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Dot-Expressions_Syntax">10.4.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><a href="#Expressions"><em>expression</em></a>
|
|
<code>.</code>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Dot-Expressions_Semantics">10.4.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The following rules give the meaning of a dot expression \$e\$<code>.x</code>:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>If \$e\$<code>.x</code> is a
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers">qualified
|
|
identifier</a> that represents one of the uses listed above according to
|
|
the
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">rules
|
|
for resolving qualified identifiers</a>, then it evaluates to the value
|
|
stored in the corresponding <a href="#Definitions">definition</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise \$e\$<code>.x</code> is invalid.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Dot-Expressions_Examples">10.4.3. Examples</h4>
|
|
<div class="sect4">
|
|
<h5 id="Expressions_Dot-Expressions_Examples_Example-1">Example 1</h5>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M {
|
|
constant a = 1
|
|
}
|
|
constant b = M.a # M.a evaluates to 1</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect4">
|
|
<h5 id="Expressions_Dot-Expressions_Examples_Example-2">Example 2</h5>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">enum E { X = 0, Y = 1 }
|
|
constant a = E.X # E.X evaluates to 0</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Expressions_Floating-Point-Literals">10.5. Floating-Point Literals</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>floating-point literal expression</strong> is a C-style representation of an
|
|
IEEE floating-point number.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Examples:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">1e-10
|
|
0.001
|
|
3.14159
|
|
6.02E23</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Expressions_Identifier-Expressions">10.6. Identifier Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>identifier expression</strong> is an
|
|
<a href="#Lexical-Elements_Identifiers">identifier</a>
|
|
that refers to a
|
|
<a href="#Definitions_Constant-Definitions">constant definition</a>
|
|
or
|
|
<a href="#Definitions_Enumerated-Constant-Definitions">enumerated constant definition</a>,
|
|
according to the
|
|
<a href="#Scoping-of-Names_Resolution-of-Identifiers">rules for resolving identifiers</a>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 42
|
|
constant b = a # a is an identifier expression</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Expressions_Integer-Literals">10.7. Integer Literals</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>integer literal expression</strong> is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A sequence of decimal digits <code>0</code> through <code>9</code> denoting the decimal
|
|
representation of a nonnegative integer.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>0x</code> or <code>0X</code> followed by a sequence of hexadecimal digits
|
|
<code>0</code> through <code>9</code>, <code>A</code> through <code>F</code>, or <code>a</code> through <code>f</code> denoting the hexadecimal
|
|
representation of a nonnegative
|
|
integer.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>An integer literal value \$v\$ is represented in the model as an integer of
|
|
arbitrary width.
|
|
During code generation, the width is narrowed (if necessary) to some machine width
|
|
less than or equal to 64 bits.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Examples:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">1234
|
|
0xABCD</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Expressions_Parenthesis-Expressions">10.8. Parenthesis Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>parenthesis expression</strong> is an expression surrounded
|
|
by parentheses in order to group subexpressions and to
|
|
force evaluation order.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Parenthesis-Expressions_Syntax">10.8.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>(</code>
|
|
<a href="#Expressions"><em>expression</em></a>
|
|
<code>)</code></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Parenthesis-Expressions_Semantics">10.8.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The type and value of the expression are the type and value of the subexpression.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Parenthesis-Expressions_Example">10.8.3. Example</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = (1 + 2) * 3</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The expression on the right-hand side of the constant definition evaluates to
|
|
9.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Expressions_String-Literals">10.9. String Literals</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>string literal expression</strong> is a single-line string literal
|
|
or a multiline string literal.
|
|
In this section</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><strong>Literal string</strong> means a literal string appearing
|
|
in the FPP source text.</p>
|
|
</li>
|
|
<li>
|
|
<p><strong>Interpreted string</strong> means the sequence
|
|
of characters represented by the literal string.</p>
|
|
</li>
|
|
<li>
|
|
<p><strong>String interpretation</strong> is the process of converting a literal
|
|
string to an interpreted string.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <strong>newline character</strong> is the NL character (ASCII code 0x0A).</p>
|
|
</li>
|
|
<li>
|
|
<p>An <strong>extended newline character</strong> is the NL character (ASCII code 0x0A),
|
|
optionally preceded by a CR character (ASCII code 0x0D).</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_String-Literals_Single-Line-String-Literals">10.9.1. Single-Line String Literals</h4>
|
|
<div class="paragraph">
|
|
<p>A <strong>single-line string literal</strong> is a sequence of <strong>single-line literal characters</strong>
|
|
enclosed in double
|
|
quote characters <code>"</code>.
|
|
A single-line literal character is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>Any character other than the newline character, <code>"</code>, or <code>\</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\</code> followed by any character <em>c</em> other than the newline character.
|
|
In this case we say that the character <em>c</em> is <strong>escaped</strong>.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The characters of the interpreted string correspond one-to-one
|
|
to the literal characters of the string, in the same order,
|
|
according to the following rule:
|
|
if the literal character is <em>c</em> or <code>\</code> <em>c</em>, then the corresponding character
|
|
of the interpreted string is <em>c</em>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Examples:</strong></p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p><code>"abc"</code> is a valid string consisting of the characters <code>a</code>, <code>b</code>, and <code>c</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>"ab\""</code> is a valid string consisting of the characters <code>a</code>, <code>b</code>, and <code>"</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>"ab\\\""</code> is a valid string consisting of the characters <code>a</code>, <code>b</code>, <code>\</code>, and <code>"</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>"ab\c"</code> is a valid string consisting of the characters <code>a</code>, <code>b</code>, <code>c</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>"abc</code> is not a valid string, because it is missing the terminating <code>"</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>"\"</code> is not a valid string, because it is missing the terminating <code>"</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>"ab"c"</code> is the valid string <code>"ab"</code> followed by the identifier <code>c</code> and an
|
|
unmatched double quote character.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_String-Literals_Multiline-String-Literals">10.9.2. Multiline String Literals</h4>
|
|
<div class="paragraph">
|
|
<p>A <strong>multiline string literal</strong> is a sequence of <strong>multiline literal characters</strong> enclosed
|
|
in sequences <code>"""</code> of three double quote characters.
|
|
A multiline literal character is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>Any character other than <code>"</code> or <code>\</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>\</code> followed by any character.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Before trimming whitespace,
|
|
the characters of the interpreted string correspond one-to-one
|
|
to the literal characters of the string, in the same order,
|
|
according to the following rule:
|
|
if the literal character is <em>c</em> or <code>\</code> <em>c</em>, then the corresponding character
|
|
of the interpreted string is <em>c</em>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Whitespace inside a multiline string literal is trimmed as follows:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The first extended newline character, if any, after the first <code>"""</code> is
|
|
deleted from the interpreted string.</p>
|
|
</li>
|
|
<li>
|
|
<p>Any whitespace occurring in columns to the left of the first <code>"""</code>
|
|
is deleted from the result of step 1.</p>
|
|
</li>
|
|
<li>
|
|
<p>Any leading and trailing extended newline characters are deleted from the
|
|
result of step 2.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example 1</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant s = """\"\"\""""</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The string literal uses escaped quotation marks.
|
|
The value of the string constant <code>s</code> is <code>"""</code>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example 2</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"> """
|
|
// This is a multiline string literal
|
|
// It represents some C++ code
|
|
instance.create(0, 1);
|
|
"""</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The interpreted string consists of the following lines, each terminated by a newline:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><code>// This is a multiline string literal</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>// It represents some C++ code</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>instance.create(0, 1);</code></p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Expressions_Struct-Expressions">10.10. Struct Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>struct expression</strong> is an expression that represents a struct value.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Struct-Expressions_Syntax">10.10.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p><code>{</code> <em>struct-element-sequence</em> <code>}</code></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>struct-element-sequence</em> is an
|
|
<a href="#Element-Sequences">element sequence</a> in which the elements
|
|
are struct elements, and the terminating punctuation is a comma.
|
|
A <strong>struct element</strong> has the following syntax:</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><a href="#Lexical-Elements_Identifiers"><em>identifier</em></a> <code>=</code> <a href="#Expressions"><em>expression</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Struct-Expressions_Semantics">10.10.2. Semantics</h4>
|
|
<div class="paragraph">
|
|
<p>The following must be true of the struct element sequence <em>S</em>:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>No two identifiers appearing in <em>S</em> may be the same.</p>
|
|
</li>
|
|
<li>
|
|
<p>Each expression appearing in <em>S</em> must have a valid type.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The expression is evaluated by evaluating each member expression
|
|
to a value and then constructing the struct value with the
|
|
corresponding member names and values.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Expressions_Struct-Expressions_Example">10.10.3. Example</h4>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># s is a struct value with members x = 0, y = 1
|
|
constant s = {
|
|
x = 0
|
|
y = 1
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Expressions_Precedence-and-Associativity">10.11. Precedence and Associativity</h3>
|
|
<div class="paragraph">
|
|
<p>Ambiguity in parsing expressions is resolved with the following
|
|
precedence table. Expressions appearing earlier in the table
|
|
have higher precedence. For example, <code>-a.b</code> is parsed as <code>-(a.b)</code>
|
|
and not <code>(-a).b</code>. Where necessary, each element in the ordering provides an
|
|
associativity for resolving expressions with equal precedence.</p>
|
|
</div>
|
|
<table class="tableblock frame-all grid-all stretch">
|
|
<colgroup>
|
|
<col style="width: 50%;">
|
|
<col style="width: 50%;">
|
|
</colgroup>
|
|
<thead>
|
|
<tr>
|
|
<th class="tableblock halign-left valign-top">Expression</th>
|
|
<th class="tableblock halign-left valign-top">Associativity</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">Dot expressions \$e\$ <code>.</code> \$i\$</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">None</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">Unary negation expressions <code>-</code> \$e\$</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">None</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">Multiplication expressions \$e_1\$ <code>*</code> \$e_2\$ and division expressions \$e_1\$ <code>/</code> \$e_2\$</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">Left</p></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">Addition expressions \$e_1\$ <code>+</code> \$e_2\$ and subtraction expressions \$e_1\$ <code>-</code> \$e_2\$</p></td>
|
|
<td class="tableblock halign-left valign-top"><p class="tableblock">Left</p></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Formal-Parameter-Lists">11. Formal Parameter Lists</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>A <strong>formal parameter list</strong> is an
|
|
<a href="#Element-Sequences">element sequence</a>
|
|
in which the elements are formal parameters,
|
|
and the terminating punctuation is a comma.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>A <strong>formal parameter</strong> is a typed symbol to which a value becomes bound
|
|
at runtime.
|
|
Formal parameters appear, for example, in
|
|
<a href="#Definitions_Port-Definitions">port definitions</a>.</p>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Formal-Parameter-Lists_Syntax">11.1. Syntax</h3>
|
|
<div class="paragraph">
|
|
<p>Formal parameters have the following syntax:</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>[</em> <code>ref</code> <em>]</em>
|
|
<a href="#Lexical-Elements_Identifiers"><em>identifier</em></a>
|
|
<code>:</code>
|
|
<a href="#Type-Names"><em>type-name</em></a></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Formal-Parameter-Lists_Semantics">11.2. Semantics</h3>
|
|
<div class="paragraph">
|
|
<p>If present, the keyword <code>ref</code> specifies that the value
|
|
bound to the formal parameter is to be passed by reference
|
|
when it is used in a synchronous port invocation.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The identifier is the name of the formal parameter.
|
|
No two parameters in the same formal parameter list
|
|
may have the same name.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The type name specifies the type <em>T</em> of the formal parameter <em>P</em>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Formal-Parameter-Lists_Examples">11.3. Examples</h3>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">a: U32
|
|
b: string size 100
|
|
ref c: Fw.Com</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Format-Strings">12. Format Strings</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>A <strong>format string</strong> is a string that specifies the display format
|
|
of a
|
|
<a href="#Definitions_Struct-Definitions">struct member</a>,
|
|
<a href="#Definitions_Array-Definitions">array element</a>,
|
|
<a href="#Specifiers_Event-Specifiers">event report</a>, or
|
|
<a href="#Specifiers_Telemetry-Channel-Specifiers">telemetry channel</a>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>An FPP format string is similar to a
|
|
<a href="https://docs.python.org/3.0/library/string.html#formatstrings">Python format
|
|
string</a>.
|
|
As in python, a format string consists of text containing one or more
|
|
<strong>replacement fields</strong> surrounded by curly braces <code>{</code> <code>}</code>.
|
|
In the output, each replacement field is replaced by the value of an
|
|
<strong>argument</strong>.
|
|
Characters outside of replacement fields are copied to the output unchanged,
|
|
except that the escape sequences <code>{{</code> and <code>}}</code> are converted to single
|
|
braces.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The number of arguments must match the number of replacement fields.
|
|
Each replacement field must also match the type of its argument, as
|
|
discussed below.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The following replacement fields are allowed:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>You can use the <strong>default replacement field</strong> <code>{}</code> to convert any argument.
|
|
It causes the argument to be displayed in a standard way
|
|
for F Prime according to its type.</p>
|
|
</li>
|
|
<li>
|
|
<p>If the type of an argument <em>a</em> is an
|
|
<a href="#Types_Internal-Types_Integer-Types">integer type</a>,
|
|
then you can use an <strong>integer replacement field</strong> to convert <em>a</em>.
|
|
An integer replacement field is one of the following:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p><code>{c}</code>: Display <em>a</em> as a character value.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>{d}</code>: Display <em>a</em> as a decimal integer value</p>
|
|
</li>
|
|
<li>
|
|
<p><code>{x}</code>: Display <em>a</em> as a hexadecimal integer value.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>{o}</code>: Display <em>a</em> as an octal integer value.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>If the type of an argument <em>a</em> is a
|
|
<a href="#Types_Floating-Point-Types">floating-point type</a>,
|
|
then you can use a <strong>rational replacement field</strong> to convert <em>a</em>.
|
|
A rational replacement field is one of the following:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p><code>{e}</code>: Display <em>a</em> as a rational number using exponent notation, e.g., <code>1.234e2</code></p>
|
|
</li>
|
|
<li>
|
|
<p><code>{f}</code>: Display <em>a</em> as a rational number using fixed-point notation, e.g., <code>123.4</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p><code>{g}</code>: Display <em>a</em> as a rational number using general format. This format
|
|
uses fixed-point notation for
|
|
numbers up to some size <em>s</em> and uses exponent notation for numbers larger than
|
|
<em>s</em>.
|
|
The value of <em>s</em> is implementation-dependent.</p>
|
|
</li>
|
|
<li>
|
|
<p>One of the replacement fields denoted above, but with a period and a literal
|
|
decimal integer after the opening brace.
|
|
The integer value <em>n</em> specifies the <strong>precision</strong>, i.e., the number of digits after
|
|
the decimal point for fixed-point notation, or before the <code>e</code> for exponent
|
|
notation.
|
|
For example, the replacement field <code>{.3f}</code>, specifies fixed-point notation
|
|
with a precision of 3.
|
|
<em>n</em> must be in the range [0,100].</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>No other replacement fields are allowed.
|
|
No other use of <code>{</code> or <code>}</code> is allowed, except in the escape sequences
|
|
<code>{{</code> and <code>}}</code>.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Comments-and-Annotations">13. Comments and Annotations</h2>
|
|
<div class="sectionbody">
|
|
<div class="sect2">
|
|
<h3 id="Comments-and-Annotations_Comments">13.1. Comments</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>comment</strong> is model text that is ignored by the translator. It
|
|
provides information to human readers of the source model.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Comments begin with the character <code>#</code> and go to the end of the line. For
|
|
example:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># This is a comment</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>To write a multiline comment, precede each line with <code>#</code>:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># This is a multiline comment.
|
|
# It has two lines.</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Comments-and-Annotations_Annotations">13.2. Annotations</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>annotation</strong> is similar to a
|
|
<a href="#Comments-and-Annotations_Comments">comment</a>, but it is attached to a
|
|
syntactic element of a model, and it is preserved during
|
|
<a href="#Analysis-and-Translation">analysis and translation</a>. The precise use of
|
|
annotations depends on the translator. A typical use
|
|
is to include annotations as comments in generated code.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Comments-and-Annotations_Annotations_Where-Annotations-Can-Occur">13.2.1. Where Annotations Can Occur</h4>
|
|
<div class="paragraph">
|
|
<p>Annotations can occur at the following syntax elements:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A <a href="#Definitions">definition</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Specifiers">specifier</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Definitions_Struct-Definitions">member of a struct definition</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Formal-Parameter-Lists">formal parameter</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Definitions_State-Machine-Definitions_Syntax">state machine member</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#State-Machine-Behavior-Elements_State-Definitions_Syntax">state definition member</a>.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>These elements are called the <strong>annotatable elements</strong> of an FPP model.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Comments-and-Annotations_Annotations_Kinds-of-Annotations">13.2.2. Kinds of Annotations</h4>
|
|
<div class="paragraph">
|
|
<p>There are two kinds of annotations: <strong>pre-annotations</strong> and
|
|
<strong>post-annotations</strong>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>A pre-annotation starts with <code>@</code> and goes to the end of the line.
|
|
Whitespace characters after the initial <code>@</code> are ignored. A
|
|
pre-annotation must occur immediately before an
|
|
<a href="#Comments-and-Annotations_Annotations_Where-Annotations-Can-Occur">annotatable element</a> <em>e</em>. It is attached to <em>e</em> during translation.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>A post-annotation starts with <code>@<</code> and goes to the end of the line.
|
|
Whitespace characters after the initial <code>@<</code> are ignored. A
|
|
post-annotation must occur immediately after an
|
|
<a href="#Comments-and-Annotations_Annotations_Where-Annotations-Can-Occur">annotatable element</a> <em>e</em>. It is attached to <em>e</em> during translation.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>You may follow either kind of annotation by one or more blank
|
|
lines.
|
|
In this case the blank lines are ignored.</p>
|
|
</div>
|
|
<div class="sect4">
|
|
<h5 id="Comments-and-Annotations_Annotations_Kinds-of-Annotations_Example">Example</h5>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ This is module M
|
|
module M {
|
|
constant a = 0 @< This is constant M.a
|
|
constant b = 1 @< This is constant M.b
|
|
@ This is an enum
|
|
enum E {
|
|
a @< This is enumerated constant M.E.a
|
|
b @< This is enumerated constant M.E.b
|
|
}
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Comments-and-Annotations_Annotations_Multiline-Annotations">13.2.3. Multiline Annotations</h4>
|
|
<div class="paragraph">
|
|
<p>You can write several pre-annotations in a row before an
|
|
<a href="#Comments-and-Annotations_Annotations_Where-Annotations-Can-Occur">annotatable element</a> <em>e</em>.
|
|
In this case, all the pre-annotations are attached to the
|
|
element, in the order that they appear.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Similarly, you can write several post-annotations in a row after an
|
|
<a href="#Comments-and-Annotations_Annotations_Where-Annotations-Can-Occur">annotatable element</a> <em>e</em>.
|
|
In this case, all the post-annotations are attached to the
|
|
element, in the order that they appear.</p>
|
|
</div>
|
|
<div class="sect4">
|
|
<h5 id="Comments-and-Annotations_Annotations_Multiline-Annotations_Example">Example</h5>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">@ This is module M
|
|
@ Its pre-annotation has two lines
|
|
module M {
|
|
constant a = 0 @< This is constant M.a
|
|
@< Its post-annotation has two lines
|
|
constant b = 1 @< This is constant M.b
|
|
@< Its post-annotation has two lines
|
|
@ This is an enum
|
|
@ Its pre-annotation has two lines
|
|
enum E {
|
|
a @< This is enumerated constant M.E.a
|
|
@< Its post-annotation has two lines
|
|
b @< This is enumerated constant M.E.b
|
|
@< Its post-annotation has two lines
|
|
}
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Translation-Units-and-Models">14. Translation Units and Models</h2>
|
|
<div class="sectionbody">
|
|
<div class="sect2">
|
|
<h3 id="Translation-Units-and-Models_Translation-Units">14.1. Translation Units</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>translation unit</strong> forms part of a <a href="#Translation-Units-and-Models_Models">model</a>
|
|
at the top level.
|
|
Translation units usually correspond to source files of a program.
|
|
However, translation units may be specified in other ways,
|
|
e.g., on standard input.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Translation-Units-and-Models_Translation-Units_Syntax">14.1.1. Syntax</h4>
|
|
<div class="paragraph">
|
|
<p>A translation unit is an
|
|
<a href="#Element-Sequences">element sequence</a> in which each
|
|
element is a <strong>translation unit member</strong>,
|
|
and the terminating punctuation is a semicolon.
|
|
A translation unit member is syntactically identical to a
|
|
<a href="#Definitions_Module-Definitions_Syntax">module member</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Translation-Units-and-Models_Translation-Units_Example">14.1.2. Example</h4>
|
|
<div class="paragraph">
|
|
<p>Here is a translation unit:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M1 { constant a = 0 }</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>And here is another one:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M1 { constant b = 0 }</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>And here is a third one:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M2 {
|
|
constant a = M1.a
|
|
constant b = M1.b
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Call these translation units 1, 2, and 3 for purposes of the example in
|
|
the following section.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Translation-Units-and-Models_Models">14.2. Models</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>model</strong> is a collection of one or more
|
|
<a href="#Translation-Units-and-Models_Translation-Units">translation
|
|
units</a>. A model is presented to one or more analyzers or translators for
|
|
<a href="#Analysis-and-Translation">analysis or translation</a>.
|
|
How this is done depends on the analyzer or translator. Typically, you ask a
|
|
translator to read a single translation unit from standard input and/or
|
|
to read one or more translation units stored in files, one unit per
|
|
file.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example:</strong></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><a href="#Translation-Units-and-Models_Translation-Units_Example">Translation
|
|
units 1-3 in the previous section</a>, taken together, form a single
|
|
model. That model is equivalent to the following single translation
|
|
unit:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M1 { constant a = 0 }
|
|
module M1 { constant b = 1 }
|
|
module M2 {
|
|
constant a = M1.a
|
|
constant b = M1.b
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>According to the
|
|
<a href="#Scoping-of-Names_Multiple-Definitions-with-the-Same-Qualified-Name_Module-Definitions">semantics
|
|
of module definitions</a>,
|
|
this is also equivalent:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M1 {
|
|
constant a = 0
|
|
constant b = 1
|
|
}
|
|
module M2 {
|
|
constant a = M1.a
|
|
constant b = M1.b
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Note that translation unit 3 alone is not a valid model, because it
|
|
uses free symbols defined in the other translation units. Similarly, the
|
|
translation unit 3 together with just translation unit 1 or translation
|
|
unit 2 is not a valid model.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Translation-Units-and-Models_Locations">14.3. Locations</h3>
|
|
<div class="paragraph">
|
|
<p>Every syntactic element <em>E</em> in a source model has an associated
|
|
<strong>location</strong> <em>L</em>.
|
|
The location is used when resolving <a href="#Specifiers_Location-Specifiers">location
|
|
specifiers</a> and
|
|
<a href="#Specifiers_Include-Specifiers">include specifiers</a>
|
|
during <a href="#Analysis-and-Translation">analysis</a>.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>If <em>E</em> is read in from a file, then <em>L</em> is the absolute path
|
|
of the file.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>E</em> is read from standard input, then <em>L</em> is the absolute path of the current
|
|
directory in the environment where the analysis occurs.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Scoping-of-Names">15. Scoping of Names</h2>
|
|
<div class="sectionbody">
|
|
<div class="sect2">
|
|
<h3 id="Scoping-of-Names_Qualified-Identifiers">15.1. Qualified Identifiers</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>qualified identifier</strong> is one of the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>An
|
|
<a href="#Lexical-Elements_Identifiers">identifier</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>Q</em> <code>.</code> <em>I</em>, where <em>Q</em> is a qualified identifier and <em>I</em> is an
|
|
identifier.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Examples:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">a
|
|
a.b
|
|
a.b.c</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Scoping-of-Names_Names-of-Definitions">15.2. Names of Definitions</h3>
|
|
<div class="paragraph">
|
|
<p>Every
|
|
<a href="#Definitions">definition</a>
|
|
<em>D</em> appearing in an FPP model has a unique <strong>qualified
|
|
name</strong>. The qualified name is a
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers">qualified identifier</a> formed as follows:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>If <em>D</em> appears outside any
|
|
<a href="#Definitions">definition</a> with a brace-delimited body, then
|
|
the qualified name is the identifier <em>I</em> appearing in <em>D</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise, the qualified name is <em>N</em> <code>.</code> <em>I</em>, where <em>N</em> is the qualified
|
|
name of the enclosing definition, and <em>I</em> is
|
|
the identifier appearing in <em>D</em>.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For example:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M { # Qualified name is M
|
|
module N { # Qualified name is M.N
|
|
enum Maybe { # Qualified name is M.N.Maybe
|
|
NO # Qualified name is M.N.Maybe.NO
|
|
YES # Qualified name is M.N.Maybe.YES
|
|
}
|
|
}
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Scoping-of-Names_Name-Groups">15.3. Name Groups</h3>
|
|
<div class="paragraph">
|
|
<p>The qualified names of definitions and
|
|
reside in the following <strong>name groups</strong>:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The <strong>component instance name group</strong></p>
|
|
</li>
|
|
<li>
|
|
<p>The <strong>component name group</strong></p>
|
|
</li>
|
|
<li>
|
|
<p>The <strong>port name group</strong></p>
|
|
</li>
|
|
<li>
|
|
<p>The <strong>state machine name group</strong></p>
|
|
</li>
|
|
<li>
|
|
<p>The <strong>topology name group</strong></p>
|
|
</li>
|
|
<li>
|
|
<p>The <strong>type name group</strong></p>
|
|
</li>
|
|
<li>
|
|
<p>The <strong>value name group</strong></p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Definitions reside in name groups as follows:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>Abstract type definitions reside in the type name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>Array type definitions reside in the type name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>Component definitions reside in the component name group,
|
|
the value name group, the type name group, and the
|
|
state machine name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>Component instance definitions reside in the component instance name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>Constant definitions reside in the value name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>Enum definitions reside in both the value name group and the type name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>Enumerated constant definitions reside in the value name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>Module definitions reside in all the name groups.</p>
|
|
</li>
|
|
<li>
|
|
<p>Port definitions reside in the port name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>State machine definitions reside in the state machine name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>Struct type definitions reside in the type name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>Topology definitions reside in the topology name group.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Notice that elements with scopes reside in the name groups of items
|
|
that they may enclose.
|
|
For example, enums reside in the value name group because they
|
|
enclose constant definitions.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Scoping-of-Names_Multiple-Definitions-with-the-Same-Qualified-Name">15.4. Multiple Definitions with the Same Qualified Name</h3>
|
|
<div class="sect3">
|
|
<h4 id="Scoping-of-Names_Multiple-Definitions-with-the-Same-Qualified-Name_Different-Name-Groups">15.4.1. Different Name Groups</h4>
|
|
<div class="paragraph">
|
|
<p>Two definitions with the same qualified name are allowed if they are in
|
|
different name groups. For example:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">struct s { x: U32 } # Defines s in the type name group
|
|
constant s = 0 # Defines s in the value name group</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Scoping-of-Names_Multiple-Definitions-with-the-Same-Qualified-Name_Module-Definitions">15.4.2. Module Definitions</h4>
|
|
<div class="paragraph">
|
|
<p>Multiple syntactic module definitions with the same qualified name are
|
|
allowed. The semantic analysis combines all such definitions into a
|
|
single module definition with that qualified name. For example, this
|
|
model is legal</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M { constant a = 0 }
|
|
module M { constant b = 1 }
|
|
a = M.a
|
|
b = M.b</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>It is equivalent to this model:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M {
|
|
constant a = 0
|
|
constant b = 1
|
|
}
|
|
a = M.a
|
|
b = M.b</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Because the <a href="#Definitions-and-Uses_Order-of-Definitions-and-Uses">order
|
|
of definitions is irrelevant</a>, this is also equivalent:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M { constant a = 0 }
|
|
a = M.a
|
|
b = M.b
|
|
module M { constant b = 1 }</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Scoping-of-Names_Multiple-Definitions-with-the-Same-Qualified-Name_Conflicting-Definitions">15.4.3. Conflicting Definitions</h4>
|
|
<div class="paragraph">
|
|
<p>Within the same name group, two definitions with the same
|
|
qualified name are not allowed, unless they are both module definitions
|
|
as described above. For example:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M {
|
|
constant a = 0
|
|
constant a = 1 # Error: Name M.a is redefined
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Two definitions with the same identifier are allowed if they have
|
|
different qualified names, for example:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 0
|
|
module M {
|
|
constant a = 1 # OK, qualified name is M.a =/= a
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Scoping-of-Names_Resolution-of-Identifiers">15.5. Resolution of Identifiers</h3>
|
|
<div class="paragraph">
|
|
<p>The following rules govern the resolution of identifiers, i.e.,
|
|
associating identifiers with definitions:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Use the context to determine which
|
|
<a href="#Scoping-of-Names_Name-Groups">name group</a>
|
|
<em>S</em> to use. For example, if we are expecting a type name, then use the
|
|
type name group.</p>
|
|
</li>
|
|
<li>
|
|
<p>At the top level (outside the brace-delimited body of any definition), the
|
|
identifier <em>I</em> refers to the unique definition with qualified name <em>I</em> if it
|
|
exists in name group <em>S</em>. Otherwise an error results.</p>
|
|
</li>
|
|
<li>
|
|
<p>Inside the brace-delimited body of a <a href="#Definitions">definition</a> with
|
|
qualified name <em>N</em> appearing at the top level:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>The identifier <em>I</em> refers to the definition with qualified name
|
|
<em>N</em> <code>.</code> <em>I</em> if it exists in name group <em>S</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise <em>I</em> refers to the definition with qualified name <em>I</em> if it
|
|
exists in name group <em>S</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise an error results.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>Inside the brace-delimited body of a definition with qualified name
|
|
<em>N</em> appearing inside the body of a definition <em>D</em>:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>The identifier <em>I</em> refers to the definition with qualified name
|
|
<em>N</em> <code>.</code> <em>I</em> if it exists in name group <em>S</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise proceed as if <em>I</em> were appearing inside <em>D</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example:</strong></p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><em>S</em> refers to the value name group.</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp"># Identifier M is in scope in S and refers to the qualified name M
|
|
# Identifier a is in scope in S and refers to qualified name a
|
|
|
|
constant a = 1 # Unique definition in S with qualified name a
|
|
|
|
module M {
|
|
# Identifier M is in scope in S and refers to the qualified name M
|
|
# Identifier N is in scope in S and refers to the qualified name N
|
|
# Identifier a is in scope in S and refers to qualified name a
|
|
# Identifier b is in scope in S and refers to qualified name M.b
|
|
constant b = 2 # Unique definition in S with qualified name M.b
|
|
}
|
|
|
|
# Identifier M is in scope in S and refers to the qualified name M
|
|
# Identifier a is in scope in S and refers to qualified name a
|
|
|
|
module M {
|
|
|
|
# Identifier M is in scope in S and refers to the qualified name M
|
|
# Identifier N is in scope in S and refers to the qualified name M.N
|
|
# Identifier a is in scope and refers to qualified name a
|
|
# Identifier b is in scope and refers to qualified name M.b
|
|
|
|
module N {
|
|
# Identifier M is in scope in S and refers to the qualified name M
|
|
# Identifier N is in scope in S and refers to the qualified name M.N
|
|
# Identifier a is in scope in S and refers to qualified name a
|
|
# Identifier b is in scope in S and refers to qualified name M.N.b
|
|
constant b = 3 # Unique definition in S with qualified name M.N.b
|
|
}
|
|
|
|
}
|
|
|
|
# Identifier M is in scope in S and refers to the qualified name M
|
|
# Identifier a is in scope in S and refers to qualified name a</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Scoping-of-Names_Resolution-of-Qualified-Identifiers">15.6. Resolution of Qualified Identifiers</h3>
|
|
<div class="paragraph">
|
|
<p>The following rules govern the resolution of
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers">qualified identifiers</a>, i.e.,
|
|
associating qualified identifiers with definitions:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>If a qualified identifier is an identifier, then resolve it as
|
|
stated in the
|
|
<a href="#Scoping-of-Names_Resolution-of-Identifiers">previous section</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise, the qualified identifier has the form <em>Q</em> <code>.</code> <em>I</em>, where
|
|
<em>Q</em> is a qualified identifier and <em>I</em> is an identifier. Do the
|
|
following:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>Recursively resolve <em>Q</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>Q</em> refers to a <a href="#Definitions">definition</a>
|
|
with a brace-delimited body, then do the following:</p>
|
|
<div class="olist lowerroman">
|
|
<ol class="lowerroman" type="i">
|
|
<li>
|
|
<p>Determine the <a href="#Scoping-of-Names_Name-Groups">name group</a> <em>S</em> of <em>Q</em> <code>.</code>
|
|
<em>I</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Look in <em>D</em> for a definition with identifier <em>I</em> in name group <em>S</em>.
|
|
If there is none, issue an error.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise the qualified identifier is invalid. Issue an error.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M {
|
|
constant a = 0
|
|
enum E {
|
|
b = 2
|
|
c = b # Refers to M.E.b
|
|
d = E.b # Refers to M.E.b
|
|
e = M.E.b # Refers to M.E.b
|
|
}
|
|
constant f = a # Refers to M.a
|
|
constant g = M.a # Refers to M.a
|
|
constant h = E.b # Refers to M.E.b
|
|
constant i = M.E.b # Refers to M.E.b
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Definitions-and-Uses">16. Definitions and Uses</h2>
|
|
<div class="sectionbody">
|
|
<div class="sect2">
|
|
<h3 id="Definitions-and-Uses_Uses">16.1. Uses</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>use</strong> is a
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers">qualified identifier</a>
|
|
that refers to a
|
|
<a href="#Definitions">definition</a>
|
|
according to the
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">scoping rules for names</a>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>A use is a <strong>qualifying use</strong> if it qualifies another use. For example, in
|
|
the following code</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>The expression <code>M.a</code> contains the expression <code>M</code>, which is a qualifying use
|
|
of the module <code>M</code>. It qualifies the use <code>M.a</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The expression <code>M.a</code> is not a qualifying use.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="FPP">module M {
|
|
|
|
constant a = 0
|
|
|
|
constant b = M.a
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>If a use <em>u</em> is not a qualifying use, then we say it is a <strong>non-qualifying use</strong>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions-and-Uses_Use-Def-Graph">16.2. Use-Def Graph</h3>
|
|
<div class="paragraph">
|
|
<p>The set of definitions and
|
|
<a href="#Definitions-and-Uses_Uses">non-qualifying uses</a>
|
|
in an FPP model induces a directed
|
|
graph called the <strong>use-def graph</strong>. In this graph,</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>The nodes are the definitions.</p>
|
|
</li>
|
|
<li>
|
|
<p>There is an edge from each definition <em>d</em> to the definitions
|
|
\$d_1, ..., d_n\$ corresponding to the non-qualifying uses
|
|
\$u_1, ..., u_n\$ appearing in <em>d</em>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For example, in the following code, the use-def graph has two nodes <code>a</code> and
|
|
<code>b</code> and one edge <code>b</code> \$rarr\$ <code>a</code>.</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="FPP">constant a = 0
|
|
constant b = a</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>In a legal FPP model, the use-def graph must be acyclic. For example,
|
|
this model is illegal:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="FPP">constant a = b
|
|
constant b = a</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>This model is also illegal:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="FPP">constant a = a</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>This model is legal:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="FPP">module M {
|
|
|
|
constant a = 0
|
|
|
|
constant b = M.a
|
|
|
|
}</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The use <code>M</code> appears inside the definition of <code>M</code>.
|
|
However, it is a qualifying use.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Definitions-and-Uses_Order-of-Definitions-and-Uses">16.3. Order of Definitions and Uses</h3>
|
|
<div class="paragraph">
|
|
<p>So long as the
|
|
<a href="#Definitions-and-Uses_Use-Def-Graph">use-def graph</a> is acyclic, there is no
|
|
constraint either on the ordering of
|
|
definitions and uses within a
|
|
<a href="#Translation-Units-and-Models">translation unit</a>,
|
|
or on the distribution of definitions and uses among translation
|
|
units. For example, if the definition <code>constant c = 0</code> appears anywhere
|
|
in any translation unit of a model <em>M</em>, then the use of <code>c</code> as a
|
|
constant value of type <em>Integer</em> is legal anywhere in any translation unit of
|
|
<em>M</em>. In particular, this model is legal:</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="FPP">constant b = a
|
|
constant a = 0</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The model consisting of two translation units</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="FPP">constant b = a</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>and</p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="FPP">constant a = 0</code></pre>
|
|
</div>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>is also legal, and the order in which the units are presented to the
|
|
translator does not matter.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Types">17. Types</h2>
|
|
<div class="sectionbody">
|
|
<div class="sect2">
|
|
<h3 id="Types_Primitive-Integer-Types">17.1. Primitive Integer Types</h3>
|
|
<div class="paragraph">
|
|
<p>The <strong>primitive integer types</strong> correspond to the
|
|
<a href="#Type-Names_Primitive-Integer-Type-Names">primitive integer type names</a>
|
|
and are written in the same way, e.g., <code>U32</code>.
|
|
The primitive integer types whose names start with <code>I</code> are <strong>signed</strong>.
|
|
The primitive integer types whose names start with <code>U</code> are <strong>unsigned</strong>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_Floating-Point-Types">17.2. Floating-Point Types</h3>
|
|
<div class="paragraph">
|
|
<p>The <strong>floating-point types</strong> correspond to the
|
|
<a href="#Type-Names_Floating-Point-Type-Names">floating-point type names</a>
|
|
and are written in the same way, e.g., <code>F64</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_Primitive-Numeric-Types">17.3. Primitive Numeric Types</h3>
|
|
<div class="paragraph">
|
|
<p>The <a href="#Types_Primitive-Integer-Types">primitive integer types</a>
|
|
together with the <a href="#Types_Floating-Point-Types">floating-point types</a> are
|
|
called the <strong>primitive numeric types</strong>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_The-Boolean-Type">17.4. The Boolean Type</h3>
|
|
<div class="paragraph">
|
|
<p>The <strong>Boolean type</strong> corresponds to the
|
|
<a href="#Type-Names_The-Boolean-Type-Name">Boolean type name</a>.
|
|
It is written <code>bool</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_Primitive-Types">17.5. Primitive Types</h3>
|
|
<div class="paragraph">
|
|
<p>Together, the <a href="#Types_Primitive-Numeric-Types">primitive numeric types</a>
|
|
and the
|
|
<a href="#Types_The-Boolean-Type">Boolean type</a>
|
|
are called the <strong>primitive types</strong>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_String-Types">17.6. String Types</h3>
|
|
<div class="paragraph">
|
|
<p>The <strong>string types</strong> correspond to the
|
|
<a href="#Type-Names_String-Type-Names">string type names</a>.
|
|
A string type is written <code>string</code> or <code>string size</code> <em>n</em>,
|
|
where <em>n</em> is an integer value in the range [1,2^31-1].
|
|
There is one string type <code>string</code> and one string type <code>string</code> <em>n</em>
|
|
for each legal value of <em>n</em>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_Array-Types">17.7. Array Types</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>array type</strong> is a type associated with an
|
|
<a href="#Definitions_Array-Definitions">array definition</a>.
|
|
There is one array type per array definition.
|
|
Each array type is computed after resolving constants,
|
|
so an array type has a constant integer value for its size.
|
|
An array type is written using its
|
|
<a href="#Scoping-of-Names_Names-of-Definitions">unique qualified
|
|
name</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_Enum-Types">17.8. Enum Types</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>enum type</strong> is a type associated with an
|
|
<a href="#Definitions_Enum-Definitions">enum definition</a>.
|
|
There is one enum type per enum definition.
|
|
An enum type is written using its
|
|
<a href="#Scoping-of-Names_Names-of-Definitions">unique qualified
|
|
name</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_Struct-Types">17.9. Struct Types</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>struct type</strong> is a type associated with a
|
|
<a href="#Definitions_Struct-Definitions">struct definition</a>.
|
|
There is one struct type per struct definition.
|
|
A struct type is written using its
|
|
<a href="#Scoping-of-Names_Names-of-Definitions">unique qualified
|
|
name</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_Abstract-Types">17.10. Abstract Types</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>abstract type</strong> is a type associated with an
|
|
<a href="#Definitions_Abstract-Type-Definitions">abstract type definition</a>.
|
|
There is is one abstract type per abstract type definition.
|
|
An abstract type is written using its
|
|
<a href="#Scoping-of-Names_Names-of-Definitions">unique qualified
|
|
name</a>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_Internal-Types">17.11. Internal Types</h3>
|
|
<div class="paragraph">
|
|
<p><strong>Internal types</strong> do not have syntactic names in FPP source models.
|
|
The compiler assigns these types to expressions during type checking.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Types_Internal-Types_Integer">17.11.1. Integer</h4>
|
|
<div class="paragraph">
|
|
<p>The type <em>Integer</em> represents all integer values, without regard
|
|
to bit width.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Types_Internal-Types_Integer-Types">17.11.2. Integer Types</h4>
|
|
<div class="paragraph">
|
|
<p><a href="#Types_Internal-Types_Integer"><em>Integer</em></a> together with the
|
|
<a href="#Types_Primitive-Integer-Types">primitive integer types</a> are called
|
|
the <strong>integer types</strong>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Types_Internal-Types_Numeric-Types">17.11.3. Numeric Types</h4>
|
|
<div class="paragraph">
|
|
<p><a href="#Types_Internal-Types_Integer"><em>Integer</em></a> together with the
|
|
<a href="#Types_Primitive-Numeric-Types">primitive numeric types</a> are called
|
|
the <strong>numeric types</strong>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Types_Internal-Types_Anonymous-Array-Types">17.11.4. Anonymous Array Types</h4>
|
|
<div class="paragraph">
|
|
<p>The type <em>[</em> <em>n</em> <em>]</em> <em>T</em>, where <em>n</em>
|
|
is an integer and <em>T</em> is a type, represents an array of <em>n</em> elements,
|
|
each of type <em>T</em>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Types_Internal-Types_Anonymous-Struct-Types">17.11.5. Anonymous Struct Types</h4>
|
|
<div class="paragraph">
|
|
<p>The type <em>{</em> \$m_1\$ <em>:</em> \$T_1, ...,\$ \$m_n\$ <em>:</em> \$T_n\$ <em>}</em>,
|
|
where each \$m_i\$ is an identifier and each \$T_i\$ is a type,
|
|
represents a struct with members \$m_i\$ <em>:</em> \$T_i\$.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The order of the members is not significant.
|
|
For example, <code>{ a: U32, b: F32 }</code> represents the same
|
|
type as <code>{ b : F32, a: U32 }</code>.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_Displayable-Types">17.12. Displayable Types</h3>
|
|
<div class="paragraph">
|
|
<p>A type is a <strong>displayable type</strong> if it is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A <a href="#Types_Primitive-Integer-Types">primitive integer type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Types_Floating-Point-Types">floating-point type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Types_The-Boolean-Type">boolean type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Types_String-Types">string type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Types_Enum-Types">enum type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Types_Array-Types">array type</a> whose member type is a displayable type.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Types_Struct-Types">struct type</a> whose member types are all displayable types.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_Types-with-Numeric-Members">17.13. Types with Numeric Members</h3>
|
|
<div class="paragraph">
|
|
<p>A type <strong>has numeric members</strong> if it is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A <a href="#Types_Internal-Types_Numeric-Types">numeric type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Types_Array-Types">array type</a> or
|
|
<a href="#Types_Internal-Types_Anonymous-Array-Types">anonymous array type</a> whose
|
|
member type has numeric members.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Types_Struct-Types">struct type</a> or
|
|
<a href="#Types_Internal-Types_Anonymous-Struct-Types">anonymous struct type</a> whose
|
|
member types all have numeric members.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Types_Default-Values">17.14. Default Values</h3>
|
|
<div class="paragraph">
|
|
<p>Every type <em>T</em> with a syntactic name in FPP has an associated <strong>default
|
|
value</strong>.
|
|
In generated C++ code, this is the value that is used to initialize a variable
|
|
of type <em>T</em>
|
|
when no other initializer is specified.
|
|
Default values are important, because they ensure that in generated code,
|
|
every variable is initialized when it is created.</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>The default value associated with each
|
|
<a href="#Types_Primitive-Numeric-Types">primitive numeric type</a> is zero.</p>
|
|
</li>
|
|
<li>
|
|
<p>The default value associated with
|
|
<a href="#Types_The-Boolean-Type"><code>bool</code></a> is <code>false</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The default value associated with any
|
|
<a href="#Types_String-Types">string type</a> is the empty string.</p>
|
|
</li>
|
|
<li>
|
|
<p>The default value associated with an
|
|
<a href="#Types_Array-Types">array type</a> <em>T</em> is (1)
|
|
the default value specified in the array definition,
|
|
if one is given; otherwise (2) the unique value
|
|
of type <em>T</em> that has the default value of the member type
|
|
of <em>T</em> at each member.
|
|
See the section on <a href="#Definitions_Array-Definitions">array definitions</a> for examples.</p>
|
|
</li>
|
|
<li>
|
|
<p>The default value associated with an
|
|
<a href="#Types_Enum-Types">enum type</a> is (1) the default value
|
|
specified in the enum definition, if one is given;
|
|
otherwise (2) the first
|
|
enumerated constant appearing in the enum definition.</p>
|
|
</li>
|
|
<li>
|
|
<p>The default value associated with a
|
|
<a href="#Types_Struct-Types">struct type</a> <em>T</em> is (1)
|
|
the default value specified in the struct definition,
|
|
if one is given; otherwise (2) the unique value of type
|
|
<em>T</em> that has the default value of the member type \$T_i\$
|
|
for each member \$m_i\$ <code>:</code> \$T_i\$ of <em>T</em>.
|
|
See the section on <a href="#Definitions_Struct-Definitions">struct definitions</a> for examples.</p>
|
|
</li>
|
|
<li>
|
|
<p>The default value associated with an
|
|
<a href="#Types_Abstract-Types">abstract type</a> <em>T</em> is the
|
|
<a href="#Values_Abstract-Type-Values">single value associated with <em>T</em></a>.
|
|
This value is left abstract in the FPP model; the implementation
|
|
of <em>T</em> must provide a concrete value.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Type-Checking">18. Type Checking</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>In this section, we explain the rules used to assign types to
|
|
expressions. FPP is a statically typed language. That means the
|
|
following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>Type checking of expressions occurs during
|
|
<a href="#Analysis-and-Translation_Analysis">analysis</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If the type checking phase detects a violation of any of these rules,
|
|
then translation halts with an error message and does not produce any
|
|
code.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Each type represents a collection of
|
|
<a href="#Values">values</a>.
|
|
The type checking rules exist to ensure that whenever an expression of
|
|
type \$T\$ is <a href="#Evaluation_Evaluating-Expressions">evaluated</a>,
|
|
the result is a value of type \$T\$.</p>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Integer-Literals">18.1. Integer Literals</h3>
|
|
<div class="paragraph">
|
|
<p>To type an
|
|
<a href="#Expressions_Integer-Literals">integer
|
|
literal expression</a>, the semantic analyzer does the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Evaluate the expression to an unsigned integer value \$v\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Assign the type <a href="#Types_Internal-Types_Integer"><em>Integer</em></a> to the expression.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Examples:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 0 # Type is Integer
|
|
constant b = 1 # Type is Integer
|
|
constant c = 256 # Type is Integer
|
|
constant d = 65536 # Type is Integer
|
|
constant e = 0x100000000 # Type is Integer</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Floating-Point-Literals">18.2. Floating-Point Literals</h3>
|
|
<div class="paragraph">
|
|
<p>The type of a
|
|
<a href="#Expressions_Floating-Point-Literals">floating-point
|
|
literal expression</a> is <code>F64</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Boolean-Literals">18.3. Boolean Literals</h3>
|
|
<div class="paragraph">
|
|
<p>The type of a
|
|
<a href="#Expressions_Boolean-Literals">boolean
|
|
literal expression</a> is <code>bool</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_String-Literals">18.4. String Literals</h3>
|
|
<div class="paragraph">
|
|
<p>The type of a
|
|
<a href="#Expressions_String-Literals">string
|
|
literal expression</a> is <code>string</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Identifier-Expressions">18.5. Identifier Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>To type an <a href="#Expressions_Identifier-Expressions">identifier
|
|
expression</a> \$e\$, the semantic analyzer
|
|
<a href="#Scoping-of-Names_Resolution-of-Identifiers">resolves the identifier to a
|
|
definition</a> and uses the type given in the definition.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 42 # a is a constant with type Integer
|
|
constant b = a # The expression a refers to the constant a and has type Integer</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Dot-Expressions">18.6. Dot Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>To type a
|
|
<a href="#Expressions_Dot-Expressions">dot
|
|
expression</a> \$e\$ <code>.x</code>, the semantic analyzer does the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>If \$e\$<code>.x</code> is a
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers">qualified identifier</a> that represents
|
|
the use of a definition according to the
|
|
<a href="#Scoping-of-Names_Resolution-of-Qualified-Identifiers">rules
|
|
for resolving qualified identifiers</a>, and the use is a valid
|
|
<a href="#Expressions_Dot-Expressions">dot
|
|
expression</a>, then use the type given in the definition.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise \$e\$<code>.x</code> is invalid. Throw an error.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Example:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">module M {
|
|
constant a = 0 # The constant M.a has type Integer
|
|
}
|
|
constant b = M.a # Expression M.a represents a use of the definition M.a.
|
|
# Its type is Integer.</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Array-Expressions">18.7. Array Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>To type an
|
|
<a href="#Expressions_Array-Expressions">array expression</a>
|
|
<code>[</code> \$e_1\$ <code>,</code> \$...\$ <code>,</code> \$e_n\$ <code>]</code>,
|
|
the semantic analyzer does the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>For each \$i in [1,n\$], compute the type \$T_i\$ of \$e_i\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Compute the <a href="#Type-Checking_Computing-a-Common-Type_Lists-of-Types">common type</a>
|
|
\$T\$ of the list of types \$T_i\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Assign the type <em>[</em> \$n\$ <em>]</em> \$T\$ to the expression.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Examples:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = [ 1, 2, 3 ] # Type is [3] Integer
|
|
constant b = [ 1, 2, 3.0 ] # Type is [3] F64</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Struct-Expressions">18.8. Struct Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>To type a
|
|
<a href="#Expressions_Struct-Expressions">struct expression</a>
|
|
<code>{</code> \$m_1\$ <code>=</code> \$e_1\$ <code>,</code> \$...\$ <code>,</code> \$m_n\$ <code>=</code> \$e_n\$ <code>}</code>,
|
|
the semantic analyzer does the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Check that the member names \$m_i\$ are distinct.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each \$i in [1,n\$], compute the type \$T_i\$ of \$e_i\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Assign the type <em>{</em> \$m_1\$ <em>=</em> \$T_1\$ <em>,</em> \$...\$ <em>,</em> \$m_n\$ <em>=</em> \$T_n\$ <em>}</em>
|
|
to the expression.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Examples:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = { x = 1, y = 2.0 } # Type is { x: Integer, y: F64 }
|
|
constant b = { x = 1, x = 2 } # Error</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Unary-Negation-Expressions">18.9. Unary Negation Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>To type a
|
|
<a href="#Expressions_Arithmetic-Expressions">unary
|
|
negation expression</a> <code>-</code> \$e\$, the semantic analyzer does the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Compute the type \$T\$ of \$e\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>If \$T\$ is a <a href="#Types_Internal-Types_Numeric-Types">numeric type</a>, then use \$T\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T\$ <a href="#Type-Checking_Type-Conversion">may be converted to</a>
|
|
<em>Integer</em>, then use <em>Integer</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise throw an error.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Examples:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = -1.0 # Type is F64
|
|
constant b = -1 # Type is Integer
|
|
constant c = -c # Type is Integer
|
|
constant d = -0xFFFFFFFF # Type is Integer
|
|
enum E { X = 1 }
|
|
constant e = -E.X # Type is Integer
|
|
constant f = -true # Error</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Binary-Arithmetic-Expressions">18.10. Binary Arithmetic Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>To type a
|
|
<a href="#Expressions_Arithmetic-Expressions">binary
|
|
arithmetic expression</a> \$e_1\$ <em>op</em> \$e_2\$, the semantic analyzer does
|
|
the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Compute the common type \$T\$ of \$e_1\$ and \$e_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>If \$T\$ is a <a href="#Types_Internal-Types_Numeric-Types">numeric type</a>, then use \$T\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T\$ <a href="#Type-Checking_Type-Conversion">may be converted to</a>
|
|
<em>Integer</em>, then use <em>Integer</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise throw an error.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Examples:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = 1 + 2 # Type is Integer
|
|
constant b = 3 + 4 # Type is Integer
|
|
constant c = -0xFFFFFFFF # Type is Integer
|
|
enum E { X = 1, Y = 2 }
|
|
constant d = X + Y # Type is Integer
|
|
constant e = true + "abcd" # Error</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Parenthesis-Expressions">18.11. Parenthesis Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>To type a
|
|
<a href="#Expressions_Parenthesis-Expressions">parenthesis
|
|
expression</a> <code>(</code> \$e\$ <code>)</code>, the semantic analyzer does the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Compute the type \$T\$ of \$e\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Use \$T\$ as the type of the expression.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p><strong>Examples:</strong></p>
|
|
</div>
|
|
<div class="listingblock">
|
|
<div class="content">
|
|
<pre class="prettyprint highlight"><code data-lang="fpp">constant a = (1.0 + 2) # Type is F64
|
|
constant b = (3 + 4) # Type is Integer
|
|
constant c = (true) # Type is bool
|
|
constant d = ("abcd") # Type is string
|
|
constant e = ([ 1, 2, 3]) # Type is [3] Integer</code></pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Identical-Types">18.12. Identical Types</h3>
|
|
<div class="paragraph">
|
|
<p>We say that types \$T_1\$ and \$T_2\$ are <strong>identical</strong> if one
|
|
of the following holds:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>\$T_1\$ and \$T_2\$ are
|
|
<a href="#Types_Internal-Types_Numeric-Types">numeric types</a>
|
|
with the same name, e.g., <code>U32</code> or <em>Integer</em>.
|
|
In each case of a numeric type, the name of the type uniquely identifies
|
|
the type.</p>
|
|
</li>
|
|
<li>
|
|
<p>\$T_1\$ and \$T_2\$
|
|
are both
|
|
<a href="#Types_The-Boolean-Type">the Boolean type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>\$T_1\$ and \$T_2\$
|
|
are both the same
|
|
<a href="#Types_String-Types">string type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Each of \$T_1\$ and \$T_2\$
|
|
is an
|
|
<a href="#Types_Array-Types">array type</a>,
|
|
<a href="#Types_Enum-Types">enum type</a>, or
|
|
<a href="#Types_Struct-Types">struct type</a>,
|
|
and both types refer to the same definition.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Type-Conversion">18.13. Type Conversion</h3>
|
|
<div class="paragraph">
|
|
<p>We say that a type \$T_1\$ <strong>may be converted to</strong> another type \$T_2\$ if
|
|
every <a href="#Values">value</a> represented by type \$T_1\$ can be
|
|
<a href="#Evaluation_Type-Conversion">converted</a> into a value of type \$T_2\$.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Here are the rules for type conversion:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>\$T_1\$ may be converted to \$T_2\$ if \$T_1\$ and \$T_2\$
|
|
are <a href="#Type-Checking_Identical-Types">identical types</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Any <a href="#Types_String-Types">string type</a> may be converted
|
|
to any other string type.</p>
|
|
</li>
|
|
<li>
|
|
<p>Any <a href="#Types_Internal-Types_Numeric-Types">numeric
|
|
type</a> may be converted to any other numeric type.</p>
|
|
</li>
|
|
<li>
|
|
<p>An <a href="#Types_Enum-Types">enum type</a> may be converted to a
|
|
<a href="#Types_Internal-Types_Numeric-Types">numeric type</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If \$T_1\$ or \$T_2\$ or both are
|
|
<a href="#Types_Array-Types">array types</a>, then
|
|
\$T_1\$ may be converted to \$T_2\$ if the conversion
|
|
is allowed after replacing the array type or types with
|
|
structurally equivalent
|
|
<a href="#Types_Internal-Types_Anonymous-Array-Types">anonymous array types</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>An anonymous array type \$T_1 =\$ <em>[</em> \$n\$ <em>]</em> \$T'_1\$
|
|
may be converted to the anonymous array type
|
|
\$T_2 =\$ <em>[</em> \$m\$ <em>]</em> \$T'_2\$
|
|
if \$n = m\$ and \$T'_1\$ may be converted to \$T'_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Types_Internal-Types_Numeric-Types">numeric type</a> type, <a href="#Types_The-Boolean-Type">Boolean
|
|
type</a>,
|
|
<a href="#Types_Enum-Types">enum type</a>, or <a href="#Types_String-Types">string types</a> \$T\$
|
|
may be converted to an anonymous array type
|
|
\$T_1\$ may be converted to the member type of \$T_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>If \$T_1\$ or \$T_2\$ or both are
|
|
<a href="#Types_Struct-Types">struct types</a>, then
|
|
\$T_1\$ may be converted to \$T_2\$ if the conversion
|
|
is allowed after replacing the struct type or types with
|
|
structurally equivalent
|
|
<a href="#Types_Internal-Types_Anonymous-Struct-Types">anonymous struct types</a>.
|
|
For purposes of structural equivalence, the member sizes of
|
|
struct types are ignored.
|
|
For example, the struct type <code>S</code> defined by <code>struct S { x: [3] U32 }</code>
|
|
is structurally equivalent to the anonymous struct type
|
|
<code>{ x: U32 }</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>An anonymous struct type
|
|
\$T =\$<em>{</em> \$m_1\$ <em>:</em> \$T_1\$ <em>,</em>
|
|
\$...\$ <em>,</em> \$m_1\$ <em>:</em> \$T_n\$ <em>}</em> may be converted to
|
|
the anonymous struct type \$T'\$ if for each \$i in [1,n]\$,</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>\$m_i\$ <em>:</em> \$T'_i\$ is a member of \$T'\$; and</p>
|
|
</li>
|
|
<li>
|
|
<p>\$T_i\$ may be converted to \$T'_i\$.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>A <a href="#Types_Internal-Types_Numeric-Types">numeric type</a> type, <a href="#Types_The-Boolean-Type">Boolean
|
|
type</a>,
|
|
<a href="#Types_Enum-Types">enum type</a>, or <a href="#Types_String-Types">string type</a> \$T\$
|
|
may be converted to an
|
|
<a href="#Types_Internal-Types_Anonymous-Struct-Types">anonymous struct type</a> \$T'\$ if
|
|
for each member \$m_i\$ <code>:</code> \$T_i\$ of \$T'\$,
|
|
\$T\$ may be converted to \$T_i\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Type convertibility is transitive: if \$T_1\$ may be converted to
|
|
\$T_2\$
|
|
and \$T_2\$ may be converted to \$T_3\$, then \$T_1\$
|
|
may be converted to \$T_3\$.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Checking_Computing-a-Common-Type">18.14. Computing a Common Type</h3>
|
|
<div class="sect3">
|
|
<h4 id="Type-Checking_Computing-a-Common-Type_Pairs-of-Types">18.14.1. Pairs of Types</h4>
|
|
<div class="paragraph">
|
|
<p>Here are the rules for resolving two types \$T_1\$ and \$T_2\$
|
|
(e.g., the
|
|
types of two subexpressions) to a common type \$T\$ (e.g., the type of
|
|
the whole expression):</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>If \$T_1\$ and \$T_2\$ are
|
|
<a href="#Type-Checking_Identical-Types">identical types</a>, then let
|
|
\$T\$ be \$T_1\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ and \$T_2\$ are both
|
|
<a href="#Types_Internal-Types_Numeric-Types">numeric types</a>, then do the following:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>If \$T_1\$ and \$T_2\$ are both floating-point types, then use <code>F64</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise use <a href="#Types_Internal-Types_Integer"><em>Integer</em></a>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ and \$T_2\$ are both
|
|
<a href="#Types_String-Types">string types</a>, then use <code>string</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ or \$T_2\$ or both are enum types, then replace
|
|
the enum type or types with the representation type specified in the enum definitions and
|
|
and reapply these rules.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ or \$T_2\$ or both are array types,
|
|
then replace the array type or types with structurally equivalent
|
|
anonymous array types and reapply these rules.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ and \$T_2\$ are anonymous array types with the same size \$n\$
|
|
and with member types \$T'_1\$ and \$T'_2\$, then apply these rules to resolve
|
|
\$T'_1\$ and \$T'_2\$ to \$T'\$ and let \$T\$ be <em>[</em> \$n\$ <em>]</em> \$T'\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if one of \$T_1\$ and \$T_2\$ is a type \$T'\$ that is
|
|
convertible to an anonymous array type
|
|
and the other
|
|
one is an anonymous array type <em>[</em> \$n\$ <em>]</em> \$T''\$, then apply these
|
|
rules to resolve
|
|
\$T'\$ and \$T''\$ to a common type \$T'''\$. Let \$T\$ be
|
|
the
|
|
array type <em>[</em> \$n\$ <em>]</em> \$T'''\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ or \$T_2\$ or both are struct types,
|
|
then replace the struct type or types with structurally equivalent
|
|
anonymous struct types and reapply these rules.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ and \$T_2\$ are both anonymous struct types, then use
|
|
the anonymous struct type \$T\$ with the following members:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>For each member \$m_1\$ <em>:</em> \$T'_1\$ of \$T_1\$,
|
|
if \$T_2\$ has a member \$m_1\$ <em>:</em> \$T'_2\$, then apply these rules
|
|
to convert \$T'_1\$ and \$T'_2\$ to a common type \$T'\$ and
|
|
use \$m_1\$ <em>:</em> \$T'\$. Otherwise use \$m_1\$ <em>:</em> \$T'_1\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each member \$m_2\$ <em>:</em> \$T'_2\$ of \$T_2\$ such
|
|
that \$T_1\$ has no member named \$m_2\$,
|
|
use \$m_2\$ <em>:</em> \$T'_2\$.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if one of \$T_1\$ and \$T_2\$ is a type \$T'\$ that is
|
|
convertible to an anonymous struct type and the other
|
|
one is an anonymous struct type \$S\$, then apply these rules to resolve
|
|
\$T'\$ and each of the struct member types to a common type.
|
|
Let \$T\$ be the struct type whose member names are the member names of
|
|
\$S\$ and
|
|
whose member types are the corresponding common types.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise the attempted resolution is invalid. Throw an error.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Type-Checking_Computing-a-Common-Type_Lists-of-Types">18.14.2. Lists of Types</h4>
|
|
<div class="paragraph">
|
|
<p>To compute a common type for a list of types
|
|
\$T_1, ... , T_n\$, do the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Check that \$n > 0\$. If not, then throw an error.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let \$T'_1\$ be \$T_1\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each \$i in [2,n\$], compute the
|
|
<a href="#Type-Options_Computing-a-Common-Type-Option">common type option</a> \$T'_i\$ of \$T'_(i-1)\$ and \$T_i\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Use \$T'_n\$ as the common type option of the list.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Type-Options">19. Type Options</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>A <strong>type option</strong> is one of the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><em>Some</em> \$T\$, representing a value of type \$T\$.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>None</em>, representing no value.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Type options are used to specify the optional types associated with
|
|
signals, actions, and guards in <a href="#Definitions_State-Machine-Definitions">state
|
|
machine definitions</a>.</p>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Options_Conversion-of-Type-Options">19.1. Conversion of Type Options</h3>
|
|
<div class="paragraph">
|
|
<p>We say that a type option \$O_1\$ <strong>may be converted to</strong> another type option
|
|
\$O_2\$ in the following cases.</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Any type option may be converted to <em>None</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p><em>Some</em> \$T_1\$ may be converted to <em>Some</em> \$T_2\$ in the following cases:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>\$T_1\$ and \$T_2\$ are <a href="#Type-Checking_Identical-Types">identical types</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>\$T_1\$ and \$T_2\$ are both
|
|
<a href="#Types_Primitive-Integer-Types">signed primitive integer types</a>,
|
|
and \$T_2\$ is at least as wide as \$T_1\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>\$T_1\$ and \$T_2\$ are both
|
|
<a href="#Types_Primitive-Integer-Types">unsigned primitive integer types</a>,
|
|
and \$T_2\$ is at least as wide as \$T_1\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>\$T_1\$ and \$T_2\$ are both
|
|
<a href="#Types_Floating-Point-Types">floating-point types</a>,
|
|
and \$T_2\$ is at least as wide as \$T_1\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>\$T_1\$ and \$T_2\$ are both <a href="#Types_String-Types">string types</a>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Type-Options_Computing-a-Common-Type-Option">19.2. Computing a Common Type Option</h3>
|
|
<div class="sect3">
|
|
<h4 id="Type-Options_Computing-a-Common-Type-Option_Pairs-of-Type-Options">19.2.1. Pairs of Type Options</h4>
|
|
<div class="paragraph">
|
|
<p>Here are the rules for resolving two type options \$O_1\$ and \$O_2\$ to
|
|
a common type option \$O\$:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>If either or both of \$O_1\$ and \$O_2\$ is <em>None</em>, then
|
|
let \$O\$ be <em>None</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise let \$O_1\$ be <em>Some</em> \$T_1\$, and let
|
|
\$O_2\$ be <em>Some</em> \$T_2\$.
|
|
Let \$O\$ be <em>Some</em> \$T\$, where \$T\$
|
|
is computed as follows:</p>
|
|
<div class="olist loweralpha">
|
|
<ol class="loweralpha" type="a">
|
|
<li>
|
|
<p>If \$T_1\$ and \$T_2\$ are <a href="#Type-Checking_Identical-Types">identical types</a>,
|
|
then let \$T\$ be \$T_1\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ and \$T_2\$ are both
|
|
<a href="#Types_Primitive-Integer-Types">signed primitive integer types</a>,
|
|
then let \$T\$ be the wider of the two types.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ and \$T_2\$ are both
|
|
<a href="#Types_Primitive-Integer-Types">unsigned primitive integer types</a>,
|
|
then let \$T\$ be the wider of the two types.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ and \$T_2\$ are both
|
|
<a href="#Types_Floating-Point-Types">floating-point types</a>,
|
|
then let \$T\$ be the wider of the two types.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ and \$T_2\$ are both
|
|
<a href="#Types_String-Types">string types</a>, then
|
|
then let \$T\$ be <code>string</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise the attempted resolution is invalid.
|
|
Throw an error.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Type-Options_Computing-a-Common-Type-Option_Lists-of-Type-Options">19.2.2. Lists of Type Options</h4>
|
|
<div class="paragraph">
|
|
<p>To compute a common type for a list of type options
|
|
\$O_1, ... , O_n\$, do the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Check that \$n > 0\$. If not, then throw an error.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let \$O'_1\$ be \$O_1\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each \$i in [2,n\$], compute the
|
|
<a href="#Type-Checking_Computing-a-Common-Type">common type</a> \$O'_i\$ of
|
|
\$O'_(i-1)\$ and \$O_i\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Use \$O'_n\$ as the common type of the list.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Values">20. Values</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p>A <strong>value</strong> is one of the following:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>A primitive integer value</p>
|
|
</li>
|
|
<li>
|
|
<p>An integer value</p>
|
|
</li>
|
|
<li>
|
|
<p>A floating-point value</p>
|
|
</li>
|
|
<li>
|
|
<p>A Boolean value</p>
|
|
</li>
|
|
<li>
|
|
<p>A string value</p>
|
|
</li>
|
|
<li>
|
|
<p>An abstract type value</p>
|
|
</li>
|
|
<li>
|
|
<p>An anonymous array value</p>
|
|
</li>
|
|
<li>
|
|
<p>An array value</p>
|
|
</li>
|
|
<li>
|
|
<p>An enumeration value</p>
|
|
</li>
|
|
<li>
|
|
<p>An anonymous struct value</p>
|
|
</li>
|
|
<li>
|
|
<p>A struct value</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Every value belongs to exactly one type.</p>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_Primitive-Integer-Values">20.1. Primitive Integer Values</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>primitive integer value</strong> is an ordinary (mathematical) integer value
|
|
together with a
|
|
<a href="#Types_Primitive-Integer-Types">primitive integer type</a>. Formally, the set of
|
|
primitive integer values
|
|
is the disjoint union over the integer types of the values
|
|
represented by each type:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>An unsigned integer type of width \$w\$ represents integers in the
|
|
range \$[0, 2^w-1]\$. For example, <code>U8</code> represents the integers
|
|
\$[0, 255]\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>A signed integer type of width \$w\$ represents integers in the range
|
|
\$[-2^(w-1), 2^(w-1)-1]\$. For example, <code>I8</code> represents the integers
|
|
\$[-128, 127]\$.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>We represent a primitive integer value as an expression followed by a colon and a type.
|
|
For example, we write the value 1 at type <code>U32</code> as <code>1: U32</code>. The value <code>1:
|
|
U32</code> is distinct from the value <code>1: U8</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_Integer-Values">20.2. Integer Values</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>integer value</strong> is an ordinary (mathematical) integer value.
|
|
It has type <em>Integer</em>.
|
|
We represent an integer value as an integer number, with no explicit type.
|
|
For example, <code>1</code> is an integer value.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_Floating-Point-Values">20.3. Floating-Point Values</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>floating-point value</strong> is an IEEE floating-point value of 4- or 8-byte
|
|
width. Formally, the set of floating-point values is the disjoint union
|
|
over the types <code>F32</code> and <code>F64</code> of the values represented by each type:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>The type <code>F32</code> represents all IEEE 4-byte floating-point values.</p>
|
|
</li>
|
|
<li>
|
|
<p>The type <code>F64</code> represents all IEEE 8-byte floating-point values.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>We write a floating-point values analogously to primitive integer values. For
|
|
example, we write the value 1.0 at type <code>F32</code> as <code>1.0: F32</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_Boolean-Values">20.4. Boolean Values</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>Boolean value</strong> is one of the values <code>true</code> and <code>false</code>.
|
|
Its type is <code>bool</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_String-Values">20.5. String Values</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>string value</strong> is a sequence of characters that can be
|
|
represented as a <a href="#Expressions_String-Literals">string literal expression</a>.
|
|
It is written in the same way as a string literal expression,
|
|
e.g., <code>"abc"</code>.
|
|
Its type is <code>string</code>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_Abstract-Type-Values">20.6. Abstract Type Values</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>abstract type value</strong> is a value associated with an abstract
|
|
type.
|
|
There is one value associated with each abstract type \$T\$.
|
|
We write the value <code>value of type</code> \$T\$.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_Anonymous-Array-Values">20.7. Anonymous Array Values</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>anonymous array value</strong> is a value associated with an anonymous
|
|
array type.
|
|
We write an anonymous array value similarly to an
|
|
<a href="#Expressions_Array-Expressions">array expression</a>:
|
|
an anonymous array value has the form <code>[</code> \$v_1\$ <code>,</code> \$...\$ <code>,</code>
|
|
\$v_n\$ <code>]</code>, where for each \$i in [1,n\$], \$v_i\$ is a value of type
|
|
\$T\$ for some \$T\$.
|
|
The type of the value is <em>[</em> \$n\$ <em>]</em> \$T\$.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_Array-Values">20.8. Array Values</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>array value</strong> is a value associated with an array type.
|
|
We write an array value like an <a href="#Values_Anonymous-Array-Values">anonymous array
|
|
value</a>, except that the value is annotated with an
|
|
<a href="#Types_Array-Types">array type</a>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>An array value has the form <code>[</code> \$v_1\$ <code>,</code> \$...\$ <code>,</code>
|
|
\$v_n\$ <code>]</code> <code>:</code> \$Q\$,
|
|
where</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>\$Q\$ is a
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers">qualified identifier</a>
|
|
that refers to a
|
|
<a href="#Definitions_Array-Definitions">array definition</a>
|
|
with member type \$T\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each \$i in [1,n\$], \$v_i\$ is a value of type \$T\$.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>The type of the value is \$Q\$.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_Enumeration-Values">20.9. Enumeration Values</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>enumeration value</strong> is a value associated with an
|
|
<a href="#Definitions_Enumerated-Constant-Definitions">enumerated constant definition</a>.
|
|
It is a pair consisting of the name and the integer value
|
|
specified in the enumerated constant definition.
|
|
Its type is the type associated with the
|
|
<a href="#Definitions_Enum-Definitions">enum definition</a> in which
|
|
the enumerated constant definition appears.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_Anonymous-Struct-Values">20.10. Anonymous Struct Values</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>anonymous struct value</strong> is a value associated with an
|
|
<a href="#Types_Internal-Types_Anonymous-Struct-Types">anonymous struct
|
|
type</a>.
|
|
We write an anonymous struct value \$v\$ similarly to a
|
|
<a href="#Expressions_Struct-Expressions">struct expression</a>:
|
|
a struct value has the form <code>{</code> \$m_1\$ <code>=</code> \$v_1\$ <code>,</code> \$...\$ <code>,</code>
|
|
\$m_n\$ <code>=</code> \$v_n\$ <code>}</code>,
|
|
where for each \$i in [1,n\$], \$v_i\$ is a value of type \$T_i\$.
|
|
The type of \$v\$ is <em>{</em> \$m_1\$ <em>:</em> \$T_1\$ <em>,</em> \$...\$ <em>,</em>
|
|
\$m_n\$ <em>:</em> \$T_n\$ <em>}</em>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_Struct-Values">20.11. Struct Values</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>struct value</strong> is a value associated with a
|
|
<a href="#Types_Struct-Types">struct type</a>.
|
|
We write a struct value similarly to an
|
|
<a href="#Values_Struct-Values">anonymous struct value</a>,
|
|
except that we annotate the value with a struct type:
|
|
a struct value has the form <code>{</code> \$m_1\$ <code>:</code> \$v_1\$ <code>,</code> \$...\$ <code>,</code>
|
|
\$m_n\$ <code>:</code> \$v_n\$ <code>}</code> <code>:</code> \$Q\$,
|
|
where</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>\$Q\$ is a
|
|
<a href="#Scoping-of-Names_Qualified-Identifiers">qualified identifier</a>
|
|
that refers to a
|
|
<a href="#Definitions_Struct-Definitions">struct definition</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>The members of \$Q\$ are \$m_i\$ <code>:</code> \$T_i\$ for \$i in [1,n]\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each \$i in [1,n\$], \$v_i\$ is a value of type \$T_i\$.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>All the members must be explicitly assigned values.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Values_Serialized-Sizes">20.12. Serialized Sizes</h3>
|
|
<div class="paragraph">
|
|
<p>Every value <em>v</em> whose type has a syntactic representation in FPP has a
|
|
<strong>serialized size</strong>. This is the number of bytes required to represent <em>v</em> in
|
|
the standard F Prime serialized format. The serialized size <em>s</em> of a value <em>v</em>
|
|
depends on the type <em>T</em> of <em>v</em>:</p>
|
|
</div>
|
|
<div class="ulist">
|
|
<ul>
|
|
<li>
|
|
<p>If <em>T</em> is a
|
|
<a href="#Types_Primitive-Numeric-Types">primitive numeric type</a>, then <em>s</em> is the byte
|
|
width of the type. For example, the serialized size of a value of type <code>F64</code>
|
|
is 8.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>T</em> is
|
|
<a href="#Types_The-Boolean-Type"><code>bool</code></a>, then <em>s</em> is 1.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>T</em> is a
|
|
<a href="#Types_String-Types">string type</a>, then <em>s</em> is the number of bytes used to
|
|
represent the length of a string plus the length of the string in characters.
|
|
The number of bytes used to represent the length of a string is
|
|
implementation-specific.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>T</em> is an
|
|
<a href="#Types_Array-Types">array type</a>, then <em>s</em> is sum of the serialized sizes of
|
|
the elements of <em>v</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>T</em> is an
|
|
<a href="#Types_Enum-Types">enum type</a>, then <em>s</em> is the byte width of the
|
|
representation type of <em>T</em>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>T</em> is a
|
|
<a href="#Types_Struct-Types">struct type</a>, then <em>s</em>
|
|
the sum of the serialized sizes of the members of <em>v</em></p>
|
|
</li>
|
|
<li>
|
|
<p>If <em>T</em> is an
|
|
<a href="#Types_Abstract-Types">abstract type</a>, then <em>s</em> is not specified in FPP. It
|
|
is up to the implementer of <em>T</em> to provide the serialized size.</p>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Evaluation">21. Evaluation</h2>
|
|
<div class="sectionbody">
|
|
<div class="paragraph">
|
|
<p><strong>Evaluation</strong> is the process of transforming an <a href="#Expressions">expression</a> into
|
|
a <a href="#Values">value</a>.
|
|
In FPP, all evaluation happens during
|
|
<a href="#Analysis-and-Translation_Analysis">analysis</a>,
|
|
in resolving expressions to compile-time constant values.</p>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Evaluation_Evaluating-Expressions">21.1. Evaluating Expressions</h3>
|
|
<div class="paragraph">
|
|
<p>Evaluation of expressions occurs as stated in the
|
|
<a href="#Expressions">expression descriptions</a>. Evaluation of integer
|
|
expressions occurs at type <a href="#Types_Internal-Types_Integer"><em>Integer</em></a>,
|
|
using enough bits to represent the result without overflow.
|
|
Evaluation of floating-point expressions occurs using 64-bit floating-point
|
|
arithmetic.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Evaluation_Type-Conversion">21.2. Type Conversion</h3>
|
|
<div class="paragraph">
|
|
<p>The following rules govern the conversion of a value \$v_1\$ of type
|
|
\$T_1\$
|
|
to a value \$v_2\$ of type \$T_2\$.</p>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Evaluation_Type-Conversion_Unsigned-Primitive-Integer-Values">21.2.1. Unsigned Primitive Integer Values</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>If \$T_1\$ and \$T_2\$ are both unsigned primitive integer types and
|
|
\$T_2\$ is
|
|
narrower than \$T_1\$, then construct \$v_2\$ by truncating the
|
|
unsigned
|
|
binary representation of \$v_1\$ to the width of \$v_2\$. For
|
|
example, converting <code>0x1234: U16</code> to <code>U8</code> yields <code>0x34: U8</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ and \$T_2\$ are both unsigned primitive integer
|
|
types, then
|
|
\$v_2\$ is the integer value of \$v_1\$ at the type of
|
|
\$v_2\$. For example,
|
|
converting <code>0x12: U8</code> to <code>U16</code> yields <code>0x12: U16</code>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Evaluation_Type-Conversion_Signed-Primitive-Integer-Values">21.2.2. Signed Primitive Integer Values</h4>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>If \$T_1\$ and \$T_2\$ are both signed primitive integer types and
|
|
\$T_2\$ is narrower than \$T_1\$, then construct \$v_2\$ by truncating
|
|
the two’s complement binary representation of \$v_1\$ to the width of
|
|
\$v_2\$. For example, converting <code>-0x1234: I16</code> to <code>I8</code> yields <code>-0x34:
|
|
I8</code>.</p>
|
|
</li>
|
|
<li>
|
|
<p>Otherwise if \$T_1\$ and \$T_2\$ are both signed primitive integer
|
|
types, then \$v_2\$
|
|
is the integer value of \$v_1\$ at the type of \$v_2\$. For
|
|
example, converting <code>-0x12: I8</code> to <code>I16</code> yields <code>-0x12: I16</code>.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Evaluation_Type-Conversion_Primitive-Integer-Values-of-Mixed-Sign">21.2.3. Primitive Integer Values of Mixed Sign</h4>
|
|
<div class="paragraph">
|
|
<p>If \$T_1\$ and \$T_2\$ are primitive integer types with one signed and
|
|
one unsigned,
|
|
then do the following:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Construct the value \$v\$ by converting \$v_1\$ to the type
|
|
\$T\$, where
|
|
\$T\$ is signed if \$T_1\$ is signed and unsigned if
|
|
\$T_1\$ is unsigned, and
|
|
\$T\$ has the same width as \$T_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Construct \$v_2\$ by converting \$v\$ to \$T_2\$.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For example converting <code>-1: I8</code> to <code>U16</code> yields <code>0xFFFF: U16</code></p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Evaluation_Type-Conversion_Primitive-and-Non-Primitive-Integer-Values">21.2.4. Primitive and Non-Primitive Integer Values</h4>
|
|
<div class="paragraph">
|
|
<p>If \$T_1\$ is <em>Integer</em> and \$T_2\$ is a primitive integer type, then
|
|
proceed as if \$T_1\$ were a signed primitive integer
|
|
type of the narrowest bit width that will hold \$v_1\$.
|
|
For example, converting <code>-0x1234</code> to <code>I8</code> yields <code>-0x34: I8</code>.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>If \$T_1\$ is a primitive integer type and \$T_2\$ is
|
|
<em>Integer</em>, then \$v_2\$ is the integer value of \$v_1\$
|
|
at type <em>Integer</em>. For example, converting
|
|
<code>0xFFFF: U32</code> to <em>Integer</em> yields <code>0xFFFF:</code> <em>Integer</em>.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Evaluation_Type-Conversion_Floating-Point-Values">21.2.5. Floating-Point Values</h4>
|
|
<div class="paragraph">
|
|
<p>We use the standard rules for IEEE floating-point values to convert
|
|
among integer values to and from floating-point values and
|
|
floating-point values to and from each other.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Evaluation_Type-Conversion_Array-Values">21.2.6. Array Values</h4>
|
|
<div class="paragraph">
|
|
<p>If \$T_2\$ is an array type and \$T_1 = T_2\$, then
|
|
let \$v_2 = v_1\$.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Otherwise if \$T_1\$ is an anonymous array type and \$T_2\$ is an
|
|
anonymous array type or array type, both with \$n\$ elements, then</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Let \$T'_2\$ be the element type of \$T_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each \$i in [1,n]\$, \$v'_i\$ be the result of converting \$v_i\$ to type \$T'_2\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>Let \$v_2\$ be the unique array value of type \$T_2\$
|
|
with value \$v'_i\$ at each element.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Otherwise the conversion is not valid.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect3">
|
|
<h4 id="Evaluation_Type-Conversion_Structure-Values">21.2.7. Structure Values</h4>
|
|
<div class="paragraph">
|
|
<p>If \$T_2\$ is a struct type and \$T_1 = T_2\$, then
|
|
let \$v_2 = v_1\$.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Otherwise if \$T_1\$ is an anonymous struct type and \$T_2\$ is
|
|
an anonymous struct type or struct type
|
|
such that for each member \$m\$ <code>:</code> \$v_m\$ of \$T_1\$ there is a member
|
|
\$m\$ <code>:</code> \$T_m\$ in \$T_2\$, then use the value of \$T_2\$ with
|
|
the following members:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>For each member \$m\$ <code>:</code> \$T_m\$ of \$T_2\$ such that there is a member
|
|
\$m\$ <code>:</code> \$v_m\$ in \$v_1\$, add the member \$m\$ <code>:</code> \$v'_m\$,
|
|
where \$v'_m\$ is the result of converting \$v_m\$ to \$T_m\$.</p>
|
|
</li>
|
|
<li>
|
|
<p>For each member \$m\$ <code>:</code> \$T_m\$ of \$T_2\$ such that there is no member
|
|
\$m\$ <code>:</code> \$v_m\$ in \$v_1\$, add the member \$m\$ <code>:</code> \$v'_m\$,
|
|
where \$v'_m\$ is the <a href="#Types_Default-Values">default value</a> at type \$T_m\$.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Otherwise the conversion is invalid.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sect1">
|
|
<h2 id="Analysis-and-Translation">22. Analysis and Translation</h2>
|
|
<div class="sectionbody">
|
|
<div class="sect2">
|
|
<h3 id="Analysis-and-Translation_Analysis">22.1. Analysis</h3>
|
|
<div class="paragraph">
|
|
<p><strong>Analysis</strong> is the process of checking a source model.
|
|
It usually involves the following steps:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Lexing and parsing to generate an abstract syntax tree (AST).</p>
|
|
</li>
|
|
<li>
|
|
<p>If step (1) succeeded, semantic analysis of the AST.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Analysis-and-Translation_Analysis-Tools">22.2. Analysis Tools</h3>
|
|
<div class="paragraph">
|
|
<p>An <strong>analysis tool</strong> is a tool that reads in and analyzes FPP
|
|
source files, but does not generate any code.
|
|
Source files for analysis are provided in one of two ways:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Via command-line arguments; or</p>
|
|
</li>
|
|
<li>
|
|
<p>On standard input, if there are no arguments.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For example, the command <code>analyze file1.fpp file2.fpp</code>
|
|
says to read in the translation units <code>file1.fpp</code> and <code>file2.fpp</code> and perform
|
|
analysis on the model consisting of these two translation units.
|
|
The command <code>cat file1.fpp file2.fpp | analyze</code> is functionally equivalent.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Analysis-and-Translation_Translation">22.3. Translation</h3>
|
|
<div class="paragraph">
|
|
<p><strong>Translation</strong> is the process of performing analysis and
|
|
generating code.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Translation usually involves the following steps:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p><a href="#Analysis-and-Translation_Analysis">Analysis</a>.</p>
|
|
</li>
|
|
<li>
|
|
<p>If step (1) succeeded, code generation.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>FPP is intended to support a variety of translation
|
|
strategies. For example, we need to generate (1) C++ code for FSW and
|
|
(2) XML, Python, or other code to export to ground tools.</p>
|
|
</div>
|
|
</div>
|
|
<div class="sect2">
|
|
<h3 id="Analysis-and-Translation_Translation-Tools">22.4. Translation Tools</h3>
|
|
<div class="paragraph">
|
|
<p>A <strong>translation tool</strong> is a tool that translates FPP source files.
|
|
A translation tool typically accepts the following two kinds of
|
|
input:</p>
|
|
</div>
|
|
<div class="olist arabic">
|
|
<ol class="arabic">
|
|
<li>
|
|
<p>Source files to be translated.</p>
|
|
</li>
|
|
<li>
|
|
<p>Source files that are <strong>imported</strong> for their symbol definitions,
|
|
but are not translated.</p>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For example, when translating a component <em>C</em>, a tool may read
|
|
in files containing the definitions of the ports used in <em>C</em>,
|
|
but not translate those files.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>Source files for translation are provided as for
|
|
<a href="#Analysis-and-Translation_Analysis-Tools">analysis tools</a>.
|
|
Imported source files are specified as arguments to a <code>-i</code> flag.</p>
|
|
</div>
|
|
<div class="paragraph">
|
|
<p>For example, the command <code>translate -i file1.fpp,file2.fpp file3.fpp</code>
|
|
says to import <code>file1.fpp</code> and <code>file2.fpp</code> and translate <code>file3.fpp</code>.
|
|
The command <code>translate -i file1.fpp,file2.fpp < file3.fpp</code> is functionally
|
|
equivalent.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="footer">
|
|
<div id="footer-text">
|
|
Last updated 2025-01-22 18:15:37 -0800
|
|
</div>
|
|
</div>
|
|
<script src="code-prettify/run_prettify.js"></script>
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({
|
|
messageStyle: "none",
|
|
tex2jax: {
|
|
inlineMath: [["\\(", "\\)"]],
|
|
displayMath: [["\\[", "\\]"]],
|
|
ignoreClass: "nostem|nolatexmath"
|
|
},
|
|
asciimath2jax: {
|
|
delimiters: [["\\$", "\\$"]],
|
|
ignoreClass: "nostem|noasciimath"
|
|
},
|
|
TeX: { equationNumbers: { autoNumber: "none" } }
|
|
})
|
|
MathJax.Hub.Register.StartupHook("AsciiMath Jax Ready", function () {
|
|
MathJax.InputJax.AsciiMath.postfilterHooks.Add(function (data, node) {
|
|
if ((node = data.script.parentNode) && (node = node.parentNode) && node.classList.contains("stemblock")) {
|
|
data.math.root.display = "block"
|
|
}
|
|
return data
|
|
})
|
|
})
|
|
</script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=TeX-MML-AM_HTMLorMML"></script>
|
|
</body>
|
|
</html> |