Implementation of a multiprocessor array for spiking neural network emulation on FPGA
Full text
IMPLEMENTATION OF A MULTIPROCESSOR ARRAY FOR SPIKING NEURAL NETWORK EMULATION ON FPGA A Degree Thesis Submitted to the Faculty of the Escola T`ecnica d’Enginyeria de Telecomunicaci´o de Barcelona Universitat Polit`ecnica de Catalunya by Sergi Juan Moreno In partial fulfilment of the requirements for the degree in ELECTRONIC SYSTEMS ENGINEERING Advisors: Mireya Zapata Rodr´ıguez Jordi Madrenas Boadas Barcelona, January 2017
Abstract During this project I have described and simulated an Array of Multiprocessors to emulate Spiking Neural Networks in a new architecture. Finally I have synthesized and implemented it on a FPGA to check the correct behaviour. The main described block is the Process Element, which contains several elements that allow the processing of the neuronal algorithm. Inside we find the ALU, which allows to perform calculations, a bank of registers to store values, a LFSR to generate pseudorandom numbers, data memory to store parameters and memories, which allow a dynamic interaction between Processing Elements. Each element connects within a parameterizable array with the necessary hardware for the complete functionality of all of the instruction set. Finally it has been synthesized and modified to meet the time constraints, achieving to generate an array of 12x12 with problemfree timings. 1
Resum Durant aquest projecte he descrit i simulat un Array de Multiprocessadors per emular Spiking Neural Networks en una nova arquitectura. Finalment ho he sintetitzat per implementar-ho sobre una FPGA i comprovar el correcte funcionament. Els principal bloc descrit ´es l’Element de Processament, el qual cont´e diversos elements que permeten processar l’algoritme neuronal. A dins trobem l’ALU, que permet realitzar c`alculs, un banc de registres per desar valors, un LFSR per generar n´umeros pseudoaleatoris, la mem`oria de dades per guardar par`ametres i les mem`ories associatives, que permeten una interconnexi´o din`amica entre elements de processament. Cada element es connecta dins d’un array parametritzable amb el hardware necessari per a la completa funcionalitat del l’arquitectura. S’han realitzat simulacions i depurat d’errors fins aconseguir un correcte funcionament de tot el set d’instruccions. Finalment s’ha sintetitzat i s’ha modificat per complir les restriccions temporals, aconseguint generar un array de 12x12 PEs sense problemes temporals. 2
Resumen Durante este proyecto he descrito y simulado un array de Multiprocesadores para emular Spiking Neural Networks en una nueva arquitectura. Finalmente lo he sintetizado para implementarlo sobre una FPGA y comprobar el correcto funcionamiento. El principal bloque descrito es el Elemento de Procesado, que contiene diversos elementos que permiten procesar el algoritmo neuronal. Dentro encontramos la ALU, que permite realizar c´alculos, un banco de registros para guardar valores, un LFSR para generar n´umeros pseudoaleatorios, la memoria de datos para guardar par´ametros y las memorias asociativas, que permiten una interconexi´on din´amica entre elementos de procesado. Cada elemento se conecta dentro de un array parametrizable con el harware necesario para la completa funcionalidad de todo el set de instrucciones. Finalmente se ha sintetizado y se ha modificado para cumplir las restricciones temporales, conseguiendo generar un array de 12x12 sin problemas temporales. 3
I want to dedicate this project and thank my parents, Linda and Lluis, for their encouragement. They always supported me during this time and gave me forces to continue on. 4
Acknowledgements This work would not have been possible without the inestimable and unconditional help of my supervisors: Mireya Zapata and Jordi Madrenas. Their advice and guidance, all the technical support and their immense experience have taught and guided me constantly and faithfully to the end. Thank you very much. I also want to thank the work done by the group of the DSP-FPGA course, Lloren¸c Manonelles, Javier P´erez and David Torres. Thanks for choosing final work of that course I decided I would do this project about SNN. Finally, I want to thank Jordi Vives for encouragement and help me with the document in L A T EX. 5
Revision history and aproval record Revision Date Purpose 0 19/11/2016 Document creation 1 19/12/2016 Document revision 2 09/01/2017 Document revision 3 13/01/2017 Document revision Document distribution list Name E-mail Sergi Juan Moreno [email protected] Mireya Zapata Rodr´ıguez [email protected] Jordi Madrenas Boadas [email protected] Written by: Reviewed and approved by: Date 15/01/2017 Date 15/01/2017 Name Sergi Juan Name Mireya Zapata Jordi Madrenas Position Project author Position Project supervisors 6
Table of contents 1 Introduction 11 1.1 Goalsoftheproject................................ 11 1.2 Requirements and specifications of the project . . . . . . . . . . . . . . . . . 12 1.3 Background .................................... 13 1.4 Workplan..................................... 13 2 State of the art 15 2.1 Neuralnetworks.................................. 15 2.2 SpikingNeuralNetworks............................. 16 2.3 ImplementationsofSNN............................. 16 2.4 Spiking Neural-network Architecture for Versatile Applications . . . . . . . . 17 3 Project development 19 3.1 VHDLdescription................................. 19 3.1.1 Components provided . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.1.2 Implemented components . . . . . . . . . . . . . . . . . . . . . . . . 20 3.1.3 Simulations ................................ 27 3.2 Synthesis and Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.2.1 Mainproblemsfound........................... 31 3.2.2 Slacktimeofsetup............................ 33 4 Results 35 5 Budget 39 6 Conclusions and future development 40 Bibliography 41 7
Glossary 42 Appendices 43 A Set of instructions 44 B Integrate and fire algorithm 46 8
Chapter 2 State of the art Neural networks are studied since many years ago, not only for understanding the biological functioning of the brain itself and their learning mechanisms, but also to create systems that can recognize objects, take decisions, learn and interact with objects and humans. 2.1 Neural networks A biological neural network is characterized by millions of cells interconnected between them. Each cell, called neuron, has three differentiate parts (see figure 2.1): dendrites (input connections), a cell body with the nucleus, and the axon (output connections). The electrochemical impulse from one neuron is propagated, through the axon, to more than a hundred of neurons up to ten thousand, by connections called synapses. An Artificial Neural Network (ANN) is a set of interconnected elements in a similar way as neurons in a biological brain. The study of these architectures allows us to start to understand how brain carry out some process, such as decision, visual recognition or remembering things. Figure 2.1: Neuron parts. Source: ”Anatomy and Physiology” by the US National Cancer Institute’s Surveillance 15
We can differentiate three generations of ANNs: •First Generation: The first generation is based on McCulloch-Pitts [1] neurons as computational elements. In terms of processing, each element generates only digital outputs from digital inputs also from other elements or from the outside. In this generation are entering threshold circuit models, Boltzmann Machines [2] and Hopfield Nets [3]. •Second Generation: The second generation is characterized by an activation function used to generate continuous output, therefore, work with analog signals that determine the output value of the subsequent neurons. An example are sigmoid function (σ(y) = 1 (1+e −y)) and saturated linear function π(π(y) = yfor 0 ≤y≤1, π(y) = 0 for y < 0 and π(y) = 1 for y > 1). With thresholds and combinational circuits, these processing units (analog interface) can generate boolean answers and interact with units of the first generation (digital interface). •Third Generation: Finally we have the third generation, the Spiking Neural Networks (SNNs), much closer to real biological neurons. This is the model used in this project and it is described in the following. [4] 2.2 Spiking Neural Networks SNNs are the third generation of Neural Networks, as indicated before. They are characterized by incorporating the time concept in operation model. In contrast to other models, each neuron generates a unique spike (pulse) only when its membrane potential reaches a given threshold and not transmits data in every processing cycle. This feature makes the SNN model more realistic and similar to brain mechanism, allowing us to study better how the learning process works. 2.3 Implementations of SNN Inside the category of SNN, there are different architectures in order of the number of neurons and synapses, algorithms, and the hardware where these are emulated. There are realistic models to emulate the neuron behaviour that require complex processor units to carry out the algorithms. On the other hand, there are models with a lighter computational load, like 16
”integrate an fire” model, which can be implemented on small chips with a lot of simple neurons with a fixed number of synapses. An example of each are: SpiNNaker is a low-power parallel neuromorphic supercomputer. It is developed at the University of Manchester in the UK. The system consists of more than 60 thousand processors with 18 cores each one, reaching more than a million cores in total. Each processor has the capacity to addresses other neurons to form synapses. [5] Our approach is similar to Spinnaker, although we focus on much more compact processing elements and fast Address Event Representation (AER) for spike transmission. TrueNorth, launched by IBM in 2011, has a 64x64 array of neurosynaptic cores with 256 neurons each one, reaching a million neurons in total. Every neuron is connected to another 256 neurons. This supports huge networks, but limitations arise in the oversimplified neural model and the connectivity problem.[6] 2.4 Spiking Neural-network Architecture for Versatile Applications SNAVA is an evolution of a previous architecture, Ubichip, which was developed during the Perplexus project, an IST-FET FP6 European research project. With SNAVA, substantial improvements were achieved, for example, a greater number of PEs, virtualized neurons, or the ability to vary the number of synapses independently for each neuron1. This architecture is characterized by a scalable and resizeable implementation which can allow us to emulate Spiking Neural Networks (SNN). Being inspired by the mechanisms of brain biology, SNAVA facilitates an experimental approach to the study of neural dynamics. It consists of a Multiprocessor Array with Single Instruction Multiple Data (SIMD) units, or Processing Elements (see figure 2.2). The processor was modified from the previous architecture and, among other improvements, was added the capability of emulate more than one neuron thanks to virtualization concept. The array is controlled by the Sequencer, which sends the instructions of the algorithm loaded in the Instruction BRAM. The Address-Event Representation (AER) Module brings the capability of interconnect more FPGAs in a ring topology to increase the number of neurons emulated. 1A comparison between the two architectures can be found at the Ph.D. thesis ”Efficient multiprocessing architectures for Spiking Neural Networks emulation devices based on configurable”[7]. 17
The SNAVA architecture had hardware non used from the previous version, this meant that its design was not optimal, occupying more resources and consuming more energy unnecessarily. The instruction set is used to program the neural algorithm by Assembler language. The array, although the dimensions of 10x10 PEs, did not have pipeline registers and this may cause sporadic bugs when signals didn’t arrive on time. Synaptic connections were made by means of combinational logic, being forced to maintain a predefined topology. This produced very long synthesis times and inconvenience for connectivity changes. Figure 2.2: SNAVA architecture block diagram [7] 18
Chapter 3 Project development This project is a part of the HEENS architecture, which is still being developed during this semester. The Multiprocessor Array project development is divided in two parts. The first one is focused on describing all components in VHDL and simulating the correct behaviour using QuestaSim. The second part is to implement these components doing the synthesis and the implementation using Vivado to obtain the ”.bit” file to load and run it on the FPGA. In contrast to SNAVA, the components of the new implemented architecture had been described again, which is optimized in concordance with the instruction set improved. The Associative Memory [8] allows dynamic synaptic connections and reduces a lot the time of synthesis. In addition, with a similar array dimensions, pipeline registers have been added to prevent slacks of setup (as discussed later). 3.1 VHDL description The main goal of this part is to describe all components to generate the Multiprocessor Array with PEs and all the other components inside. Also, after each modification, it is necessary to check the correct logical operation of the whole system and test the set of instructions forcing extreme cases to detect possible bugs and unexpected results. 3.1.1 Components provided The following components, provided by both supervisors, and the Multiprocessor Array implemented in this project (explained in detail at 3.1.2 Described Components section) conforms the whole HEENS architecture. Each component is an evolution of the previous 19
one, from SNAVA, in order to solve problems of resource utilization, optimize instruction set and improve the system scalability. Top entity As its name says, this component includes all the other entities and allows the connection between the whole system and the FPGA. Sequencer This is the controller of the whole system. It’s in charge to read the algorithm loaded, manage the control signals and syncronize the Multiprocessor Array with the AER System. Address-Event Representation (AER) To make the system scalable it is necessary to manage spike communications between FPGA boards. The AER interface allows to transmit this spikes through a ring topology allowing the interconnection of 126 Kintex7 plus a master one, a PicoZed Z030. Block Memories In every PE also there are three memories implemented with Block RAMs to save the synapses with other neurons (associative memory) and input spikes (local and global memories). All of them are inside this component and are one of the improvements to achieve a bigger array than the 10x10 of the previous architecture. 3.1.2 Implemented components In this project the following components are compiled and simulated using QuestaSIM. The waveform generated in each simulation is very useful to check the operation codes and the expected results for all the signals involved in the process. The components described in this project are: Multiprocessor Array It consists in nMultiprocessor Rows (each one with mProcessing Elements inside). Is described using a generate loop with prefixed parameters; by this way the array can be resizeable (until fill all the FPGA) changing only the number of rows and columns from the definition package. 20
There are two communication buses, one for data and another one for memory address, to transmit data to all units and load configurations. The capability to activate only one PE by enable signals allows to preconfigure parameters of each neuron separately. Also, there are control signals to synchronize all the execution between PEs and the Sequencer. The combinational logic at the end of the rows and columns allows generated spikes to flow out from all the PEs. Figure 3.1: Multiprocessor Array block diagram 21
Figure 3.2: Read and Reset spike circuit located inside each PE As shown in the figure 3.1, the blocks of the Multiprocessor Rows are expanded to see the complete structure with its connections. The operation of the HEENS architecture is separated into four modes: initialization, configuration, execution and distribution. These modes are alternated throughout the process to perform the neuron network emulation. Initialization takes place only at the beginning and is controlled by the Address-Event Representation (AER) system. In this mode, AER System sends a ChipID and the RingSize to all FPGAs. First one allows the identification of each node at the transmission bus, and the second value determines the total number of FPGAs connected. Instruction memory is also configured with the algorithm that will be executed at the Multiprocessor Array. Setup mode is in charge to write the memories located inside the PEs. To do it, an address bus enables each processor individually to load the network topology definition and the neural parameters and synapses of the algorithm to be emulated. Execution of the neural algorithm starts once the entire array is set. In this mode the Sequencer sends the instructions to all processors at the same time. All of them calculate the membrane potential in function of the input spikes, synapses and initial configuration. After each execution loop, the Sequencer enables the distribution signal. Then, 22
spikes generated by each PE are processed and forwarded to the other processors to start once the loop. The first processor in the first row (row 0 and column 0) is the one with higher priority, so if it have a spike, will be the first to leave the array and reset (combinational circuit at figure 3.2). Then, the following processors of the same row will continue to transmit spikes when all the previous ones were cleaned. Once the entire first row is empty, the next one is enabled and the sequence starts again. This cycle is repeated to empty the multiple layers of virtualization and does not end until the sequencer disable the distribution signal. Figure 3.3 is an example of the complete process of spike distribution. At the simulation there are several signals involved, but the most significant are the addresses of the spikes of rows and columns (blue) signal with spikes codified (green) and control signals (yellow), which allow an ordered output. The last ones enable a row each time and the processors with a spike to be distributed, one by one. Distribution stage is when the spikes are distributed to the other FPGAs via bus AER, and then, to all the associative memories to emulate the synaptic behaviour of neurons. Multiprocessor Row This component implements every row of PEs inside the Array. It is generated, also by generate loop, in a new instantiation to make easier the utilization of pipeline registers to manage time slacks afterwards. It also depends on the parameters of the package definitions, allowing to resize the number of columns changing only the correspondent value. Inside this component there are the mPEs with corresponding connections to configure, send data and read generated spikes. During the implementation process, due to the dimensions and the complexity of a 12x12 array, pipeline registers were added to neutralize the slack time errors (see 3.2.2 Slack time of setup section). 23
Figure 3.3: Spike distribution of 8x8 Multiprocessor Array Processing Element (PE) Is the basic processing unit of the array. It is responsible for emulating the behaviour of a neuron and, if virtualitation is enabled, the same PE will emulate a maximum of 8 different neurons, each with own parameters and synapses. As we see at figure 3.4, the internal components correspond to a Harvard type architecture: ALU, Registers, Memory and communication buses. The HEENS architecture is able to run several models of SNN and it have to compute various functions and algorithms needed to achieve an approximation to neurons behaviour. 24
two registers to determine if there are time problems. Due to the large amount of time it takes for the synthesis and implementation, the first tests should be done with an array of reduced dimensions. Tests carried out on the FPGA can reveal errors which do not appear in the simulations. 3.2.1 Main problems found The problems to be solved in this part were related with time constrains. Due to the main characteristic of the VHDL hardware describing language, all the values (signals processed by combinational circuits and saved with registers) have a time dependence. In other words, if a signal (real wire between two registers) is too long across the FPGA or it depends of many cascaded combinational circuits (each logic component have an specific time of response), the time needed by the destination register to load the next value when the clock arrives is too short or negative (slack time of setup2), it may cause incorrect data capture and/or metastability and, therefore, computational problems. Vivado detects critical paths of signals involved in opcode lines from the Sequencer to the memory registers, crossing the ALU and, in special, the multiplier module. Then, it shows the time constrain that is violated and the extra time required, as it is shown at figure 3.9. Figure 3.9: Screenshot of the faulty paths by a setup slack in a 10x10 array Using the Floorplanning view, its possible to see the physical paths, affected by slack time, through the FPGA. An example is shown at the figure 3.10. Also, its very helpful to use the critical path option (see figure 3.11) to see all the blocks involved (blue signal). 2There are three types of slacks: setup, hold and pulse width. The first occurs when the signal comes too close to clock pulse (or later). The second appears when the signal changes before the period required for charging value. The third slack indicates that the clock waveform meets all the requirements. 31
Figure 3.10: Scrheenshot of VIVADO windows with the Report Timing summary report Figure 3.11: Screenshot of a critical path of a 10x10 array 32
3.2.2 Slack time of setup The best way to solve problems of timing is using pipeline registers. Reduce the frequency under 125 MHz is not optimal because the rest of the system has not problems and the architecture must work at selected frequency. But the most important consequence of using pipeline registers inconsistently is the desynchronization between components, in other words, all the pipelined signals will arrive one or more clocks later to the other component (depending on the number of registers added). Because of that, it’s necessary to be very careful and apply pipeline registers to all the signals coming from the same component and taking in account the delay generated of all the output signals that depend on the previous ones. In total, during the implementation, three pipeline points must be added to ensure the constraints compliance of the slack time of setup: Input signals All the input signals from the sequencer (opcode, data, address and control signals) have to be pipelined because opcode signal was a very critical path (adding more than a half of a clock period). This modification causes a general delay of one clock in all the array, but it isn’t important if all the input signals are synchronized. Multiplication opcodes Both operands of the multiplication unit inside the ALU also need to be pipelined to achieve the minimum time required to carry out the multiplication. The addition of a register before the multiplier unit is very sensitive because it affects only to the multiplication opcode. The delay causes a desynchronization between operations and it forces to modify the Sequencer behaviour only in the multiplying case. The solution adopted was to increment one clock the opcode duration of MUL and MULS instructions and modify the enable logic to allow the write process only during the second period clock. This modification can be observed at the simulation of the figure 3.12. 33
Figure 3.12: Detail of the double clock cycle for execute MUL and MULS opcodes Spike distribution During the spike distribution, due to the big size of the array, is necessary to add one clock delay before the activation of the next row. This causes a discontinuity during the spikes distribution that has been solved by modifying the combinational circuit of the spike valid signal. The discontinuity is clearly visible at the simulation waveform of the figure 3.13. Figure 3.13: Detail of the discontinuous spike distribution and the spike valid signal 34
Chapter 4 Results After the simulations and tests carried out, it is verified that the PEs are working properly, spikes are correctly read from the array and the subsequent feedback to carry out several cycles. Although some components may be more optimized and the system may be tested with various interconnected FPGAs in a ring topology, the Multiprocessor Array of the HEENS architecture meets the specifications described in the introduction. The new architecture using Block RAMs instead of registers for synaptic interconnects optimizes the utilization of the FPGA resources and allows to implement a bigger Multiprocessor Array. The previous version array achieved a 10x10 PEs and the main limitation was the utilization of registers. With the HEENS architecture using Block RAMs, the array achieve a dimension of 12x12 PEs. Taking in account the maximum virtualization layers (8 neurons by PE), the total number of emulated neurons is 1,152 in each FPGA. Finally, assuming that the AER System supports 126 chips connected in a ring topology, the potential number of neurons reaches 145,152. Moreover, the utilization of Block RAMs is the new limitation on the used FPGA, reaching almost a 100 % of them. At the table 4.1 is shown the utilization of HEENS architecture in a full FPGA and the number of resources used by one Process Element. Also there is a comparative between SNAVA and HEENS architectures implementing a 10x10 Multiprocessor Array (figure )4.1). The instruction set has also been modified. The improvement allows to execute faster (in less cycles) some usual actions. This is vital to reduce the among of time of the entire algorithm or program a more extensive one without increasing the duration of the execution. 35
Resources Total Used by array [%] Used by PE Slice LUTs 203800 88.60 1,245 Slice Registers 407600 18.78 512 F7 Muxes 101900 7.09 50 F8 Muxes 50950 2.27 8 Slice 50950 96.01 418 LUT as Logic 203800 88.53 1,245 LUT as memory 64000 0.22 0 LUT Flip Flop Pairs 203800 90.16 1,308 Block RAM Tile 445 97.64 3 DSPs 840 17.14 1 Bonded IOB 500 0.60 0 BUFGCTRL 32 12.50 0 MMCME2 ADV 10 10.00 0 BSCANE2 4 25.00 0 Table 4.1: Total of resources, total utilzation by a 12x12 array and utilization by one PE 0 10 20 30 40 50 60 70 80 90 100 BRAMs LUTs Flip-Flops 13 79 22 68 61 63 SNAVA HEENS Figure 4.1: Percentage of the utilization between HEENS and SNAVA at 10x10 array 36
The improvement also reduces in more than 90 % the time required to synthesize and implement all the components. This is because the connections are defined in Block RAMs and is faster to generate huge memory blocks than interconnect a lot of isolated registers to generate only one of them. Before, with the SNAVA architecture, the synthesis and implementation process could take more than 18 hours, but now, using HEENS, is completed in not more than 30 minutes (i.e. 9:33 min. for synthesis and 20:26 min. for implementation), as shown on the table 4.2. Process SNAVA HEENS Synthesis 17:35 00:10 Implementation 00:39 00:20 Total time 18:14 00:30 Table 4.2: Comparsion of the utilization between the previous and the current PEs resources As an interesting fact, the figure 4.2 shows the maximum occupancy of the FPGA, in blue color. Only a few small areas near corners are free, except two central regions, which are dedicated to another unused functionality. Figure 4.2: Floorplanning of the 12x12 Multiprocessor Array with AER interface Integrate and fire is one of the most used models for emulation SNN. It is based on the membrane potential computing in function of the receiver spikes through the synapses predefined. Running this algorithm (included at Appendix B Integrate and Fire) and showing the membrane potential, at the waveform of the figure 4.4 can be observed a spike generated by a neuron. In this case, the programmed topology is all the neurons spiking to the neuron at position row 0 and column 0, as is shown on image 4.3, so the spike generated is from this one. 37
Figure 4.3: Topology of all spiking to one Figure 4.4: Waveform membrane potential when the neuron generates a spike 38
Chapter 5 Budget Budget items e/item Amortization Time Budget [e] Xilinx Kintex 7 KC705 1,600 e3 years 3 months 133 QuestaSIM University Licence 1,550 e1 year 6 months 755 Vivado Academic Licence Free - - 0 RRHH 8 e/h - 720 hours 5,760 Total 6,648 Table 5.1: Project cost The total budget for this project is 6,648 e. 39
Chapter 6 Conclusions and future development Compared to the previous SNAVA architecture, the HEENS architecture optimizes the FPGA resources and allows to implement more Process Elements in one chip (44 % of improvement). Also reduces the necessary time to implement all the components; that is very important because modifications of the design can be changed and tested faster. With the virtualization layers and the ring topology (outside the work of this scope) thanks to the scalable capability, the number of emulated neurons can be significantly higher than the previous architecture. To increase the number of neurons, Block RAM memories would be optimized to use less resources by each PE and allow the implementation of more of them. Another improvement is to reform the ALU, because it is an extremely complex component and has many combinational circuits that limit the maximum frequency (increases the slacks time). A more drastic solution is to use another FPGA with more resources. It very is important to describe all the components optimized to reduce delays between registers and prevent timing slacks, very frequently due to the complexity and longitude of signals between registers, in particular, between each PE and the Sequencer. 40
LDALL R4,DMEM1 ;R4 <-- DECAY DONATOR 1 LDALL R5,VREST1 ;R5 <-- Vres1 SWAPS R0 ;R0 <-- SR0 = Si MOVR R3 ;R3 <-- Si SWAPS R0 ;SR0_2 <-- R0 = Si ;-------------------- R2 <-- (1-Si(t))*(Vi(t)-Vres)*(Kmem) ----------------- MOVA R3 ;R0 <-- R3 = Si RTR FREEZEC ;IF (Si = 0) THEN R2 <-- ((1)*(Vi(t)-Vres)*(Kmem) SWAPS R6 ;R6 <-- SR6_2 = Vi MOVA R6 ;R0 <-- R6 = Vi SUB R5 ;R0 <-- Vi - Vres MULS R4 ;R0 <--(Vi(t)-Vres) * (Kmem) --MZ MOVR R2 ;R2 <--(Vi(t)-Vres) * (Kmem) UNFREEZE MOVA R3 RTR FREEZENC ;IF (Si = 1) THEN R2 <-- ((0)*(Vi(t)-Vres)*(Kmem) = 0 RST R2 ;R2 <-- ((0)*(Vi(t)-Vres)*(Kmem) UNFREEZE MOVA R2 ;R0 <-- (Vi(t)-Vres)*(Kmem) ADD R5 ;R0 <-- Vres1 + (1-Si(t))*(Vi(t)-Vres)*(Kmem) SWAPS R2 ;R2 <-- SR2_2 = SUM_WEIGHTS ADD R2 ;R0 <-- (Vres1 or Vres2)+(1-Si(t))*(Vi(t)-Vres)*(Kmem)+ ;SUM_WEIGHTS MOVR R6 ;R6 <-- Vres1+(1-Si(t))*(Vi(t)-Vres)*(Kmem)+SUM_WEIGHTS SWAPS R6 ;SR6 <-- R6 = Vi RST R2 ;SUM_WEIGHTS <-- 0 SWAPS R2 ;SR2_2 <-- R2 = SUM_WEIGHTS RET ; -------------------------------------------------------------------------- ; ----------------------------- SYNAPSE LOAD ------------------------------- .SYNAPSE_LOAD LOADSP ;ACC <-- BRAM(BP,15:1) & Spike_reg(BP) : Sj 47
;R1 <-- BRAM(BP,31:16) : Wij RET ; -------------------------------------------------------------------------- ; --------------------------- SYNAPTIC WEIGHT ------------------------------ .SYNAPTIC_WEIGHT RTR ; C <-- Sj FREEZENC ;IF (Sj = 1) THEN R0 <-- wji = Aji * P MOVA R1 ; R0 <-- Wij SWAPS R2 ;R2 <-- SR2_2 = sumW ADD R2 ;SR0 <-- wji = Sj * P MOVR R2 ;R2 <-- wji = Sj * P SWAPS R2 ;SR2_2 <-- R2 = sumW UNFREEZE RET ;--------------------------------------------------------------------------- ; --------------------------- SYNAPSE_SAVE --------------------------------- .SYNAPSE_SAVE ; THE SYNAPTIC PARAMETERS GO TO BUFFER 32 bits RST R0 STORESP RET ; -------------------------------------------------------------------------- ; ---------------------------- SPIKE UPDATE -------------------------------- .SPIKE_UPDATE RST R0 ; SWAPS R0 ;R0 <-- SR0 = Si ; RTR ; RTL MOVR R2 ;R2 <-- Si has been reset = 0 LDALL R3,THETA1 ;R3 <-- THETA1 = "0000F060" THRESHOLD VOLTAGE SWAPS R6 ;R6 <-- SR6_2 = Vi MOVA R6 SWAPS R6 ;SR6_2 <-- R6 = Vi SUB R3 ;R0 <-- Vi - (THETA1) RTL ; Vi - (THETA1) > 0 ? 48
FREEZEC SWAPS R4 ;R4 <-- SR4 = Tref RST R0 XOR R4 SWAPS R4 FREEZENZ ; IF (Z = 1) THEN Tref=0 and Si is set RST R0 BITSET CERO MOVR R2 ; LDALL R3,UNO ; MOVA R2 ; ADD R3 ; MOVR R2 LDALL R4,CTE_1 ;CTE_1 = 7 SWAPS R4 ;Load again in SR4 initial refractory time UNFREEZE UNFREEZE MOVA R2 ;R0 <-- Si SWAPS R0 ;SR0_2 <-- R0 = Si RET ; -------------------------------------------------------------------------- ; ------------------------------- REFRACTORY P ----------------------------- .REFRACTORY_P SWAPS R4 ;R4 <-- SR4 = Tref MOVA R4 RTR MOVR R4 SWAPS R4 ;SR4 <-- R4 = Tref RET ; -------------------------------------------------------------------------- ; ------------------------ENABLE SPIKES PROPAGATION------------------------- .SPIKES_ENABLE SWAPS R0 MOVR R2 ; R2 <-- Si SWAPS R0 MOVA R2 ; R0 <== Spikes STOREPS 49
RET ; -------------------------------------------------------------------------- ; **************************** PROCEDURES END ****************************** ; ************************** MAIN PROGRAMME BEGIN ************************** .MAIN LDALL R6,VREST1 ; Vi<-Vrest SWAPS R6 .ALG_LOOP GOSUB MEMBRANE_VALUE LOOP synapses ;synaptic loop GOSUB SYNAPSE_LOAD GOSUB SYNAPTIC_WEIGHT GOSUB SYNAPSE_SAVE ENDL GOSUB SPIKE_UPDATE GOSUB REFRACTORY_P GOSUB SPIKES_ENABLE SPKDIS GOTO ALG_LOOP ; **************************** MAIN PROGRAMME END ************************** 50