Pythonic Virtual Machine
Machine Class Reference

Detailed Description

This is the main virtual machine object. It can also be used as a conventional circuit , acting as a circuit container. Every Machine circuit has one default output channel 'time', but other input/output channels can be added.

Initialisation parameters:

  • dt = timestep (only for main machine)
  • assembly = constructor function (only for composites)
  • pushed = True|False push the output buffer immediately if True

Input channels:

  • custom inputs (only for composites)

Output channels:

  • time = global simulation time
  • custom outputs (only for composites)

Example:

1 #create the main virtual machine
2 machine = Machine(name='machine', dt=1.0e-8)
3 
4 #create a machine circuit inside the main machine
5 composite = machine.AddCircuit(type="Machine", name='pll', assembly=PLL, ...)

Inherits Circuit.

Public Member Functions

def __init__ (self, machine=None, name="machine", keys)
 Class contructor. More...
 
def Assemble (self)
 Fabricator function. More...
 
def AddInput (self, name)
 Create an input channel with the given name. More...
 
def AddOutput (self, name)
 Create an output channel with the given name. More...
 
def SetInput
 Set the value of an input channel. More...
 
def Wait (self, dtime)
 Integrate the machine. More...
 
def WaitSteps (self, nsteps)
 Integrate the machine. More...
 

Public Attributes

 circuits
 Ordered dictionary of the circuits in the setup. More...
 
 dt
 Integration timestep.
 
- Public Attributes inherited from Circuit
 name
 Name of the circuit. More...
 
 enabled
 if it is working... More...
 
 machine
 Reference to the virtual machine to which this circuit belongs. More...
 
 pushed
 Push output buffer at the end of Update. More...
 
 I
 Dictionary of input channels.
 
 O
 Dictionary of output channels.
 
 cCoreID
 index of circuit in cCore
 

Constructor & Destructor Documentation

def __init__ (   self,
  machine = None,
  name = "machine",
  keys 
)

This should be used only to create the main virtual machine circuit.

Example:

1 machine = Machine(name='machine', dt=1.0e-8)
Note
Only one machine can be initialised this way.

Member Function Documentation

def AddInput (   self,
  name 
)

Add a global input channel to the machine. This is done when the machine is intended to be used as a composite circuit inside another machine, and thus it needs to communicate with other circuits.

Parameters
nameName of the new input channel.

Example:

1 machine = Machine(name='machine', dt=0.01);
2 composite = machine.AddCircuit(type='Machine', name='compo', ...)
3 composite.AddInput('signal')
def AddOutput (   self,
  name 
)

Add a global output channel to the machine. This is done when the machine is intended to be used as a composite circuit inside another machine, and thus it needs to communicate with other circuits.

Parameters
nameName of the new output channel.

Example:

1 machine = Machine(name='machine', dt=0.01);
2 composite = machine.AddCircuit(type='Machine', name='compo', ...)
3 composite.AddOutput('outsignal')
def Assemble (   self)

This function is called when the machine is instantiated, only if the "assembly" parameter was given among initialisation arguments. The function is originally left unimplemented, so the user can build the setup after the machine is instantiated.

Example:

Assembly function definition:

1 def MyAssembly(compo):
2 
3  # add global channels
4  compo.AddInput("signal1")
5  ...
6  # add internal circuits
7  compo.AddCircuit(type='opAdd',name='adder',factors=2, pushed=True)
8  ...
9  # connect internal circuits to global input and outputs
10  compo.Connect("global.signal1","adder.in1")
11  compo.Connect("adder.out","global.out")
12  ...

Main script:

1 def main():
2 
3  main = Machine(name='machine', dt=0.01, pushed=True);
4 
5  # add a Machine circuit to main, and set it up with the MyAssembly function
6  main.AddCircuit(type='Machine', name='compo1', assembly=MyAssembly, pushed=True)
7  ...
8 
9 if __name__ == '__main__':
10  main()
def SetInput (   self,
  channel = None,
  value = None 
)

Immediately sets the value of an input channel.

Parameters
channelTag of the channel to set as a 'circuit.channel' string.
valueValue to be assigned.

Example:

1 machine.SetInput(channel='waver.freq', value=10)
def Wait (   self,
  dtime 
)

Calls the update routine of each circuit in the setup for a given amount of time.

def WaitSteps (   self,
  nsteps 
)

Calls the update routine of each circuit in the setup for a given amount of steps.

Member Data Documentation

circuits

Ordered dictionary of the circuits in the setup. The dictionary keys are the circuit names, the values are references to the circuit objects.

Example:

1 waver = machine.circuits['oscillator']

Documentation for pyVAFM
Generated on Wed Feb 8 2017 10:13:49 for pyVAFM by doxygen 1.8.9.1