Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Event driven programming

Fahim
2012-08-06
2013-06-12
  • Fahim
    Fahim
    2012-08-06

    Hi,

    I am trying to do some event driven programming in ngspice. The scenario is as follows.

    There are two part of circuit one part(u can say analog part) will generate the event and will be given to second part(digital part).
    The second part will process that event and will give back to first part .Its not like continuous simulation rather than event depend simulation.
    Do we have any function which can be useful to establish this scenerio.

    Regards,
    Fahim Khan   

     
  • Holger Vogt
    Holger Vogt
    2012-08-06

    Fahim,

    please have a look at the new example of a phase-locked loop circuit simulation, which combines analog and digital (event driven) simulation.

    http://ngspice.sourceforge.net/xspicehowto.html

    Holger

     
  • Fahim
    Fahim
    2012-08-08

    Hi Holger,

    I am looking for something like wait state i.e a node is waiting for event and then go ahead with that event. Its like when I get the event then I will perform the other operation.

    Also is there any scope to use VHDL code into ngspice.

    Regards,
    Fahim Khan

     
  • Holger Vogt
    Holger Vogt
    2012-08-08

    Fahim,

    ngspice is basically a circuit simulator, which offers dc, ac, and transient simulation and some derivatives of these basic modes.

    If you can conceive of a circuit, which holds a node at a state, and then, after an event received, goes on, ngspice can do it.

    Circuits may not necessarily comprise of transistors, Rs, Ls and Cs only, but may contain behavioral souces (B source with expressions and functions), code models, switches, transmission lines, etc., the whole bunch of circuit blocks described in the manual. I am sure that you may be able to generate the functionality you need. For example you may have a flip flop, which after receiving the event, sets an analog switch, which connects the node, or impesses a voltage onto the node or resets the circuit for restart. You have to express the wait state as a circuit block!

    You may also consider interrupting the simulation flow with the conditional stop command, change some parameters and resume the simulation.

    There are no plans to support VHDL. For plain VHDL, please have a look at http://tams-www.informatik.uni-hamburg.de/research/vlsi/vhdl/.

    Regards

    Holger

     
  • Fahim
    Fahim
    2012-08-13

    Hi Holger,

    Can you explore something regarding simulation stop and start? I am looking  for a way to simulate the circuit in a discrete way rather than continuous with some conditions.

    Regards,
    Fahim Khan

     
  • Fahim
    Fahim
    2012-08-13

    Do I need to look at source code also for this?

     
  • Holger Vogt
    Holger Vogt
    2012-08-13

    Fahim,

    ngspice supports time continuous transient simulation. XSPICE offers event driven simulation as an add on, to save computing time for digital devices. Still the simulation is time continuous. I am not aware of any other simulation mode.

    Concerning stop and resume, please have a look at the manual, chapt. 17.5 for usage of the two commands inside of a .control section. I will check for an example file later on.

    Holger

     
  • Fahim
    Fahim
    2012-08-14

    Hi Holger,

    Apart from this I have one more query regarding switch sw and csw model in manual. Is it automatic switch which work on threshold value like below threshold open and above threshold close.

    Also do we have any digital switch in ngspice which will close when there is new event at the input.

    Regards,
    Fahim Khan

     
  • Holger Vogt
    Holger Vogt
    2012-08-14

    Fahim,

    yes, input voltage (or current) controles switch at output. Please check  the example on page 75.

    XSPICE is low level logic:  Think of an 'and' gate, one input is a bit stream, output depends on the other input: low, output low, high, output is bit stream: a logic switch, isn't it?

    You may consider your event as a logic pulse, or as the rising edge of a pulse, and then use logic gates and edge triggered flip flops for processing

    You may take a logic output of a gate, convert it to analog using the dac bridge, and then control a sw (voltage controlled) analog switch or any other circuit. Or take an analog voltage, using the adc bridge to create a logic output value, depending on the thresholds you have set, and then do digital processing.

    Holger

     
  • veysel
    veysel
    2012-11-27

    Hi fahimk,

    What is your application for this program?? Where do you plan to use the circuit??