Forum Discussion
How to simulate the FPGA neural network in Altera
I want to simulate the some kind of schematics that work by principle of neural networks. I have Altera Quadrus 11. But when trying create some verilog or vhdl code I see that compilation and simulation items of menu is disabled. Should it due to absence of installed device --such warning is appered when creating the project or I do not entered the license properly. If the issue is in not installed device, which one can I use for my student work, how much space it could take. Can I use the web-edition for this purposes, with or without device?
And the next set of questions relates to the ocding of logical circuit in Altera or Modelsim (which one could I use-- now I have just Model-Sim free edition). The logic circuit should sort analog signals. The other components of circuits is adders with 2 addings and one substraction, and one with adding of all N signals (or non-binary numbers) the N+2 step functions (comparators of amplitude of signals with some x), and one multiplicator and one integrator. So definitive question is the concept and specific of neural networs with back-propagation method in HDL, and other ones is concerning the converting decimal numbers to binary ones (or it could be allowed to be binary from the start), how implement of multiplication for the big coeficent, how the comparator works in Verilog/VHDL, and the most unsure --about integrating the function. I do not exactly even know what is the role of integrator in logic circle (in this case it is connected with the multiplicator and authors even jjust whol ethe whole structure --inverting integrator --*(-Alpha)). Where I could find such examples in VHDL, but it would be better in Verilog, that I studied something. What structure and size of teh whole programming module should be if N (number of sorted items) is 5-6...67 Replies
- Altera_Forum
Honored Contributor
I have converted yesterday my Simulink design to Verilog file foe about 8000 lines. Is it incorrect? It even automatically launched in Model sim but it said there is no design files. And to add wave window I do not know through menu. Anyway what such quadratic shaped signals could show in HDL simulation--could it show the decreasing of signal as it is in Simulink?
I appeciate your fixdt conversion but I do not understand how do you do it. You apply it to adders, integartor, constants, gain. But why some is 1,12,24 but other 1,6,12--what it means? If so could I now correctly convert it to HDL. And one more note--the if-else blcok should be replaced by two switch blocks--1-3 input like. And what about DSP--should I also convert to fixdt for it? Where I could find fine tutorial for it? And yet the question again--how can I note the Matlab path for Dsp Blockset? Now I have Matlab2009a and it has more opportunities, such as fixdt, Simulink Fixed Point (with reference to Block Libarry), Matlab fixed-point but just help - Altera_Forum
Honored Contributor
Here is the Simulink design without if-else but with 2 switchs--but works the same --
and is simplified. http://s000.tinyupload.com/?file_id=18120771512038272863 And what about dsp blockset--it doesnt see as I have portab version of Matlab. Probably it is impossible to correct it. - Altera_Forum
Honored Contributor
OK you seem to not understand the fundamentals of FPGAs.
HDL is a hardware - description language. It isn't software. Hardware needs a defined input and an output. Right now it simulink your "inputs" are some constants, but when you convert to HDL using HDLCoder you basically have a system without any "input ports" and "output ports". This means that when the synthesizer looks at your design it sees it doing nothing. Since the digital design works (sinmulink44_dig2009a.mdl) you need to replace your constant inputs with input ports (look in the simulink library) and replace the output scope you have with an output port. Set their data types to fixdt(1,12,6). Then regenerate the HDL. It should recognize several 12 - bit inputs (input1, input2, input3....) and one 12 - bit output. Then you can send this to Modelsim and look at each 12 -bit bus. If you need more explanation about fixed point representation just search "matlab fixed point toolbox" on google. There are plenty examples and explanations. Altera's DSP blockset also needs fixed point toolbox. - Altera_Forum
Honored Contributor
Should fixed point toolbox convert my simulink design automatically? It should probably present on my Matlab 2009a? How launch it?
On FPGA--yes I just read about it and I do not know how many inputs and outputs it has? But as far as I inderstand it is consisted with some blocks that could do logical functions (<,+,*). But why it should has several input (I need 6 ones as well as such number of output), and just 1 output? Why iy should be 12-bit? And retuening to my circuit in Simulink how integrator by time could be realized there on FPGA, so with the help of HDL. Yes maybe I can use input ports instead the inputs in Simulink (MAtlab 2009a), as previous one do not have even fixdt. But what can I get in Model SIm --waht this wave could show. How my wave (graph) in Simulink could be different with ModelSim after HDL conversion as I see the quadratic waves but the same level. And yet another question: Can I launch DSP Blockset and just only then connect to MAtlab? - Altera_Forum
Honored Contributor
No. You still need to convert manually to fixed point. It is a toolbox in Matlab. Type "ver" in the command window to see what toolboxes you have. It should include Fixed-Point Designer.
For the inputs and outputs I was talking about YOUR design. It have several inputs (which you currently set to constants) and 1 output (which u connect to a scope). I used 12 bits because I didn't want to spend a lot of time picking the proper bit widths. With fixdt(1,12,6) i can cover -32 to 32 - (1/2)^6 with the resolution of (1/2)^6 In HDL one of your basic inputs is a CLOCK, you would externally drive this with some clock. It may will be w/e you want it to be. However, the z -domain representation of the integrator will change with the clock frequency you choose b/c an integrator is T/(1-z^-1) where T is 1/clock frequency. Right now the simulink is for a clock frequency of 10kHz, which is much slower than the max clock frequency that an FPGA can use. Modelsim shows you individual bits ( 0's and 1's ). To actually see meaningful information you need to group the bits. So if your output is 12 bits you will need to group output[11] thru output[0] into a single bus. DSP builder acts like a library in Matlab. You need to tell matlab which folder it is located in. - Altera_Forum
Honored Contributor
How to tell Matlab where my DSP blockset is located? If I should do it manually what is the sense of Fixed-Point toolbox?
The objective of this KWTA circuit is to show K biggest signals (numbers) among N. So if K=4, and N=7, just 4 signals should be above the 0 level, so what is the sense to transform to logic signals as the analog show the real decrease of signal. If so -- how to group them? And I could dsiplay not in one Scope but I should identify this signals-- maybe I could do it by some marker -- 3-bit number (8 signals) -- and then show they are above the 0 level. Anyway the final task is to sort this signal in decresing order, so at first palce will be biggset signal, then 2nd biggest and so on.. But in theory I should do it converting the K biggest signals to 1, and other to 0, then by substracting the K from K+1 and I will be get this K+1 sorted number. Even in Simulink this comparator should compare with 0, so it turns the logical function. So how then to group it? - Altera_Forum
Honored Contributor
Fixed point toolbox is the solver engine. If you don't have it, the simulation won't run. To add DSP builder use "Set Paths" >> All folders with subfolders >> Find your DSP builder folder >> OK
So based on what you said, you are trying to replicate the algorithm in the following paper: "A discrete-time dynamic K-winners-take-all neural circuit" Pavlo V. Tymoshchuk 2009. Correct? If so, Figure 2 from this paper shows you the digital implementation of this neural network... Here a1, a2,....aN are your input ports (N inputs). and b1,b2,....bN are your output ports (MY BAD, i said 1 output last time).... Out of these N outputs you will select the K largest b values. Actually the sorting algorithm might be a little more difficult than your neural network, b/c you have to sort the b outputs and record their initial positions to finally sort the a inputs. - Altera_Forum
Honored Contributor
Despite I added path it doesnot work with Matlab 6.5.
I do not undestand why do we need this fixed point toolbox when we ned do it manually, but probably in 2009a it should to be. If you transferred to discrete time could you generate and simulate this HDL in ModelSim or DSP Blockset to help me to see the results in binary realization? - Altera_Forum
Honored Contributor
DSP builder won't work with Matlab 6.5... It needs something recent. I used Matlab 2013b.
The reason you still need fixed point toolbox because matlab can't interpret fixed point math without it. On its own Matlab can only do floating point math. These operations may look the same, but they work very differently. Fixed point toolbox is an addition to matlab to expand its abilities. I can try to generate a dsp blockset model. It will take me some time, i'm pretty busy. Meanwhile you need to specify the# of input you need (parameter N in the model description above). That will be fixed. I think currently you have 6 inputs, correct? - Altera_Forum
Honored Contributor
Also I think you need to revise your model. Based on Figure 2 of the paper I attached, the large accumulator is the summation of b1 through bN, AND 2K - N...
R = 2K - N - sum (sgn(b1)+sgn(b2)+sgn(b3)+....sgn(bN)); where sgn is the sign of the number (1 if >0, 0 if = 0, -1 if < 0) You neglected the -N term.......