b_asic.signal_generator

Inheritance diagram of b_asic.signal_generator

B-ASIC Signal Generator Module.

These can be used as input to Simulation to algorithmically provide signal values. Especially, all classes defined here will act as a callable which accepts an integer time index and returns the value at that time.

It is worth noting that the standard basic arithmetic operations do work on these, so one can, e.g., write 0.5 * Step() to get a step input with height 0.5. This is handled by a number of private generator classes. Check out the source code if you want more information.

class b_asic.signal_generator.Constant(constant: complex = 1.0)

Bases: SignalGenerator

Signal generator that outputs a constant value.

Parameters:
constantcomplex, default: 1.0

The constant.

class b_asic.signal_generator.Delay(generator: SignalGenerator, delay: int = 1)

Bases: SignalGenerator

Signal generator that delays the value of another signal generator.

This can be used to easily delay a sequence during simulation.

Note

Although the purpose is to delay, it is also possible to look ahead by providing a negative delay.

Parameters:
generatorSignalGenerator

The signal generator to delay the output of.

delayint, default: 1

The number of time units to delay the generated signal.

class b_asic.signal_generator.Downsample(data: SignalGenerator | Sequence[complex], factor: int, phase: int = 0)

Bases: SignalGenerator

Signal generator that downsamples the value of a signal generator or a sequence.

Return every factor:th value. If a sequence, it will automatically be zero-padded.

Parameters:
dataSignalGenerator or 1-D array

The signal generator or array to downsample.

factorint

Downsampling factor.

phaseint, default 0

The phase of the downsampling.

class b_asic.signal_generator.FromFile(path)

Bases: SignalGenerator

Signal generator that reads from file and pads a sequence with zeros.

File should be of type .txt or .csv and contain a single column vector

Parameters:
pathstr

Path to input file.

class b_asic.signal_generator.Gaussian(seed: int | None = None, loc: float = 0.0, scale: float = 1.0)

Bases: SignalGenerator

Signal generator with Gaussian noise.

See numpy.random.Generator.normal() for further details.

Parameters:
seedint, optional

The seed of the random number generator.

locfloat, default: 0.0

The average value of the noise.

scalefloat, default: 1.0

The standard deviation of the noise.

class b_asic.signal_generator.Impulse(delay: int = 0)

Bases: SignalGenerator

Signal generator that creates an impulse at a given delay.

Parameters:
delayint, default: 0

The delay before the signal goes to 1 for one sample.

class b_asic.signal_generator.SignalGenerator

Bases: object

Base class for signal generators.

Handles operator overloading and defines the __call__ method that should be overridden.

class b_asic.signal_generator.Sinusoid(frequency: float, phase: float = 0.0)

Bases: SignalGenerator

Signal generator that generates a sinusoid.

Parameters:
frequencyfloat

The normalized frequency of the sinusoid. Should normally be in the interval [0, 1], where 1 corresponds to half the sample rate.

phasefloat, default: 0.0

The normalized phase offset.

class b_asic.signal_generator.Step(delay: int = 0)

Bases: SignalGenerator

Signal generator that creates a step at a given delay.

Parameters:
delayint, default: 0

The delay before the signal goes to 1.

class b_asic.signal_generator.Uniform(seed: int | None = None, low: float = -1.0, high: float = 1.0)

Bases: SignalGenerator

Signal generator with uniform noise.

See numpy.random.Generator.normal() for further details.

Parameters:
seedint, optional

The seed of the random number generator.

lowfloat, default: -1.0

The lower value of the uniform range.

highfloat, default: 1.0

The upper value of the uniform range.

class b_asic.signal_generator.Upsample(data: SignalGenerator | Sequence[complex], factor: int, phase: int = 0)

Bases: SignalGenerator

Signal generator that upsamples the value of a signal generator or a sequence.

factor - 1 zeros are inserted between every value. If a sequence, it will automatically be zero-padded.

Parameters:
dataSignalGenerator or 1-D array

The signal generator or array to upsample.

factorint

Upsampling factor.

phaseint, default 0

The phase of the upsampling.

class b_asic.signal_generator.ZeroPad(data: Sequence[complex])

Bases: SignalGenerator

Signal generator that pads a sequence with zeros.

Parameters:
data1-D array

The data that should be padded.