…ludes. In ivl_alloc.h we redefine malloc(), realloc() and calloc() to have standard error checking. We don't want to do this for anything that comes from the standard headers. This specifically doesn't work if a C++ header files does std::malloc, etc. Also change to -W instead of -Wextra since that is more portable. I plan to add a check from -Wextra and use it when available since it is more descriptive.
This patch adds defines that translate all malloc(), realloc() and calloc() calls into ones with error checking when ivl_alloc.h is included.
The functions (malloc, free, etc.) that used to be provided in malloc.h are now provided in cstdlib for C++ files and stdlib.h for C files. Since we require a C99 compliant compiler it makes sense that malloc.h is no longer needed. This patch also modifies all the C++ files to use the <c...> version of the standard C header files (e.g. <cstdlib> vs <stdlib.h>). Some of the files used the C++ version and others did not. There are still a few other header changes that could be done, but this takes care of much of it.
It is acceptable to call delete on a NULL object. It's also acceptable to assign the value to zero if it is already zero. Removing the superfluous if should produce slightly better code since there is no conditional to deal with except for what is likely in the delete implementation, but that should be highly optimized.
This patch cleans up some style issues: no need to check that a value is defined before freeing or deleting it, use C++ style casts, make sure to NULL terminate strncpy(), empty() is faster than size() for size == 0 or size >= 0 checks, re-scope some variables, etc.
These types are useless repetition of the ivl_drive_t type. This is also another chapter in the series to push ivl_target generation further upstream.
It turns out that although there was all kinds of code to manage these members, there were no uses anywhere. It must have been a legacy from a previous era. So remove the dead code so that it doesn't confuse me again.
Remove some wasteful and excess scans of the Nexus of some links, and remove dead code so we can see what we're doing. Also inline some commonly used and trivial functions.
Once code generation starts, the Nexus structure no longer needs to support fast insertion/connect operations. So have the code generator lock down the Nexus structures and adjust the Link lists for optimal access during readout.
When netlists get very large, the Nexus::connect() method tickles the O(N) performance and elaboration gets very slow. Rework the connect method to be O(C), for a drastic performance boost for large designs.
This simplifies and reorganizes this function in order to improve the performance of this function by a constant factor. I think we really need to improve this by an entire order (and not just a simple factor) but this helps.
It turns out that it is possible for an otherwise constant net mux to be non-constant if there is a force that can drive the net. This can be detected as an l-value reference to an otherwise constant selector.
By not creating Nexus objects until necessary, we avoid creating a lot of spurious objects. In fact, it is true that almost every link that is created and connected to another link will create a spurious Nexus object without this patch.
Remove redundant pointer to the containing NetPins object by keeping the pointer only in the first Link (pin 0) of an array of links. In this link, replace the pin number with the NetPins pointer, and set a pins_zero_ flag to indicate that this has happened. This way, only the first pin in a Link array will have the pointer to the NetPins that contains the array, and the pointer takes up practically no space at all.
When driving an input port to a module, watch out for the case where the net is also driven within the instance. If this is the case, take pains to make sure what goes on in the instance doesn't leak out through the input port. Add a BUFZ (continuous assignment) to isolate the context from internal driving.
The NetBranch object is connected, but not like an object, so the NetPins object base class is factored out from NetObj to handle the connectivity, and the NetBranch class uses the NetPins to connect a branch. Also, account for the fact that nets with a discipline are by default real-valued.
This patch fixes a delete vs free problem in the NexusSet class. The items_ array was being allocated with malloc/realloc and freed with delete. The quick fix was to replace delete with a call to free(). A better fix would probably be to rework the class to use a vector.
Padding and continuous assignment caused problems if the continuous assignment includes a delay. The problem is that the padding was not necessarily included in the delay. Rework the elaboration to make sure the padding is indeed included in the delay.