# Evolving Multi-Output Digital Circuits Using Multi-Genome Grammatical Evolution

^{1}

^{2}

^{*}

*Algorithms*Editorial Board Members)

## Abstract

**:**

## 1. Introduction

- We present a multi-genome implementation of GE better suited for tackling multi-output problems;
- We adapt genetic operators, initialisation routine, and mapping mechanism and implement a wrapping operator well-suited for MG-GE;
- We introduce custom grammar syntax rules and a cyclic dependency-checking algorithm that facilitates the evolution of inter-output dependencies;
- We investigate the performance of MG-GE with and without using our custom grammar syntax rules on multi-output combinational circuit problems.

## 2. Background

#### 2.1. Grammatical Evolution

#### 2.2. Multi-Output Problems

#### 2.3. Hardware Description Languages

#### 2.4. Related Work

## 3. Proposed Approach: Multi-Genome GE

#### 3.1. Problem Description

#### 3.2. Problem Formulation

#### 3.3. Multi-Genome GE

#### 3.4. Grammar Design

Listing 1. A sample program with cyclic dependency. |

`output_1`and

`output_2`) as shown in Figure 3. Also, note that the exact order in which output rules are defined for each corresponding output variable must be followed when defining an output variable rule as observed in Figure 3. For implementation purposes, extra attributes (corresponding output rule) are used to differentiate these outputs (e.g.,

`output_1`and

`output_2`), which are terminals from other terminals in the grammar during initialisation and mapping processes. An output variable rule is how evolution evolves dependencies that may potentially exist between outputs. During the initialisation and mapping process of each output rule (in other words, when an output variable is being modelled), the cyclic dependency checker algorithm ensures only choices of output variables that do not cause cyclic dependency can be chosen whenever an output variable rule non-terminal is encountered. The cyclic dependency checker algorithm is described in Section 3.7.

#### 3.5. Initialisation

#### 3.6. Multi-Genome Mapping

`mapped_output_rules`. Otherwise, it continues the mapping process consuming codons from the first genome (lines 13–18 in Algorithm 2). Lines 21–55 remain the same as standard GE mapping where symbols belonging to selected rule production are placed on a stack for subsequent derivation steps. Wrapping events are checked and applied accordingly.

Algorithm 1: Multi-Genome GE Mapper |

Algorithm 2: Output Rule Sub-Mapping |

#### 3.7. Cyclic Dependency Checking Algorithm

`UpdateGraphMatrix`is a recursive function, which has the inputs

`M`, a square matrix with shape $n\times n$, and

`pos`, the respective position to be updated. This function assigns 0 to the position

`pos`in the matrix

`M`, but this assignment triggers subsequent updates in its consequence. Subsequent calls of this function are recursive to ensure the necessary updates are made to prevent cyclic dependencies between output variables. For example, if output variable

`a`depends on output variable

`b`, then output variable

`b`cannot depend on output variable

`a`. Subsequently, any output variable which depends on output variable

`b`cannot depend on output variable

`a`.

Algorithm 3: Cyclic Dependency Checking |

`FillMatrix`initialises an empty matrix M with shape $n\times n$. Since the variables cannot depend on themselves, the positions $i,j$, where $i=j$, are initialised with 0. The input

`dependencies`is a list with the respective dependencies to be filled in the matrix. In the next step, the positions regarding each dependency are filled with 1 (if possible), and the updates in consequence of that are made by calling the function

`UpdateGraphMatrix`.

#### 3.8. Perfect Wrapping

#### 3.9. Selection

#### 3.10. Well-formed Crossover and Mutation

#### 3.11. Substitution Operator

`output_1`has completely been solved. Recall the best-evolved solution is a combination of the best-performing genome per output variable. Given that

`output_1`is dependent on

`output_2`and

`output_2`is, in turn, dependent on

`output_3`, if we extract

`output_1`without recursively substituting output variables with their corresponding expressions to obtain an expression devoid of output variables,

`output_1`will no longer be regarded as solved, as

`output_2`and

`output_3`are very likely to be different in the created best individual. Applying the substitution operator, we will obtain the solved expression devoid of any output variables as shown in Listing 3. Hence, the importance of the cyclic dependency checking algorithm is to ensure the substitution operator does not get stuck in a non-terminating loop as a result of cyclic dependency existing between output variables.

Listing 2. An individual that completely evolves the solution to output_ 1 (50 out of 50 total cases). |

Listing 3. Final perfect output_ 1 statement after applying the substitution operator. |

`output_1`variable before it is extracted. As can be observed from Listing 3, output variable

`output_1`used output variable

`output_2`twice which were replaced by the same expression at the end of the substitution operation. That is, in cases where an output variable uses another output variable multiple times will result in an increase in the size of the phenotype. In the case of digital circuits, such a scenario will increase the total number of gates required to realise the gate-level design of the circuit. However, this is a post-processing issue and is not addressed in this work.

#### 3.12. Evolutionary Cycle

## 4. Experiments

#### 4.1. Ripple Carry Adder

#### 4.2. Hamming Code Encoder

#### 4.3. Grammars

Listing 4. N-bit + N-bit Adder Grammar. |

Listing 5. Hamming Code (N,M) Encoder. |

#### 4.4. Experimental Parameters

## 5. Results and Discussions

#### 5.1. Limitations and Drawbacks of The Proposed Approach

## 6. Conclusions and Future Work

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Conflicts of Interest

## Appendix A

Listing A1. 5-bit + 5-bit Adder Grammar with Output Variable Sharing. Output variable sharing is enabled by making an output variable rule non-terminal a production of $\langle \mathrm{expr-*}\rangle $ rules as highlighted in the grammar. |

Listing A2. 5-bit + 5-bit Adder Grammar without Output Variable Sharing. |

## References

- Kalganova, T. Bidirectional incremental evolution in extrinsic evolvable hardware. In Proceedings of the Second NASA/DoD Workshop on Evolvable Hardware, Palo Alto, CA, USA, 15 July 2000; pp. 65–74. [Google Scholar] [CrossRef] [Green Version]
- Stomeo, E.; Kalganova, T.; Lambert, C. Generalized Disjunction Decomposition for the Evolution of Programmable Logic Array Structures. In Proceedings of the First NASA/ESA Conference on Adaptive Hardware and Systems (AHS’06), Istanbul, Turkey, 15–18 June 2006; pp. 179–185. [Google Scholar] [CrossRef] [Green Version]
- Hodan, D.; Mrazek, V.; Vasicek, Z. Semantically-Oriented Mutation Operator in Cartesian Genetic Programming for Evolutionary Circuit Design. In Proceedings of the 2020 Genetic and Evolutionary Computation Conference, GECCO ’20, Cancún, Mexico, 8–12 July 2020; Association for Computing Machinery: New York, NY, USA, 2020; pp. 940–948. [Google Scholar] [CrossRef]
- Tetteh, M.K.; Mota Dias, D.; Ryan, C. Evolution of Complex Combinational Logic Circuits Using Grammatical Evolution with SystemVerilog. In Proceedings of the Genetic Programming, Lille, France, 10–14 July 2021; Hu, T., Lourenço, N., Medvet, E., Eds.; Springer International Publishing: Cham, Switzerland, 2021; pp. 146–161. [Google Scholar]
- O’Neill, M.; Ryan, C. Grammatical evolution. IEEE Trans. Evol. Comput.
**2001**, 5, 349–358. [Google Scholar] [CrossRef] [Green Version] - Rothlauf, F.; Oetzel, M. On the Locality of Grammatical Evolution. In Proceedings of the EuroGP, Budapest, Hungary, 10–12 April 2006. [Google Scholar]
- Castle, T.; Johnson, C.G. Positional Effect of Crossover and Mutation in Grammatical Evolution. In Proceedings of the Genetic Programming, Istanbul, Turkey, 7–9 April 2010; Esparcia-Alcázar, A.I., Ekárt, A., Silva, S., Dignum, S., Uyar, A.Ş., Eds.; Springer: Berlin/Heidelberg, Germany, 2010; pp. 26–37. [Google Scholar]
- Nicolau, M.; Agapitos, A. Understanding Grammatical Evolution: Grammar Design. In Handbook of Grammatical Evolution; Springer International Publishing: Cham, Switzerland, 2018; pp. 23–53. [Google Scholar] [CrossRef] [Green Version]
- O’Neill, M.; Ryan, C.; Keijzer, M.; Cattolico, M. Crossover in Grammatical Evolution. Genet. Program. Evolvable Mach.
**2003**, 4, 67–93. [Google Scholar] [CrossRef] - Zhen, X.; Yu, M.; He, X.; Li, S. Multi-Target Regression via Robust Low-Rank Learning. IEEE Trans. Pattern Anal. Mach. Intell.
**2018**, 40, 497–504. [Google Scholar] [CrossRef] [PubMed] - Shaker, N.; Nicolau, M.; Yannakakis, G.N.; Togelius, J.; O’Neill, M. Evolving levels for Super Mario Bros using grammatical evolution. In Proceedings of the 2012 IEEE Conference on Computational Intelligence and Games (CIG), Granada, Spain, 11–14 September 2012; pp. 304–311. [Google Scholar] [CrossRef] [Green Version]
- O’Neill, M.; McDermott, J.; Swafford, J.M.; Byrne, J.; Hemberg, E.; Brabazon, A.; Shotton, E.; McNally, C.; Hemberg, M. Evolutionary design using grammatical evolution and shape grammars: Designing a shelter. Int. J. Des. Eng.
**2010**, 3, 4–24. [Google Scholar] [CrossRef] [Green Version] - Grammatical Evolution. In Biologically Inspired Algorithms for Financial Modelling; Springer: Berlin/Heidelberg, Germany, 2006; pp. 73–88. [CrossRef]
- de la Puente, A.O.; Alfonso, R.S.; Moreno, M.A. Automatic Composition of Music by Means of Grammatical Evolution. SIGAPL APL Quote Quad
**2002**, 32, 148–155. [Google Scholar] [CrossRef] [Green Version] - Mariani, T.; Guizzo, G.; Vergilio, S.R.; Pozo, A.T. Grammatical Evolution for the Multi-Objective Integration and Test Order Problem. In Proceedings of the Genetic and Evolutionary Computation Conference 2016, GECCO ’16, Denver, CO, USA, 20–24 July 2016; Association for Computing Machinery: New York, NY, USA, 2016; pp. 1069–1076. [Google Scholar] [CrossRef]
- Osojnik, A.; Panov, P.; Džeroski, S. Multi-label classification via multi-target regression on data streams. Mach. Learn.
**2017**, 106, 745–770. [Google Scholar] [CrossRef] [Green Version] - Borchani, H.; Varando, G.; Bielza, C.; Larrañaga, P. A survey on multi-output regression. WIREs Data Min. Knowl. Discov.
**2015**, 5, 216–233. [Google Scholar] [CrossRef] [Green Version] - Harris, S.; Harris, D. Digital Design and Computer Architecture: ARM Edition, 1st ed.; Morgan Kaufmann Publishers Inc.: San Francisco, CA, USA, 2015. [Google Scholar]
- LaMeres, B.J. Introduction to Logic Circuits & Logic Design with Verilog; Chapter Verilog (Part 1); Springer International Publishing: Berlin/Heidelberg, Germany, 2019; p. 157. [Google Scholar] [CrossRef]
- Sutherland, S. RTL Modeling with SystemVerilog For Simulation and Synthesis: Using SystemVerilog for ASIC and FPGA Design; Sutherland HDL, Inc.: Tualatin, OR, USA, 2017. [Google Scholar]
- Slowik, A.; Białko, M. Evolutionary Design and Optimization of Combinational Digital Circuits with Respect to Transistor Count. Bull. Pol. Acad. Sci. Tech. Sci.
**2006**, 54, 4. [Google Scholar] - Walker, J.A.; Völk, K.; Smith, S.L.; Miller, J.F. Parallel Evolution Using Multi-Chromosome Cartesian Genetic Programming. Genet. Program. Evolvable Mach.
**2009**, 10, 417–445. [Google Scholar] [CrossRef] - Coimbra, V.; Lamar, M.V. Design and Optimization of Digital Circuits by Artificial Evolution Using Hybrid Multi Chromosome Cartesian Genetic Programming. In Proceedings of the Applied Reconfigurable Computing, Mangaratiba, Brazil, 22–24 March 2016; Lecture Notes in Computer Science. Bonato, V., Bouganis, C., Gorgon, M., Eds.; Springer International Publishing: Berlin/Heidelberg, Germany, 2016; pp. 195–206. [Google Scholar] [CrossRef]
- Baine, N. A Simple Multi-Chromosome Genetic Algorithm Optimization of a Proportional-plus-Derivative Fuzzy Logic Controller. In Proceedings of the NAFIPS 2008—2008 Annual Meeting of the North American Fuzzy Information Processing Society, New York, NY, USA, 19–22 May 2008; pp. 1–5. [Google Scholar] [CrossRef]
- Reyes, O.; Moyano, J.; Luna, J.; Ventura, S. A gene expression programming method for multi-target regression. In Proceedings of the International Conference on learning and optimization algorithms: Theory and applications, LOPAL ’18, Rabat, Morocco, 2–5 May 2018; ACM: New York, NY, USA, 2018; pp. 1–6. [Google Scholar]
- Ryan, C.; Azad, R.M.A. Sensible Initialisation in Grammatical Evolution. In Proceedings of the GECCO 2003: Bird of a Feather Workshops, Genetic and Evolutionary Computation Conference, Chicago, IL, USA, 12–16 July 2003; Barry, A.M., Ed.; AAAI: Chigaco, IL, USA, 2003; pp. 142–145. [Google Scholar]
- Miller, F.P.; Vandome, A.F.; McBrewster, J. Hamming Code: Parity Bit, Two- out- of- Five Code, Hamming(7,4), Reed-Muller Code, Reed-Solomon Error Correction, Turbo Code, Low- Density Parity-Check Code, Telecommunication, Linear Code; Alpha Press: Lagos, Nigeria, 2009. [Google Scholar]
- Hernandez, J.G.; Lalejini, A.; Dolson, E.; Ofria, C. Random Subsampling Improves Performance in Lexicase Selection. In Proceedings of the Genetic and Evolutionary Computation Conference Companion, GECCO ’19, Prague, Czech Republic, 13–17 July 2019; Association for Computing Machinery: New York, NY, USA, 2019; pp. 2028–2031. [Google Scholar] [CrossRef]

**Figure 1.**Grammatical Evolution Mapping Mechanism. The numbers enclosed in parenthesis after each production do not form part of the grammar but instead are shown for ease of interpretation and represent the production choice value.

**Figure 6.**Mean average best across 30 independent runs for Hamming Code (7,4) using MG-GE and standard GE.

**Figure 7.**Mean average best across 30 independent runs for Hamming Code (15,11) using MG-GE and standard GE.

**Figure 8.**Mean average best across 30 independent runs for 5-bit + 5-bit Adder using MG-GE and standard GE.

**Figure 9.**Mean average best across 30 independent runs for 10-bit + 10-bit Adder using MG-GE and standard GE.

**Table 1.**Evolutionary Run Parameters. In bold are the default population sizes used for the actual experiments.

Parameter | Value | |
---|---|---|

Initialization | Sensible Initialization | |

Selection | Down-sampled Lexicase Selection | |

Crossover Rate | 0.8 | |

Mutation Rate | 0.01 | |

Replacement Rate | 0.05 | |

Number of Runs | 30 | |

Generations | 100 | |

Mutation | All-events Well-formed Crossover | |

Crossover | All-events Well-formed Crossover | |

Wrapping Operator | Perfect Wrapping | |

Population Size | 1000 | All other problems |

2000 | 10-bit + 10-bit Adder | |

Termination Condition | When mean, minimum and maximum fitness equals the maximum fitness or generation number equal specified generation number |

Problem | Standard GE | MG-GE | ||
---|---|---|---|---|

Output Variable Sharing | No-Output Variable Sharing | Output Variable Sharing | No-Output Variable Sharing | |

5-bit + 5-bit Adder | 0 | 0 | 16 | 0 |

10-bit + 10-bit Adder | 0 | 0 | 21 | 0 |

Hamming Code (7,4) Encoder | 18 | 24 | 30 | 30 |

Hamming Code (15,11) Encoder | 0 | 0 | 0 | 27 |

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |

© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Tetteh, M.; de Lima, A.; McEllin, J.; Murphy, A.; Dias, D.M.; Ryan, C.
Evolving Multi-Output Digital Circuits Using Multi-Genome Grammatical Evolution. *Algorithms* **2023**, *16*, 365.
https://doi.org/10.3390/a16080365

**AMA Style**

Tetteh M, de Lima A, McEllin J, Murphy A, Dias DM, Ryan C.
Evolving Multi-Output Digital Circuits Using Multi-Genome Grammatical Evolution. *Algorithms*. 2023; 16(8):365.
https://doi.org/10.3390/a16080365

**Chicago/Turabian Style**

Tetteh, Michael, Allan de Lima, Jack McEllin, Aidan Murphy, Douglas Mota Dias, and Conor Ryan.
2023. "Evolving Multi-Output Digital Circuits Using Multi-Genome Grammatical Evolution" *Algorithms* 16, no. 8: 365.
https://doi.org/10.3390/a16080365