6. Digital simulation in Alecsis - LEDA

6. Digital simulation in Alecsis - LEDA 6. Digital simulation in Alecsis - LEDA

leda.elfak.ni.ac.rs
from leda.elfak.ni.ac.rs More from this publisher
09.07.2015 Views

6. Digital simulation in Alecsis 896.2.1. Interpretation of signals in expressionsThe name of a signal can legally appear in the expressions of the process. (Be aware about the masking rulesgiven in the previous chapter.) However, they must be treated differently than C/C++-like variables. Links, andtherefore signals as digital links, are complex entities, which can be differently treated in different situations. Thetreatment of the signal depends on the context.In all non- assignment expressions, the name of the signal refers to the memory storing the current valueof the signal. The size, dimensionality, and the type of the memory depend upon the type of the signal (scalars,vector, or a structure). In other words, in such expressions, the name of the signal refers to it value - it is used as avariable.Signals must not appear on the left side of the assignment operator (such as =, =+, ++, etc.) since theyare not l-values. The change of the signal value can be performed exclusively using a special AleC++ assignmentoperator for signals

90 Alecsis 2.3 - User’s manual6.2.2. Conversion of link typeIf a link has more than one aspect, i.e. it is both digital and analogue, the operator of link type conversioncan solve the ambiguity. This operator is very similar to C/C++ cast operator used for type conversion.signal s;action {process {double s_as_node;s_as_node = (node)s;}}We can perform link type conversion by stating (in parentheses) the desired type before the signal name.Priority and the associating rules of this conversion operator is the same as was with cast operator.Note: A wrong assumption that signal s possesses analogue aspect will result in a usually harmless value of0 during the simulation. However, if we try the reverse, to convert the node into a signal, where the node does nothave digital aspect, effect can be harmful.6.2.3. Conditional process suspension -- command waitWe have already said in the previous chapter that a process can be synhronized by giving the list ofsignals it is sensitive to. Another method of synchronizing a process is using command wait. Commandwait suspends the current process for a period of time, giving t the same time conditions for its reactivation.wait_command:wait ;An empty command is also legal:wait;In this case, the process is suspended until the end of the simulation. The sensitivity_list is the same listof signals that can be defined in the process heading (the process using wait command must not besynchronized using some other method). The process execution stops at the wait command, until an eventhappens to some of the signals the command is sensitive to. If suspension_condition is given, it has to become zero,if the process is to activate, regardless of the events on some of the signals from the sensitivity_list. If time_outis defined, all of that can last up to time_out seconds.enum Edge { RisingEdge, FallingEdge };module (three_t in clock) {action (Edge mode) {process {...switch (mode) {case RisingEdge:wait clock while clock != '1' for 100ns;break;case FallingEdge:wait clock while clock != '0';break;}

90 <strong>Alecsis</strong> 2.3 - User’s manual<strong>6.</strong>2.2. Conversion of l<strong>in</strong>k typeIf a l<strong>in</strong>k has more than one aspect, i.e. it is both digital and analogue, the operator of l<strong>in</strong>k type conversioncan solve the ambiguity. This operator is very similar to C/C++ cast operator used for type conversion.signal s;action {process {double s_as_node;s_as_node = (node)s;}}We can perform l<strong>in</strong>k type conversion by stat<strong>in</strong>g (<strong>in</strong> parentheses) the desired type before the signal name.Priority and the associat<strong>in</strong>g rules of this conversion operator is the same as was with cast operator.Note: A wrong assumption that signal s possesses analogue aspect will result <strong>in</strong> a usually harmless value of0 dur<strong>in</strong>g the <strong>simulation</strong>. However, if we try the reverse, to convert the node <strong>in</strong>to a signal, where the node does nothave digital aspect, effect can be harmful.<strong>6.</strong>2.3. Conditional process suspension -- command waitWe have already said <strong>in</strong> the previous chapter that a process can be synhronized by giv<strong>in</strong>g the list ofsignals it is sensitive to. Another method of synchroniz<strong>in</strong>g a process is us<strong>in</strong>g command wait. Commandwait suspends the current process for a period of time, giv<strong>in</strong>g t the same time conditions for its reactivation.wait_command:wait ;An empty command is also legal:wait;In this case, the process is suspended until the end of the <strong>simulation</strong>. The sensitivity_list is the same listof signals that can be def<strong>in</strong>ed <strong>in</strong> the process head<strong>in</strong>g (the process us<strong>in</strong>g wait command must not besynchronized us<strong>in</strong>g some other method). The process execution stops at the wait command, until an eventhappens to some of the signals the command is sensitive to. If suspension_condition is given, it has to become zero,if the process is to activate, regardless of the events on some of the signals from the sensitivity_list. If time_outis def<strong>in</strong>ed, all of that can last up to time_out seconds.enum Edge { Ris<strong>in</strong>gEdge, Fall<strong>in</strong>gEdge };module (three_t <strong>in</strong> clock) {action (Edge mode) {process {...switch (mode) {case Ris<strong>in</strong>gEdge:wait clock while clock != '1' for 100ns;break;case Fall<strong>in</strong>gEdge:wait clock while clock != '0';break;}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!