CamJ

At its core, CamJ simulates the noise and energy consumption of an CMOS Image Sensor (CIS) in seconds under a Frame Per Second (FPS) target. CamJ allow users to describe the CIS hardware, both the analog and digital components, and the (imaging, image processing, and computer vision) algorithm to be executed on the CIS using a declarative interface in Python. Under the surface, CamJ models the interplay across main structures of a computational CIS pipeline: pixel sensing → analog processing → digital processing. Thus, CamJ enables end-to-end modeling and optimization of the CIS architecture from photon ingestion to semantic results.

This project is under active development.

Cite Us

To know more about CamJ, please check out our paper and cite us:

@inproceedings{ma2023camj,
  title={CamJ: Enabling System-Level Energy Modeling and Architectural Exploration for In-Sensor Visual Computing},
  author={Ma, Tianrui and Feng, Yu and Zhang, Xuan and Zhu, Yuhao},
  booktitle={Proceedings of the 50th Annual International Symposium on Computer Architecture},
  year={2023}
}

What is CamJ Useful For?

CamJ is meant to be used for system-level exploration after each component design is sketched out; an analogy would be Systems-on-a-Chip (SoC) vs. accelerator design. Before system-level exploration, a team usually has at hand a range of component-level designs, which could be licensed Intellectual Property (IP) blocks, reference designs from the literature, or earlier designs from other teams in the organization; in all cases the component-level energy behavior is known or can be modeled using external tools.

CamJ helps designers make design decisions when assembling the individual (digital and analog) components into an optimal system. Ideally, a designer uses CamJ to estimate the system energy given initial designs of individual components; using the estimation, a designer can iteratively refine the components/system design. For instance, CamJ can identify energy bottlenecks and guide the re-design of corresponding components. Orthogonally, a designer can use CamJ to explore optimal mapping and partitioning of the algorithms between analog vs. digital domains or in vs. off CIS to minimize overall system energy under performance targets.

CamJ is not a synthesis tool; it does not generate a digital accelerator (or analog circuits for that matter), which is the goal of a High-Level Synthesis (HLS) tool. Rather, CamJ can be used in conjunction with HLS: one could use HLS to first generate an accelerator and then use CamJ to explore, in the bigger system, how/whether that accelerator would fit in a computational CIS to maximize end-to-end application gains.

Tutorial

The best way to learn how to use CamJ is to go through this tutorual. We host the tutorial on a Google Colab notebook, which provides a step-by-step walk-through of how to use CamJ APIs to describe a simple computational CIS, both its software and hardware, and then perform functional (noise) and energy simulations.

Want More Examples?

In CamJ repository, we have more examples of existing image sensor designs from recent literature.

What Are Supported by CamJ?

CamJ provides a high-level interface that describes some commonly-used analog and digital structures. Users can directly plug-in CamJ APIs in their image sensor designs. Here we summarize these hareware structures.

Analog Domain

The figure shown below presents all the analog components that are supported by CamJ.

_images/supported_ops.png

In this figure, the top level shows the algorithmic operations that are currently supported in CamJ. The second level shows the analog components that support the algorithmic operations at the top level. The bottom level shows the major basic analog components that compose the analog components at the second level. Both the energy and noise modeling in CamJ are performed in the analog components at the bottom level. The energy and noise modeling at the second level are composed by the bottom level analog component.

CamJ Analog Interface

To make CamJ easy to use, we expose the second-level as our standard interface. Expert users can also extend our standard interface to implement more complex analog compoenent in their design. In later Sections, we also introduce how to extend our standard interface.

The table below shows the overview of analog components at the second level:

Component
Name
Functionality Building
Blocks
Schematic
Algorithmic
Ops
Mathematic
Expression
3T Active
Pixel Sensor
(3T-APS)
Sensing - Photodiode (PD),
Floating Diffusion (FD),
Source Follower (SF)
4T Active
Pixel Sensor
(4T-APS)
Sensing - Photodiode (PD),
Floating Diffusion (FD),
Source Follower (SF)
Digital Pixel Sensor
(DPS)
Sensing - Photodiode (PD),
Floating Diffusion (FD),
Source Follower (SF),
ADC
Pulse Width
Modulation Pixel
(PWM Pixel)
Sensing - Photodiode (PD),
Ramp,
Comparator (CMP)
Analog-to-Digital
Convertor
(ADC)
Conversion,
Quanization
- ADC
Digital-to-Current
Convertor
(DAC)
Conversion - DAC
Comparator Compare (In1 > In2) ? In1 : 0 Comparator (CMP)
AnalogReLU ReLU (In > 0) ? In : 0 Comparator (CMP)
Passive
Average
Average Passive Switched
Capacitor Array (PSCA),
Source Follower (SF)
Active
Average
Average Amplifier (AMP) -
Passive
Binning
Binning Passive Switched
Capacitor Array (PSCA),
Source Follower (SF)
Active
Binning
Binning Amplifier (AMP) -
Voltage-to-Voltage
Convolution
Convolution Passive Switched
Capacitor Array (PSCA),
Source Follower (SF)
Time-to-Voltage
Convolution
Convolution Current Mirror (CM),
Passive Analog Memory (PAM)
Binary Weight
Convolution
Convolution Amplifier (AMP)
Passive
Analog Memory
Store - Passive Analog Memory (PAM)
Acitve
Analog Memory
Store - Active Analog Memory (AAM)
Max Pool Max Pooling Amplifier (AMP)
Max Voltage Max Amplifier (AMP)
Adder Add Amplifier (AMP)
Subtractor Subtraction Amplifier (AMP)
Absolute Difference Absolute Difference Amplifier (AMP)
Comparator (CMP)

Analog Design Check Rules

In ensure the correctness of user’s implementation, CamJ provides a set of rules to check the correctness of user’s sensor designs in analog domain:

Input/Output Size Compatibility This rule enforces that an analog component has a sufficient number of producers to generate inputs if an analog component requires multiple input sources.

Domain Compatibility This rule enforces that each connected analog component pair has compatible input and output interfaces. For instance, if the producer component’s output signal is in voltage domain, then, the input signal of the corresponding consumer component should be also in voltage domain.

Input Driver Compatibility This rule ensures that the producer needs to have a driver if the corresponding consumer component requires a driver to drive the input signal.

How to Extend CamJ Interface

In addition to using Cam standard interface, users can also implement their own customized analog component class. For each customized component class, users need to implement two main functions:

  • energy(self): which calculates the energy consumption of this analog component when generating a given number of outputs. This given number of outputs should match num_output when assigning this customized analog component to an AnalogComponent instance.

  • noise(self, input_signal_list: list): which defines how signals are processed in this analog component. The return of this function should be a tuple. The first element in this tuple is the name of this analog component in str, the second element is the processed signals.

Digital Domain

The interface in digital domain is much concise. Unlike analog domain, which has a handful of simulators or synthesis tools, designers can easily obtain per-cycle/access memory of their digital structures via simulators or synthesis tools. Therefore, instead of providing low-level structure blocks, we provide rather high-level interface for users. This is because of the design philosophy of CamJ: it is not used to generate digital accelerators; rather, it helps assess how an accelerator fits in the entire computational CIS system. For that reason, CamJ expects designers to have a preliminary design of the digital accelerators (whether it’s your manual design, HLS generated, or a licensed IP), in which case one will have the per-cycle/access energy statistics.

The figure shown below presents the digital interface supported by CamJ. For more details, please check out camj.digital package.

_images/supported_digital_structures.png

CamJ APIs

camj.analog package

camj.analog.component module

Analog Component Interface

This module contains the high-level interface to configure analog component and performs functional and energy simulation.

Each analog component class contains two main functions, energy() and noise(input_signals). energy() function calculates the energy of the analog component. noise(input_signals) function simulates the functional properties with the given input signals.

Examples

To run energy simulation:

>>> energy_number = [analog_component].energy()

To run functional simulation:

>>> output_signals = [analog_component].noise(input_signals)
class camj.analog.component.AbsoluteDifference(load_capacitance=1e-12, input_capacitance=1e-12, t_sample=2e-06, t_hold=0.01, supply=1.8, gain_cl=1.0, differential=False, i_bias=1e-05, t_readout=1e-09, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

Absolute Difference

This class models the behavior of absolution difference in analog processing. It can be used to model element-wise subtraction for two matrices of analog signals. This class contains one comparator and one column ampilifer.

The comparator determines which input element is larger. The amplifier first samples the larger input element to the output then subtracts the smaller input element from the larger input element at the output. Note that the digital logic that determines the amplifier’s sampling order based on the comparator’s output is ignored.

This class can be implemented as a pixel-wise component (each pixel contains an abs) or a column-wise component (one-dimensional array to perform absolute difference for all 2D pixel array).

For instance:

two lists as input signals, [0, 1, 2, 3] and [3, 2, 1, 0] will output [3, 1, 1, 3] as the result.

To see the details of function modeling, please refer its function noise().

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • load_capacitance (float) – [unit: F] load capacitance.

  • input_capacitance (float) – [unit: F] input capacitance.

  • t_sample (float) – [unit: s] sampling time, which mainly consists of the amplifier’s settling time.

  • t_hold (float) – [unit: s] holding time, during which the amplifier is turned on and consumes power relentlessly.

  • supply (float) – [unit: V] supply voltage.

  • gain_cl (int) – amplifier’s closed-loop gain. This gain describes the ratio of input_capacitance over feedback capacitance.

  • differential (bool) – if using differential-input amplifier or single-input amplifier.

  • i_bias (float) – [unit: A] bias current of the circuit in comparator.

  • t_readout (float) – [unit: s] readout time in comparator, during which the comparison is finished.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • ennable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative PRNU standard deviation respect to gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.ColumnAmplifierEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of an absolute difference. This function takes two input signals and performs absolute difference element-wise.

Parameters:

input_signal_list (list) – A list of input signals. The length of this list of 2. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.ActiveAnalogMemory(sample_capacitance=2e-12, comp_capacitance=2.5e-12, t_sample=1e-06, t_hold=0.01, supply=1.8, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

Active Analog Memory

This class models the behavior of active analog memory. The model itself consists of a capacitor, a compensation capacitor, and an amplifier which holds the stored analog data through feedback.

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • sample_capacitance (float) – [unit: F] sample capacitance.

  • comp_capacitance (float) – [unit: F] compensation capacitance

  • t_sample (float) – [unit: s] sampling time, which mainly consists of the amplifier’s settling time.

  • t_hold (float) – [unit: s] holding time, during which the amplifier is turned on and consumes power relentlessly.

  • supply (float) – [unit: V] supply voltage.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative prnu standard deviation respect to gain. prnu gain standard deviation = prnu_std * gain. the default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.ActiveAnalogMemoryEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

Simulate the functional behavior of an acitve analog memory. Here, we use a generic functional modeling class.

To see the details of function modeling, please refer:
  • analog.function_model.PixelwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 2D/3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.ActiveAverage(load_capacitance=1e-12, input_capacitance=1e-12, t_sample=2e-06, t_hold=0.01, supply=1.8, gain_cl=1, differential=False, noise=None, enable_prnu=False, prnu_std=0.001, enable_offset=False, pixel_offset_voltage=0.1, col_offset_voltage=0.05)

Bases: object

Active Average

The class performs element-wise average. It is implemented by two column amplifiers. [TODO:fixed]. The two amplifiers first transfer the two input elements to two load capacitors, respectively, then the two capacitors are connected together for charge-redistribution.

For instance:

if two input signals, [1, 2, 3] and [3, 4, 5], are used as input in noise() function, the expected output signals will be [2, 3, 4].

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • load_capacitance (float) – [unit: F] load capacitance.

  • input_capacitance (float) – [unit: F] input capacitance.

  • t_sample (float) – [unit: s] sampling time, which mainly consists of the amplifier’s settling time.

  • t_hold (float) – [unit: s] holding time, during which the amplifier is turned on and consumes power relentlessly.

  • supply (float) – [unit: V] supply voltage.

  • gain_cl (int) – amplifier’s closed-loop gain. This gain describes the ratio of input_capacitance over feedback capacitance.

  • differential (bool) – if using differential-input amplifier or single-input amplifier.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • ennable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative PRNU standard deviation respect to gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

  • enable_offset (bool) – flag to enable adding offset voltage. Default value is False.

  • pixel_offset_voltage – pixel offset voltage in unit of volt (V). Default value is 0.1.

  • col_offset_voltage – column-wise offset voltage in unit of volt (V). Default value is 0.05.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.ColumnAmplifierEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of averaging.

To see the details of function modeling, please refer:
  • analog.function_model.ColumnwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.ActiveBinning(load_capacitance=1e-12, input_capacitance=1e-12, t_sample=2e-06, t_hold=0.01, supply=1.8, gain_cl=2, differential=False, noise=None, enable_prnu=False, prnu_std=0.001, enable_offset=False, pixel_offset_voltage=0.1, col_offset_voltage=0.05)

Bases: object

Active Binning

The class performs binning operations. It is implemented by one column amplifier. The amplifier transfers the input elements sequentially to its load capacitor, and the transferred inputs are averaged at the capacitor by charge-redistribution.

The binning kernel size and stride are determined by the mapped software stage.

For instance:

if [[1, 2], [3, 4]] is used as input for a 2x2 binning, the expected output signals will be [2.5].

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • load_capacitance (float) – [unit: F] load capacitance.

  • input_capacitance (float) – [unit: F] input capacitance.

  • t_sample (float) – [unit: s] sampling time, which mainly consists of the amplifier’s settling time.

  • t_hold (float) – [unit: s] holding time, during which the amplifier is turned on and consumes power relentlessly.

  • supply (float) – [unit: V] supply voltage.

  • gain_cl (int) – amplifier’s closed-loop gain. This gain describes the ratio of input_capacitance over feedback capacitance.

  • differential (bool) – if using differential-input amplifier or single-input amplifier.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • ennable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative PRNU standard deviation respect to gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

  • enable_offset (bool) – flag to enable adding offset voltage. Default value is False.

  • pixel_offset_voltage – pixel offset voltage in unit of volt (V). Default value is 0.1.

  • col_offset_voltage – column-wise offset voltage in unit of volt (V). Default value is 0.05.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.ColumnAmplifierEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of binning.

To see the details of function modeling, please refer:
  • analog.function_model.ColumnwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.ActivePixelSensor(pd_capacitance=1e-13, pd_supply=1.8, dynamic_sf=False, output_vs=1, num_transistor=3, enable_cds=False, fd_capacitance=1e-14, load_capacitance=1e-12, tech_node=130, pitch=4, array_vsize=128, dark_current_noise=0.0, enable_dcnu=False, enable_prnu=False, dcnu_std=0.001, fd_gain=1.0, fd_noise=None, fd_prnu_std=0.001, sf_gain=1.0, sf_noise=None, sf_prnu_std=0.001)

Bases: object

Active Pixel Sensor Model

Our APS model includes modeling photodiode (PD), floating diffusion (FD), source follower (SF), and parasitic during the readout. This APS model supports energy estimation for both 3T-APS and 4T-APS. Users need to define num_transistor to get the correct energy estimation.

Input/Output domains:
  • input domain: ProcessDomain.OPTICAL.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • pd_capacitance (float) – [unit: F] the capacitance of PD.

  • pd_supply (float) – [unit: V] supply voltage of pixel.

  • dynamic_sf (bool) – using dynamic SF or not. In most cases, the in-pixel SF is not dynamic, meaning that it is statically-biased by a constant current. However, some works [JSSC-2021] use dynamic SF to save energy.

  • output_vs (float) – [unit: V] voltage swing at SF’s output node. Typically it is one or two units of threshold voltage smaller than pd_supply, depending on the pixel’s circuit structure.

  • num_transistor (int) – {3 or 4}. It defines using 3T APS or 4T APS.

  • enable_cds (bool) – enabling CDS or not.

  • fd_capacitance (float) – the capacitance of FD.

  • load_capacitance (float) – [unit: F] load capacitance at the SF’s output node.

  • tech_node (int) – [unit: nm] pixel’s process node.

  • pitch (float) – [unit: um] pixel pitch size (width or height).

  • array_vsize (int) – the vertical size of the entire pixel array. This is used to estimate the parasitic capacitance on the SF’s readout wire.

  • dark_current_noise (float) – average dark current noise in unit of electrons (e-).

  • enable_dcnu (bool) – flag to enable dark current non-uniformity, the default value is False.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • dcnu_std (float) – dcnu standard deviation percentage. it is relative number respect to dark_current_noise, the dcnu standard deviation is, dcnu_std * dark_current_noise, the default value is 0.001.

  • fd_gain (float) – the gain of FD, the default value is 1.0.

  • fd_noise (float) – the standard deviation of FD read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • fd_prnu_std (float) – relative PRNU standard deviation respect to FD gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

  • sf_gain (float) – the gain of SF, the default value is 1.0.

  • sf_noise (float) – the stadard deviation of SF read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • sf_prnu_std (float) – relative PRNU standard deviation respect to SF gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

energy()

Calculate Energy

This APS model is a wrapper class for its energy model:
  • analog.energy_model.ActivePixelSensorEnergy.

Please check out this class for more details.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list: list)

Perform functional simulation

This function simulates the signal processing behavior inside APS, including signal processing in photodiode, floating diffusion and source follower. Each input signal in input_signal_list will go through each analog componennt functional simulation sequentially.

Please refer to these functions for more detailed descriptions:
  • Photodiode: analog.function_model.PhotodiodeFunc.

  • Floating Diffusion: analog.function_model.FloatingDiffusionFunc.

  • Source Follower: analog.function_model.PixelwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is the simulated result.

Return type:

Simulation result (tuple)

class camj.analog.component.Adder(load_capacitance=1e-12, input_capacitance=1e-12, t_sample=2e-06, t_hold=0.01, supply=1.8, gain_cl=1.0, differential=False, columnwise_op=True, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

This class models the behavior of adder in analog processing. It can be used to model element-wise addition for two matrices of analog signals. This class contains one column ampilifer. [TODO:fixed] The amplifier first samples one input element to the output then accumulates the other input element to the previous input element at the output.

This class can be implemented as a pixel-wise component (each pixel contains an adder) or a column-wise component (one-dimensional array to perform addition for all 2D pixel array).

For instance:

two lists as input signals, [0, 1, 2, 3] and [3, 2, 1, 0] will output [3, 3, 3, 3] as the result.

To see the details of function modeling, please refer its function noise().

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • load_capacitance (float) – [unit: F] load capacitance.

  • input_capacitance (float) – [unit: F] input capacitance.

  • t_sample (float) – [unit: s] sampling time, which mainly consists of the amplifier’s settling time.

  • t_hold (float) – [unit: s] holding time, during which the amplifier is turned on and consumes power relentlessly.

  • supply (float) – [unit: V] supply voltage.

  • gain_cl (int) – amplifier’s closed-loop gain. This gain describes the ratio of input_capacitance over feedback capacitance.

  • differential (bool) – if using differential-input amplifier or single-input amplifier.

  • columnwise_op (bool) – flag to set if this operation is column-wise or not. This flag will affect the PRNU.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • ennable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative PRNU standard deviation respect to gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.ColumnAmplifierEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of an adder. This function takes two input signals and adds them together element-wise. Because we implement this adder using amplifier, the input signals are first read by amplifiers and then add together. Here, we model this behavior by first simulating the noise effects on these two inputs and then adding the noising outputs (out of the amplifier) together.

Parameters:

input_signal_list (list) – A list of input signals. The length of this list of 2. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.AnalogReLU(supply=1.8, i_bias=1e-05, t_readout=1e-09, enable_prnu=False, prnu_std=0.001)

Bases: object

Analog ReLU

This class performs ReLU operation using analog comparator. Funtionally, this class performs ReLU after getting the convolutional results: the class outputs 0 when the result is negative and outputs the result as-is when the result is positive. Note that in real circuits the analog ReLU is performed before getting the convolutional results: the convolutional results are stored at two memories (positive part and negative part) based on the output polarity. If the positive part is smaller than the negative part, the output is set to 0; otherwise, the ReLU transfers the two parts as-is to the next analog processing stage. No subtractor is needed since the next stage usually takes differential inputs.

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • i_bias (float) – [unit: A] bias current of the circuit.

  • t_readout (float) – [unit: s] readout time, during which the comparison is finished.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative prnu standard deviation respect to gain. prnu gain standard deviation = prnu_std * gain, the default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.ComparatorEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of ReLU operation.

To see the details of function modeling, please refer:
  • analog.function_model.ComparatorFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.AnalogToDigitalConverter(supply=1.8, type='SS', fom=1e-13, resolution=8, adc_noise=0.0)

Bases: object

Analog-to-Digital Converter.

This class model the behavior of ADC.

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.DIGITAL.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • type (str) – ADC type.

  • fom (float) – [unit: J/conversion] ADC’s Figure-of-Merit, expressed by energy per conversion.

  • resolution (int) – ADC resolution.

  • adc_noise (float) – ADC noise.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.AnalogToDigitalConverterEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of a ADC. The output value range depends on the resolution parameter. For instance, when resolution = 8, the output value range is [0, 256).

To see the details of function modeling, please refer:
  • analog.function_model.AnalogToDigitalConverterFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.BinaryWeightConv(load_capacitance=1e-12, input_capacitance=1e-12, t_sample=2e-06, t_hold=0.01, supply=1.8, gain_cl=2, differential=False, noise=None, enable_prnu=False, prnu_std=0.001, enable_offset=False, pixel_offset_voltage=0.1, col_offset_voltage=0.05)

Bases: object

Binary Weight Convolution [TODO: questionable]

This class performs binary convolution operations in analog domain. All the kernel weights in this convolution operation should be either -1 or 1. The convolution is realized by driving all positive weight input signals to one capacitor and all negative ones to another capacitor, and then, uses a comparator to generate the final output.

Note

Map corresponding WeightInput in software pipeline definition directly to this class for correct functional simulation.

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • load_capacitance (float) – [unit: F] load capacitance.

  • input_capacitance (float) – [unit: F] input capacitance.

  • t_sample (float) – [unit: s] sampling time, which mainly consists of the amplifier’s settling time.

  • t_hold (float) – [unit: s] holding time, during which the amplifier is turned on and consumes power relentlessly.

  • supply (float) – [unit: V] supply voltage.

  • gain_cl (int) – amplifier’s closed-loop gain. This gain describes the ratio of input_capacitance over feedback capacitance.

  • differential (bool) – if using differential-input amplifier or single-input amplifier.

  • noise (float) – the standard deviation of read noise. Default value is None.

  • ennable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative PRNU standard deviation respect to gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

  • enable_offset (bool) – flag to enable adding offset voltage. Default value is False.

  • pixel_offset_voltage – pixel offset voltage in unit of volt (V). Default value is 0.1.

  • col_offset_voltage – column-wise offset voltage in unit of volt (V). Default value is 0.05.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.ColumnAmplifierEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of convolution operation. This function inherits some functionalities from analog.function_model.ColumnwiseFunc.

To see the details of function modeling, please refer:
  • analog.function_model.ColumnwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. One input should be input signal and the other one should be weight signal.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.ColumnAmplifier(load_capacitance=1e-12, input_capacitance=1e-12, t_sample=2e-06, t_hold=0.01, supply=1.8, gain_cl=2, gain_open=256, differential=False, gain=1, noise=None, enable_prnu=False, prnu_std=0.001, enable_offset=False, pixel_offset_voltage=0.1, col_offset_voltage=0.05)

Bases: object

Column Amplifier

The class models the hardware behavior of a typical column amplifier. It includes an input capacitor, a feedback capacitor, a load capacitor, and an amplifier. This amplifier can be used either as pixel array’s column amplifier or as a general-purpose switched-capacitor amplifier, such as switched-capacitor integrator, switched-capacitor subtractor, and switched-capacitor multiplier.

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • load_capacitance (float) – [unit: F] load capacitance.

  • input_capacitance (float) – [unit: F] input capacitance.

  • t_sample (float) – [unit: s] sampling time, which mainly consists of the amplifier’s settling time.

  • t_hold (float) – [unit: s] holding time, during which the amplifier is turned on and consumes power relentlessly.

  • supply (float) – [unit: V] supply voltage.

  • gain_cl (int) – amplifier’s closed-loop gain. This gain describes the ratio of input_capacitance over feedback capacitance.

  • differential (bool) – if using differential-input amplifier or single-input amplifier.

  • gain (float) – the average gain. Default value is 1.0.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • ennable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative PRNU standard deviation respect to gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

  • enable_offset (bool) – flag to enable adding offset voltage. Default value is False.

  • pixel_offset_voltage – pixel offset voltage in unit of volt (V). Default value is 0.1.

  • col_offset_voltage – column-wise offset voltage in unit of volt (V). Default value is 0.05.

energy()

Calculate Energy

This class supports both energy modeling and functional modeling. The details of energy modeling, please check out:
  • analog.energy_model.ColumnAmplifierEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the signal processing behavior of column amplifier. Each input signal in input_signal_list will perform functional simulation sequentially.

To see the details of function modeling, please refer:
  • analog.function_model.ColumnwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.Comparator(supply=1.8, i_bias=1e-05, t_readout=1e-09, enable_prnu=False, prnu_std=0.001)

Bases: object

Dynamic Voltage Comparator

The class models the behavior of dynamic voltage comparator.

Note

The functional simulation of this class is slightly different than the actual analog comparator. In the actual comparator, it compares the two different input signals (In1 and In2) and output either Vdd (if In1 >= In2) or 0 (if In1 < In2). Here, in order to support other computations, we modified the output of the comparator to be In1 (if In1 >= In2) or 0 (if In1 < In2).

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • i_bias (float) – [unit: A] bias current of the circuit.

  • t_readout (float) – [unit: s] readout time, during which the comparison is finished.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative prnu standard deviation respect to gain. prnu gain standard deviation = prnu_std * gain. the default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.ComparatorEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of a comparator.

To see the details of function modeling, please refer:
  • analog.function_model.ComparatorFunc.

Parameters:

input_signal_list (list) – A list of input signals. The length of this list is 2. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.CurrentMirror(supply=1.8, load_capacitance=2e-12, t_readout=1e-06, i_dc=1e-06, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

Current Mirror.

This class models the behavior of current mirror. The class models a constant current path and a load capacitor.

Note

This class can perform current duplication or current-time multiplication depending on user’s definition. When i_dc is not None, this class will perform current duplication and the output signal domain is current. Otherwise, this class performs current-time multiplication and accumulate the charges on its own load capacitor. The output signal domain would be voltage.

Input/Output domains:
  • input domain: ProcessDomain.CURRENT and ProcessDomain.TIME.

  • output domain: if i_dc is None, then ProcessDomain.VOLTAGE, else, ProcessDomain.CURRENT.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • load_capacitance (float) – [unit: F] load capacitance.

  • t_readout (float) – [unit: s] readout time, during which the constant current drives the load capacitance from 0 to VDD.

  • i_dc (float) – [unit: A] the constant current. If i_dc == None, then i_dc is estimated from the other parameters.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative prnu standard deviation respect to gain. prnu gain standard deviation = prnu_std * gain. The default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.CurrentMirrorEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of an current mirror.

Note

This function accepts two types of inputs. When the length of input_signal_list is 1. This function will perform copy operation that directly copy the input signal to the output signal with noise simulation. When the length of input_signal_list is 2. This function will perform element-wise multiplication. One input is the time signal and the second one is the current signal.

To see the details of function modeling, please refer:
  • analog.function_model.CurrentMirrorFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array. The length of input_signal_list should be either 1 or 2.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.DigitalPixelSensor(pd_capacitance=1e-13, pd_supply=1.8, dynamic_sf=False, output_vs=1, num_transistor=3, enable_cds=False, fd_capacitance=1e-14, load_capacitance=1e-12, tech_node=130, pitch=4, array_vsize=128, adc_type='SS', adc_fom=1e-13, adc_reso=8, dark_current_noise=0.0, enable_dcnu=False, enable_prnu=False, dcnu_std=0.001, fd_gain=1.0, fd_noise=None, fd_prnu_std=0.001, sf_gain=1.0, sf_noise=None, sf_prnu_std=0.001, cds_gain=1.0, cds_noise=None, cds_prnu_std=0.001, adc_noise=0.0)

Bases: object

Digital Pixel Sensor

This class models the energy consumption of digital pixel sensor (DPS). This DPS class models behavior of a APS and an per-pixel ADC.

Input/Output domains:
  • input domain: ProcessDomain.OPTICAL.

  • output domain: ProcessDomain.DIGITAL.

Parameters:
  • pd_capacitance (float) – [unit: F] the capacitance of PD.

  • pd_supply (float) – [unit: V] supply voltage of pixel.

  • dynamic_sf (bool) – using dynamic SF or not. In most cases, the in-pixel SF is not dynamic, meaning that it is statically-biased by a constant current. However, some works [JSSC-2021] use dynamic SF to save energy.

  • output_vs (float) – [unit: V] voltage swing at SF’s output node. Typically it is one or two units of threshold voltage smaller than pd_supply, depending on the pixel’s circuit structure.

  • num_transistor (int) – {3 or 4}. It defines using 3T APS or 4T APS.

  • enable_cds (bool) – enabling CDS or not.

  • fd_capacitance (float) – [unit: F] the capacitance of FD.

  • load_capacitance (float) – [unit: F] load capacitance at the SF’s output node.

  • tech_node (int) – [unit: nm] pixel’s process node.

  • pitch (float) – [unit: um] pixel pitch size (width or height).

  • array_vsize (int) – the vertical size of the entire pixel array. This is used to estimate the parasitic capacitance on the SF’s readout wire.

  • adc_type (str) – the actual ADC type. Please check ADC class for more details.

  • adc_fom (float) – [unit: J/conversion] ADC’s Figure-of-Merit, expressed by energy per conversion.

  • adc_resolution (int) – ADC’s resolution. 8 stands for 8-bit digital resolution, [0, 256).

  • dark_current_noise (float) – average dark current noise in unit of electrons (e-).

  • enable_dcnu (bool) – flag to enable dark current non-uniformity, the default value is False.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • dcnu_std (float) – dcnu standard deviation percentage. it is relative number respect to dark_current_noise, the dcnu standard deviation is, dcnu_std * dark_current_noise, the default value is 0.001.

  • fd_gain (float) – the gain of FD, the default value is 1.0.

  • fd_noise (float) – the stadard deviation of FD read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • fd_prnu_std (float) – relative PRNU standard deviation respect to FD gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

  • sf_gain (float) – the gain of SF, the default value is 1.0.

  • sf_noise (float) – the stadard deviation of SF read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • sf_prnu_std (float) – relative PRNU standard deviation respect to SF gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

  • cds_gain (float) – the gain of CDS, the default value is 1.0.

  • cds_prnu_std (float) – relative PRNU standard deviation respect to CDS gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

  • adc_noise (float) – the standard deviation of read noise from ADC. the default value is 0..

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.DigitalPixelSensorEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the signal processing behavior inside DPS, including signal processing in photodiode, floating diffusion, source follower and ADC. Each input signal in input_signal_list will perform functional simulation sequentially.

To see the details of function modeling, please refer:
  • Photodiode: analog.function_model.PhotodiodeFunc.

  • Floating Diffusion: analog.function_model.FloatingDiffusionFunc.

  • Source Follower: analog.function_model.PixelwiseFunc.

  • Correlated Double Sampling: analog.function_model.CorrelatedDoubleSamplingFunc.

  • Analog-To-Digital Converter: analog.function_model.AnalogToDigitalConverterFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is the simulated result.

Return type:

Simulation result (tuple)

class camj.analog.component.DigitalToCurrentConverter(supply=1.8, load_capacitance=2e-12, t_readout=1.6e-05, gain=3.90625e-08, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

Digital-to-Current Converter

This class models the behavior of Digital-to-Current Converter. This model consists of a constant current path and a load capacitor.

Input/Output domains:
  • input domain: ProcessDomain.DIGITAL.

  • output domain: ProcessDomain.CURRENT.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • load_capacitance (float) – [unit: F] load capacitance.

  • t_readout (float) – [unit: s] readout time, during which the constant current drives the load capacitance from 0 to VDD.

  • gain (float) – the average gain. Default value is 10e-6/256 in unit of [A/digital number]. Here, we assume the maximum current is 10 uA and the input digital resolution is 8 bits.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative prnu standard deviation respect to gain. prnu gain standard deviation = prnu_std * gain. the default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.DigitalToCurrentConverterEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of a DAC.

To see the details of function modeling, please refer:
  • analog.function_model.PixelwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.GeneralCircuit(supply=1.8, t_operation=0.03, i_dc=1e-06)

Bases: object

A model for general circuits from first principle.

TODO: Tianrui.

Note

This class is just a rough estimation for its energy, no functional simulation is implemented.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • t_operation (float) – [unit: s] operation time, during which the circuit completes its particular operation.

  • i_dc (float) – [unit: A] direct current of the circuit.

energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)
class camj.analog.component.MaxPool(supply=1.8, t_hold=0.03, t_readout=1e-06, load_capacitance=1e-12, gain=10, noise=None)

Bases: object

Max Pooling

This class performs max pooling in analog processing. The model consists of a constant current path, a group of common-source amplifiers, and a load capacitor.

Based on the mapping software stage, it will perform max pooling with the given kernel size.

For instance:

If the input signal is a 2D matrix, [[1, 1], [2, 3]], a 2x2 max pooling will output [[3]] as the result.

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • t_hold (float) – [unit: s] holding time, during which the circuit is turned on and consumes power relentlessly.

  • t_readout (float) – [unit: s] readout time, during which the maximum voltage is output.

  • load_capacitance (float) – [unit: F] load capacitance

  • gain (float) – open-loop gain of the common-source amplifier.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

energy()

Calculate Energy

Here, we use some functionalities of analog.energy_model.MaximumVoltageEnergy to model the energy of this class.

To see the details of energy modeling, please check out:
  • analog.energy_model.MaximumVoltageEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of an max pooling.

Here, we use some functionalities of analog.energy_model.MaximumVoltageFunc to model the noise simulation of this class.

To see the details of function modeling, please refer:
  • analog.function_model.MaximumVoltageFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.MaximumVoltage(supply=1.8, t_hold=0.03, t_readout=1e-06, load_capacitance=1e-12, gain=10, noise=None)

Bases: object

Maximum Voltage

A circuit that outputs the maximum voltage among the input voltages. The output of its noise() function takes a list of input signals matrices and compare element-wise across those input signals. The return of “noise()” is the maximum value for each element-wise comparison across those input signals.

For instance:

two lists as input signals, [0, 1, 2, 3] and [3, 2, 1, 0] will output [3, 2, 2, 3] as the result.

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • t_hold (float) – [unit: s] holding time, during which the circuit is turned on and consumes power relentlessly.

  • t_readout (float) – [unit: s] readout time, during which the maximum voltage is output.

  • load_capacitance (float) – [unit: F] load capacitance

  • gain (float) – open-loop gain of the common-source amplifier.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.MaximumVoltageEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of a maximum voltage. This function takes a list of input signals and performs element-wise max comparison. The output of this function is a list of signal with length of 1.

To see the details of function modeling, please refer:
  • analog.function_model.MaximumVoltageFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.PassiveAnalogMemory(sample_capacitance=1e-12, supply=1.8, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

Passive Analog Memory

This class models the behavior of passive analog memory. The model only contains a sample capacitor. Compared to active analog memory, it has higher data leakage rate.

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • sample_capacitance (float) – [unit: F] sample capacitance.

  • supply (float) – [unit: V] supply voltage.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative prnu standard deviation respect to gain. prnu gain standard deviation = prnu_std * gain. the default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.PassiveAnalogMemoryEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

Simulate the functional behavior of an passive analog memory. The functional behavior of this component is used a generic noise model.

To see the details of function modeling, please refer:
  • analog.function_model.PixelwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 2D/3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.PassiveAverage(capacitance_array, vs_array, sf_load_capacitance=1e-12, sf_supply=1.8, sf_output_vs=1, sf_bias_current=5e-06, psca_noise=None, sf_noise=None, sf_enable_prnu=False, sf_prnu_std=0.001)

Bases: object

Passive Average

The class performs element-wise average. It uses passive switched capacitor array to realize the functionality of averaging (charge redistribution) and uses source followers for signal readout.

For instance:

if two input signals, [1, 2, 3] and [3, 4, 5], are used as input in noise() function, the expected output signals will be [2, 3, 4].

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • capacitance_array (array, float) – [unit: F] a list of capacitors.

  • vs_array (array, float) – [unit: V] a list of voltages that corresponds to the voltage swing at each capacitor.

  • sf_load_capacitance (float) – [unit: F] load capacitance.

  • sf_supply (float) – [unit: V] supply voltage.

  • sf_output_vs (float) – [unit: V] voltage swing at the SF’s output node.

  • sf_bias_current (float) – [unit: A] bias current.

  • psca_noise (float) – the stadard deviation of passive switched capacitor array’s read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • sf_noise (float) – the stadard deviation of SF read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • sf_enable_prnu (bool) – flag to enable SF PRNU. Default value is False.

  • sf_prnu_std (float) – the relative prnu standard deviation respect to SF gain. prnu gain standard deviation = prnu_std * gain. the default value is 0.001.

energy()

Calculate Energy

Passive average inherits some of the functionalities of the energy class below.

To see the details of energy modeling, please check out:
  • analog.energy_model.PassiveSwitchedCapacitorArrayEnergy.

  • analog.energy_model.SourceFollowerEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of an averaging.

To see the details of function modeling, please refer:
  • analog.function_model.PassiveSwitchedCapacitorArrayFunc.

  • analog.function_model.PixelwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.PassiveBinning(capacitance_array, vs_array, sf_load_capacitance=1e-12, sf_supply=1.8, sf_output_vs=1, sf_bias_current=5e-06, psca_noise=None, sf_noise=None, sf_enable_prnu=False, sf_prnu_std=0.001)

Bases: object

Passive Binning

The class performs binning operations. It uses passive switched capacitor array to realize the functionality of binning (via charge redistribution) and uses source followers for signal readout.

The binning kernel size and stride are determined by the mapped software stage.

For instance:

if [[1, 2], [3, 4]] is used as input for a 2x2 binning, the expected output signals will be [2.5].

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • capacitance_array (array, float) – [unit: F] a list of capacitors.

  • vs_array (array, float) – [unit: V] a list of voltages that corresponds to the voltage swing at each capacitor.

  • sf_load_capacitance (float) – [unit: F] load capacitance.

  • sf_supply (float) – [unit: V] supply voltage.

  • sf_output_vs (float) – [unit: V] voltage swing at the SF’s output node.

  • sf_bias_current (float) – [unit: A] bias current.

  • psca_noise (float) – the stadard deviation of passive switched capacitor array’s read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • sf_noise (float) – the stadard deviation of SF read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • sf_enable_prnu (bool) – flag to enable SF PRNU. Default value is False.

  • sf_prnu_std (float) – the relative prnu standard deviation respect to SF gain. prnu gain standard deviation = prnu_std * gain. the default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.PassiveSwitchedCapacitorArrayEnergy.

  • analog.energy_model.SourceFollowerEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of binning.

To see the details of function modeling, please refer:
  • analog.function_model.PassiveSwitchedCapacitorArrayFunc.

  • analog.function_model.PixelwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.PassiveSwitchedCapacitorArray(capacitance_array, vs_array, noise=None)

Bases: object

Passive Switched Capacitor Array

The model consists of a list of capacitors and a list of voltages that corresponds to the voltage swing at each capacitor. The model is used to represent all passive switched-capacitor computational circuits, including charge-redistribution-based MAC operation.

Note

The default behavior of this class is to perform element-wise accumulation. For instance, if input_signal_list is [np.array([1, 2, 3]), np.array([1, 2, 3]), np.array([1, 2, 3])], the output from noise function is np.array([3, 6, 9]). For achieve functionality of convolution, please check out analog.component.Voltage2VoltageConv.

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • capacitance_array (array, float) – [unit: F] a list of capacitors.

  • vs_array (array, float) – [unit: V] a list of voltages that corresponds to the voltage swing at each capacitor.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.PassiveSwitchedCapacitorArrayEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of a passive switched capacitor array.

To see the details of function modeling, please refer:
  • analog.function_model.PassiveSwitchedCapacitorArrayFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.PulseWidthModulationPixel(pd_capacitance=1e-13, pd_supply=1.8, array_vsize=126, ramp_capacitance=1e-12, gate_capacitance=1e-14, num_readout=1)

Bases: object

Pulse-Width-Modulation (PWM) Pixel

The modeled PWM pixel consists of a photodiode (PD), a ramp signal generator, and a comparator. The comparator output toggles when the ramp signal is smaller than the pixel voltage at PD.

This PWM pixel class ONLY supports energy modeling, currently no functional modeling.

Input/Output domains:
  • input domain: ProcessDomain.OPTICAL.

  • output domain: ProcessDomain.TIME.

Parameters:
  • pd_capacitance – PD capacitance.

  • pd_supply – PD voltage supply.

  • array_vsize – , the vertical size of the pixel array. For A 720x1280 (H, W) resolution pixel array, its vertical size is 720.

  • ramp_capacitance – the capacitance of ramp signal generator.

  • gate_capacitance – the gate capacitance of readout transistor.

  • num_readout – number of read from pixel.

energy()

Calculate Energy

For energy modeling, please check out analog.energy_model.PulseWidthModulationPixelEnergy for more details.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

TODO: (tianrui)

Note

Currently, we don’t support the functional simulation for PWM pixels, input_signal_list will be directly returned ny this function.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is the simulated result.

Return type:

Simulation result (tuple)

class camj.analog.component.SourceFollower(load_capacitance=1e-12, supply=1.8, output_vs=1, bias_current=5e-06, gain=1.0, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

Source Follower

This class models the behavior of source follower. It can be applied to not only the single-transistor source follower but also flipped-voltage-follower (FVF).

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • load_capacitance (float) – [unit: F] load capacitance.

  • supply (float) – [unit: V] supply voltage.

  • output_vs (float) – [unit: V] voltage swing at the SF’s output node.

  • bias_current (float) – [unit: A] bias current.

  • gain (float) – the average gain. Default value is 1.0.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative prnu standard deviation respect to gain. prnu gain standard deviation = prnu_std * gain. the default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.SourceFollowerEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

Simulate the functional behavior of a source follower. Here, we use a generic functional modeling class to model source follower.

To see the details of function modeling, please refer the pixel-wise generic modeling class:
  • analog.function_model.PixelwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.Subtractor(load_capacitance=1e-12, input_capacitance=1e-12, t_sample=2e-06, t_hold=0.01, supply=1.8, gain_cl=1.0, differential=False, columnwise_op=True, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

This class models the behavior of subtractor in analog processing. It can be used to model element-wise subtraction for two matrices of analog signals. This class contains one column ampilifer. The amplifier first samples one input element to the output then subtracts the other input element from the previous input element at the output.

This class can be implemented as a pixel-wise component (each pixel contains an sub) or a column-wise component (one-dimensional array to perform subtraction for all 2D pixel array).

For instance:

two lists as input signals, [0, 1, 2, 3] and [3, 2, 1, 0] will output [-3, -1, 1, 3] as the result.

To see the details of function modeling, please refer its function noise().

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • load_capacitance (float) – [unit: F] load capacitance.

  • input_capacitance (float) – [unit: F] input capacitance.

  • t_sample (float) – [unit: s] sampling time, which mainly consists of the amplifier’s settling time.

  • t_hold (float) – [unit: s] holding time, during which the amplifier is turned on and consumes power relentlessly.

  • supply (float) – [unit: V] supply voltage.

  • gain_cl (int) – amplifier’s closed-loop gain. This gain describes the ratio of input_capacitance over feedback capacitance.

  • differential (bool) – if using differential-input amplifier or single-input amplifier.

  • noise (float) – the stadard deviation of read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • ennable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative PRNU standard deviation respect to gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.ColumnAmplifierEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of an subtractor. This function takes two input signals (In1 and In2) and subtract In2 from In1 element-wise.

Parameters:

input_signal_list (list) – A list of input signals. The length of this list of 2. Each input signal should be a 3D array.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.Time2VoltageConv(cm_supply=1.8, cm_load_capacitance=2e-12, cm_t_readout=1e-06, cm_i_dc=1e-06, am_sample_capacitance=1e-12, am_supply=1.8, cm_noise=None, cm_enable_prnu=False, cm_prnu_std=0.001, am_noise=None, am_enable_prnu=False, am_prnu_std=0.001)

Bases: object

Time-to-Voltage Convolution

This class performs convolution operations in analog domain. The convolution is realized by current mirror, the input current is used as kernel weight and the time signal from PWM pixel is used as input in convolution layer. Passive Analog Memory is used to store convolution output. [TODO:fixed] The memory accumulates convolutional partial sums sequentially.

Note

Map corresponding WeightInput in software pipeline definition to a DigitalToCurrentConverter and then connect the DigitalToCurrentConverter to this class for correct functional simulation.

Input/Output domains:
  • input domain: ProcessDomain.CURRENT and ProcessDomain.TIME.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • cm_supply (float) – [unit: V] supply voltage of current mirror.

  • cm_load_capacitance (float) – [unit: F] load capacitance of current mirror.

  • cm_t_readout (float) – [unit: s] readout time of current mirror, during which the constant current drives the load capacitance from 0 to VDD.

  • cm_i_dc (float) – [unit: A] the constant current of current mirror. If i_dc == None, then i_dc is estimated from the other parameters.

  • am_sample_capacitance (float) – [unit: F] sample capacitance of passive analog memory.

  • am_supply (float) – [unit: V] supply voltage of passive analog memory.

  • cm_noise (float) – the standard deviation of current mirror read noise. Default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • cm_ennable_prnu (bool) – flag to enable PRNU of current mirror. Default value is False.

  • cm_prnu_std (float) – the relative PRNU standard deviation respect to current mirror gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

  • am_noise (float) – the standard deviation of analog memory read noise. Default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • am_ennable_prnu (bool) – flag to enable PRNU of analog memory. Default value is False.

  • am_prnu_std (float) – the relative PRNU standard deviation respect to gain of analog memory. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.CurrentMirrorEnergy.

  • analog.energy_model.PassiveAnalogMemoryEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of convolution operation.

To see the details of function modeling, please refer:
  • analog.function_model.CurrentMirrorFunc.

  • analog.function_model.PixelwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. One input should be input signal and the other one should be weight signal.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

class camj.analog.component.Voltage2VoltageConv(capacitance_array, vs_array, sf_load_capacitance=1e-12, sf_supply=1.8, sf_output_vs=1, sf_bias_current=5e-06, psca_noise=None, sf_noise=None, sf_enable_prnu=False, sf_prnu_std=0.001)

Bases: object

Voltage-to-Voltage Convolution

This class performs convolution operations in analog domain. The convolution is realized by passive switched capacitor array, the capacitance of each capacitor is served as kernel weight. Source follower is used for signal readout.

Note

Map corresponding WeightInput in software pipeline definition directly to this class for correct functional simulation.

Input/Output domains:
  • input domain: ProcessDomain.VOLTAGE.

  • output domain: ProcessDomain.VOLTAGE.

Parameters:
  • capacitance_array (array, float) – [unit: F] a list of capacitors in passive switched capacitor array.

  • vs_array (array, float) – [unit: V] a list of voltages that corresponds to the voltage swing at each capacitor.

  • sf_load_capacitance (float) – [unit: F] load capacitance.

  • sf_supply (float) – [unit: V] supply voltage.

  • sf_output_vs (float) – [unit: V] voltage swing at the SF’s output node.

  • sf_bias_current (float) – [unit: A] bias current.

  • psca_noise (float) – the stadard deviation of passive switched capacitor array’s read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • sf_noise (float) – the stadard deviation of SF read noise, the default value is None. If users do not specific this parameter, CamJ will calculate the noise STD based on the kTC noise.

  • sf_enable_prnu (bool) – flag to enable SF PRNU. Default value is False.

  • sf_prnu_std (float) – the relative prnu standard deviation respect to SF gain. prnu gain standard deviation = prnu_std * gain. the default value is 0.001.

energy()

Calculate Energy

To see the details of energy modeling, please check out:
  • analog.energy_model.PassiveSwitchedCapacitorArrayEnergy.

  • analog.energy_model.SourceFollowerEnergy.

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

noise(input_signal_list)

Perform functional simulation

This function simulates the functional behavior of convolution operation.

To see the details of function modeling, please refer:
  • analog.function_model.PassiveSwitchedCapacitorArrayFunc.

  • analog.function_model.PixelwiseFunc.

Parameters:

input_signal_list (list) – A list of input signals. One input should be input signal and the other one should be weight signal.

Returns:

The first element in the tuple is the name of this simulated analog component, the second one is a list of simulation results.

Return type:

Simulation result (tuple)

camj.analog.energy_model module
class camj.analog.energy_model.ActiveAnalogMemoryEnergy(sample_capacitance=2e-12, comp_capacitance=2.5e-12, t_sample=1e-06, t_hold=0.01, supply=1.8)

Bases: object

Analog memory with active feedback.

The model is based on the design in [JSSC-2004]. The model consists of a sample capacitor, a compensation capacitor, and an amplifier which holds the stored analog data through feedback.

Parameters:
  • sample_capacitance (float) – [unit: F] sample capacitance.

  • comp_capacitance (float) – [unit: F] compensation capacitance

  • t_sample (float) – [unit: s] sampling time, which mainly consists of the amplifier’s settling time.

  • t_hold (float) – [unit: s] holding time, during which the amplifier is turned on and consumes power relentlessly.

  • supply (float) – [unit: V] supply voltage.

References Link:
energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.ActivePixelSensorEnergy(pd_capacitance, pd_supply, dynamic_sf=False, output_vs=1, num_transistor=4, fd_capacitance=1e-14, num_readout=2, load_capacitance=1e-12, tech_node=130, pitch=4, array_vsize=128)

Bases: PinnedPhotodiodeEnergy

Active pixel sensor (APS).

The model includes photodiode (PD), floating diffusion (FD), source follower (SF), and parasitic capacitance on the SF’s readout wire.

Our APS model supports energy estimation for both 3T-APS and 4T-APS. Users need to define num_transistor to get the correct energy estimation.

Parameters:
  • pd_capacitance (float) – [unit: F] the capacitance of PD.

  • pd_supply (float) – [unit: V] supply voltage of pixel.

  • dynamic_sf (bool) – using dynamic SF or not. In most cases, the in-pixel SF is not dynamic, meaning that it is statically-biased by a constant current. However, some works [JSSC-2021] use dynamic SF to save energy.

  • output_vs (float) – [unit: V] voltage swing at SF’s output node. Typically it is one or two units of threshold voltage smaller than pd_supply, depending on the pixel’s circuit structure.

  • num_transistor (int) – {3 or 4}. It defines using 3T APS or 4T APS.

  • num_readout (int) – {2 or 1}. It defines enabling CDS or not.

  • load_capacitance (float) – [unit: F] load capacitance at the SF’s output node.

  • tech_node (int) – [unit: nm] pixel’s process node.

  • pitch (float) – [unit: um] pixel pitch size (width or height).

  • array_vsize (int) – the vertical size of the entire pixel array. This is used to estimate the parasitic capacitance on the SF’s readout wire.

References Link:
energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.AnalogToDigitalConverterEnergy(supply=1.8, type='SS', fom=1e-13, resolution=8)

Bases: object

Analog-to-digital converter.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • type (str) – ADC type.

  • fom (float) – [unit: J/conversion] ADC’s Figure-of-Merit, expressed by energy per conversion.

  • resolution (int) – ADC resolution.

energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.ColumnAmplifierEnergy(load_capacitance=1e-12, input_capacitance=1e-12, t_sample=2e-06, t_hold=0.01, supply=1.8, gain_cl=2, differential=False)

Bases: object

Switched-capacitor amplifier.

The model is based on Fig. 13.5 in [Book-Razavi]. The model includes an input capacitor, a feedback capacitor, a load capacitor, and an amplifier. This amplifier can be used either as pixel array’s column amplifier or as a general-purpose switched-capacitor amplifier, such as switched-capacitor integrator, switched-capacitor subtractor, and switched-capacitor multiplier.

Parameters:
  • load_capacitance (float) – [unit: F] load capacitance.

  • input_capacitance (float) – [unit: F] input capacitance.

  • t_sample (float) – [unit: s] sampling time, which mainly consists of the amplifier’s settling time.

  • t_hold (float) – [unit: s] holding time, during which the amplifier is turned on and consumes power relentlessly.

  • supply (float) – [unit: V] supply voltage.

  • gain_cl (int) – amplifier’s closed-loop gain. This gain describes the ratio of input_capacitance over feedback capacitance, and determines the amplifier’s bias current in gm/id method.

  • differential (bool) – if using differential-input amplifier or single-input amplifier.

References Link:
  • Book-Razavi: Design of Analog CMOS Integrated Circuits (Second Edition)

energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.ComparatorEnergy(supply=1.8, i_bias=1e-05, t_readout=1e-09)

Bases: object

Dynamic voltage comparator.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • i_bias (float) – [unit: A] bias current of the circuit.

  • t_readout (float) – [unit: s] readout time, during which the comparison is finished.

energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.CurrentMirrorEnergy(supply=1.8, load_capacitance=2e-12, t_readout=1e-06, i_dc=1e-06)

Bases: object

Current mirror.

The model consists of a constant current path and a load capacitor.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • load_capacitance (float) – [unit: F] load capacitance.

  • t_readout (float) – [unit: s] readout time, during which the constant current drives the load capacitance from 0 to VDD.

  • i_dc (float) – [unit: A] the constant current. If i_dc == None, then i_dc is estimated from the other parameters.

energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.DigitalPixelSensorEnergy(pd_capacitance, pd_supply, dynamic_sf, output_vs, num_transistor, fd_capacitance, num_readout, load_capacitance, tech_node, pitch, array_vsize, adc_type='SS', adc_fom=1e-13, adc_reso=8)

Bases: ActivePixelSensorEnergy

Digital pixel sensor (DPS).

The model consists of an APS and an in-pixel ADC.

Parameters:
  • pd_capacitance (float) – [unit: F] the capacitance of PD.

  • pd_supply (float) – [unit: V] supply voltage of pixel.

  • dynamic_sf (bool) – using dynamic SF or not. In most cases, the in-pixel SF is not dynamic, meaning that it is statically-biased by a constant current. However, some works [JSSC-2021] use dynamic SF to save energy.

  • output_vs (float) – [unit: V] voltage swing at SF’s output node. Typically it is one or two units of threshold voltage smaller than pd_supply, depending on the pixel’s circuit structure.

  • num_transistor (int) – {3 or 4}. It defines using 3T APS or 4T APS.

  • num_readout (int) – {2 or 1}. It defines enabling CDS or not.

  • load_capacitance (float) – [unit: F] load capacitance at the SF’s output node.

  • tech_node (int) – [unit: nm] pixel’s process node.

  • pitch (float) – [unit: um] pixel pitch size (width or height).

  • array_vsize (int) – the vertical size of the entire pixel array. This is used to estimate the parasitic capacitance on the SF’s readout wire.

  • adc_type (str) – the actual ADC type. Please check ADC class for more details.

  • adc_fom (float) – [unit: J/conversion] ADC’s Figure-of-Merit, expressed by energy per conversion.

  • adc_resolution (int) – ADC’s resolution.

energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.DigitalToCurrentConverterEnergy(supply=1.8, load_capacitance=2e-12, t_readout=1.6e-05)

Bases: object

Current digital-to-analog converter.

The model consists of a constant current path and a load capacitor.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • load_capacitance (float) – [unit: F] load capacitance.

  • t_readout (float) – [unit: s] readout time, during which the constant current drives the load capacitance from 0 to VDD.

energy()
class camj.analog.energy_model.GeneralCircuitEnergy(supply=1.8, i_dc=1e-05, t_operation=1e-09)

Bases: object

Energy model for general circuits from first principle.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • i_dc (float) – [unit: A] direct current of the circuit.

  • t_operation (float) – [unit: s] operation time, during which the circuit completes its particular operation.

energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.MaximumVoltageEnergy(supply=1.8, t_hold=0.03, t_readout=1e-06, load_capacitance=1e-12)

Bases: object

A circuit that outputs the maximum voltage among the input voltages.

The model is based on the design in [Sensors-2020]. The model consists of a constant current path, a group of common-source amplifiers, and a load capacitor. The number of common-source amplifiers matches the number of input voltages. Note that all common-source amplifiers share one bias current so the bias current doesn’t scale with the number of input voltages.

Parameters:
  • supply (float) – [unit: V] supply voltage.

  • t_hold (float) – [unit: s] holding time, during which the circuit is turned on and consumes power relentlessly.

  • t_readout (float) – [unit: s] readout time, during which the maximum voltage is output.

  • load_capacitance (float) – [unit: F] load capacitance

References Link:
energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.PassiveAnalogMemoryEnergy(sample_capacitance=1e-12, supply=1.8)

Bases: object

Analog memory without active feedback.

The model only contains a sample capacitor. Compared to ActiveAnalogMemory it has higher data leakage rate.

Parameters:
  • sample_capacitance (float) – [unit: F] sample capacitance.

  • supply (float) – [unit: V] supply voltage.

energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.PassiveSwitchedCapacitorArrayEnergy(capacitance_array, vs_array)

Bases: object

Passive switched-capacitor array.

The model consists of a list of capacitors and a list of voltages that corresponds to the voltage swing at each capacitor. The model is used to represent all passive switched-capacitor computational circuits, including charge-redistribution-based MAC operation.

Parameters:
  • capacitance_array (array, float) – [unit: F] a list of capacitors.

  • vs_array (array, float) – [unit: V] a list of voltages that corresponds to the voltage swing at each capacitor.

energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.PinnedPhotodiodeEnergy(pd_capacitance=1e-13, pd_supply=3.3)

Bases: object

Pinned photodiode (PD).

The model only contains the dynamic energy of the PD’s internal capacitance.

Parameters:
  • pd_capacitance (float) – [unit: F] the capacitance of PD.

  • pd_supply (float) – [unit: V] supply voltage of pixel.

energy()
class camj.analog.energy_model.PulseWidthModulationPixelEnergy(pd_capacitance, pd_supply, array_vsize, ramp_capacitance=1e-12, gate_capacitance=1e-14, num_readout=1)

Bases: PinnedPhotodiodeEnergy

Pulse-Width-Modulation (PWM) Pixel.

The model is based on the design in [JSSC-2020] and [ISSCC-2022]. The model consists of a photodiode (PD), a ramp signal generator, and a comparator. The comparator output toggles when the ramp signal is smaller than the pixel voltage at PD.

Parameters:
  • pd_capacitance (float) – [unit: F] PD capacitance.

  • pd_supply (float) – [unit: V] PD voltage supply.

  • array_vsize (int) – the vertical size of the entire pixel array. This is used to estimate the parasitic capacitance on the SF’s readout wire.

  • ramp_capacitance (float) – [unit: F] capacitance of ramp signal generator.

  • gate_capacitance (float) – [unit: F] the gate capacitance of readout transistor.

  • num_readout (int) – number of read from pixel.

References Link:
energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

class camj.analog.energy_model.SourceFollowerEnergy(load_capacitance=1e-12, supply=1.8, output_vs=1, bias_current=5e-06)

Bases: object

Source follower (SF) with constant current bias.

This model is applicable to not only the simplest single-transistor source follower but also flipped-voltage-follower (FVF).

Parameters:
  • load_capacitance (float) – [unit: F] load capacitance.

  • supply (float) – [unit: V] supply voltage.

  • output_vs (float) – [unit: V] voltage swing at the SF’s output node.

  • bias_current (float) – [unit: A] bias current.

energy()

Calculate Energy

Returns:

the energy consumption of this analog compoenent in unit of J.

Return type:

float

camj.analog.energy_utils module
camj.analog.energy_utils.get_delay(current_stage_output_impedance, next_stage_input_impedance, current_stage_output_capacitance, next_stage_input_capacitance)

Compute analog component delay.

This model assumes the delay of an analog component is 5 times of the RC constant at the analog component’s output node. The total impedance (R) is the sum of the output impedance of this analog component and the input impedance of the following analog component. The total capacitance (C) is the sum of the output capacitance of this analog component and the input capacitance of the following analog component. 5 times of the RC constant represents the latency required by charging the total capacitance to 99% of the nodal voltage swing.

Parameters:
  • current_stage_output_impedance (float) – [unit: Ohm] output impedance of the current analog component.

  • next_stage_input_impedance (float) – [unit: Ohm] output impedance of the next analog component.

  • current_stage_output_capacitance (float) – [unit: F] output capacitance of the current analog component.

  • next_stage_input_capacitance (float) – [unit: F] output capacitance of the next analog component.

Returns:

delay [unit: s]

Return type:

float

camj.analog.energy_utils.get_nominal_supply(tech_node)

Compute nominal supply voltage under different process nodes.

Parameters:

tech_node (int) – [unit: nm] pixel’s process node.

Returns:

supply voltage [unit: V]

Return type:

float

camj.analog.energy_utils.get_pixel_parasitic(array_v, tech_node, pitch)

Compute column parasitic capacitance (Farad per column) on the pixel’s output node.

This parasitic capacitance usually dominates the load capacitance if the pixel’s follow-up circuitry (e.g., readout or processing) is placed at the column level. Based on [JSSC-2019] where the parasitic capacitance is 9fF/pixel under 130nm process node and 5um pixel pitch, this model assumes the parasitic capacitance scales with process node, pixel pitch, and pixel array’s vertical size (i.e., the number of pixels in one column).

References Link:
Parameters:
  • array_v (int) – vertical size of the pixel array.

  • tech_node (int) – [unit: nm] pixel’s process node.

  • pitch (float) – [unit: um] pixel’s pitch size.

Returns:

parasitic capacitance [unit: F]

Return type:

float

camj.analog.energy_utils.gm_id(load_capacitance, gain, bandwidth, differential=True, inversion_level='moderate')

Compute transconductance (gm) and drain current (id) of linear amplifiers.

The method is based on [Book-Jespers].

References Link:
Parameters:
  • load_capacitance (float) – [unit: F] amplifier’s load capacitance.

  • gain (float) – amplifier’s open-loop gain.

  • bandwidth (float) – [unit: Hz] amplifier’s bandwidth.

  • differential (bool) – if using differential-input amplifier or single-input amplifier.

  • inversion_level (str) – [‘weak’, ‘moderate’, or ‘strong’] the inversion level of the transistors in the amplifier.

Returns:

drain current (id) [unit: A], transconductance (gm) [unit: S]

Return type:

float, float

camj.analog.energy_utils.parallel_impedance(impedance_array)

Compute parallel impedance of an array of input impedance.

Parameters:

impedance_array (array, float) – [unit: Ohm] input impedance array.

Returns:

parallel impedance [unit: Ohm]

Return type:

float

camj.analog.function_model module

Func Model Module

This module includes all basic noise model for CamJ functional simulation.

Note

CamJ models the output of each component by applying a gain and a read noise to its input. Analytically, the model performs output = input * gain + read_noise. This formula implies that we only consider two main types of hardware non-idealities: gain variation (or, PRNU) and read noise (zero-mean Gaussian).

Note

Because nearly all of our implemented components are linear circuits which have linear transfer functions, we can use “gain” and “gain variation” as the proxy to describe the component’s functional behavior.

The proxy is also applicable to quantization circuits (ADCs and comparators), which are non-linear circuits but have uniformly-stepped transfer functions. We describe these transfer functions by applying a “gain” and a “gain variation” to their linear frontiers but ignoring the non-linear effect at each quantization step (i.e., DNL, INL).

The proxy is also applicable to those non-linear circuits whose transfer functions are non-uniform but can be approximated in piece-wise linear manner. For example, the circuit that performs quantize(log(x1/x2)) in [JSSC-2019] can be described by a set of “gain”s and “gain variation”s and each pair of “gain” and “gain variation” describes a linear segment of the transfer function.

However, the proxy is not applicable to the non-linear circuits which do not belong to either of the above, such as the circuit that generates the maximum output voltage from a group of input voltages in [Sensors-2020]. For those circuits, we only add the read_noise and do not apply the gain.

Note

Note that the proxy doesn’t always reflect the physical reality of the circuit, meaning that the “gain” may not be an explicit parameter in the circuit and the “gain variation” is not analytically derived from the circuit parameters. However, the proxy trades low level circuit details off for the model’s simplicity.

References Link:
class camj.analog.function_model.AbsoluteDifferenceFunc(name: str, gain=1.0, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

Func model for absolute difference subtractor.

This noise model simulates the noises happened in absolute difference operation. Two inputs will first compute the absolute difference, and then, apply gain and noises.

Mathematical Expression:

out = gain * (Abs(in1 - in2)) + Norm(noise)

Parameters:
  • name (str) – the name of the noise.

  • gain (float) – the gain applied in absolute difference, the default value is 1.0.

  • noise (float) – the read noise standard deviation during readout in the unit of voltage (V).

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – relative PRNU standard deviation respect to gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

simulate_output(input_signal1, input_signal2)

apply gain and noise to input signal

Parameters:
  • input_signal1 – the first input signal to ABS component in a 2D/3D tensor.

  • input_signal2 – the second input signal to ABS component in a 2D/3D tensor.

Returns:

signal values after ABS component.

Return type:

2D/3D tensor

class camj.analog.function_model.AnalogToDigitalConverterFunc(name: str, adc_noise: float, max_val: float, resolution: int)

Bases: object

Func model for ADC.

This model only considers a coarse-scale ADC noise, which we model in normal distribution. We don’t consider non-linear noise errors which can be calibrated during manufacture.

Mathematical Expression:

output_signal = Quantization(input_signal + Norm(adc_noise))

Parameters:
  • name (str) – the name of the noise.

  • adc_noise (float) – the overall noise on ADC.

  • max_val (float) – the maximum value in ADC input. We assume the input voltage range is from [0, max_val]

  • resolution (int) – the resolution of the output value in digital domain. 8 means the maximum value in digital value is 8^2 - 1 == 255 bit.

simulate_output(input_signal)

apply gain and noise to input signal

Parameters:

input_signal – input signal to ADC in unit of voltage in a 2D/3D tensor.

Returns:

digital values after quantization of ADC.

Return type:

2D/3D tensor

class camj.analog.function_model.ColumnwiseFunc(name, gain=1.0, noise=None, enable_prnu=False, prnu_std=0.001, enable_offset=False, pixel_offset_voltage=0.1, col_offset_voltage=0.05)

Bases: object

A general interface for column-wise function.

A general interface for any noise source that applies to each column, such as column amplifier. Assumption for this class is that it has a row-like struction such as column amplifier, and this class can capture the different properties in column-wise structure. One example is the column amplifier has PRNU column-wisely.

Mathematical Expression:

output = gain * in + Norm(noise)

Parameters:
  • name (str) – the name of the noise.

  • gain (float) – the average gain. Default value is 1.0.

  • noise (float) – the standard deviation of read noise. Default value is None.

  • ennable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative PRNU standard deviation respect to gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001.

  • enable_offset (bool) – flag to enable adding offset voltage. Default value is False.

  • pixel_offset_voltage – pixel offset voltage in unit of volt (V). Default value is 0.1.

  • col_offset_voltage – column-wise offset voltage in unit of volt (V). Default value is 0.05.

simulate_output(input_signal)

apply gain and noise to input signal

Parameters:

input_signal – the input signals.

Returns:

signal values after processed by column-wise noise component.

Return type:

2D/3D tensor

class camj.analog.function_model.ComparatorFunc(name, gain=1.0, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

Func model for comparator.

The general assumption for comparator component is that its gain is 1, and its noise follows zero-mean normal distribution.

Mathematical Expression:

output = GreaterThanOne(Diff(input_signal1 - input_signal2) * gain + Norm(noise))

Parameters:
  • name (str) – the name of the noise.

  • gain (float) – the average gain. Default value is 1.0.

  • noise (float) – the standard deviation of read noise. Default value is None.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative PRNU standard deviation respect to gain. PRNU gain standard deviation = prnu_std * gain. The default value is 0.001

simulate_output(input_signal1, input_signal2)

apply gain and noise to input signals.

Parameters:
  • input_signal1 – the first input signal.

  • input_signal2 – the second input signal.

Returns:

signal values in input_signal1 that are greater that corresponding values in input_signal2. Otherwise, output zeros.

Return type:

2D/3D tensor

class camj.analog.function_model.CorrelatedDoubleSamplingFunc(name: str, gain=1, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

Func model for correlated double sampling circuit.

General assumption of CDS is gain is 1, read noise follows zero-mean normal distribution.

Mathematical Expression:

output = (input_signal - reset_signal) * gain + Norm(noise)

Parameters:
  • name (str) – the name of the noise.

  • gain (float) – the average gain. Default value is 1.0.

  • noise (float) – the standard deviation of read noise. Default value is None.

  • enable_prnu – flag to enable PRNU. Default value is False.

  • prnu_std – the relative prnu standard deviation respect to gain. prnu gain standard deviation = prnu_std * gain. The default value is 0.001.

simulate_output(input_signal, reset_noise)

apply gain and noise to input signal

Parameters:
  • input_signal – the input signals.

  • reset_noise – reset noise signal from floating diffusion.

Returns:

signal values after processed by CDS.

Return type:

2D/3D tensor

class camj.analog.function_model.CurrentMirrorFunc(name: str, gain=1, noise=None, enable_compute=False, enable_prnu=False, prnu_std=0.001)

Bases: object

Func model for current mirror.

Current mirror has two possible outputs to model two functionalities of current mirror. 1. output charge: in this case, the input current will multiply with integrated time and output the charge which is current*time. 2. output current: in this case, there is no computation, just perform gain amplification.

Mathematical Expression:
  1. out = gain * (input_signal * weight_signal) + Norm(noise)

  2. out = gain * input_signal + Norm(noise).

Parameters:
  • name (str) – the name of the noise.

  • gain (float) – the average gain. Default value is 1.0.

  • noise (float) – the standard deviation of read noise. Default value is None.

  • enable_compute (bool) – flag to enable compute and output charges. Default value is False.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative prnu standard deviation respect to gain. prnu gain standard deviation = prnu_std * gain. The default value is 0.001.

simulate_output(input_signal, weight_signal=None)

apply gain and noise to input signal

Parameters:
  • input_signal – the input signal to current mirror in a 2D/3D tensor.

  • weight_signal – the weight signal to current mirror in a 2D/3D tensor.

Returns:

signal values after current mirror.

Return type:

2D/3D tensor

class camj.analog.function_model.FloatingDiffusionFunc(name: str, gain=1.0, noise=None, enable_cds=False, enable_prnu=False, prnu_std=0.001)

Bases: object

Func model for floating diffusion.

General assumption of the noise model is that the noise follows a zero-mean Gaussian distribution. Users need to provide the average noise error (sigma value). Gain is generally slightly less than 1, here, the default value is 1.0.

To enable CDS and PRNU, just set enable flag to be True. If enable_cds is True, simulate_output function will return two values, one is the input + reset noise, and the other is the reset noise.

Mathematical Expression:

out = (gain * in) + Norm(noise)

Parameters:
  • name (str) – the name of the noise.

  • gain (float) – the average gain. Default value is 1.0.

  • noise (float) – the standard deviation of read noise. Default value is None.

  • enable_cds (bool) – flag to enable CDS (correlated double sampling). Default value is False.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative prnu standard deviation respect to gain. prnu gain standard deviation = prnu_std * gain. the default value is 0.001.

simulate_output(input_signal)

apply gain and noise to input signal

Parameters:

input_signal – the input signals.

Returns:

signal values after processed by floating diffusion. If enable_cds is True, then the second return value is reset noise.

Return type:

2D/3D tensor

class camj.analog.function_model.MaximumVoltageFunc(name, noise=None)

Bases: object

Func model for max voltage comparator.

Maximum voltage produce element-wise maximum for a list of input signals. It is used for operations like MaxPool.

Mathematical Expression:

out = Max(in_1, …, in_N) + Norm(noise)

Parameters:
  • name (str) – the name of the noise.

  • noise (float) – the standard deviation of read noise. Default value is None.

simulate_output(input_signal_list: list)

apply gain and noise to input signal

Parameters:

input_signal_list – a list of input signals to maximum voltage.

Returns:

maximum signal after maximum voltage.

Return type:

2D/3D tensor

class camj.analog.function_model.PassiveSwitchedCapacitorArrayFunc(name, num_capacitor, noise=None)

Bases: object

Func model for passive switched capacitor array.

Passive switched capacitor array can realize many mathematical operations such as average, addition/subtraction, and multiplication.

Mathematical Expression:

out = Average(in_1, …, in_N) + Norm(noise)

Parameters:
  • name (str) – the name of the noise.

  • num_capacitor (int) – number of capacitor in capacitor array.

  • noise (float) – the standard deviation of read noise. Default value is None.

simulate_output(input_signal_list: list)

apply gain and noise to input signal

Parameters:

input_signal_list – a list of input signals to passive switched capacitor array.

Returns:

averaged signal value after passive switched capacitor array.

Return type:

2D/3D tensor

class camj.analog.function_model.PhotodiodeFunc(name: str, dark_current_noise: float, enable_dcnu=False, dcnu_std=0.001)

Bases: object

Func model for photediode.

This model simulates the behavior of photodiode, including shot noise, dark current and dark current non-uniformity.

Mathematical Expression:

output_signal = Poisson(x_in) + Norm(DCNU * dark_current)

Parameters:
  • name (str) – the name of this noise.

  • dark_current_noise (float) – average dark current noise in unit of electrons (e-).

  • enable_dcnu (bool) – flag to enable dark current non-uniformity, the default value is False.

  • dcnu_std (float) – dcnu standard deviation percentage. it is relative number respect to dark_current_noise, the dcnu standard deviation is, dcnu_std * dark_current_noise, the default value is 0.001.

simulate_output(input_signal)

apply gain and noise to input signal

Parameters:

input_signal – input signal to photodiode in unit of photons in a 2D tensor.

Returns:

signal out of photodiode in unit of voltage.

Return type:

2D tensor

class camj.analog.function_model.PixelwiseFunc(name, gain=1.0, noise=None, enable_prnu=False, prnu_std=0.001)

Bases: object

A general interface for pixel-wise function.

A general interface for any noise source resided inside each pixel, including floating diffusion, source follower, etc. General assumption of the noise source is that the noise follows a “zero-mean” Gaussian distribution. Users need to provide mean noise (sigma value).

Mathematical Expression:

out = (gain * in) + Norm(noise)

Parameters:
  • name (str) – the name of the noise.

  • gain (float) – the average gain. Default value is 1.0.

  • noise (float) – the standard deviation of read noise. Default value is None.

  • enable_prnu (bool) – flag to enable PRNU. Default value is False.

  • prnu_std (float) – the relative prnu standard deviation respect to gain. prnu gain standard deviation = prnu_std * gain. the default value is 0.001.

simulate_output(input_signal)

apply gain and noise to input signal

Parameters:

input_signal – the input signals.

Returns:

signal values after processed by analog component.

Return type:

2D/3D tensor

camj.analog.function_utils module
camj.analog.function_utils.default_functional_simulation(functional_pipeline_list, input_list)
camj.analog.function_utils.process_signal_stage(stage, input_signals)
camj.analog.infra module
class camj.analog.infra.AnalogArray(name: str, layer: int, num_input: list, num_output: tuple)

Bases: object

The High-level interface to define analog structures. In CamJ, each analog array is defined as a 2D structure. In this structure, it contains multiple AnalogComponent s. Additionally, each AnalogArray has a regular input/output rate.

Parameters:
  • name (str) – the name of this analog array.

  • layer (int) – the location of this analog array. Please see general.enum.ProcessorLocation.

  • num_input (list) – a list of input 3D shapes in (H, W, C) format. Each input defines the number of input signals needed per cycle in order to obtain the output define in num_output.

  • num_output (tuple) – output signals per cycle in 3D shape (H, W, C).

add_component(component: AnalogComponent, component_size: tuple)

Add components to its component list

This function adds the analog components that construct this analog array. Multiple calls of this function will add multiple components to this analog array.

Parameters:
  • component (AnalogComponent) – the analog component that constructs this analog array.

  • component_size (tuple) – the number of compoenent needs for this analog array. Component_size needs in a 3D shape (H, W, C).

Returns:

None

add_input_array(analog_array)

Add producer of this analog array

Define the producer of this analog array. If multiple producers are needed, call this function multiple times.

Parameters:

analog_array (AnalogArray) – the producer of this analog array.

Returns:

None

add_output_array(analog_array)

Add consumer of this analog array

Define the consumer of this analog array. If multiple consumers are needed, call this function multiple times.

Parameters:

analog_array (AnalogArray) – the consumer of this analog array.

Returns:

None

energy()

Energy consumption

Calculate the energy needed to generate the given output shape.

Returns:

energy consumption in J.

Return type:

Energy (float)

noise(input_signal_list: list)

Function and Noise Simulation

This function will iterate each component in the component list and perform functional and noise simulation for each component.

Parameters:

input_signal_list (list) – a list of input signal to this analog array.

Returns:

the signal simulation result after each analog component. Each item in this list is a tuple in (component_name, output_signal_list) format.

Return type:

Simulation result (list)

class camj.analog.infra.AnalogComponent(name: str, input_domain: list, output_domain: int, component_list=None, num_input: list = [(1, 1, 1)], num_output: tuple = (1, 1, 1))

Bases: object

Analog Component

This is the low-level interface to define an analog component. This class serves as a container that consists of mulitple analog components from analog.component module.

Parameters:
  • name (str) – the name of this analog component.

  • input_domain (list) – a list contains input domains. Each input domain defines the domain of each input signal. This input_domain list should match num_input. Domains are defined in general.enum.ProcessDomain.

  • output_domain (enum) – the domain of the output signal of this analog component. Domains are defined in general.enum.ProcessDomain.

  • component_list (list) – a list of analog components that construct this AnalogComponent instance.

  • num_input (list) – a list of tuple, each tuple represents an input shape. Each input shape represents the number of input signals needed to obtain the output signal (num_output) per cycle. Each input shape is a 3D tuple in (H, W, C) format.

  • num_output (tuple) – the number of output signals per cycle in this output shape.

Examples

To create a mega-pixel component with 2x2 binning capability.

>>> AnalogComponent(
    name = "BiningPixel",
    input_domain =[ProcessDomain.OPTICAL],
    output_domain = ProcessDomain.VOLTAGE,
    component_list = [(ActivePixelSensor(...), 4)],
    num_input = [],
    num_output = (1, 1, 1)
)

Here, ProcessDomain.OPTICAL shows pixel takes photons as input and converts to ProcessDomain.VOLTAGE as shown in output_domain. component_list shows how this analog component is implemented. In this case, it is ActivePixelSensor. Each Pixel needs 4 ActivePixelSensor to achieve 2x2 binning.

energy()

Calculate the energy consumption of this analog compoenent.

This function calculates the overall energy consumption for this analog component per cycle. The overall energy equals to the energy consumption of each component in component_list times the count of each component.

Returns:

Energy (float) in pJ.

noise(input_signal_list)

Noise Simulation

The noise function performs the functional/noise simulation based on the functional model of each component in component_list. The input signal will pass through each component’s functional model one-by-one.

Parameters:

input_signal_list (list) – a list of input signals in a form of numpy array.

Returns:

Simulated output signal after each analog component (dict)

camj.analog.utils module
camj.analog.utils.analog_energy_simulation(analog_arrays, sw_desc, mapping)

Launch Energy Simulation in Analog Domain

The harness function for analog energy simulation.

Parameters:
  • analog_arrays – a list of analog arrays.

  • sw_desc – software pipeline description.

  • mapping – software-hardware mapping.

Returns:

energy numbers from simulation, stores in a dictionary.

Return type:

Energy Result (dict)

camj.analog.utils.check_analog_connect_consistency(analog_arrays: list)

Check analog connection correctness

This function checks the correctness of two connected analog components. It checks if the output domain of any producer analog component matches the input domain of the consumer analog component.

Parameters:

analog_arrays (list) – a list of analog arrays.

Returns:

None

camj.analog.utils.compute_total_energy(analog_arrays, analog_sw_desc, mapping)

Compute Energy in Analog Domain

This function calculates the overall energy consumption of simulated CIS in analog domain.

Parameters:
  • analog_arrays – a list of analog arrays.

  • sw_desc – software pipeline description corresponding to analog domain.

  • mapping – software-hardware mapping.

Returns:

energy numbers from simulation, stores in a dictionary.

Return type:

Energy Result (dict)

camj.digital package

camj.digital.compute module

Digital Compute Library

This module defines the digital compute interface. It contains three types of compute units which can be used in digital simulation.

class camj.digital.compute.ADC(name: str, output_pixels_per_cycle: tuple, location, energy_per_pixel=600)

Bases: object

ADC compute unit

ADC is special in digital domain because it serves as an interface between digital and analog domain. Here, to perform digital simulation, we assume the computation starts with ADC. Users need to define ADC to launch digital simulation.

Parameters:
  • name (str) – name of this class.

  • output_pixels_per_cycle (tuple) – the output pixel rate per cycle. It should be in (H, W, C) format.

  • location – defines the location of the ADC. see general.enum for more details.

  • energy_per_pixel – the energy consumption generated in digital domain per pixel.

compute_energy()

Total Compute Energy

This function calculates the total compute energy for this compute instance. CamJ simulator calls this function after the simulation is finished.

Mathematically Expression:

Total Compute Energy = Energy per Pixel * Output Pixels

Returns:

Compute energy number in pJ (int)

get_total_read()

Calculate number of reads before output the given number of pixels defined by users.

Returns:

Number of Reads (int)

get_total_write()

Calculate number of writes to output the given number of pixels defined by users.

Returns:

Number of Write (int)

set_input_buffer(input_buffer)

Set Input Buffer

This function sets the input buffer for this compute unit. Each compute can have one input buffer, call this function multiple times will overwrite the old input buffer.

Parameters:

input_buffer – input buffer object for this compute instance.

Returns:

None

set_output_buffer(output_buffer)

Set Output Buffer

This function sets the output buffer for this compute unit. Each compute can have one output buffer, call this function multiple times will overwrite the old output buffer.

Parameters:

output_buffer – output buffer object for this compute instance.

Returns:

None

class camj.digital.compute.ComputeUnit(name: str, location: int, input_pixels_per_cycle: list, output_pixels_per_cycle: list, energy_per_cycle: float, num_of_stages: int)

Bases: object

Generic Compute Unit Interface

This is the generic Compute Unit interface for digital domain. It can be used to model any digital compute hardware that performs stencil operations.

Parameters:
  • name (str) – name of this class.

  • location – defines the location of the ADC. see general.enum for more details.

  • output_pixels_per_cycle (tuple) – the input pixel rate per cycle in order to perform computation. It should be a list of tuple. Each tuple should be in (H, W, C) format.

  • output_pixels_per_cycle – the output pixel rate per cycle. It should be in (H, W, C) format.

  • energy_per_cycle (float) – the average energy per cycle in unit of pJ.

  • num_of_stages (int) – number of stage of this compute unit in the pipeline.

Examples

To instantiate a 3x3x1 convolution operation with 3-stage pipeline. Each cycle, this compute unit takes 1x3x1 inputs and output 1x1x1. When fully pipelined, this compute unit consumes 9 pJ (9 operations, each takes 1 pJ).

>>> ComputeUnit(
    name = "ConvUnit",
    location = ProcessorLocation.COMPUTE_LAYER,
    input_pixels_per_cycle = [(1, 3, 1)],
    output_pixels_per_cycle = (1, 1, 1),
    energy_per_cycle = 9,   # pJ
    num_of_stages = 3,      # 3-stage pipeline
)
compute_energy()

Total Compute Energy

This function calculates the total compute energy for this compute instance. CamJ simulator calls this function after the simulation is finished.

Mathematically Expression:

Total Compute Energy = Energy per cycle * Compute Cycles

Returns:

Compute energy number in pJ (int)

get_total_read()

Calculate number of reads before output the given number of pixels defined by users.

Returns:

Number of Reads (int)

get_total_write()

Calculate number of writes to output the given number of pixels defined by users.

Returns:

Number of Write (int)

set_input_buffer(input_buffer)

Set Input Buffer

This function sets the input buffer for this compute unit. Each compute can have one input buffer, call this function multiple times will overwrite the old input buffer.

Parameters:

input_buffer – input buffer object for this compute instance.

Returns:

None

set_output_buffer(output_buffer)

Set Output Buffer

This function sets the output buffer for this compute unit. Each compute can have one output buffer, call this function multiple times will overwrite the old output buffer.

Parameters:

output_buffer – output buffer object for this compute instance.

Returns:

None

class camj.digital.compute.SystolicArray(name, location, size_dimension, energy_per_cycle)

Bases: object

This class emulate a classic architecture design, systolic array.

Parameters:
  • name (str) – name of this class.

  • location – defines the location of the ADC. see general.enum.ProcessorLocation for more details.

  • size_dimension (tuple) – the dimension of the systolic array in a format of (H, W).

  • energy_per_cycle (float) – the average energy per cycle in unit of pJ.

Example

To instantiate a 16x16 systolic array

>>> SystolicArray(
    name = "SystolicArray",
    location = ProcessorLocation.COMPUTE_LAYER,
    size_dimension = (16, 16),
    energy_per_cycle = 0.5 * 16 *16, # 0.5 pJ per MAC op
)
compute_energy()

Total Compute Energy

This function calculates the total compute energy for this compute instance. CamJ simulator calls this function after the simulation is finished.

Mathematically Expression:

Total Compute Energy = Energy per cycle * Compute Cycles

Returns:

Compute energy number in pJ (int)

get_total_read()

Calculate number of reads before output the given number of pixels defined by users.

Returns:

Number of Reads (int)

get_total_write()

Calculate number of writes to output the given number of pixels defined by users.

Returns:

Number of Write (int)

set_input_buffer(input_buffer)

Set Input Buffer

This function sets the input buffer for this compute unit. Each compute can have one input buffer, call this function multiple times will overwrite the old input buffer.

Parameters:

input_buffer – input buffer object for this compute instance.

Returns:

None

set_output_buffer(output_buffer)

Set Output Buffer

This function sets the output buffer for this compute unit. Each compute can have one output buffer, call this function multiple times will overwrite the old output buffer.

Parameters:

output_buffer – output buffer object for this compute instance.

Returns:

None

camj.digital.memory module
class camj.digital.memory.DigitalStorage(name: str, access_units: list, location=ProcessorLocation.INVALID)

Bases: object

Base class for digital storage class

This is the base class for digital storage memory.

IMPORTANT: Don’t use this class directly, use the derived class instead!

A very important attribute in DigitalStorage class is reserved_buffer. Reserved_buffer is used to find the consumer-producer connections between two hardware compute units. It is important to find whether the data dependency is ready or not.

class camj.digital.memory.DoubleBuffer(name: str, size: tuple, write_energy_per_word: int, read_energy_per_word: int, pixels_per_write_word: int, pixels_per_read_word: int, location: int)

Bases: DigitalStorage

This class emulates the hardware behavior of double buffer.

Parameters:
  • name (str) – name of this memory structure.

  • size (tuple) – the size of double buffer in a shape of (A, B, C). A is number of SRAM, B is the number of bank, C is the size of each bank.

  • location – the location of this memory unit.

  • write_energy_per_word (float) – energy cost for each write

  • read_energy_per_word (float) – energy cost for each read

  • pixels_per_write_word (int) – the length of each write. Unit in pixel

  • pixels_per_read_word (int) – the length of one read. Unit is pixel

total_memory_access_energy()

Calculate the total memory access energy

Returns:

the memory access energy in unit of pJ.

Return type:

Memory Access Energy (flaot)

class camj.digital.memory.FIFO(name: str, size: int, location: int, write_energy_per_word: int, read_energy_per_word: int, pixels_per_write_word: int, pixels_per_read_word: int)

Bases: DigitalStorage

FIFO Buffer

This class emulates the hardware behavior of FIFO. Each FIFO will have one read port and one write port.

Parameters:
  • name (str) – name of this memory structure.

  • size (tuple) – the size of FIFO in unit of pixel.

  • location – the location of this memory unit.

  • write_energy_per_word (float) – energy cost for each write

  • read_energy_per_word (float) – energy cost for each read

  • pixels_per_write_word (int) – the length of each write. Unit in pixel

  • pixels_per_read_word (int) – the length of one read. Unit is pixel

total_memory_access_energy()

Calculate the total memory access energy

Returns:

the memory access energy in unit of pJ.

Return type:

Memory Access Energy (flaot)

class camj.digital.memory.LineBuffer(name: str, size: tuple, location: int, write_energy_per_word: int, read_energy_per_word: int, pixels_per_write_word: int, pixels_per_read_word: int)

Bases: DigitalStorage

Line Buffer, extended from DigitalStorage base class

This class follows a specific memory access pattern. The size of this class defines the number of read and write per cycle. For instance, a size of (3, 128) line buffer can be read 3 pixels per cycle and can be written 1 pixel per cycle.

However, this class doesn’t check if per-cycle read and write surpass its capacity. This class does check if the number of read and write requests by consumer/producer can be fulfilled or not.

Parameters:
  • name (str) – name of this memory structure.

  • size (tuple) – the size of the line buffer in a shape of (A, B). A is the number of rows in this line buffer, B is the size of each row in unit of pixel.

  • location – the location of this memory unit.

  • write_energy_per_word (float) – energy cost for each write

  • read_energy_per_word (float) – energy cost for each read

  • pixels_per_write_word (int) – the length of each write. Unit in pixel

  • pixels_per_read_word (int) – the length of one read. Unit is pixel

total_memory_access_energy()

Calculate the total memory access energy

Returns:

the memory access energy in unit of pJ.

Return type:

Memory Access Energy (flaot)

camj.general package

camj.general.enum module

This file documents the global configuration enums.

class camj.general.enum.ProcessDomain(value)

Bases: Enum

An enumeration.

CHARGE = 4
CURRENT = 2
DIGITAL = 1
OPTICAL = 6
TIME = 5
VOLTAGE = 3
class camj.general.enum.ProcessorLocation(value)

Bases: Enum

An enumeration.

COMPUTE_LAYER = 2
INVALID = 0
OFF_CHIP = 3
SENSOR_LAYER = 1
camj.general.launch module

camj.sw package

camj.sw.interface module
class camj.sw.interface.DNNProcessStage(name: str, op_type: str, ifmap_size: list, kernel_size: list, stride: int, padding=True)

Bases: object

A Class to Define DNN Processing Stage

Parameters:
  • name (str) – the name of this software stage.

  • op_type (str) – define the DNN operation type. Now we support Conv2D, DWConv2 and FC.

  • ifmap_size (list) – define the input shape of this processing stage. The input size should be in a list of int. The order should be [H, W, C_in].

  • kernel_size (list) – define the operation kernel shape of this processing stage. The kernel size should be a list of int. The order should be [H, W, C_in, C_out].

  • stride (int) – define the processing stride of this DNN operation.

  • padding (bool) – define whether applying paddings to DNN operation.

Examples

To define convolution with input of 128x128x3 and kernel shape of 3x3x3x16.

>>> DNNProcessStage(
    name = "DNN-Conv",
    op_type = "Conv2D",
    ifmap_size = [128, 128, 3],
    kernel_size = [3, 3, 3, 16],
    stride = 2,
    padding = True
)
flatten()

Set flatten flag when operating from convolution to FC layer.

set_input_stage(stage)

Specify the input stage for this DNNProcessStage.

Specify the input stage for this DNNProcessStage. This function can be called multiple times to this DNNProcessStage has multiple producers.

Parameters:

stage – input stage of this ProcessStage instance.

set_output_stage(stage)

Specify the output stage for this DNNProcessStage.

Specify the output stage for this DNNProcessStage. This function can be called multiple times to this DNNProcessStage has multiple consumers.

Parameters:

stage – output stage of this DNNProcessStage instance.

class camj.sw.interface.PixelInput(name, size)

Bases: object

Pixel Input Interface

This class is used to define pixel input stage in software pipeline.

Parameters:
  • name (str) – define a name for this PixelInput class.

  • size (tuple) – define the input size of this pixel input, the format is (H, W, C).

Examples

To initialized a PixelInput instance.

>>> PixelInput("Input", (128, 128, 1))

This will initialize a 128x128x1 pixel input.

set_output_stage(stage)

Specify the output stage for this PixelInput.

Specify the output stage for this PixelInput. This function can be called multiple times to this PixelInput has multiple consumers.

Parameters:

stage – output stage of this PixelInput instance.

Examples

>>> pixel_stage.set_output_stage(resize_stage)
class camj.sw.interface.ProcessStage(name: str, input_size: list, kernel_size: list, num_kernels: list, stride: list, padding: list)

Bases: object

A Class to Define General Processing Stages in Software

This class is used to define a general processing stages in software pipeline. The software stage needs to fulfill one requirement: this processing stage is a stencil operation.

Parameters:
  • name (str) – the name of this software stage.

  • input_size (list) – define the input shape of this processing stage. The input size should be in a list of tuples.

  • kernel_size (list) – define the operation kernel shape of this processing stage. The kernel size should be a list of tuple. Each input can only has one kernel shape operating on it. See examples below.

  • num_kernels (list) – define the number of kernels for each kernel in kernel_size list. This parameter should be a list of int.

  • stride (list) – define the processing stride for each kernel. This parameter should be a list of tuple.

  • padding (list) – define whether applying paddings to each kernel operation. This parameter should be a list of int.

Examples

To define a convolution with two (3x3x1) weights, stride of 2 and no padding.

>>> ProcessStage(
    name = "Conv",
    input_size = [(128, 128, 1)],
    kernel_size = [(3, 3, 1)],
    num_kernels = [2],
    stride = [(2, 2, 1)],
    padding = [False]
)

To define a stencil operation with two inputs, 128x128x1 and 64x64x1, each input is operated with different kernel sizes 2x2x1 and 1x1x1, assuming no padding.

>>> ProcessStage(
    name = "Conv",
    input_size = [(128, 128, 1), (64, 64, 1)],
    kernel_size = [(2, 2, 1), (1, 1, 1)],
    num_kernels = [1, 1],
    stride = [(2, 2, 1), (1, 1, 1)],
    padding = [False, False]
)

Here, each kernel operates on its own input. The first 128x128x1 input operates with 2x2x1 kernel and the second 64x64x1 input operates with 1x1x1 kernel. Make sure both inputs result in the same output, otherwise, an error will occur.

set_input_stage(stage)

Specify the input stage for this ProcessStage.

Specify the input stage for this ProcessStage. This function can be called multiple times to this ProcessStage has multiple producers.

Parameters:

stage – input stage of this ProcessStage instance.

set_output_stage(stage)

Specify the output stage for this ProcessStage.

Specify the output stage for this ProcessStage. This function can be called multiple times to this ProcessStage has multiple consumers.

Parameters:

stage – output stage of this ProcessStage instance.

class camj.sw.interface.WeightInput(name, size)

Bases: object

Weight Input Interface

This class is used to define some input stages other than pixel inputs. For instance, users can use this stage to define a weight input in convolution.

Parameters:
  • name (str) – define a name for this PixelInput class.

  • size (tuple) – define the input size of this pixel input, the format is (H, W, C).

Examples

To initialized a WeightInput instance.

>>> WeightInput("Input", (3, 3, 1))

This will initialize a 3x3x1 weight input which can be used in a convolution.

set_output_stage(stage)

Specify the output stage for this WeightInput.

Specify the output stage for this PixelInput. This function can be called multiple times to this WeightInput has multiple consumers.

Parameters:

stage – output stage of this WeightInput instance.

Examples

>>> weight_input.set_output_stage(conv_stage)
camj.sw.utils module
camj.sw.utils.build_sw_graph(sw_stage_list: list)

Build Software Graph

This function complete the software graph after user defines the software pipeline. In software pipeline definition, it only asks users to define the output stages for each software stage, Here, this function completes the graph by finding input stages for each software stage.

Parameters:

sw_stage_list (list) – a list of user-defined software stages.