Python-Based Circuit Design for Fundamental Building Blocks of Spiking Neural Network
Abstract
:1. Introduction
- We propose a method for designing hardware SNNs, which uses Python to describe the neuron and memristor models and then automatically generates HDL code to build neuron and memristor circuits using MSDSL. The most basic SNN model was constructed based on this method and imported into the FPGA for prototype verification.
- We demonstrate with experimental comparisons that the IZ and LIF neuron circuits are suitable for use as neurons in SNNs, and that the EG memristor model is more suitable as synapses in SNNs, as it better satisfies the STDP learning rule.
- We evaluated the resources and power consumption required for the generated neural model to be implemented on FPGA and compared it with other related studies. We found that the proposed method required fewer resources to implement the SNN model on FPGA.
2. Materials and Methods
2.1. Electronic System Level Design Methodology
2.2. Neuron Circuit Modeling
Listing 1. LIF neuron model in Python. | |
1 | v = m.add_analog_output(‘v’,init = −2) |
2 | flag = m.add_digital_state(‘flag’,init = 1,width = 1,signed = False) |
3 | m.set_this_cycle(flag,v < v_threshold) |
4 | m.set_next_cycle(v, (v + dt*(1/Tm)*((El − v) + R*I))*flag − 2*(~flag),clk = m.clk, rst = m.rst) |
2.3. Memristor Circuits Modeling
Listing 2. EG memristor model in Python. | |
# setting various critical conditions in eg memristor model | |
1 | m.set_this_cycle(flag1,v < 0) m.set_this_cycle(flag2,v < -Vn) |
2 | m.set_this_cycle(flag3,v > Vp) m.set_this_cycle(flag4,x < Xp) |
3 | m.set_this_cycle(flag5,x > 1-Xn) |
# setting constants in eg memristor model | |
4 | ean = exp(an*(Xn − 1)) eap = exp(ap*Xp) |
5 | evn = exp(Vn) evp = exp(Vp) |
# use the lookup table function to complete the modeling of exponential function | |
6 | func1 = lambda v:np.exp(v) |
7 | ev1 = m.set_from_sync_func(‘ev1’, f1, v, clk = m.clk, rst = m.rst) |
8 | func2 = lambda v:1/np.exp(v) |
9 | ev2 = m.set_from_sync_func(‘ev2’, f2, v, clk = m.clk, rst = m.rst) |
10 | func3 = lambda v:np.exp(0.05*v) |
11 | ev3 = m.set_from_sync_func(‘ev3’, f3, v, clk = m.clk, rst = m.rst) |
12 | func4 = lambda v:1/np.exp(0.05*v) |
13 | ev4 = m.set_from_sync_func(‘ev4’, f4, v, clk = m.clk, rst = m.rst) |
14 | func5 = lambda x:np.exp(x) |
15 | ex1 = m.set_from_sync_func(‘ex1’, f5, x, clk = m.clk, rst = m.rst) |
16 | func6 = lambda x:1/np.exp(x) |
17 | ex2 = m.set_from_sync_func(‘ex2’, f6, x, clk = m.clk, rst = m.rst) |
# modeling of Equation (3) | |
18 | m.set_this_cycle(i, (a1*x*0.5*(ev3-ev4))*(~flag1) + (a2*x*0.5*(ev3-ev4))*flag1) |
# modeling of Equation (4) | |
19 | m.set_next_cycle(x,x + dt*((Ap*(ev1-evp)*(flag3) + (-An)*(ev2-evn)*(flag2))* |
(ex2*eap*((Xp-x)/(1-Xp) + 1)*(~flag1)*(~flag4) + 1*(~flag1)*(flag4) + | |
(ex1*ex1*ex1*ex1*ex1)*ean*(x/(1-Xn))* | |
(flag1)*(~flag5) + 1*(flag1)*(flag5))),clk = m.clk, rst = m.rst) |
2.4. STDP (Spike-Timing-Dependent Plasticity)
3. Results
3.1. Simulation Results of Neuron HDL Models
3.2. Simulation Results of Memristor HDL Models
3.3. Simulation Results of STDP
3.4. FPGA Experiments
4. Discussion
4.1. Compared with the SNN Software Simulator Based on Python
4.2. Compared with Circuit Simulation
4.3. Future Direction
- Establish SNN coprocessor automatic generation, resource evaluation, and software and hardware co-simulation driven by SNN basic primitives (similar to the primitives of CNN model) to provide methods and platforms for the agile design of SNN chips;
- Build a large SNN network with FPGA array, map the typical intelligent recognition algorithm to the large SNN network, and evaluate the calculation effect.
5. Conclusions
Supplementary Materials
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Akopyan, F.; Sawada, J.; Cassidy, A.S.; Alvarez-Icaza, R.; Arthur, J.V.; Merolla, P.; Imam, N.; Nakamura, Y.; Datta, P.; Nam, G.-J.; et al. TrueNorth: Design and Tool Flow of a 65 mW 1 Million Neuron Programmable Neurosynaptic Chip. IEEE Trans. Comput.-Aided Des. Integr. Circuits Syst. 2015, 34, 1537–1557. [Google Scholar] [CrossRef]
- Meier, K. Special report: Can we copy the brain?—The brain as computer. IEEE Spectr. 2017, 54, 28–33. [Google Scholar] [CrossRef]
- Kheradpisheh, S.R.; Ganjtabesh, M.; Masquelier, T. Bio-inspired unsupervised learning of visual features leads to robust invariant object recognition. Neurocomputing 2016, 205, 382–392. [Google Scholar] [CrossRef]
- Davies, M.; Srinivasa, N.; Lin, T.H.; Chinya, G.; Cao, Y.; Choday, S.H.; Dimou, G.; Joshi, P.; Imam, N.; Jain, S.; et al. Loihi: A Neuromorphic Manycore Processor with On-Chip Learning. IEEE Micro 2018, 38, 82–99. [Google Scholar] [CrossRef]
- Shen, J.; Ma, D.; Gu, Z.; Zhang, M.; Zhu, X.; Xu, X.; Xu, Q.; Shen, Y.; Pan, G. Darwin: A neuromorphic hardware co-processor based on Spiking Neural Networks. Sci. China Inf. Sci. 2016, 59, 1–5. [Google Scholar] [CrossRef]
- Benjamin, B.V.; Gao, P.; McQuinn, E.; Choudhary, S.; Chandrasekaran, A.R.; Bussat, J.M.; Alvarez-Icaza, R.; Arthur, J.V.; Merolla, P.A.; Boahen, K. Neurogrid: A Mixed-Analog-Digital Multichip System for Large-Scale Neural Simulations. Proc. IEEE 2014, 102, 699–716. [Google Scholar] [CrossRef]
- Qiao, N.; Mostafa, H.; Corradi, F.; Osswald, M.; Stefanini, F.; Sumislawska, D.; Indiveri, G. A reconfigurable on-line learning spiking neuromorphic processor comprising 256 neurons and 128K synapses. Front. Neurosci. 2015, 9, 141. [Google Scholar] [CrossRef]
- Pei, J.; Deng, L.; Song, S.; Zhao, M.; Zhang, Y.; Wu, S.; Wang, G.; Zou, Z.; Wu, Z.; He, W.; et al. Towards artificial general intelligence with hybrid Tianjic chip architecture. Nature 2019, 572, 106–111. [Google Scholar] [CrossRef]
- Feng, J. Is the integrate-and-fire model good enough?—A review. Neural Netw. 2001, 14, 955–975. [Google Scholar] [CrossRef]
- Elhamdaoui, M.; Rziga, F.O.; Mbarek, K.; Besbes, K. Spike-time-dependent plasticity rule in memristor models for circuit design. J. Comput. Electron. 2022, 21, 1038–1047. [Google Scholar] [CrossRef]
- Bi, G.-Q.; Poo, M.-M. Synaptic Modifications in Cultured Hippocampal Neurons: Dependence on Spike Timing, Synaptic Strength, and Postsynaptic Cell Type. J. Neurosci. 1998, 18, 10464. [Google Scholar] [CrossRef] [PubMed]
- Maestro-Izquierdo, M.; Gonzalez, M.B.; Campabadal, F. Mimicking the spike-timing dependent plasticity in HfO2-based memristors at multiple time scales. Microelectron. Eng. 2019, 215, 111014. [Google Scholar] [CrossRef]
- Yamazaki, K.; Vo-Ho, V.-K.; Bulsara, D.; Le, N. Spiking Neural Networks and Their Applications: A Review. Brain Sci. 2022, 12, 863. [Google Scholar] [CrossRef] [PubMed]
- Huang, W.; Xia, X.; Zhu, C.; Steichen, P.; Quan, W.; Mao, W.; Yang, J.; Chu, L.; Li, X. Memristive Artificial Synapses for Neuromorphic Computing. Nano-Micro Lett. 2021, 13, 85. [Google Scholar] [CrossRef]
- Hajiabadi, Z.; Shalchian, M. Behavioral Modeling and STDP Learning Characteristics of a Memristive Synapse. In Proceedings of the 2020 28th Iranian Conference on Electrical Engineering (ICEE), Tabriz, Iran, 4–6 August 2020; pp. 1–5. [Google Scholar]
- Zhao, L.; Hong, Q.; Wang, X. Novel designs of spiking neuron circuit and STDP learning circuit based on memristor. Neurocomputing 2018, 314, 207–214. [Google Scholar] [CrossRef]
- Bensimon, M.; Greenberg, S.; Ben-Shimol, Y.; Haiut, M. A New SCTN Digital Low Power Spiking Neuron. IEEE Trans. Circuits Syst. II Express Briefs 2021, 68, 2937–2941. [Google Scholar] [CrossRef]
- Abderrahmane, N.; Lemaire, E.; Miramond, B. Design Space Exploration of Hardware Spiking Neurons for Embedded Artificial Intelligence. Neural Netw. 2020, 121, 366–386. [Google Scholar] [CrossRef]
- Ntinas, V.; Vourkas, I.; Abusleme, A.; Sirakoulis, G.C.; Rubio, A. Experimental Study of Artificial Neural Networks Using a Digital Memristor Simulator. IEEE Trans. Neural Netw. Learn. Syst. 2018, 29, 5098–5110. [Google Scholar] [CrossRef] [PubMed]
- Baran, A.Y.; Korkmaz, N.; Öztürk, I.; Kılıç, R. On addressing the similarities between STDP concept and synaptic/memristive coupled neurons by realizing of the memristive synapse based HR neurons. Eng. Sci. Technol. Int. J. 2022, 32, 101062. [Google Scholar] [CrossRef]
- Dahasert, N.; Öztürk, İ.; Kiliç, R. Experimental realizations of the HR neuron model with programmable hardware and synchronization applications. Nonlinear Dyn. 2012, 70, 2343–2358. [Google Scholar] [CrossRef]
- Burkitt, A.N. A Review of the Integrate-and-fire Neuron Model: I. Homogeneous Synaptic Input. Biol. Cybern. 2006, 95, 1–19. [Google Scholar] [CrossRef] [PubMed]
- Izhikevich, E.M. Simple model of spiking neurons. IEEE Trans. Neural Netw. 2003, 14, 1569–1572. [Google Scholar] [CrossRef] [PubMed]
- Strukov, D.B.; Snider, G.S.; Stewart, D.R.; Williams, R.S. The missing memristor found. Nature 2008, 453, 80–83. [Google Scholar] [CrossRef] [PubMed]
- Yakopcic, C.; Taha, T.M.; Subramanyam, G.; Pino, R.E. Generalized Memristive Device SPICE Model and its Application in Circuit Design. IEEE Trans. Comput. -Aided Des. Integr. Circuits Syst. 2013, 32, 1201–1214. [Google Scholar] [CrossRef]
- Zhang, Y.; Wang, Z.; Zhu, J.; Yang, Y.; Rao, M.; Song, W.; Zhuo, Y.; Zhang, X.; Cui, M.; Shen, L.; et al. Brain-inspired computing with memristors: Challenges in devices, circuits, and systems. Appl. Phys. Rev. 2020, 7, 011308. [Google Scholar] [CrossRef]
- Morris, R.G.M. DO Hebb: The Organization of Behavior, Wiley: New York; 1949. Brain Res. Bull. 1999, 50, 437. [Google Scholar] [CrossRef]
- Herbst, S.; Rutsch, G.; Ecker, W.; Horowitz, M. An Open-Source Framework for FPGA Emulation of Analog/Mixed-Signal Integrated Circuit Designs. IEEE Trans. Comput.-Aided Des. Integr. Circuits Syst. 2022, 41, 2223–2236. [Google Scholar] [CrossRef]
- Decaluwe, J. MyHDL: A python-based hardware description language. Linux J. 2004, 2004, 5. [Google Scholar]
- Nic30/hdlConvertor: Fast Verilog/VHDL Parser Preprocessor and Code Generator for C++/Python Based on ANTL4. Available online: https://github.com/Nic30/hdlConvertor (accessed on 25 April 2023).
- Takamaeda-Yamazaki, S. Pyverilog: A Python-Based Hardware Design Processing Toolkit for Verilog HDL. In Proceedings of the International Workshop on Applied Reconfigurable Computing, Bochum, Germany, 13–17 April 2015. [Google Scholar]
- Mizusaki, B.E.P.; Li, S.S.Y.; Costa, R.P.; Sjöström, P.J. Pre- and postsynaptically expressed spike-timing-dependent plasticity contribute differentially to neuronal learning. PLoS Comput. Biol. 2022, 18, e1009409. [Google Scholar] [CrossRef]
- Stimberg, M.; Brette, R.; Goodman, D.F.M. Brian 2, an intuitive and efficient neural simulator. eLife 2019, 8, e47314. [Google Scholar] [CrossRef]
- Li, Y.; Zhong, Y.; Xu, L.; Zhang, J.; Xu, X.; Sun, H.; Miao, X. Ultrafast Synaptic Events in a Chalcogenide Memristor. Sci. Rep. 2013, 3, 1619. [Google Scholar] [CrossRef] [PubMed]
- Heidarpur, M.; Ahmadi, A.; Ahmadi, M.; Azghadi, M.R. CORDIC-SNN: On-FPGA STDP Learning With Izhikevich Neurons. IEEE Trans. Circuits Syst. I: Regul. Pap. 2019, 66, 2651–2661. [Google Scholar] [CrossRef]
- Soleimani, H.; Drakakise, E.M. An Efficient and Reconfigurable Synchronous Neuron Model. IEEE Trans. Circuits Syst. II Express Briefs 2018, 65, 91–95. [Google Scholar] [CrossRef]
- Grassia, F.; Levi, T.; Kohno, T.; Saïghi, S. Silicon neuron: Digital hardware implementation of the quartic model. Artif. Life Robot. 2014, 19, 215–219. [Google Scholar] [CrossRef]
- Hazan, H.; Saunders, D.J.; Khan, H.; Patel, D.; Sanghavi, D.T.; Siegelmann, H.T.; Kozma, R. BindsNET: A Machine Learning-Oriented Spiking Neural Networks Library in Python. Front. Neuroinformatics 2018, 12, 89. [Google Scholar] [CrossRef]
- Elhamdaoui, M.; Rziga, F.O.; Mbarek, K.; Besbes, K. The EGM Model and the Winner-Takes-All (WTA) Mechanism for a Memristor-Based Neural Network. Arab. J. Sci. Eng. 2022, 48, 6175–6183. [Google Scholar] [CrossRef]
- Liu, Y.; Chen, Y.; Ye, W.; Gui, Y. FPGA-NHAP: A General FPGA-Based Neuromorphic Hardware Acceleration Platform with High Speed and Low Power. IEEE Trans. Circuits Syst. I Regul. Pap. 2022, 69, 2553–2566. [Google Scholar] [CrossRef]
FPGA Resource Utilization | Slice LUT’s | Slice Registers | On-Chip Power | Device |
---|---|---|---|---|
IZ_EG_IZ | 541 | 107 | 186 mW | Xilinx xc7a200tfbg484-2 |
LIF_EG_LIF | 448 | 86 | 196 mW | Xilinx xc7a200tfbg484-2 |
FPGA Resource Utilization | Slice LUT’s | Slice Registers | Max Speed (MHz) | DSPs | Device |
---|---|---|---|---|---|
MSDSL | 175 | 103 | 100 | 0 | Xilinx xc7a200tfbg484-2 |
IZHCOR6 [35] | 410 | 229 | 183.4 | 0 | Spartan-6 XC6SLX75 |
Soleimani et al. [36] | 617 | 493 | 241.9 | 0 | Virtex-II Pro XC2VP30 |
Grassia et al. [37] | 1048 | 646 | 105 | 22 | Virtex-5 XC5VLX50 |
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
Qin, X.; Li, C.; He, H.; Pan, Z.; Lai, C. Python-Based Circuit Design for Fundamental Building Blocks of Spiking Neural Network. Electronics 2023, 12, 2351. https://doi.org/10.3390/electronics12112351
Qin X, Li C, He H, Pan Z, Lai C. Python-Based Circuit Design for Fundamental Building Blocks of Spiking Neural Network. Electronics. 2023; 12(11):2351. https://doi.org/10.3390/electronics12112351
Chicago/Turabian StyleQin, Xing, Chaojie Li, Haitao He, Zejun Pan, and Chenxiao Lai. 2023. "Python-Based Circuit Design for Fundamental Building Blocks of Spiking Neural Network" Electronics 12, no. 11: 2351. https://doi.org/10.3390/electronics12112351
APA StyleQin, X., Li, C., He, H., Pan, Z., & Lai, C. (2023). Python-Based Circuit Design for Fundamental Building Blocks of Spiking Neural Network. Electronics, 12(11), 2351. https://doi.org/10.3390/electronics12112351