Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| language:langs:chp [2023/04/09 23:28] – [Arrays: dynamic v/s non-dynamic indices] rajit | language:langs:chp [2025/11/17 18:26] (current) – [Debugging and other support functions for simulation] rajit | ||
|---|---|---|---|
| Line 156: | Line 156: | ||
| ===== Advanced expression syntax ===== | ===== Advanced expression syntax ===== | ||
| + | |||
| + | ==== Bitslice assignment ==== | ||
| + | |||
| + | For integer-valued variables, one can assign to some of the bits. The syntax for this is: | ||
| + | |||
| + | <code act> | ||
| + | | ||
| + | ... | ||
| + | chp { | ||
| + | ... | ||
| + | x{4..2} := 4; | ||
| + | ... | ||
| + | } | ||
| + | </ | ||
| + | This will update three bits of '' | ||
| + | |||
| + | |||
| ==== Channels in expressions ==== | ==== Channels in expressions ==== | ||
| Line 290: | Line 307: | ||
| <code act> | <code act> | ||
| [ v = 0 -> x := x - v | [ v = 0 -> x := x - v | ||
| - | [] ( [] i : 3 : v = i+2 -> x := x + i | + | [] ( [] i : 3 : v = i+2 -> x := x + i ) |
| ] | ] | ||
| </ | </ | ||
| Line 313: | Line 330: | ||
| </ | </ | ||
| where '' | where '' | ||
| + | |||
| + | ===== Debugging and other support functions for simulation ===== | ||
| + | |||
| + | When running CHP simulations, | ||
| + | |||
| + | <code act> | ||
| + | ... | ||
| + | chp { | ||
| + | ... | ||
| + | log (" | ||
| + | ... | ||
| + | } | ||
| + | </ | ||
| + | The statement above will display '' | ||
| + | |||
| + | <code act> | ||
| + | int x; | ||
| + | ... | ||
| + | chp { | ||
| + | ... | ||
| + | log (" | ||
| + | log ("%x This is hex: ", x+3); | ||
| + | log ("%b This is binary", | ||
| + | ... | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Booleans are displayed as integers, with '' | ||
| + | |||
| + | Other support functions of this type are: | ||
| + | * '' | ||
| + | * '' | ||
| + | * In the standard '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | |||
| ====== The chp-txt sublanguage ====== | ====== The chp-txt sublanguage ====== | ||