4.5 CCL Configurator
The Configurable Custom Logic (CCL) is a programmable logic peripheral which can be connected to the device pins, to events, or to other internal peripherals. This allows the user to eliminate logic gates for simple glue logic functions on the PCB and logic operations can be performed using Programmable Lookup Tables (LUT) and sequential logic without CPU intervention.
Each LUT consists of three individually configurable inputs and a truth table, in addition to the optional filter, synchronizer, and edge detector. Inputs can either be I/O pins, internal feedback, peripherals, or events from the Event System. Each LUT can generate an output as a user programmable logic expression from the three inputs. Two adjacent LUTs are connected to a sequential logic block, forming a unit. The optional sequential logic can be enabled for complex waveform generation such as JK flip-flop, RS latch, D latch, or gated D flip-flop. The output can be routed to I/O pins, peripherals, event system, or as feedback to the corresponding unit.
CCL Configurator supports end-to-end configuration of the CCL module graphically.
How to use CCL Configurator
The following application demonstrates the use of internal peripherals and I/O pins as inputs to the CCL. The CCL uses the LUTs and sequential modules to generate the output based on the inputs. The example application below detects motion in low-light condition and provides the output signal to a pin. The signal will be available in that pin until a switch is pressed to turn off the signal.
- Create a new project using ATtiny817.
-
Click on Add software component and add the Digital
Glue Logic driver.
Once the Digital Glue Logic driver has been added, a tab named CCL appears on the left side of the screen.
- Click again on Add software component and add AC and Event System drivers.
- Configure the Analog Comparator module to provide the desired output (light or dark) based on its inputs. Use the Dashboard view to configure the AC module.
- Configure the Event System (EVSYS) module to provide the desired output (motion detected) based on its inputs.
-
Go to the CCL tab and enable the first LUT (LUT 0).
Drag and drop AC0 OUT input source to the first Input
(A) of LUT0. Then drag and drop LUT0 event 0 to the
second input (B) of LUT0. Leave the third input disconnected.
Truth table rows and columns are updated based on the selected inputs and invalid rows are disabled in the figure below.
-
We can configure the truth table by one of the following methods:
- Selecting one of the predefined logic gate types (AND, NAND, OR, NOR, XOR, XNOR)
-
Entering an expression
AND is represented using ‘*’. If an operator is not specified, AND (*) is assumed
OR is represented using ‘+’
XOR is represented using ‘^’
NOT is represented using ‘!’
NAND can be created by using the expression - !(a*b). If an operator is not specified, NAND !(*) is assumed
NOR can be created by using the expression - !(a+b)
XNOR can be created by using the expression - !(a^b)
Complex combinational logic can be created using an expression that involves the operators listed above. Brackets can be used to control the precedence of operators by grouping the part of an expression. E.g. - a+((b^c)*(!c))
-
Entering Value of truth logic
The VALUE column in the truth table will be enabled to set individual bits.
"Custom" should be elected in gate type for using option 7.2 and 7.3. The Truth table will automatically be updated based on the option selected.
Based on the example that is being considered here, "LUTO output" represents "motion in low light condition". In order to configure that, select the AND gate from the drop-down box as shown in the figure below. Note that the truth table is updated to reflect the AND gate. - Configure the PC3 pin as Digital input using the PINMUX view. Assume that the appropriate external signal (e.g., from a push button) is connected to the PC3 pin.
-
Select and enable the second LUT (LUT1) and drag and drop
PC3 to the first Input (A) of "LUT1".
The signal in PC3 should be made available "LUT1 output" to give to sequential circuit. Select "Custom" in Gate type Drop-down list and select value option under Truth Logic. Toggle the values in the truth table grid or directly enter the value in the Value-field as shown in the figure below.
-
Select the JK flip-flop. “LUT0 output” is hardwired to the J input and
“LUT1 output” is hardwired to the K input.
The Configurator will be updated automatically to show these connections.
Redirect the JK flip-flop output to pin PB4.
A logic high will be available in PB4 whenever motion is detected under the low-light condition and the signal will be held available in PB4 until a switch is pressed (PC3).