Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users Abstract Teak is a tool for synthesizing asynchronous circuits from the University of Manchester, UK. Teak creates asynchronous implementations of circuit descriptions written in the Balsa language. Handshaking channels are used to connect Teak network components, drawn from a fixed library of templates. The Teak tool currently consists of: A Balsa synthesizer A Teak component networks plotter A Balsa simulator A component networks optimizer A GUI to visualize component networks A Verilog gate-level generator More information about Teak: Tool homepage: http://apt.cs.man.ac.uk/projects/teak/ Tool package download: ftp://ftp.cs.man.ac.uk/pub/apt/projects/teak/ Tool Owners: Andrew Bardsley, Luis Tarazona, and Ren Hongguang The APT Group, School of Computer Science, The University of Manchester, Manchester, United Kingdom. Publications: o Posters from ASYNC2010 Teak demonstration [poster1] [poster2] [poster3] [poster4] o A. Bardsley, L. Tarazona, and D. Edward, “Teak: A Token-Flow Implementation for the Balsa Language,” ACSD'09, Augsburg, Germany, July 2009. [paper] [presentation] o D.Edwards, A.Bardsley, L.Janin, L.Plana, and W.Toms, “Balsa: A Tutorial Guide,” 1996. [pdf] This manual describes how to install and use Teak on the Technion’s VLSI lab environment. The optimal operating-system for Teak installation is Fedora. It is possible to have your own version of Fedora installed on a USB stick, then you should Teak will be installed on that OS as described in section 1. Alternatively, you can use the Fedora and Teak installation from the Technion’s VLSI lab or connect from home to the Technion’s VLSI lab (VPN is not needed) using Go-Global, as described in section 2. A details guide and example to Teak command-line and GUI usage id described in section 3. Responsibilities: Technion’s VLSI lab computing: Amir Baer ( 04-8294671) and Goel Samuel ( 04-8294668) Go-Global: Taub Computer Center – Airit Hasid ( 04-829-3694) This manual: Ameer Abdelhadi 1 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT 1. Teak on Fedora Live: a USB-bootable OS Fedora Linux is a popular Linux distribution. It can be installed on a computer system or started from a CD or USB stick. The Fedora Live USB Creator is an application aids users to create Fedora-based bootable USB stick. The tool will setup Fedora on a USB stick giving the user the option to either select an already present Fedora distribution on the local disk or to download one of the available Fedora distributions from the Internet. A Live USB system stored on flash memory lets you boot any USB-bootable computer into a Fedora operating system environment without writing to local hard disk. The Live USB stick can feature an area to store changes to the system, called a persistent overlay. It can also has a separate area to store user account information and. With a nondestructive installation, pre-existing files on the USB stick are accessible from the system. For more information, see: [Fedora Hosted Live USB Creator] and [Fedora Project Live USB WIKI]. 1.1. System Requirements A USB flash drive with 1 GB or more of storage space. Ability to boot from USB media: Though most modern ones can, not all computers can boot from USB media, due to system capabilities or BIOS settings. Some flash drives may not be bootable. You may need to mark the partition bootable or to reformat the flash drive. 1.2. Download and install “Fedora Live USB creator” The process for most people is simple. Almost all USB sticks are provided by hardware manufacturers ready to use with this process. If you have any documents on your USB stick, it's not a bad idea to back them up before you start. 1.2.1.Download the LiveUSB Creator program from [Fedora Hosted Live USB Creator], or directly download the latest version liveusb-creator-3.10.0. 1.2.2.Double click the download executable file 'liveusb-creator…' to install LiveUSB Creator. 1.2.3.Run the LiveUSB Creator program. 1.2.4.Plug in your USB drive, and make sure it's selected in the "Target" field. Pre-existing files won’t be touched; as long as the tool has space to put Fedora on there. 1.2.5.The top options on the window let you choose to use an existing live Fedora CD you've already downloaded (using browse) or have the tool grab a copy of the standard Fedora itself (using the drop list). If you'd rather grab the file yourself or download, use one of the links listed under "live media" at Fedora Project. 2 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT 1.2.6.Recommendation: download Fedora-13-i686-Live-KDE.iso into your local disk. Use “Browse” option to select the downloaded file. 1.2.7.The "Persistent Overlay" slider to the right is the space on the flash drive you want to use for storing your files and settings. The Fedora system itself is going to take up roughly one CD size; using an empty 1GB flash drive, you may allocate 204MB for the overlay, which left 64MB free, but you can scale that up for larger drives or down if you want more free space. Keep in mind that any files you store on the drive itself can be accessed from inside your USB-booted system, so a bigger persistent overlay isn't always necessary. 1.2.8.Hit "Create Live USB". Once it's finished successfully, your stick is ready to get booted. 1.3. How to Boot a Live USB Drive 1.3.1.Power off the computer. 1.3.2.Plug the USB drive into a USB port. 1.3.3.Remove all other portable media, such as CD, DVD, or floppy disks. 1.3.4.Power on the computer. 1.3.5.If the computer is configured to automatically boot off of the USB drive, you will see a screen that says "Automatic boot in 10 seconds..." with a countdown. 1.3.6.If the computer starts to boot the hard drive, you'll need to manually configure it to boot off the USB drive, as follows. 1.3.6.1. Wait for a safe point to reboot safely. 1.3.6.2. As the machine starts to reboot, watch carefully for instructions on which key to press (usually a function key such as F12 or Escape) to enter the boot device 3 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT selection menu, or "BIOS setup". Press and hold that key. If you miss the window of opportunity (often only a few seconds) then reboot and try again. 1.3.6.3. Use the BIOS setup menu to put your USB drive first in the boot sequence. It might be listed as a hard drive rather than a removable drive. Each hardware manufacturer has a different method for doing so. Use caution! Your computer could become unbootable or lose functionality if you change any other settings. Though these settings can be reverted, you'll need to remember what you changed in order to do so. 1.3.6.4. Save the changes, exit, and the computer should boot the Live USB drive. 1.3.7.Now you should be set to boot into Fedora. You'll see a splash screen counting down from 10 when you boot (hit Enter twice to speed it up), and you'll land at a desktop that's pretty much a fresh Fedora install. 1.4. Installing Teak 1.4.1.On your fresh Fedora installation, open a terminal window by a right mouse click , then choosing 'Konsole'. 1.4.2.In the terminal, type the following: su yum install ghc yum install ghc-gtk-devel yum install graphviz yum install wget yum install xpdf wget ftp://ftp.cs.man.ac.uk/pub/apt/projects/teak/teak-0.2.tar.gz tar -zxvf teak-0.2.tar.gz cd teak-0.2; ./configure --prefix=/usr/local make make install 1.4.3.Make sure all commands finish successfully. 4 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT 2. Connecting to the VLSI Lab computers 1.1. Go-Global installation and connection GO-Global is a remote application from GraphOn. GO-Global allows users to run Windows and Linux applications installed on a remote server. [Detailed installation instruction] 1.1.1. Access: http://www.technion.ac.il/GG install ActiveX Control or Add-ons if needed. Allow all pop-ups and ActiveX or Add-ons to install and work with Technion’s GG site. 1.1.2. A new "Go-Global for UNIX V2.2.8" window will appear, with a "Connection" window inside. 1.1.3. Provide your account and server details inside the “Connection” window. For undergraduate students (having t2 account): o Server Address : t2Username@stud.technion.ac.il o Transport : “Secure Socket” o Click “Connect”. For graduate students and staff members (having tx account): o Server Address : txUsername@staff.technion.ac.il o Transport : “Secure Socket” o Click “Connect”. 1.1.4. A new “Security Alert” window will appear, click yes. 5 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT 1.1.5. A new “Authentication” window will appear. Provide your t2 password if you have logged in with your t2 username. Provide your tx password if you have logged in with your tx username. Click “OK”. 1.1.6. If the connection established successfully, several icons will appear in the Go-Global window. 1.1.7. Double-click the Xterm icon to invoke a terminal. 1.1.8. If the Xterm icon does not exist then engage KDE, click on right mouse , chose 'Konsole'. 1.2. Connecting to Fedora’s Machine in the Technion’s VLSI lab Fedora OS is installed on one of the VLSI lab machines called luna80; you can choose any of the following ways to connect to luna80. 1.2.1. Use luna80 machine physically located in the Technion’s VLSI lab. (only one machine) 1.2.2. Use another machine physically in the VLSI lab, or through Go-Global, then connect to luna80 through a terminal using ssh as follows. In the terminal type: xhost + (with space before the ‘+’ sign) ssh -X -l VLSILabUsername luna80 or ssh -X -l VLSILabUsername 132.68.59.80 Logout twice – from the luna80 machine and from the stud/staff (tx/t2) machine when you're done. 6 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT 2. Using Teak 2.1. Prepare your Balsa design, (see Appendix B) use “.balsa” as file extension. The following is the content of “encode.balsa”, a Balsa design for one-hot encoder, which will be used as an example for the rest of this manual. procedure onehot ( input i : 2 bits; output o : 4 bits ) is begin loop i -> then case i of | 0 then o | 1 then o | 2 then o | 3 then o end end end end <<<<- 1 2 4 8 procedure encode_test is channel i : 2 bits channel o : 4 bits begin loop o -> then print o end end || loop for ; j in 0..3 then i <- j end end || onehot (i, o) end 2.2. Command-line usage: 2.2.1.To compile you Balsa code, invoke in the command-line: (See Appendix A.1) teak <BalsaFile> For the one-hot encoder: teak encode.balsa The compilation process will create a new Teak output file, with extension “.teak”. For the one-hot encoder, “encode.teak” will be generated. The following is the header of this file. -- Teak output file -- from command: teak encode.balsa Part { networkName = "onehot", … 7 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT 2.2.2.To plot a pdf file of your compiled design, invoke: (See Appendix A.6) teak --plot -p lang=pdf <BalsaFile> For the one-hot encoder: teak --plot -p lang=pdf encode.balsa The following pdf file will be plotted, each page contains one design part. 2.2.3.To produce a gate-level netlist, invoke: teak --gates <BalsaFile> For the one-hot encoder: teak --gates encode.balsa The following is the header of this file. // // from command: teak --gates encode.balsa // // Generated on: Fri Feb 4 21:11:03 EST 2011 // `timescale 1ns/1ps module tko0m4_1nm4b1 (i_0r, i_0a, o_0r0, o_0r1, o_0a, reset); input i_0r; output i_0a; output [3:0] o_0r0; input o_0a; … 8 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT 2.2.4.To simulate the last/top level produced, invoke: (See Appendix A.4) teak --simulate <BalsaFile> For the one-hot encoder: teak --simulate encode.balsa The following output will be dumped to STDOUT, which has been produced by the “print” command inside “encode_test” procedure. *** Simulating BEGIN: encode_test +++ Simulating encode_test: 1 2 4 8 … 2.2.5.To optimize your design use the “--optimise” switch: (see Appendix A.3) teak --optimise <BalsaFile> For the one-hot encoder: teak –-optimise encode.balsa To plot the output of the optimization process, use: teak –-optimise --plot -p lang=pdf encode.balsa The following pdf file will be plotted, each page contains one design part. 9 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT 2.2.6. To get help for Teak switches usage, type the following and the help dumped to STDOUT: teak teak teak teak teak teak teak teak --teak-usage --optim-usage --sim-usage --gui-usage --plot-usage --gates-usage --latch-usage (W/O switches, Teak switches usage, see Appendix A.1) (Teak sub-options status and usage, see Appendix A.2) (Optim sub-options status and usage, see Appendix A.3) (Sim sub-options status and usage, see Appendix A.4) (GUI sub-options status and usage, see Appendix A.5) (Plot sub-options status and usage, see Appendix A.6) (List available cell-based technologies) (Latch sub-options status and usage, see Appendix A.7) 2.3. GUI usage: 2.3.1.Engaging Teak GUI: From the command line, invoke: teak --gui <BalsaFile> (other switches are also possible, e.g. --optimise) For the one-hot encoder: teak --gui encode.balsa The following window will show up: 10 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT 2.3.2.Teak window components: “Selected Part” : A canvas viewing your selected design part. “Parts” : Choose you design parts. “Optimisation Leads” : Choose available optimization leads. “Apply All” will choose all optimization in the list. “New Leads” will recalculate new design leads. 2.3.3.Teak menu lists: File o Compile Balsa (Ctrl-B) : Compile “.balsa” source file. o Open Network (Ctrl-O) : Open “.teak” network file. o Save Network (Ctrl-S) : Save “.teak” network file. o Save Network As : Save “.teak” network file while changing file name. 11 o Make Gate-level Netlist: You can choose netlist file name and cell-based technology, available cell-based technologies are: umc130f, st65, nand2, and amust. o Plot Parts: You can choose output plot file name and type (PDF,PS,SVG), and which parts to plot. o Quit (Ctrl-Q) Edit o Undo (Ctrl-Z) o Redo (Ctrl-Y) o Optimization Flags: Select optimization flags by ticking the check-box. Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT o Preferences: Change window preferences. Selected Part o Set As Top Level. o Insert Latches: Insert latches to any part of the design. For example, adding one latch every link will generate the following netlist. o 12 Remove Latches: Remove all previously inserted latches. Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT Appendix A: Teak switches, options and sub-options A.1: Teak switches usage _|_ _ _ | Teak synthesiser for the Balsa language | |_| _| |/ . version: 0.2 |_ |_ |_| |\ . (C) 2007-2010 The University of Manchester This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under the conditions of version 3 (or greater) of the GNU GPL (Graph library (C) 2002-2004 The University of Glasgow) usage: teak <switch>* [<file>] switch: -v (or --verbose) -t <procedure> (or --top-level) -I <directory> (or --include) --teak-home <directory> --teak-share-home <directory> -k <opt> (or --teak-opt) --teak-usage --dump-parse-trees --------- verbose output (for simulation, prints state changes) top most procedure for simulation, initial-opt add <directory> to Balsa module path Teak installation path (also reads env. TEAKHOME) Teak installation `share' path component-generation sub-options display component-generation options usage dump parse trees to .tree{,-bind,-eval,-finish} files -S (or --simulate) -D <name> <value> (or --define) --pn-test-card <file> -s <opt> (or --sim-opt) --sim-usage ------ simulate the last/top level procedure bind <value> to <name> as a simulation defn. generate Petri net `test card' Dot file and exit simulation sub-options display simulation sub-options usage -n <file> (or --network-file) -o <file> (or --output) --pretty-network -- input network file name (rather than Balsa compilation -- output file name prefix (rather than using input file) -- use `pretty' network format -O (or --optimise) -q <opt> (or --named-opt) -r <file> (or --rules) --rules-test-card <file> <secword> --optim-passes <int> --optim-usage ------- -L (or --latch) -l <opt> (or --latch-opt) --latch-usage -- insert latches -- latch sub-options -- display latch options usage --plot -p <opt> (or --plot-opt --plot-usage -- make a postscript plot of the compiled parts -- plot sub-options -- display plot options usage --gates -X <tech> (or --technology) --test-protocol --gates-usage ----- make a gate level netlist technology for gate level netlist test channel protocol violations in Verilog display gates options usage --gui -g <opt> (or --gui-opt) -e <file> (or --monitor-events) --gui-usage ----- launch GUI gui sub-options read monitor events file display gui options usage optimise teak components. apply named optim (`all' adds all, `none' removes all) load optimisation rules file (drops default rules) print rules test card perform this many optimisation passes display optimisation usage *** pass exactly one <file> argument, or a network file, or use --gui 13 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT A.2: Teak sub-options status and usage usage: -k (<option>:)*[<option>] where <option> ::= [no-]<name>[=<value>] `no-' prefix indicates that the option is off for the set of arguments given `default' can be given as <name> to return options to defaults choice = onehot -- data encoding for steering values (onehot|binary) break-v -- break Vs on boundaries on write accesses single-write-port -- only use on write port on Vs where all the writes cover the whole V A.3: Optimization sub-options status and usage usage: -q (<option>:)*[<option>] where <option> ::= [no-]<name>[=<value>] `no-' prefix indicates that the option is off for the set of arguments given `none' can be given as <name> to remove existing options `default' can be given as <name> to return options to defaults no-verbose ff mm jj sm fj0 fjl1 fjl2 fj fj2 sv vv fal jal sal sal2 mal gal jo oo sho ns vjv tvn tv1 fo il njl njh nvr0 nvr nm no no0 fv sf ss ffmm soom som no-svrr rf rm -------------------------------------------- verbose reporting of all optimisation steps collapse connected Fs collapse connected Ms collapse connected Js merge shared S-M links remove redundant F-J token links remove redundant F-J token links remove redundant F-J token links merge adjacent J inputs from same F like fj but with overlap/opposite order, inserting O to reorder remove `buffer' Vs merge Vs with joined writes remove F aliases remove J aliases remove S aliases reduce S to narrowing F remove M aliases any non-teak component acting as a simple alias move O through J collapse connected Os shorten O terms narrow S outputs cascading V writes trim V read ports trim last V read port move Fs through Os remove I loop narrow datapath - J low end narrow datapath - J high end remove V read port narrow V read port narrow M narrow O remove O push Fs through V read move Fs to before S S merge F-M cross use O for S-M with constants use O for S-M with constants S to variable read ports Push R through F R - M becomes I Option group abbreviations all -- all rules none -- no rules no-al -- remove link aliases (mal,sal,sal2,jal,fal,lal,gal) tv -- trim V read ports (tvn,tv1) nd -- narrow datapath (njl,njh,nvr0,nvr,nm,no,no0) stom -- S-M with some Os between (soom,som) no-offoptims -- off-by-default rules (stom) 14 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT A.4: Sim sub-options status and usage usage: -s (<option>:)*[<option>] where <option> ::= [no-]<name>[=<value>] `no-' prefix indicates that the option is off for the set of arguments given `none' can be given as <name> to remove existing options `default' can be given as <name> to return options to defaults no-verbose -- verbosely report state changes capacity = 3 -- channel token capacity type = language -- simulation type (language|pn) no-write-pn -- Generate file with the simulation Petri net write-pn-format = dot -- Format for Petri net file (dot|hl_net) no-write-events -- Write a monitor events file from link activity in a PN sim. simulate -- actually simulate (no- means just do other sim. activities) A.5: GUI sub-options status and usage usage: -g (<option>:)*[<option>] where <option> ::= [no-]<name>[=<value>] `no-' prefix indicates that the option is off for the set of arguments given `default' can be given as <name> to return options to defaults display = dot diff-depth = 1 only-passing-leads no-show-step-diff show-link-widths show-monitor-events no-show-time-window no-show-o-window no-show-diff-window no-time-step ----------- network display mode {spring,dot} depth of netlist diff. component view show only optimisation leads show network diff. when stepping show link widths as colours show monitor events on links show time window at startup show O component window at startup show network diff. window at startup size of steps in Time window A.6: Plot sub-options status and usage usage: -p (<option>:)*[<option>] where <option> ::= [no-]<name>[=<value>] `no-' prefix indicates that the option is off for the set of arguments given no-break-v no-show-pos title box no-uniform-l show-uc token-colour = comp-colour = no-horiz-parts no-parts no-paper size = ratio = no-o-len lang = no-labels ------black -white ----180x260 -2.0 --ps --- break Vs into read/write portions show component positions show parts titles show parts with outline boxes show Ls all the same size show unconnected end points on links zero-width link colour component background colour connect parts horizontally plot only named parts (no- prints all parts) plot paper size (in mm) plot size (in mm) plot aspect ratio (>1 means portrait) longest O description string length output language {ps,pdf,svg} plot labeled components (comma sep. list): <label>('+'<depth>)* A.7: Latch sub-options status and usage usage: -l (<option>:)*[<option>] where <option> ::= [no-]<name>[=<value>] `no-' prefix indicates that the option is off for the set of arguments given `none' can be given as <name> to remove existing options `default' can be given as <name> to return options to defaults no-simple no-after-v no-after-o no-before-i no-between-inst no-through no-loop 15 -------- latch latch latch latch latch latch latch every link after every V's read/write port after every O before every I between every instance links that connect ports to ports loops to guarantee deadlock-freedom Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT Appendix B: Balsa Grammar Lexical: <digit> ::= `0'...`9' <letter> ::= `a'...`z' | `A'...`Z' <identifier> ::= ( <letter> | `_' ) ( ( <letter> | <digit> | `_' ) )* <label> ::= <identifier> `:' <literal> ::= `1'...`9' ( ( <digit> | `_' ) )* | `0' ( `0'...`7' | `_' )* | ( `0b' | `0B' ) ( `0' | `1' | `_' | `x' | `X' | `?' )+ | ( `0x' | `0X' ) ( `0'...`9' | `a'...`f' | `A'...`F' | `_' | `x' | `X' | `?' )+ | `?' <string_char> ::= ( <letter> | <digit> | ` ' | `!' | `#' | `$' | `%' | `&' | "'" | `(' | `)' | `*' | `+' | `,' | `-' | `.' | `/' | `:' | `;' | `<' | `=' | `>' | `?' | `@' | `[' | `]' | `^' | `_' | "`" | `{' | `|' | `}' | `~' ) <string> ::= `"' ( <string_char> )* `"' Non terminals: <file> ::= ( `import' `[' <dotted_path> `]' )* <outer_declarations> <dotted_path> ::= <identifier> ( `.' <identifier> )* <outer_declarations> ::= ( <outer_declaration> )* <outer_declaration> ::= `type' <identifier> `is' <type_declaration> | `constant' <identifier> `=' <expression> | `procedure' <identifier> ( <attributes> )? `is' <identifier> ( `(' <procedure_formals> `)' )? | `procedure' <identifier> ( `(' <procedure_formals> `)' )? `is' ( `local' )? <inner_declarations> ( <block_body> | <loop_command> ) | `function' <identifier> ( `(' <function_formals> `)' )? `=' <expression> | `function' <identifier> ( `(' <builtin_function_formals> `)' )? `is' `builtin' `:' <type> | `if' <expression> `then' <outer_declarations> ( `|' <expression> `then' <outer_declarations> )* ( `else' <outer_declarations> )? `end' <type_declaration> ::= <type> | `record' <identifiers> `:' <type> ( `;' <identifiers> `:' <type> )* ( `end' | ( `over' <type> ) ) | `enumeration' <identifier> ( `=' <expression> )? ( `,' <identifier> ( `=' <expression> )? )* ( `end' | ( `over' <type> ) ) | `builtin' <identifiers> ::= <identifier> ( `;' <identifier> )* <type> ::= <identifier> | <expression> ( `signed' )? `bits' | `array' <range> `of' <type> <function_formals> ::= <identifiers> `:' <type> ( `;' <identifiers> `:' <type> )* <builtin_function_formals> ::= <formal_parameters> | <function_formals> | <formal_parameters> `;' <function_formals> <procedure_formals> ::= <formal_parameters> | <formal_ports> | <formal_parameters> `;' <formal_ports> <formal_parameters> ::= `parameter' <identifiers> `:' <type> ( `;' `parameter' <identifiers> `:' <type> )* <formal_ports> ::= <formal_port> ( `;' <formal_port> )* 16 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT <channel_array> ::= ( `array' <range> `of' )* <formal_port> ::= <channel_array> ( `input' | `output' ) <identifiers> `:' <type> | <channel_array> `sync' <identifiers> | `if' <expression> `then' <formal_ports> ( `|' <expression> `then' <formal_ports> )* ( `else' <formal_ports> )? `end' <range> ::= <expression> | <expression> `..' <expression> | `over' <type> <inner_declarations> ::= ( <inner_declaration> )* <inner_declaration> ::= <outer_declaration> | `variable' <identifiers> `:' <type> . | <channel_array> `channel' <identifiers> `:' <type> | <channel_array> `sync' <identifiers> | `shared' <identifier> `is' ( `local' )? <inner_declarations> ( <block_body> | <loop_command> ) | `if' <expression> `then' <inner_declarations> ( `|' <expression> `then' <inner_declarations> )* ( `else' <inner_declarations> )? `end' <expression> ::= <identifier> | <literal> | <string> | ( <identifier> )? `{' <expressions> `}' | <identifier> "'" <identifier> | <unary_operator> <expression> | `sizeof' <identifier> | <expression> <binary_operator> <expression> | <expression> `.' <identifier> | <expression> `[' <range> `]' | <expression> `as' <type> | <expression> `:' <type> | `#' <expression> | `(' <expression> `)' | <identifier> `(' ( <expressions> )? `)' <attribute> ::= <identifier> ( `=' <expression> )? <attributes> ::= `(*' ( <attribute> ( `,' <attribute> )* )? `*)' <expressions> ::= <expression> ( `,' <expression> )* <unary_operator> ::= ( `-' | `+' | `not' | `log' | `#' ) <binary_operator> ::= ( `+' | `-' | `*' | `/' | `%' | `^' | `=' | `/=' | `<' | `>' | `<=' | `>=' | `and' | `or' | `xor' | `@' ) <command> ::= | <label> <command> | `continue' | `halt' | <channel> `->' <lvalue> | <channel> `->' <channel> | <channels> `->' `then' <command> `end' | <channel> `<-' <expression> | `sync' <channel> | <lvalue> `:=' <expression> | <block> | <command> `;' <command> | <command> `||' <command> | <loop_command> | `if' <guards> ( `else' <command> )? `end' | `case' <expression> `of' <case_guard> 17 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT | | | | | ( `|' <case_guard> )* ( `else' <command> )? `end' `for' ( `||' | `;' ) <identifier> `in' <range> `then' <command> `end' `select' <channel_guard> ( `|' <channel_guard> )* `end' `arbitrate' <channel_guard> `|' <channel_guard> `end' `print' <expressions> <identifier> `(' ( <procedure_actuals> )? `)' <loop_command> ::= `loop' ( <command> )? ( `while' <expression> ( `then' <command> )? )? `end' <channels> ::= <channel> ( `,' <channel> )* <channel> ::= <identifier> | <identifier> `[' <expression> `]' <lvalue> ::= <identifier> | <lvalue> `.' <identifier> | <lvalue> `[' <expression> `]' <block> ::= ( `local' <inner_declarations> )? <block_body> | `[' <command> `]' <block_body> ::= `begin' <command> `end' <guards> ::= <expression> `then' <command> ( `|' <expression> `then' <command> )* <case_guard> ::= <case_matches> `then' <command> | `for' <identifier> `in' <case_matches> `then' <command> <case_match> ::= <expression> | <expression> `..' <expression> <case_matches> ::= <case_match> ( `,' <case_match> )* <channel_guard> ::= <channels> `then' <command> ( `|' <channels> `then' <command> )* <procedure_actuals> ::= <actual_parameters> | <actual_channels> | <actual_parameters> `,' <actual_channels> <actual_parameters> ::= <actual_parameter> ( `,' <actual_parameter> )* <actual_parameter> ::= <expression> | ( `type' )? <type> <actual_channels> ::= <actual_channel> ( `,' <actual_channel> )* <actual_channel> ::= <identifier> | <actual_channel> `[' <range> `]' | `<-' <expression> | `->' <lvalue> | <block> | `{' <actual_channel> ( `,' <actual_channel> )* `}' | <actual_channel> `@' <actual_channel> 18 Teak: A Token-Flow Balsa Synthesizer A Manual for Technion Users February, 2011 Technion ― IIT