What alternatives can be used instead of dynamic arrays in Verilog and Quartus?

In summary, you need a synthesizable dynamic array to avoid wasting logic cells. A string variable is not dimensionable on the fly, so you have to either assume there is infinite memory, or use a large enough array for input.
  • #1
nadersb
28
0
hello everyone
I know that dynamic array is not supported in Verilog and Quartus. I want to know does anybody has an idea or algorithm to use instead of dynamic array. I mean I am searching for something that works instead of a dynamic array.
thanks
 
Engineering news on Phys.org
  • #2
nadersb,
Dynamic arrays is a verification feature, i.e. for use in test bench. It is not generally synthesizable.

Think of what Quartus would have to do to synthesize int dyn_array[];. How much memory, or how many logic elements should it assign? How would it know if the logic fit in a the target device?

Perhaps explain why you think you need a synthesizable dynamic array.
 
Last edited:
  • #3
yes I know it is not synthesizable because the problems you have mentioned and that's why I need something else.
let me explain more, I have a module that its input is not fixed size. it can be 16,32,64... bits. the easiest solution is to use a large enough array for input, but it wastes too much logic cells. so I am thinking and searching for an algorithm that help me in this case.
 
  • #4
When is the size determined, during instantiation of the module or after download?
 
  • #5
size itself is an input. it is a filter that number of its coefficient is changeable.and size depends on how accurate filter should be.
 
  • #6
Is it an input to the module during instantiation or an input to the FPGA itself (say from software) after it has been downloaded?
 
  • #7
it is an input to FPGA itself
 
  • #8
Sounds like your options are either dynamic reconfiguration, or design to accommodate the largest possible size.

If this is a transversal (FIR) filter of max length, say, 128 coefficients than you need enough RAM to store these coefficients anyway. If you want to scale back the accuracy then just zero out the unused coefficients. Filter will work normally except with some non-optimal delay.

Of course I am speculating without having any idea about your architecture.
 
  • #9
yes I think so. I think there is no way instead of using large size array unfortunately
 
  • #10
hmmm

are string variables dimensionable on the fly?

ignore suggestion if it's silly - I'm still living in the age of interpreted Basic.


old jim
 
  • #11
Hey Jim,

In an ordinary programming language the programmer often has the luxury of assuming that there is limitless memory available. When the program is run and it decides it needs a certain amount of memory, say for a string variable, it makes the request to the operating system. The operating system keeps track of how much memory is available, and who is using what, and will allocate a block to this program. Later, the program can notify the operating system that it no longer needs this memory, and it gets returned to "the heap".

Synthesizable Verilog kind of looks like a programming language but is actually a "hardware description language". It is really just a text way of doing what we did years ago with pencil, stencil, and D-size schematic sheet to design digital logic. If I needed a register big enough to hold a 32-bit word, I drew in 32 flip-flops on my schematic, then build my board. Today in verilog we "instantiate a 32 bit register" and program the FPGA. In both cases a piece of hardware has been created. And, just like there was limited real estate on my digital logic board, there are limited logic resources available within an FPGA, so we try to be very conservative (the point of the OPs post). If I change my mind and decide I needed it to be a 64-bit register, I have to change the verilog code, and reprogram the FPGA and hope that it can "fit" the design. If it needs to be 32-bit most of the time, and 64-bit occasionally, I need to build it with 64-bits.

Of course, this is somewhat simplified for clarity's sake. It is actually pretty unlikely that bumping a single register up in size by 32 bits would cause a fitting issue. Even modest FPGAs today provide tens of thousands of flip-flops.
 
Last edited:
  • #12
Thanks EMIguy for that neat introduction. What amazing tools you have these days!

If I needed a register big enough to hold a 32-bit word, I drew in 32 flip-flops on my schematic...

i remember an old Honeywell DDP15 with discrete transistor flip-flops and drum memory about a foot diameter
it replaced the old 12AU7 based machine for an airline reservation system...
but in my heyday we had 4 bit MSI registers...

anyhow , thanks again. I'll probably never use such a thing but it is comforting to have a rudimentary idea of its existence.

old jim
 

Related to What alternatives can be used instead of dynamic arrays in Verilog and Quartus?

1. What is a dynamic array in Verilog?

A dynamic array in Verilog is a data structure that allows for the storage of a varying number of elements at run-time. It is declared using the "dynamic" keyword and can be used to store and manipulate data in a more flexible way compared to a static array.

2. How is a dynamic array different from a static array in Verilog?

A dynamic array can have a variable size, while a static array has a fixed size that is determined at compile-time. This means that elements can be added or removed from a dynamic array during run-time, whereas a static array cannot be resized after declaration.

3. How do you declare and initialize a dynamic array in Verilog?

To declare a dynamic array in Verilog, use the "dynamic" keyword followed by the data type and the array name. For example: "dynamic [31:0] my_array;". To initialize the array, use curly braces to enclose the initial values, such as "{1, 2, 3, 4}".

4. How do you access and modify elements in a dynamic array in Verilog?

To access elements in a dynamic array, use the square bracket notation, like with a static array. For example: "my_array[2]". To modify an element, use the assignment operator (=) followed by the new value. For example: "my_array[2] = 5;".

5. What are the advantages of using dynamic arrays in Verilog?

Dynamic arrays offer more flexibility and efficiency compared to static arrays. They can be resized at run-time, reducing memory usage and allowing for easier manipulation of data. Dynamic arrays are also useful for storing and working with data structures that have a varying number of elements.

Similar threads

  • Electrical Engineering
Replies
6
Views
1K
Replies
19
Views
2K
Replies
1
Views
1K
  • Electrical Engineering
Replies
11
Views
3K
Replies
2
Views
2K
  • Programming and Computer Science
Replies
1
Views
725
  • Aerospace Engineering
Replies
1
Views
769
  • Programming and Computer Science
Replies
4
Views
5K
  • Electrical Engineering
Replies
10
Views
963
  • Linear and Abstract Algebra
Replies
2
Views
977
Back
Top