09.07.2015 Views

6. Digital simulation in Alecsis - LEDA

6. Digital simulation in Alecsis - LEDA

6. Digital simulation in Alecsis - LEDA

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

88 <strong>Alecsis</strong> 2.3 - User’s manualdebug. It is better to use two buffers - the result is formed <strong>in</strong> _op_buff buffer, and is then copied <strong>in</strong>to_res_buff buffer.The return of a vector is rather uncommon -- we have used our macro Vreturn. Macro Vreturn returnsnot only the po<strong>in</strong>ter to a vector, but also its length, which enables later usage of command lengthof. FromVreturn, usual command return is <strong>in</strong>voked as:return v;where po<strong>in</strong>ter v is returned. Po<strong>in</strong>ter is stored <strong>in</strong>to lower register of the virtual processor accumulator %d0. Butbefore <strong>in</strong>vok<strong>in</strong>g usual command return, we have stored the length of the vector <strong>in</strong>to %d4 (the higheraccumulator register). Assembler command is used for that. If this result is passed to a function as an operator,operator lengthof can determ<strong>in</strong>e the vector length from this higher register. Macro Vreturn is available <strong>in</strong>the standard header file "alec.h").With a similar overload of operator =, you can handle enumeration vectors the same way as ord<strong>in</strong>arynumbers. Therefore, the user of the logic simulator, which has a library already prepared, can be unaware of bothlengthof operator and temporary buffers, as <strong>in</strong> function foo <strong>in</strong> the example above.It is up to the designer if he or she is go<strong>in</strong>g to allow for the comb<strong>in</strong>ation of vectors of different length and/ordifferent direction <strong>in</strong> such b<strong>in</strong>ary operators.Unary operators of left and right shift (>) can be overloaded <strong>in</strong> this manner, as well as <strong>in</strong>crement,and decrement (++ and --), etc.<strong>6.</strong>2. Synchronization of digital processesSuch program support, consist<strong>in</strong>g of prepared systems of states, logic truth tables, and appropriate operatorsis now available to model digital components. On the other hand, we have available an <strong>in</strong>ternal <strong>Alecsis</strong> discreteeventselective-trace <strong>simulation</strong> eng<strong>in</strong>e, that is able to manage the logic events. The construct discrete-event meansthat the simulator does not solve the time-cont<strong>in</strong>uum, but only time <strong>in</strong>stants when a logic event (change of logicstate) happens. Outside of these time-<strong>in</strong>stants, there are no changes <strong>in</strong> the circuit, i.e. noth<strong>in</strong>g for the simulator tosolve. Selective-trace means that only some models are executed when an event happens. When an event isgenerated at the output signal of some digital component, it activates only those components where the same signalacts as <strong>in</strong>put. Therefore, there is no need to simulate the whole circuit, only activated components (models) aresimulated. Therefore, we can consider execution of logic <strong>simulation</strong> as execution of synchronized processes, andtransmission of messages via signals.When we are def<strong>in</strong><strong>in</strong>g digital models, we are us<strong>in</strong>g the program support from the library. We have to providethe <strong>in</strong>formation for the <strong>simulation</strong> eng<strong>in</strong>e how to synchronize the processes. Here is an example:module and2 (three_t <strong>in</strong> a, b; three_t out y) {action (double delay) {process (a, b) { y

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

Saved successfully!

Ooh no, something went wrong!