Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
language:langs:chp [2021/09/13 10:57]
rajit
language:langs:chp [2021/12/29 15:47]
rajit [More on channel expressions and probes]
Line 19: Line 19:
    * ''X!e'': communication action (send). The expression ''e'' is evaluated and sent over channel ''X''. Communication is blocking (slack zero). ''X!'' is also supported, which means complete the synchronization operation. This is normally used when no data needs to be sent on the channel.    * ''X!e'': communication action (send). The expression ''e'' is evaluated and sent over channel ''X''. Communication is blocking (slack zero). ''X!'' is also supported, which means complete the synchronization operation. This is normally used when no data needs to be sent on the channel.
    * ''X?v'': communication action (receive). ''v'' is a variable, and the value received on channel ''X'' is assigned to ''v''. ''X?'' is also supported, which means complete the synchronization operation. This is normally used when no data needs to be sent on the channel.    * ''X?v'': communication action (receive). ''v'' is a variable, and the value received on channel ''X'' is assigned to ''v''. ''X?'' is also supported, which means complete the synchronization operation. This is normally used when no data needs to be sent on the channel.
 +
 +==== Typechecking ====
 +
 +Expressions are evaluated using the [[language:expressions|standard expression rules]] for bit-width conversion. All operations are unsigned. Subtraction uses two's complement arithmetic, and unary minus computes the two's complement of the integer.
 +
 +Variables can be set via either assignment statements or via receive operations. When an integer variable of bit-width //w1// is set to an integer value of bitwidth //w2//, then
 +   * If //w1//=//w2//, then a standard bit-wise assignment is performed.
 +   * If //w1//<//w2//, then the high-order bits of the value being assigned are discarded.
 +   * If //w1//>//w2//, the value being assigned is zero-extended prior to assignment
 +An integer cannot be assigned a Boolean value or vice versa. Explicit conversion via ''bool()'' and ''int()'' can be used to support this functionality.
 +
 +The same rules outlined above apply to receive operations, where the value being assigned is the value received from the channel. To support int/bool conversion during a receive operation, we also support the following extended syntax:
 +   * ''X?bool(v)'' : permits the assignment of a Boolean value to an integer variable ''v''
 +   * ''X?int(v)'' : permits the assignment of an integer value to a Boolean variable ''v''
  
 ===== Composition operators ===== ===== Composition operators =====
Line 203: Line 217:
 Essentially every channel variable ''V'' can be translated into ''(#V ? V : ERR)''. Note that this is a different translation compared to guards. Note that since probes are only allowed in guards of selection statements, negated probes are not possible in other contexts.  Essentially every channel variable ''V'' can be translated into ''(#V ? V : ERR)''. Note that this is a different translation compared to guards. Note that since probes are only allowed in guards of selection statements, negated probes are not possible in other contexts. 
  
 +==== Exchange channels ====
 +
 +Exchange channels are those where data is exchanged between sender and receiver, and this is indicated directly in the channel type. The syntax for exchange channels is:
 +   * ''X!e?v'' : exchange send operation, sends ''e'' and receives into variable ''v''
 +   * ''X?v!e'' : exchange receive operation, receives into ''v'' and sends the value ''e''
 +In this case, we assume that the exchange send will initiate the operation, and hence only the exchange receive can be probed. This doesn't restrict functionality, since the symmetry of the exchange channel means we can simply swap the two ends.
  
 +==== Split synchronization ====
  
 +Four-phase handshake channels involve two synchronizations. If you need to make this explicit in the CHP, the ''!'' (send) and ''?'' (receive) operators can be replaced with ''!+'' (first half of send), ''!-'' (second half of send), or ''?+'' (first half of receive), ''?-'' (second half of receive). The second half is purely synchronization and should not have any data.