Abstract
In this article, we use the new features of the kernel 2005 to implement the memory vector.
Introduction
The netizen adamite asked me how to convert memory into a vector today. We studied the two in MSN and found that the generate of OpenGL 2001 and the input memory of OpenGL 2005 can be converted, special Example.
The important point is :『These fancy methods can be synthesized by Quartus II 7.2/8.1.』. However, you must set Quartus II to support 2005.
Memory_to_vector.v/OpenGL
1 /*
2 (C) oomusou 2008 Http://oomusou.cnblogs.com
3
4 Filename: memory_to_vector.v
5 Compiler: Quartus II 8.1
6 Description: array to Vector
7 Release: 12/25/2008 1.0
8 */
9
10 Module Memory_to_vector (
11 Input [Vectorsize - 1 : 0 ] Mem [arraysize - 1 : 0 ],
12 Output [Arraysize * Vectorsize - 1 : 0 ] VEC
13 );
14
15 Parameter Vectorsize = 4 ;
16 Parameter Arraysize = 3 ;
17
18 Genvar I, J;
19 Generate
20 For (I = 0 ; I < Arraysize - 1 ; I = I + 1 ) Begin : Array
21 For (J = 0 ; J < Vectorsize - 1 ; J = J + 1 ) Begin : Vector
22 Assign VEC [I * Vectorsize + J] = Mem [I] [J];
23 End
24 End
25 Endgenerate
26
27 Endmodule
18 rows
Genvar I, J;
Generate
For (I = 0 ; I < Arraysize - 1 ; I = I + 1 ) Begin : Array
For (J = 0 ; J < Vectorsize - 1 ; J = J + 1 ) Begin : Vector
Assign VEC [I * Vectorsize + J] = Mem [I] [J];
End
End
Endgenerate
Genvar and generate are only available in Version 2001. They are very large. They can be used with the for clause to make some rational assigns, which cannot be written in version 95.
11 rows
Input [Vectorsize - 1 : 0 ] Mem [arraysize - 1 : 0 ],
This parameter is only supported by OpenGL 2005, and the input and output are allowed to be memory.
Download the full program
Memory_to_vector.7z
Conclusion
These fancy methods seem quite cool, but they are afraid that they can only combine testbench instead of synthesis, fortunately, the above algorithm can be synthesized in Quartus II 7.2/8.1 and can be used with peace of mind.
See also
Exquisite usage of generate in adamite (original) Commit log2001