Using Turbo Pascal as hardware simulator.


How to define simple components:

We would like to make a NAND component with two inputs and one output. The inputs must be event driven.
First we define an object which contains three pointers to signals and two event buffers for the inputs. It also contains a constructor which maps the signals, a procedure which describes the behavior of the component and a destructor to remove the component. The behavior procedure must be visible to the simulator why we need to define the component as an object of the process class. The constructor maps the signals to the component. It saves pointers to the inputs and outputs and it enables the eventbuffers. The behavior procedure describes the function of the component. The destructor disables the eventbuffers:

Events:

Some simulators have a function which detects when a signal changes. This facility is obtained by saving an event pointer to the event signal. By using this event pointer we can make a function which detects change on signals: The simulator also contains a stopflag. Assigning it to a nonzero value causes the simulation to stop. By examine the stopflag it is posible to find the triggering condition.


How to define complex components:

It is easy to combine simple components to more complex components. As an example we can build a RS-flipflop of two nand gates:

Showing the results:

The probe6 unit contains a probe component which stores the values on the signal assigned to it. Showing the probes is done by the probescreen procedure in the thdlsim6 unit.


Example

This example ilustrates the use of the thdlsim6 unit: You may try the examples above by downloading the Turbo Hardware Description Language, THDL6V15.ZIP (41K). Try running example.pas and counter.pas.

It is possible to combine THDL and multitasking: Create the new task in the component constructor, switch the task in the component behavior and close it in the component destructor. Remember to switch the main task in all wait-loops.
MULTIV11.ZIP (33K).



[Back]
E-Mail address: Guestbook.