pyCBD.lib.std module

This file contains the standard library for CBD building blocks.

class pyCBD.lib.std.ConstantBlock(block_name, value=0.0)[source]

Bases: pyCBD.Core.BaseBlock

The constant block will always output its constant value.

Parameters
  • block_name (str) – The name of the block.

  • value (float) – The constant value of the block.

Output Ports

OUT1 – The (current) constant value.

Note

This value may be “tuned” during a simulation, making it variable through time.

getValue()[source]

Obtains the current value.

setValue(value)[source]

Alters the constant value.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.NegatorBlock(block_name)[source]

Bases: pyCBD.Core.BaseBlock

The negator will output the value of the input multiplied with -1.

Parameters

block_name (str) – The name of the block.

Input Ports

IN1 – The value to be negated.

Output Ports

OUT1 – The negated value.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.InverterBlock(block_name, tolerance=1e-30)[source]

Bases: pyCBD.Core.BaseBlock

The inverter will output the input’s inverse.

Parameters
  • block_name (str) – The name of the block.

  • tolerance (float) – The maximal value when to throw a ZeroDivisionError. When the input is larger than tolerance, no error will be thrown. Defaults to 1e-30.

Input Ports

IN1 – The value to be inverted.

Output Ports

OUT1 – The inverted value.

Raises

ZeroDivisionError – When the input is less than tolerance.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.GainBlock(block_name, value)[source]

Bases: pyCBD.Core.BaseBlock

The gain will output the input, multiplied by a constant.

Parameters
  • block_name (str) – The name of the block.

  • value (numeric) – The value of the block.

Input Ports

IN1 – The value to be multiplied.

Output Ports

OUT1 – The multiplied value.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.AdderBlock(block_name, numberOfInputs=2)[source]

Bases: pyCBD.Core.BaseBlock

The adderblock will add all the inputs.

Parameters
  • block_name (str) – The name of the block.

  • numberOfInputs (int) – The amount of input ports.

Input Ports
  • IN1 – The first addendend.

  • IN2 – The second addendend.

  • …

Output Ports

OUT1 – The sum of all inputs.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

getNumberOfInputs()[source]

Gets the total number of input ports.

class pyCBD.lib.std.ProductBlock(block_name, numberOfInputs=2)[source]

Bases: pyCBD.Core.BaseBlock

The product block will multiply all the inputs.

Parameters
  • block_name (str) – The name of the block.

  • numberOfInputs (int) – The amount of input ports.

Input Ports
  • IN1 – The first factor.

  • IN2 – The second factor.

  • …

Output Ports

OUT1 – The product of all inputs.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

getNumberOfInputs()[source]

Gets the total number of input ports.

class pyCBD.lib.std.ModuloBlock(block_name)[source]

Bases: pyCBD.Core.BaseBlock

A basic block that computes the modulo division, w.r.t. the C-standard.

Parameters

block_name (str) – The name of the block.

Input Ports
  • IN1 – The dividend.

  • IN2 – The divisor.

Output Ports

OUT1 – The remainder after division.

See also

math.fmod

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

defaultInputPortNameIdentifier()[source]

Algorithm that identifies which input port name to select if no input port name is provided for a link/connection.

Be default, all ports with name INx are analyzed, where x identifies an integer of the auto-increment port. E.g. if the last connected port was IN1, IN2 will be returned (if there is no incoming connection yet).

Returns

The new input port.

class pyCBD.lib.std.RootBlock(block_name, tolerance=1e-30)[source]

Bases: pyCBD.Core.BaseBlock

A basic block that computes the IN2-th root of IN1. Hence,

\[OUT1 = \sqrt[IN2]{IN1}\]
Parameters
  • block_name (str) – The name of the block.

  • tolerance (float) – The maximal value when to throw a ZeroDivisionError. When the input is larger than tolerance, no error will be thrown. Defaults to 1e-30.

Input Ports
  • IN1 – The radicand.

  • IN2 – The root index.

Output Ports

OUT1 – The IN2-th root of IN1.

Raises

ZeroDivisionError – When the input is less than tolerance.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

defaultInputPortNameIdentifier()[source]

Algorithm that identifies which input port name to select if no input port name is provided for a link/connection.

Be default, all ports with name INx are analyzed, where x identifies an integer of the auto-increment port. E.g. if the last connected port was IN1, IN2 will be returned (if there is no incoming connection yet).

Returns

The new input port.

class pyCBD.lib.std.PowerBlock(block_name)[source]

Bases: pyCBD.Core.BaseBlock

A basic block that computes the IN2-th power of IN1. Hence,

\[OUT1 = IN1^{IN2}\]
Parameters

block_name (str) – The name of the block.

Input Ports
  • IN1 – The base.

  • IN2 – The exponent.

Output Ports

OUT1 – The IN2-th power of IN1.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

defaultInputPortNameIdentifier()[source]

Algorithm that identifies which input port name to select if no input port name is provided for a link/connection.

Be default, all ports with name INx are analyzed, where x identifies an integer of the auto-increment port. E.g. if the last connected port was IN1, IN2 will be returned (if there is no incoming connection yet).

Returns

The new input port.

class pyCBD.lib.std.AbsBlock(block_name)[source]

Bases: pyCBD.Core.BaseBlock

The abs block will output the absolute value of the input.

Parameters

block_name (str) – The name of the block.

Input Ports

IN1 – The input.

Output Ports

OUT1 – The absolute value of the input.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.IntBlock(block_name)[source]

Bases: pyCBD.Core.BaseBlock

The int block will output the integer value (floored) of the input.

Parameters

block_name (str) – The name of the block.

Input Ports

IN1 – The input.

Output Ports

OUT1 – The integer (i.e., floored) value of the input.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.ClampBlock(block_name, min=- 1, max=1, use_const=True)[source]

Bases: pyCBD.Core.BaseBlock

The clamp block will clamp the input between min and max. A clamp function is sometimes also known as a limiter or saturation function.

Parameters
  • block_name (str) – The name of the block.

  • min (numeric) – The minimal value.

  • max (numeric) – The maximal value.

  • use_const (bool) – When True, the min and max values will be used. Otherwise, the minimal and maximal values are expected as inputs 2 and 3, respectively.

Input Ports
  • IN1 – The signal to clamp.

  • IN2 – The minimal value. Only available when use_const is True.

  • IN3 – The maximal value. Only available when use_const is True.

Output Ports

OUT1 – The clamped value.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

defaultInputPortNameIdentifier()[source]

Algorithm that identifies which input port name to select if no input port name is provided for a link/connection.

Be default, all ports with name INx are analyzed, where x identifies an integer of the auto-increment port. E.g. if the last connected port was IN1, IN2 will be returned (if there is no incoming connection yet).

Returns

The new input port.

class pyCBD.lib.std.GenericBlock(block_name, block_operator=None)[source]

Bases: pyCBD.Core.BaseBlock

The generic block will evaluate an operator on the input.

Parameters
  • block_name (str) – The name of the block.

  • block_operator (str) – The name (string) of a single-argument Python function that is available in the math module. Defaults to None.

Input Ports

IN1 – The signal to transform.

Output Ports

OUT1 – The input to which the operation was applied.

Note

Multi-argument functions cannot be used.

Warning

When the CBD model is exported to be used in another simulator (e.g., FMUs, plain C…), it is possible the function does not exist in the corresponding mathematics libraries. It is up to the user to ensure correctness in this case.

getBlockOperator()[source]

Obtains the block operator.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.MinBlock(block_name, numberOfInputs=2)[source]

Bases: pyCBD.Core.BaseBlock

The min block will output the minimal value of all its inputs.

Parameters
  • block_name (str) – The name of the block.

  • numberOfInputs (int) – The amount of input ports. Defaults to 2.

Input Ports
  • IN1 – The first input.

  • IN2 – The second input.

  • …

Output Ports

OUT1 – The minimal value of all inputs.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

getNumberOfInputs()[source]

Gets the total number of input ports.

class pyCBD.lib.std.MaxBlock(block_name, numberOfInputs=2)[source]

Bases: pyCBD.Core.BaseBlock

The max block will output the maximal value of all its inputs.

Parameters
  • block_name (str) – The name of the block.

  • numberOfInputs (int) – The amount of input ports. Defaults to 2.

Input Ports
  • IN1 – The first input.

  • IN2 – The second input.

  • …

Output Ports

OUT1 – The maximal value of all inputs.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

getNumberOfInputs()[source]

Gets the total number of input ports.

class pyCBD.lib.std.LessThanBlock(block_name)[source]

Bases: pyCBD.Core.BaseBlock

A simple block that will test if IN1 is smaller than IN2. This block will output a falsy or truthy value (i.e., 0 or 1), based on the signal.

Parameters

block_name (str) – The name of the block.

Input Ports
  • IN1 – The value that will be tested to be smaller.

  • IN2 – The value that will be tested to be larger.

Output Ports

OUT1 – Yields a 1 when IN1 is smaller than IN2, otherwise 0. In Python, 0 is a falsy value and can therefore be used as boolean check, or as computation value for other equation in the CBD. Similaryly, 1 is a truthy value.

Tip

To check the “greater than” relationship, you can swap the IN1 and IN2 inputs around.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

defaultInputPortNameIdentifier()[source]

Algorithm that identifies which input port name to select if no input port name is provided for a link/connection.

Be default, all ports with name INx are analyzed, where x identifies an integer of the auto-increment port. E.g. if the last connected port was IN1, IN2 will be returned (if there is no incoming connection yet).

Returns

The new input port.

class pyCBD.lib.std.EqualsBlock(block_name)[source]

Bases: pyCBD.Core.BaseBlock

A simple block that will test if IN1 equals IN2. This block will output a falsy or truthy value (i.e., 0 or 1), based on the signal.

Parameters

block_name (str) – The name of the block.

Input Ports
  • IN1 – The first value.

  • IN2 – The second value.

Output Ports

OUT1 – Yields a 1 when IN1 equals IN2, otherwise 0. In Python, 0 is a falsy value and can therefore be used as boolean check, or as computation value for other equation in the CBD. Similaryly, 1 is a truthy value.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.LessThanOrEqualsBlock(block_name)[source]

Bases: pyCBD.Core.BaseBlock

A simple block that will test if IN1 is smaller than or equal to IN2. This block will output a falsy or truthy value (i.e., 0 or 1), based on the signal.

Parameters

block_name (str) – The name of the block.

Input Ports
  • IN1 – The value that will be tested to be smaller (or equal).

  • IN2 – The value that will be tested to be larger (or equal).

Output Ports

OUT1 – Yields a 1 when IN1 is smaller than or equal to IN2, otherwise 0. In Python, 0 is a falsy value and can therefore be used as boolean check, or as computation value for other equation in the CBD. Similaryly, 1 is a truthy value.

Tip

To check the “greater than or equal” relationship, you can swap the IN1 and IN2 inputs around.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

defaultInputPortNameIdentifier()[source]

Algorithm that identifies which input port name to select if no input port name is provided for a link/connection.

Be default, all ports with name INx are analyzed, where x identifies an integer of the auto-increment port. E.g. if the last connected port was IN1, IN2 will be returned (if there is no incoming connection yet).

Returns

The new input port.

class pyCBD.lib.std.NotBlock(block_name)[source]

Bases: pyCBD.Core.BaseBlock

A simple block that will (boolean) invert IN1. This is similar to the not operator in programming. This block expects a falsy or truthy value and outputs the (boolean) inverse.

Parameters

block_name (str) – The name of the block.

Input Ports

IN1 – The value that will be (boolean) inverted.

Output Ports

OUT1 – Yields a 1 when IN1 is falsy and 0 when it’s truthy. In Python, 0 is a falsy value and can therefore be used as boolean check, or as computation value for other equation in the CBD. Similaryly, 1 is a truthy value.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.OrBlock(block_name, numberOfInputs=2)[source]

Bases: pyCBD.Core.BaseBlock

A simple block that will apply the or operator to multiple inputs. This block expects and returns falsy and/or truthy values.

Parameters
  • block_name (str) – The name of the block.

  • numberOfInputs (int) – The amount of inputs. Defaults to 2.

Input Ports
  • IN1 – The first input.

  • IN2 – The second input.

  • …

Output Ports

OUT1 – Yields a 1 when at least one of the inputs is truthy. Otherwise, 0. In Python, 0 is a falsy value and can therefore be used as boolean check, or as computation value for other equation in the CBD. Similaryly, 1 is a truthy value.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

getNumberOfInputs()[source]

Gets the total number of input ports.

class pyCBD.lib.std.AndBlock(block_name, numberOfInputs=2)[source]

Bases: pyCBD.Core.BaseBlock

A simple block that will apply the and operator to multiple inputs. This block expects and returns falsy and/or truthy values.

Parameters
  • block_name (str) – The name of the block.

  • numberOfInputs (int) – The amount of inputs. Defaults to 2.

Input Ports
  • IN1 – The first input.

  • IN2 – The second input.

  • …

Output Ports

OUT1 – Yields a 1 when all inputs are truthy. Otherwise, 0. In Python, 0 is a falsy value and can therefore be used as boolean check, or as computation value for other equation in the CBD. Similaryly, 1 is a truthy value.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

getNumberOfInputs()[source]

Gets the total number of input ports.

class pyCBD.lib.std.MultiplexerBlock(block_name, numberOfInputs=2, zero=True)[source]

Bases: pyCBD.Core.BaseBlock

The multiplexer block will output the signal from an input, based on the index select.

Parameters
  • block_name (str) – The name of the block.

  • numberOfInputs (int) – The amount of input ports to choose from. Defaults to 2.

  • zero (bool) – When True, the index is zero-based. Otherwise, the select signal is interpreted as 1-indexed. Defaults to True.

Input Ports
  • select – The input index to choose from. When out of range, an exception is thrown.

  • IN1 – The first option.

  • IN2 – The second option.

  • …

Output Ports

OUT1 – The input to which the operation was applied.

Raises

IndexError – When the select input is out of range.

Note

This block is not optimized in the simulator. Even though there can be a part of the block that is not necessary to be computed, the dependency graph still includes both inputs. While this is a definite optimization, recomputing the dependency graph at each iteration is much less ideal.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

getNumberOfInputs()[source]

Gets the number of input ports to choose from.

defaultInputPortNameIdentifier()[source]

Algorithm that identifies which input port name to select if no input port name is provided for a link/connection.

Be default, all ports with name INx are analyzed, where x identifies an integer of the auto-increment port. E.g. if the last connected port was IN1, IN2 will be returned (if there is no incoming connection yet).

Returns

The new input port.

class pyCBD.lib.std.SplitBlock(block_name, numberOfOutputs=2)[source]

Bases: pyCBD.Core.BaseBlock

The split block will split a signal over multiple paths. While this block can generally be omitted, it may still be used for clarity and clean-ness of the models.

Parameters
  • block_name (str) – The name of the block.

  • numberOfOutputs (int) – The amount of paths to split into. Defaults to 2.

Input Ports

IN1 – The signal.

Output Ports
  • OUT1 – The first output.

  • OUT2 – The second output.

  • …

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

getNumberOfOutputs()[source]

Gets the total number of output ports.

class pyCBD.lib.std.DelayBlock(block_name)[source]

Bases: pyCBD.Core.BaseBlock

A block that delays the input for one iteration.

Parameters

block_name (str) – The name of the block.

Input Ports
  • IN1 – The input.

  • IC – The value to output at iteration 0 (i.e., the first iteration).

Output Ports

OUT1 – Outputs the input of the previous iteration.

Note

The delay block is the only base block that alters the default behaviour of the dependency graph, because of the difference at iteration 0 and iteration 1.

Warning

The block delays based on an iteration, not on a specific time-delay. When using adaptive stepsize simulation (either in the CBD simulator, or when exported), this block may be the cause for errors.

For fixed step-size iterations, this block’s behaviour is predictable, however, in adaptive stepsize, it may be more complicated. You may need to use the DeltaTBlock for frame-independent logic (as it is called in the videogame-world) to ensure correct behaviour.

getDependencies(curIteration)[source]

Helper function to help the creation of the dependency graph.

Parameters

curIteration (int) – The current simulation’s iteration, for which the dependency graph must be constructed.

Returns

A list of ports that must be computed in order to compute this block, at the time of the iteration.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.DeltaTBlock(block_name, min=0.0)[source]

Bases: pyCBD.Core.BaseBlock

Helperblock that will always output the current time delta, even when using adaptive step-size simulation.

Parameters
  • block_name (str) – The name of the block.

  • min (numeric) – The minimal value of the allowed delta T. Note that setting this argument will result in possibly invalid results. Defaults to 0.

Output Ports

OUT1 – The current time-delta.

Note

Technically, this block is extraneous, as it re-uses information from the Clock. However, it is meant to simplify the usage of time in CBD models. In general, this block is therefore preferred over the Clock (unless you really know what you’re doing).

Warning

For fixed step-size iterations, you may need to use this block for frame-independent logic (as it is called in the videogame-world) to ensure correct behaviour.

getValue()[source]

Obtains the current time delta.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.TimeBlock(block_name)[source]

Bases: pyCBD.Core.BaseBlock

Obtains the (current) absolute and relative time of the simulation.

Parameters

block_name (str) – The name of the block.

Output Ports
  • OUT1 – The absolute simulation time.

  • relative – The relative current simulation time. If the simulation started at a time \(t\) \((t > 0)\), this equals OUT1 - \(t\).

Note

Technically, this block is extraneous, as it re-uses information from the Clock. However, it is meant to simplify the usage of time in CBD models. In general, this block is therefore preferred over the Clock (unless you really know what you’re doing).

See also

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.LoggingBlock(block_name, string, lev=30, logger='CBD')[source]

Bases: pyCBD.Core.BaseBlock

A simple logging block that logs a string if the input is truthy.

Parameters
  • block_name (str) – The name of the block.

  • string (str) – The string to log.

  • lev (int) – The level at which to log. Defaults to logging.WARNING.

  • logger (str) – The name of the logger. Defaults to CBDLogger.

Input Ports

IN1 – The input.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

class pyCBD.lib.std.AddOneBlock(block_name)[source]

Bases: pyCBD.Core.CBD

Helperblock that adds 1 to the input. It is included as an example on how to create custom CBD blocks, while also really useful (it is used often for MUX).

Parameters

block_name (str) – The name of the block.

Input Ports

IN1 – The input.

Output Ports

OUT1 – The input + 1.

class pyCBD.lib.std.DerivatorBlock(block_name)[source]

Bases: pyCBD.Core.CBD

The derivator block is a CBD that calculates the derivative, using the backwards formula.

Changed in version 1.4: Replaced delta_t input port with internal DeltaTBlock.

Parameters

block_name (str) – The name of the block.

Input Ports
  • IN1 – The input.

  • IC – The initial condition. I.e., this value is outputted at iteration 0.

Output Ports

OUT1 – The derivative of the input.

class pyCBD.lib.std.IntegratorBlock(block_name)[source]

Bases: pyCBD.Core.CBD

The integrator block is a CBD that calculates the integration. The block is implemented according to the backwards Euler rule.

Changed in version 1.4: Replaced delta_t input port with internal DeltaTBlock.

Parameters

block_name (str) – The name of the block.

Input Ports
  • IN1 – The input.

  • IC – The initial condition. I.e., this value is outputted at iteration 0.

Output Ports

OUT1 – The integral of the input.

class pyCBD.lib.std.Clock(block_name, start_delta=0.1, start_time=0.0)[source]

Bases: pyCBD.Core.BaseBlock

System clock. Must be present in a simulation model.

Parameters
  • block_name (str) – The name of the block.

  • start_delta (float) – Time delta at the start of the simulation. Defaults to 0.1.

  • start_time (float) – Time at which the simulation starts. Defaults to 0.

Input Ports
h – The delta for the next iteration. I.e., the time to wait until the next

iteration can be computed.

Output Ports
  • time – The current simulation time.

  • rel_time – The relative simulation time, ignoring the start time.

  • delta_t – The current delta.

Warning

Clock Usage Assumption: When adding a (custom) clock to your model(s), its outputs will always represent the (relative) simulated time and time-delta, independent of the simulation algorithm used. I.e., changing the delay of a fixed-rate clock should only influence the accuracy of the signals, not the correctness of the signals. It is forbidden to misuse these outputs for specific simulations (e.g., using the time as a counter, assuming delta_t is a constant value…).

In other words, the clock is guaranteed to output a correct value and should only be used in the context of “time”. When exporting the CBD model to other formalisms/simulators, the Clock’s outputs should be replaced with the corresponding simulator’s clock without loss of generality.

getDependencies(curIteration)[source]

Helper function to help the creation of the dependency graph.

Parameters

curIteration (int) – The current simulation’s iteration, for which the dependency graph must be constructed.

Returns

A list of ports that must be computed in order to compute this block, at the time of the iteration.

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.

getStartTime()[source]

Gets the starting time of the model.

getTime(curIt)[source]

Gets the time of the clock at a certain iteration.

Parameters

curIt (int) – The iteration to look at.

getRelativeTime(curIt)[source]

Gets the relative simulation time (ignoring the start time).

Parameters

curIt (int) – The iteration to look at.

setStartTime(start_time=0.0)[source]
setDeltaT(delta_t=0.1)[source]
getDeltaT()[source]
reset()[source]

Resets the clock. Required for restarting a simulation.

class pyCBD.lib.std.SequenceBlock(block_name, sequence)[source]

Bases: pyCBD.Core.BaseBlock

A simple sequence block. Will output the sequence iteratively.

Parameters
  • block_name (str) – The name of the block.

  • sequence (iter) – The sequence that needs to be outputted.

Output Ports

OUT1 – The values from the sequence.

Warning

Preferably only use this block in the tests!

compute(curIteration)[source]

Computes this block’s operation, based on its inputs and store it as an output signal.

Parameters

curIteration (int) – The iteration at which we must compute this value.