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.

<strong>6.</strong> <strong>Digital</strong> <strong>simulation</strong> <strong>in</strong> <strong>Alecsis</strong> 95The resolution function is a global function fulfill<strong>in</strong>g certa<strong>in</strong> conditions regard<strong>in</strong>g results and parameters. If asignal is of l<strong>in</strong>k (signal) data type T, its resolution function will return the same type. The function has to have twoparameters, a po<strong>in</strong>ter to data type T, and a po<strong>in</strong>ter to <strong>in</strong>t type. The former is a vector of <strong>in</strong>stantaneous values of alldrivers of a signal, and the second is a flag <strong>in</strong>dicator. This flags conveys whether the resolution needs to report aconflict on the bus or not (the flag needs to be set to 1 for the message to appear).An association of a signal and its resolution function is obta<strong>in</strong>ed on signal declaration, if the character ':' andthe name of the resolution function are listed after the signal data type. Another way is to create new type (us<strong>in</strong>gtypedef) that <strong>in</strong>cludes the resolution function:four_t bus4or (const four_t *drv, <strong>in</strong>t *report);four_t bus4and (const four_t *drv, <strong>in</strong>t *report);typedef four_t:bus4or four_t_or; // new, resolved type fout_t_ortypedef four_t:bus4and four_t_and; // second versiontypedef struct {four_t send, recv;four_t:bus4and data[3:0];}:bus4or Connector;The last example shows the application of the resolution function <strong>in</strong> case of structures. The whole structurehas a resolution function bus4or, which is applied on members send and recv. However, structure memberdata has its own resolution function bus4and.For one system of states, you can def<strong>in</strong>e a desired number of resolution functions, e.g wired-AND, wired-OR. For system of states with high number of states it can be useful to create tables of resolutions as arrays.If a signal has one driver, and its resolution function is def<strong>in</strong>ed, it is applied. However, signal with one driverneeds not a resolution function. In such case, driver value is copied to the signal.<strong>6.</strong>2.5.4. Driver <strong>in</strong>itializationIf the system of states beg<strong>in</strong>s with 'x' (the first enumerated symbol is <strong>in</strong>dexed as 0), all non-<strong>in</strong>itializedsignals <strong>in</strong> the circuit would be set to 'x' at the beg<strong>in</strong>n<strong>in</strong>g of the <strong>simulation</strong>. For most of the cases, this is naturalchoice, as 'x' denotes undef<strong>in</strong>ed state. Nevertheless, for modell<strong>in</strong>g of switch<strong>in</strong>g logic this can be a problem.Transmission gate (switch) is actually a MOS transistor, and drivers for source and dra<strong>in</strong> would be set to 'x' evenif the gate is open. Such transmission gates are usually used for connections to the bus. Undef<strong>in</strong>ed state 'x' on anydriver of the bus means usually that the state 'x' would be resolved for the whole bus. However, correct model ofreal circuit behaviour demands that an open switch means that bus is driven with high impedance state, 'z'.The solution is found by <strong>in</strong>itialization of formal signals.module tgate (four_t <strong>in</strong> gate; four_t <strong>in</strong>out dra<strong>in</strong>='z', source='z');If formal signals have direction <strong>in</strong> or <strong>in</strong>out, and an <strong>in</strong>itial value is given, then all drivers created by theprocesses of that module will have that <strong>in</strong>itial value.The problem can arise with <strong>in</strong>itialization of multidimensional-array-signals. Their first dimension can beunknown, as they are formal signals, so one cannot utilize aggregate <strong>in</strong>itial array of values with fixed length. In suchcases, one can use operator

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

Saved successfully!

Ooh no, something went wrong!