|
|
|
|
|
by simias
1912 days ago
|
|
In emulators I often have to implement various FIFOs with a fixed word size (8 bits, 16bits, 32bits etc...) and depth (16, 32 or 64 elements etc...). I could very easily make the word size generic, but not the depth. So I either had to make the depth dynamic (pretty expensive if you have hundreds of thousands of FIFO operations per second) or hack around it somehow. Now I can just make the depth a generic parameter. You can also abuse these types of generics to force the compiler to generate specialized versions of some methods in order to get better performance (at the cost of binary size) without having to manually create a bunch of variants of the same code. |
|