Compare commits

...
1218 Commits
Author SHA1 Message Date
Stephen Williams 105521b547 Merge branch 'master' into vec4-stack 2014-12-06 08:24:46 -08:00
Cary R fd3086f0a9 Fix compile warnings on RHEL5 2014-12-05 19:03:07 -08:00
Cary R 77ebfcacb9 Correctly pass if a darray element is signed or unsigned. 2014-12-05 18:23:02 -08:00
Cary R d62a307c34 Fix 32-bit issue in vector4_to_value() 2014-12-05 18:00:08 -08:00
Stephen Williams 011519cb5b Merge branch 'master' into vec4-stack 2014-12-05 13:55:51 -08:00
Stephen Williams 8a0b9acadc Snapshot 2014-12-05 2014-12-05 12:36:34 -08:00
Stephen Williams 77d1671d8f Merge branch 'master' into vec4-stack 2014-12-05 10:44:49 -08:00
Stephen Williams 561564065d deal with mixed nested index directions. 2014-12-05 10:43:39 -08:00
Stephen Williams 409f8c5823 Add the vec4 %subi instruction 2014-12-05 09:45:29 -08:00
Stephen Williams 03198356a5 vec4-stack stack manipulation improvements. 2014-12-04 17:15:27 -08:00
Stephen Williams b1d2393789 Optimize the %sub instruction by integrating it with vvp_vector4_t class 2014-12-04 17:01:16 -08:00
Stephen Williams 0f740289e9 Optimize %mul instructions by integrating with vvp_vector4_t class. 2014-12-04 16:00:57 -08:00
Stephen Williams 46ce236cfb Optimize the %add and %addi instructions
Tightly integrate with the vvp_vector4_t class to get much
better add performance.
2014-12-04 12:38:08 -08:00
Stephen Williams 86139c855d Optimize the vec4-stack %cmp/s and %cmpi/s instructions.
Magnitude compare is called a LOT, so it is worth putting some
special effort into it.
2014-12-04 10:42:48 -08:00
Stephen Williams eb070b061b Optimize the vec4_to_index, which implements %ix/vec4 instructions. 2014-12-03 17:53:45 -08:00
Stephen Williams 2b1393e7b9 Reduce some vector copies in %load/vec4 and %concat/vec4 instructions.
By clever stack manipulations, we can eliminate some vector copies,
which can improve performance.
2014-12-03 13:12:06 -08:00
Stephen Williams 85c7b07a9b Implement %cmp/ne and %cmpi/ne
These pull in the inversion of the output flags so that they more
efficiently implement != and !==, without %flag_inv instructions.
2014-12-03 11:06:11 -08:00
Stephen Williams 0c5ed2b60f Merge branch 'master' into vec4-stack 2014-12-03 08:36:38 -08:00
Stephen Williams 8fd1ead082 Revert "ivl: Allow to initialize variables with other variables (since Verilog-2001)."
This reverts commit 610ca95cbe.
It turns out that the new feature is actually a bug.
2014-12-03 08:27:01 -08:00
Stephen Williams 3bd307db85 Expression cast handles size if need be. 2014-12-02 16:54:32 -08:00
Stephen Williams 35db02d35d elaborate dump cast operators. 2014-12-02 16:50:42 -08:00
Stephen Williams f287546f49 Fix a %vpi_call call syntax. 2014-12-02 15:28:22 -08:00
Stephen Williams 1645e682f4 Generate more efficient vec4-stack code for real le compare. 2014-12-02 14:53:01 -08:00
Stephen Williams a57e0a1e3f vvp implementation of copy from vec4 to vec2 can use subarray method. 2014-12-02 14:52:37 -08:00
Stephen Williams b83144c552 The __vpiArray::set_word method should take a reference.
Seem to have missed a case where a vvp_vector4_t can be passed by
const reference instead of by value.
2014-12-02 13:02:46 -08:00
Stephen Williams 58fb80aec4 Implement and put to use the %muli instruction. 2014-12-02 12:46:17 -08:00
Stephen Williams 38f277d81b Merge branch 'master' into vec4-stack
Conflicts:
	vvp/array.cc
	vvp/vthread.cc
2014-12-02 11:21:58 -08:00
Stephen Williams f3ba335493 Merge pull request #49 from orsonmmz/darray_vpi
Support for dynamic arrays in the VPI
2014-12-01 17:12:57 -08:00
Stephen Williams fb5ae48b18 Merge branch 'master' into vec4-stack 2014-12-01 17:00:35 -08:00
Cary R 68258f244e Update cppcheck suppression file for latest lz4.c file 2014-11-29 07:36:51 -08:00
Cary R ee34ccec70 Update lz4 files from GTKWave 2014-11-29 07:36:44 -08:00
Maciej Suminski 1834d470cb vvp: Refactored __vpiArrayVthrA & __vpiArrayVthrAPV. 2014-11-28 14:14:42 +01:00
Maciej Suminski 9bc463aac0 vvp: Moved array_word_change(), array_attach_word(), array_alias_word() to __vpiArray. 2014-11-28 14:14:42 +01:00
Maciej Suminski 7c77097f71 vvp: array_[set/get]_word changed to __vpiArray::[set/get]_word. 2014-11-28 14:14:42 +01:00
Maciej Suminski cc4c5f4998 vvp: Changed get_array_word_size(vvp_array_t) to __vpiArray::get_word_size(). 2014-11-28 14:14:42 +01:00
Maciej Suminski 230c435ae7 vvp: Added missing functions for __vpiDarray. 2014-11-28 14:14:42 +01:00
Maciej Suminski 4ddef32631 vvp: __vpiArray::get_word_value handles StrVal variants. 2014-11-28 14:14:42 +01:00
Maciej Suminski a236c274f3 vvp: Minor changes. 2014-11-28 14:14:42 +01:00
Maciej Suminski 21a8cb71ee vvp: Handles for dynamic array ranges. 2014-11-28 14:14:42 +01:00
Maciej Suminski b4ccaa1b0c vvp: Fixed iterators for dynamic arrays. 2014-11-28 14:14:42 +01:00
Maciej Suminski a8d43fa743 vvp: Stop simulation in case of errors in $ivl_string_method$to_vec. 2014-11-28 14:14:42 +01:00
Maciej Suminski ca2ef5c956 vvp: Cleaning. 2014-11-28 14:14:39 +01:00
Maciej Suminski 6015aceda2 vvp: vpiArrayIterator::vpi_index core moved to vpiArrayBase::get_iter_index. 2014-11-28 14:14:37 +01:00
Maciej Suminski 9538501b54 vvp: Moved __vpiArrayBase::vpi_iterate to __vpiArayBase::vpi_array_base_iterate. 2014-11-28 14:12:49 +01:00
Maciej Suminski ea7fa24f9e vvp: Further extraction of common code pieces from ArrayBase. 2014-11-28 14:12:46 +01:00
Maciej Suminski 48d3701c02 vvp: get_word_index() & get_word_parent() moved to __vpiArrayWord. 2014-11-28 14:12:43 +01:00
Maciej Suminski c1164dcc33 vvp: Initial work on support for dynamic arrays in VPI.
Added array_common.[ch] to store shared code.
2014-11-28 14:12:37 +01:00
Maciej Suminski 1166cd932a vpi: Handle new formats in vpi_get_value() for unpacked arrays.
It is possible to use vpiIntVal, vpiVectorVal, vpiRealVal,
vpiStringVal and vpiObjTypeVal to retrieve data from unpacked
array cells.
2014-11-27 17:36:23 +01:00
Maciej Suminski c3a318f14e ivl: Casting vectors to strings. 2014-11-27 17:36:23 +01:00
Maciej Suminski b2deae7ba9 ivl: More meaningful errors messages. Minor code formatting. 2014-11-27 17:36:23 +01:00
Maciej Suminski 675dd91403 ivl: Added sign checking & casting between integers of different size. 2014-11-27 17:36:23 +01:00
Maciej Suminski b12e00d875 ivl: String to vector casting. 2014-11-27 17:36:23 +01:00
Maciej Suminski 103828577b ivl: Fixed indentations. 2014-11-27 17:36:23 +01:00
Maciej Suminski 21c8b8ca5a vpi: Added $ivl_string_method$to_vec for strings to vectors conversion. 2014-11-27 17:36:23 +01:00
Maciej Suminski 25c588252f ivl: Added vpiSysFuncVoid to the system function types. 2014-11-27 17:36:23 +01:00
Maciej Suminski 89d1125979 ivl: Bit selection using variables in strings. 2014-11-27 17:36:23 +01:00
Maciej Suminski 43c6a0bacd ivl: Casting to int. 2014-11-27 17:36:23 +01:00
Maciej Suminski 610ca95cbe ivl: Allow to initialize variables with other variables (since Verilog-2001). 2014-11-27 17:36:23 +01:00
Maciej Suminski daa59a95ad ivl: Parsing rules for type casting. 2014-11-27 17:36:23 +01:00
Maciej Suminski 13f861a963 ivl: Added PECastType to handle type casting. 2014-11-27 17:36:23 +01:00
Stephen Williams 82ca4cf641 Add a warning if an expression pads itself to a crazy width. 2014-11-25 14:49:04 -08:00
Cary R ac2e8dd6cd Report that packed arrays can not currently be elaborated in all cases 2014-11-24 19:11:08 -08:00
Cary R cd992b4d5a Add file/line information for parray data type. 2014-11-24 18:37:40 -08:00
Stephen Williams 679021a1b5 Optimize special cases of immediate value extraction. 2014-11-22 10:38:16 -08:00
Stephen Williams f3392561ed Optimize the vvp pad implementation. 2014-11-22 09:59:02 -08:00
Stephen Williams 7a9a022744 Remove some dead code. 2014-11-21 17:36:22 -08:00
Stephen Williams c222b3b6a4 Minor improvements to the %split/vec4 instruction. 2014-11-21 16:51:59 -08:00
Stephen Williams 663c79d4af Add the %cmp/e instructions, and put them to use.
When testing for == and ===, there is no need to also calculate <,
so it makes sense to have a special instruction for these cases.
2014-11-21 16:45:27 -08:00
Stephen Williams bea03db25d Minor vec4 stack manipulation optimizations. 2014-11-21 14:41:31 -08:00
Stephen Williams b96f04ccce Implement the %parti/X instructions
This allows part select with constant base to be handled optimally.
Also update some more instructions to more optimally work with
the vec4 stack.
2014-11-20 18:43:24 -08:00
Stephen Williams a9db765f98 Generate better code for condition expressions. 2014-11-20 14:47:44 -08:00
Stephen Williams c71ab5869a vvp code generator try to generate condition flags directly.
When generating code for a condition expression, i.e. directly
before a %jmp/X statement, try to generate the result into the
flag bit without passing through the vec4 stack. For example, the
%cmpX/X instructions generate results into the flag bits, so it
makes no sense to push these bits into the vec4 stack then pop
them back into the flag bit. So try to handle this case.
2014-11-19 18:32:19 -08:00
Stephen Williams 04bdfbccee Add %cmpi/s and %cmpi/u instructions for performance
These bypass the vec4 stack in some common cases, saving instructions
and vec4 manipulations.

Also, minor improvement to the %flag/set/vec4 statement.

Kill a few warnings.
2014-11-19 16:38:43 -08:00
Stephen Williams 2acc9fbdee Remove dead instructsion %set/qb and %set/qf / Kill some warnings. 2014-11-19 09:15:01 -08:00
Stephen Williams 725ed869ba Remove dead %load/vp0 instructions and related infrastructure
Also remove some &A<> and &PV<> symbols that use this now dead
infrastructure.
2014-11-19 09:02:21 -08:00
Stephen Williams 301edf69d3 Add and use %concati/vec4 and %addi instructions.
Also, clean up some warnings, and optimize some existing opcodes.
2014-11-18 12:27:55 -08:00
Stephen Williams 1612c6d638 Instruction %concat/vec4, %pad/u and %shiftl manipulate stack in place 2014-11-17 16:32:18 -08:00
Stephen Williams aadd67cd3b Some instructions can do stack manipultations in place.
By doing some stack manipulations in place, certain instructions
can eliminate, or optimize, vector copies.
2014-11-14 18:38:15 -08:00
Stephen Williams c2ca9c3b73 Optimize draw_number_vec4 to use %pushi/vec4 zero-padding. 2014-11-14 18:37:10 -08:00
Stephen Williams 0601b4e43b Optimizations for %pushi/vec4 and %load/vec4
- Have %pushi/vec4 handle some special cases optimally.
- Eliminate some duplicated method calls in %load/vec4.
- Optimize the vvp_vector4_t::copy_from_ method by inlining
some parts.
2014-11-14 14:41:04 -08:00
Stephen Williams 8aca66b109 Performance tweaks
Better performance for %cmp/s and the vvp_fun_part_sa node.
2014-11-14 11:48:36 -08:00
Stephen Williams 2aeb3871ed Merge branch 'master' into vec4-stack
This was a challenging merge...
Conflicts:
	elab_scope.cc
	synth2.cc
	tgt-vvp/eval_expr.c
	vvp/vthread.cc
2014-11-13 16:26:15 -08:00
Stephen Williams ea21fb856e Mux with default, handle possible large selector. 2014-11-09 16:49:21 -08:00
Martin Whitaker 754899c99e Make asynchronous case statement synthesis more robust.
Added various error/warning messages for behaviour not supported
in synthesis. Also give correct behaviour when multiple case item
expressions evaluate to the same constant value.
2014-11-09 20:20:03 +00:00
Cary R 4e94b81a4b On a 32 bit system you can print a 32 bit value as a long (verinum) 2014-11-05 14:43:58 -08:00
Cary R 6948c27c2d Enumerations are compatible if their type definitions match. 2014-11-04 15:05:49 -08:00
Cary R 2e9c4cde55 More refined check for enumeration width and constant width 2014-11-04 12:10:38 -08:00
Cary R 2e8c4e3dbc Basic patch from github #44 2014-11-04 11:39:01 -08:00
Cary R cc9fcfd13d Only a literal constant size has to match the enumeration width. 2014-11-03 19:46:10 -08:00
Cary R 4660e0bf2f Another tweak to the enumeration elaboration code 2014-11-02 20:26:36 -08:00
Cary R 1e7509a021 Update enumeration elaboration checks 2014-11-02 11:45:19 -08:00
Martin Whitaker c2e53f0d63 Fix for br963 - vvp qpop instructions need to call thr_check_addr. 2014-11-02 15:36:52 +00:00
Martin Whitaker f171161822 Fix for br962 - pop from dynamic array is not padded to correct width.
When the expression width is greater than the dynamic array width,
we need to generate code to pad the popped value to the correct
width.
2014-11-02 15:26:15 +00:00
Martin Whitaker 0237297e93 Added pruning of case statement expressions.
When unsized literals are used in case item expressions, it is likely
that the calculated expression width will be larger than necessary to
unambiguously select the correct case item (particularly when using
"strict" expression elaboration). This patch adds an optimisation
step that prunes the expressions to the minimum necessary width.
2014-11-02 13:02:57 +00:00
Martin Whitaker e38b5d9fb7 Eliminate unnecessary rerun of test_width in case statement elaboration.
Also fix a typo in a comment.
2014-11-02 13:02:57 +00:00
Stephen Williams d5123011b3 Merge branch 'master' into vec4-stack
Conflicts:
	elab_scope.cc
2014-11-01 14:57:05 -07:00
Cary R 9a471bd81c Don't crash if there are problems elaborating an enumeration. 2014-10-31 20:08:05 -07:00
Cary R 632e15a55c Catch enumerations with the same name. 2014-10-31 20:06:28 -07:00
Cary R d4313dad75 Merge branch 'master' of github.com:steveicarus/iverilog 2014-10-31 18:09:29 -07:00
Cary R c25538d750 Pass the integer type for enumerations to the IVL target stage 2014-10-31 18:09:19 -07:00
Martin Whitaker 871d447ff7 Reinstate error recovery for range expressions.
If an error is found whilst elaborating a range expression in a signal
declaration, create a dummy range and continue elaboration. This stops
the compiler reporting an error every time that signal is referenced.
2014-10-31 21:42:23 +00:00
Martin Whitaker b286b76134 Fix null pointer dereference in pform debug output. 2014-10-31 18:40:51 +00:00
Cary R 4f62a0d1f2 Check enum trimmed bits for values with undefined bits
If an enumeration constant has undefined bits then we need to verify that
the bits that are trimmed match the MSB of the remaining bits.
2014-10-30 19:54:38 -07:00
Cary R e7df9774aa When comparing that an enumeration is in range cast the value to 2-state
When checking that an enumeration value is in range we need to cast it to
a 2-state value so that when we compare it we get a true or false value
instead of an undefined value. Undefined bits in the comparison return
undefined which is not logically false.
2014-10-30 18:23:47 -07:00
Cary R 08afbde08d Update cppcheck suppression file for tgt-vlog. 2014-10-30 18:23:39 -07:00
Martin Whitaker 7ab0824adf Fix for br961 - function return type elaborated in wrong scope.
The return type of a function should be elaborated in the context of
the enclosing scope, not in the context of the function itself.
2014-10-30 21:09:17 +00:00
Martin Whitaker 7fad4779c5 Add error recovery when elaboration of a type range fails.
If elaboration of the msb or lsb expression in the range of a vector
type specification failed (due to an error in the Verilog code being
compiled), an assertion failure was being triggered when the compiler
attempted to evaluate the expressions. Bypassing the evaluation (and
using a default value) should allow us to recover from the error.
2014-10-30 20:42:12 +00:00
Stephen Williams 8ac06fb63f Support vpiObjTypeVal for vec4Stack values.
Also allow vpi_get_value outside of scope. (Return 'x)
2014-10-25 20:38:39 -07:00
Stephen Williams 4e727adc25 Merge branch 'master' into vec4-stack 2014-10-25 09:49:39 -07:00
Stephen Williams 3e9c14060f lexor handles arbitrary length defines in the precompiled_defiles file. 2014-10-25 09:48:11 -07:00
Stephen Williams 702a8c3a05 Merge branch 'master' into vec4-stack 2014-10-24 15:17:31 -07:00
Stephen Williams 48d3972299 Remove a bunch of dead vvp opcodes. 2014-10-24 15:13:28 -07:00
Stephen Williams 62fce50f8c Remove dead code for allocate_vec handling. 2014-10-24 13:07:53 -07:00
Stephen Williams e4b862f3d1 Clean up vector handling dead code. 2014-10-24 11:17:36 -07:00
Stephen Williams 09d3a5de59 Port %pushv/str to vec4-stack style. 2014-10-24 10:16:35 -07:00
Stephen Williams 97bde47c31 Remove dead %set/dar and %set/dar/obj instructions. 2014-10-24 10:03:22 -07:00
Stephen Williams 1c80c6e37a Remove dead stuff_ok_flags from draw_eval_vec4 functions. 2014-10-24 09:32:32 -07:00
Stephen Williams 4588f7c615 vec4 stack versions of queue pop methods. 2014-10-24 09:03:20 -07:00
Cary R 006aef93d0 Fix a reference to an undefined element. 2014-10-23 16:56:13 -07:00
Stephen Williams 24b8752475 More cases where %store/prop/v takes a width. 2014-10-22 16:15:10 -07:00
Stephen Williams 3ddcf03764 Kill some eval_vec4.c warnings. 2014-10-22 13:01:25 -07:00
Stephen Williams 35f5d51028 Support testing nul for property that is an object. 2014-10-22 12:58:50 -07:00
Stephen Williams 87c019c65c Merge branch 'master' into vec4-stack 2014-10-21 12:19:40 -07:00
Stephen Williams 69a1fecd2e Handle arrays of object is comparison with null. 2014-10-21 11:47:22 -07:00
Stephen Williams 9964d67e5e Implicit crop of vectors assigned to vector properties.
The %store/prop/v takes a width so that it is guaranteed that
all assignments to a vector property will get the size right.
2014-10-21 11:46:59 -07:00
Stephen Williams a98f21aa65 Merge branch 'master' into vec4-stack
Conflicts:
	elab_lval.cc
	netmisc.cc
	tgt-vvp/eval_object.c
	tgt-vvp/vvp_process.c
	vvp/codes.h
	vvp/compile.cc
	vvp/opcodes.txt
	vvp/vpi_tasks.cc
	vvp/vpi_vthr_vector.cc
	vvp/vthread.cc
2014-10-21 09:12:02 -07:00
Cary R a63ca15735 Add support for putting a single delay from the VPI 2014-10-18 18:27:39 -07:00
Stephen Williams d139142c29 Merge pull request #47 from orsonmmz/concat
Expression concatenation in VHDL
2014-10-18 15:13:50 -07:00
Cary R af85d44d9f Add support for putting three and six delays from the VPI 2014-10-17 20:06:01 -07:00
Cary R c5e0507941 Fix the modpath edge and vpi_put_delay() code
The code to get the correct modpath delay for a given edge had the X and Z
entries swapped.

When putting a delay from the VPI the 2 delay to twelve delay mapping was
incorrect and the to/from X delays were also not being calculated correctly.
2014-10-17 19:42:55 -07:00
Maciej Suminski c55a013162 vhdlpp: Support for integer() function.
Note: I could not find any info about the integer() function, but it is
used in the VHDL standard packages (e.g. math_real, see:
http://www.csee.umbc.edu/portal/help/VHDL/packages/mathpack.vhd)
Real numbers are rounded, this is compatible with ModelSim behavior.
2014-10-17 14:53:59 +02:00
Maciej Suminski dfbca0b186 vhdlpp: Emit use_types in Architecture. 2014-10-17 14:13:06 +02:00
Maciej Suminski 4a779f43bd vhdlpp: Fix error message for 'right attribute. 2014-10-17 14:13:06 +02:00
Maciej Suminski 97df6183a9 vhdlpp: Emit '-' std_logic value as 'x'.
Note: It is not a direct ("don't care" vs "unknown"), but I could not
find anything that suits better.
2014-10-17 14:13:06 +02:00
Maciej Suminski 95faed8e9d vhdlpp: Added basic support for concatenated expressions. 2014-10-15 10:51:21 +02:00
Maciej Suminski 76aab15798 vhdlpp: Minor code cleaning. 2014-10-15 10:51:21 +02:00
Cary R e896f0c8e6 Remove some compile warnings in the vhdlpp code 2014-10-14 09:03:42 -07:00
Cary R f36bebf0e1 Remove some compile warnings. 2014-10-13 16:31:53 -07:00
Cary R 3fd622e4eb vlog95: Add support for emitting global tasks and functions 2014-10-13 09:51:55 -07:00
Cary R da4200c5bd Update lz4 files to the latest from GTKWave 2014-10-13 09:44:57 -07:00
Stephen Williams 712f394224 Elaborate classes in packages. 2014-10-10 18:53:53 -07:00
Stephen Williams d6685f40a1 Merge pull request #46 from orsonmmz/range
VHDL attributes: 'range, 'reverse_range, 'left & 'right
2014-10-10 17:23:59 -07:00
Maciej Suminski 9ff9cbf4aa vhdlpp: Smarter determining the direction in for loops. 2014-10-10 18:39:14 +02:00
Maciej Suminski a992f3ce7c vhdlpp: Evaluation for 'left and 'right attributes. 2014-10-10 18:35:17 +02:00
Maciej Suminski 1a4edcac48 vvp: Accepts continuous assignment for 2-state nets. 2014-10-10 16:16:46 +02:00
Maciej Suminski 8cac72192f vhdlpp: Fix array typedefs in packages. 2014-10-09 10:37:33 +02:00
Maciej Suminski 7f6100be2a vhdlpp: Emit VHDL 'integer' as SystemVerilog 'int'. 2014-10-09 10:29:14 +02:00
Maciej Suminski 4b60d2737e vhdlpp: Skip signed & unsigned in types dump in packages. 2014-10-09 10:28:35 +02:00
Maciej Suminski c7beef907d vhdlpp: Support for 'range and 'reverse_range attributes. 2014-10-08 11:18:06 +02:00
Maciej Suminski 44da7de651 vhdlpp: prange_t may have the direction determined automatically. 2014-10-08 10:26:37 +02:00
Maciej Suminski 6887c82540 vhdlpp: Added ExpAttribute::write_to_stream(). 2014-10-08 10:21:03 +02:00
Maciej Suminski 1333bc54a2 vhdlpp: Support for 'left & 'right attributes. 2014-10-08 10:05:04 +02:00
Maciej Suminski fddb3ec129 vhdlpp: ForLoopStatement emits range boundaries expressions instead of evaluating them.
Unfortunately without evaluation it is not possible to warn against
degenerated loops, so it had to be removed.
2014-10-07 14:25:00 +02:00
Stephen Williams bfafd175fa Fix parse.y bad handling of file names in some situations.
The YYLLOC_DEFAULT() macro needs to get the .text value even
when the rules are empty.
2014-10-02 19:42:48 -07:00
Stephen Williams 23238aa7ac Handle functions in $root scope. 2014-10-02 15:04:14 -07:00
Stephen Williams 2397aa1587 Merge pull request #45 from orsonmmz/subprogram
Subprograms
2014-10-02 14:14:52 -07:00
Stephen Williams b4119de9b1 Merge branch 'master' of github.com:steveicarus/iverilog 2014-10-02 14:10:10 -07:00
Stephen Williams 338a0eb11a Get $root scope tasks/fuctions down to the ivl_target API. 2014-10-02 14:09:27 -07:00
Maciej Suminski fde6525acb vhdlpp: Libraries are searched for subprograms during the ExpFunc elaboration. 2014-10-01 14:56:32 +02:00
Stephen Williams c5fee8bdb9 Elaborate root tasks/functions. 2014-09-30 16:06:32 -07:00
Maciej Suminski 194a950f8d vhdlpp: Elaboration of ExpFunc parameters fallbacks to the types given in the Subprogram header. 2014-09-30 15:59:46 +02:00
Maciej Suminski 9951521212 vhdlpp: Subprogram parameters are taken into account when distinguishing between function calls and vector elements. 2014-09-30 15:59:46 +02:00
Maciej Suminski 9e856810b9 vhdlpp: Workaround to avoid translation of variables to wires in functions. 2014-09-30 15:59:45 +02:00
Maciej Suminski 675b7d8efa vhdlpp: Support for std_logic_vector return type in functions.
VHDL does not allow to specify the size of returned std_logic_vector,
whereas Verilog requires the size to be known in advance. The size of
the vector is determined by checking the type of expression used in the
return statement.
2014-09-30 15:58:26 +02:00
Maciej Suminski e352bea476 vhdlpp: Support for variable declarations in subprograms.
Fixes sorrymsg: "variable_declaration not supported."
2014-09-30 15:58:13 +02:00
Maciej Suminski 747e656a0e vhdlpp: Added ScopeBase::transfer_from() method. 2014-09-30 15:00:55 +02:00
Maciej Suminski 7b5470c8a7 vhdlpp: Subprogram class inherits from ScopeBase. 2014-09-30 15:00:55 +02:00
Cary R 985a3eb206 Update lz4 files to the latest from GTKWave 2014-09-26 15:04:55 -07:00
Stephen Williams e1ec27e18c Merge pull request #43 from orsonmmz/record_elab
Elaboration & emit functions for aggregate expressions used as record initializers.
2014-09-18 12:59:28 -07:00
Stephen Williams d13e488f4c Merge pull request #42 from orsonmmz/const_package
Enable constant initializers that require elaboration in packages.
2014-09-18 12:58:19 -07:00
Maciej Suminski f5dd2ac87e vhdlpp: Aggregate expressions for records can be specified in any order. 2014-09-17 16:32:56 +02:00
Maciej Suminski 94abef195a vhdlpp: Commented out named assignment for records. 2014-09-17 16:30:44 +02:00
Maciej Suminski 54696e0127 vhdlpp: Elaboration & emit support for aggregate initializer expressions in records. 2014-09-17 11:24:16 +02:00
Cary R d85096c56a Add support for implict this in class methods 2014-09-16 17:08:57 -07:00
Cary R d16a9dcfc6 Add support for calling a class function method using this/super
Also standardize the parser code that uses this/super.
2014-09-16 12:25:14 -07:00
Maciej Suminski 9842035d89 vhdlpp: Simplified the initalization for signals/variables. 2014-09-16 16:31:18 +02:00
Stephen Williams 480668fee6 Add support for classes defined in $root scope. 2014-09-15 17:37:30 -07:00
Stephen Williams fa21527e9f Classes in $root scope up to elaboration. 2014-09-15 17:37:30 -07:00
Stephen Williams 98799ff7fa Allow class properties to be arrayed.
This adds the runtime support for class properties that are classes
to be arrayed. Add a means to define the dimensions of a property
in the vvp format, and add functions for setting/extracting elements
of a property.
2014-09-15 17:37:30 -07:00
Stephen Williams ea4b000be6 Get arrayed property expressions down to the ivl_target API. 2014-09-15 17:37:30 -07:00
Maciej Suminski e330a0bd6e vhdlpp: Corrected VTypeArray::write_to_stream().
Now it outputs "typedef(range)" instead of "array (range) of type".
2014-09-15 12:10:05 +02:00
Maciej Suminski cb03802a17 vhdlpp: Added VTypeArray::basic_type() to cope with
arrays based on typedefs.
2014-09-15 12:10:05 +02:00
Maciej Suminski 22d18cb28d vhdlpp: Typedefs in packages are emitted before constants. 2014-09-15 12:10:04 +02:00
Maciej Suminski c98c3e5d14 vhdlpp: Inlined a few functions. 2014-09-15 12:10:04 +02:00
Maciej Suminski a63289c2fc vhdlpp: VTypeArray::range_t handles direction (to/downto). 2014-09-15 12:10:04 +02:00
Maciej Suminski 251b75003f vhdlpp: Skip writing '=>' for ExpAggregates if there are no fields specified. 2014-09-15 12:10:04 +02:00
Maciej Suminski 01b4d49d4a vhdlpp: Do not emit constants from packages.
They are elaborated and emitted by architectures that make use of packages.
2014-09-15 12:10:04 +02:00
Maciej Suminski f851fc6981 vhdlpp: Fixed ExpAggregate::write_to_stream(). 2014-09-15 12:10:04 +02:00
Maciej Suminski a25cde3bc7 vhdlpp: Added ExpString::write_to_stream(). 2014-09-15 12:10:04 +02:00
Maciej Suminski 51b121ae7a vhdlpp: Added ExpBitString::write_to_stream(). 2014-09-15 12:10:04 +02:00
Maciej Suminski 94caa4881e vhdlpp: Added VTypeEnum::write_to_stream(). 2014-09-15 12:10:04 +02:00
Maciej Suminski ef7ac5ed03 vhdlpp: Elaborate all types of initializing expressions. 2014-09-15 12:10:04 +02:00
Cary R acce9fc2a0 Report that external class methods/constructors are not supported 2014-09-11 16:35:24 -07:00
Cary R 1cfbd2db63 Fix some cppcheck warnings. 2014-09-10 18:54:01 -07:00
Stephen Williams 853512868b Merge branch 'x-mil15' 2014-09-08 21:10:14 -07:00
Cary R 9b1de4b038 Call IEEE 1800 SystemVerilog 2014-09-08 20:49:40 -07:00
Cary R ec2793c9b0 Warn that classes defined in the compilation unit scope are not supported 2014-09-08 16:59:18 -07:00
Stephen Williams 697701a26e Sorry messages for property arrays. 2014-09-07 17:48:19 -07:00
Stephen Williams facc982af4 Ability to compare arbitrary class-valued expression to nil. 2014-09-07 16:22:49 -07:00
Stephen Williams 8bb1d3dabe Emit class definitions after ALL scopes are scanned. 2014-09-06 17:39:52 -07:00
Stephen Williams 88e951418b Handle elaboration of class properties referenced within sub-scopes. 2014-09-06 16:26:08 -07:00
Cary R 1572dcd3fd Add a couple missing va_end() calls 2014-09-05 15:40:23 -07:00
Cary R 96d793ed6b vlog95: switch to C99 real number classification routines 2014-09-05 15:18:13 -07:00
Stephen Williams 15ccd8f4c9 Handle foreach array name as class property. 2014-09-04 20:52:51 -07:00
Stephen Williams d1a35d5152 Handle nil queue as a was to delete a queue.
Treat this like assigning null to a dynamic array. This deletes the
queue and thus has the effect of clearing it.
2014-09-02 12:19:58 -07:00
Stephen Williams 3b0dfaadba Some support for unpacked arrays in class properties. 2014-09-02 09:23:54 -07:00
Stephen Williams 1465fd1570 Class definitions may reference class types in containing scopes.
We need the scope where the class is defined so that it can find
types in that containing scope. Note that most definitions cannot
escape into the the lexical scope of the class, but some can.
2014-09-02 09:22:41 -07:00
Stephen Williams 886b6cd349 Debug messages. 2014-08-30 10:18:57 -07:00
Stephen Williams 0dc28c0fc3 Fix the %qpop/f instruction detection. 2014-08-30 10:18:57 -07:00
Stephen Williams dec4cd5071 Handle arrays of class objects.
This goes all the way down to the vvp level, where we create support
for arrays of objects, generate the new code in the -tvvp code
generator, and elaborate the arrays in the first place.
2014-08-30 10:18:57 -07:00
Stephen Williams 0cd6fbaf41 foreach loops around static arrays
Arrays with static dimensions can be handled specially.
This also allows for arbitrary numbers of dimensions.
2014-08-30 10:18:57 -07:00
Stephen Williams 9fa764285a foreach multiple indices through the pform. 2014-08-30 10:18:57 -07:00
Stephen Williams fe8e7a6261 Merge pull request #39 from orsonmmz/testenum_fix
Fixed enum typedefs.
2014-08-29 21:06:20 -07:00
Cary R a0ea7e17cf Packages can contain enum definitions so emit them in the pform. 2014-08-28 17:01:30 -07:00
Cary R 8c3f7d78b9 Partial fix for br956 (various enumeration bugs)
This patch fixes the following enumeration bugs:

When looking for an enumeration look in the current scope and then
recursively in any parent scope.

Add enumeration definitions to a package scope.
2014-08-28 13:02:42 -07:00
Maciej Suminski 684c2fe19e Fixed enum typedefs. 2014-08-28 11:04:25 +02:00
Maciej Suminski a67f18f8ef ivl: Do not delete range objects right after setting range for a net. 2014-08-28 10:02:56 +02:00
Cary R 931039761a Don't try to print the vector size if it is empty (a single bit) 2014-08-27 17:54:46 -07:00
Stephen Williams 3852545f21 Merge pull request #38 from orsonmmz/unbounded_array
Support for VHDL unbounded arrays.
2014-08-27 09:15:28 -07:00
Cary R b4d0c43a96 Remove some compile warnings. 2014-08-25 18:24:58 -07:00
Cary R c24c26725e A method call needs to ignore a single NULL argument from the parser
The parser always passes a single NULL argument for system tasks. For a
method call which will add a signal to call the method on we need to
ignore this NULL argument.
2014-08-25 18:06:08 -07:00
Cary R 1269c12054 vlog95: Handle a system task with a NULL last argument 2014-08-25 18:06:01 -07:00
Cary R 4fb91ec7c7 vlog95: Add SV queue specific error message and code generation. 2014-08-25 16:41:08 -07:00
Martin Whitaker e5f49baaac Fix for GitHub issue #37 - bug in expression width pruning.
If an expression contains a division, remainder, or right shift operation,
set the expression min_width to UINT_MAX to flag that the expression width
cannot be pruned. Using UINT_MAX ensures that the min_width won't change
as we continue to elaborate the expression.
2014-08-25 20:27:22 +01:00
Maciej Suminski 0f728b9150 vhdlpp: Minor cleaning, fixed copyright notices. 2014-08-25 17:29:35 +02:00
Maciej Suminski b0c79d5d1c vhdlpp: Added VType::emit_name() that skips emission of a name if it is empty (otherwise '\' is outputted). 2014-08-25 17:05:15 +02:00
Maciej Suminski 150fe088a6 vhdlpp: VTypeRecord is marked as acceptable in packed arrays. VTypeDef is accepted depending on the base type. 2014-08-25 16:56:46 +02:00
Maciej Suminski bb66ed8b9d vhdlpp: "integer" is emitted as "bool[31:0" but is marked as accepted to be used in packed arrays. 2014-08-25 16:51:35 +02:00
Cary R 447e402d16 Require a space between the synthesis and translate_* key words 2014-08-22 16:55:47 +02:00
Martin Whitaker 86bb269d47 Fix for GitHub issue #33 - Problem with multi-dimensional arrays.
normalize_variable_unpacked() was not correctly calculating the
minimum expression width required to calculate the canonical
index.
2014-08-22 16:55:47 +02:00
Stephen Williams 486dc7abeb Do a better job with synthesis translate pragmas. 2014-08-22 16:55:47 +02:00
Cary R 6765e32ab9 Add message that L-value concatenation is not supported in synthesis 2014-08-22 16:55:47 +02:00
Maciej Suminski b1d15436fd Removed ExpReal::evaluate().Its signature does not match the one meant to be overridden. 2014-08-22 16:55:47 +02:00
Maciej Suminski c846b2cf3f vhdlpp: 'integer' is emitted as 'integer' instead of 'bool [31:0]'. 2014-08-22 16:45:17 +02:00
Maciej Suminski 10446df80e vhdlpp: Invert range in ExpAggregate when necessary. 2014-08-22 16:23:22 +02:00
Maciej Suminski 0a2100c87f vhdlpp: Turn on the reg_flag for types that cannot be packed. 2014-08-22 16:22:59 +02:00
Maciej Suminski 27730395ca vhdlpp: Type of an array is selected depending on the element type. 2014-08-22 10:49:55 +02:00
Maciej Suminski 8e9c25a23e vhdlpp: Added 'packed' property for VTypes.
It detetermines if a type can be used as the base type of a packed array.
2014-08-22 10:45:02 +02:00
Maciej Suminski feccae56bf libmisc: Added empty_perm_string. 2014-08-22 10:42:51 +02:00
Stephen Williams 5de83906f7 Sorry message for multi-dimension foreach loop indices. 2014-08-21 20:34:55 -07:00
Stephen Williams 8b969202c0 Clean up some bugs introduced by recent patches. 2014-08-21 20:21:23 -07:00
Stephen Williams ea5789e4d9 Implement $low() for certain types. 2014-08-21 16:44:46 -07:00
Stephen Williams f602ae84ab Elaborate foreach loops as synthetic for loops.
Create an implicit scope to hold the index variable, and
generate a for loop to perform the functionality of the
foreach.
2014-08-21 16:44:46 -07:00
Stephen Williams 335db49282 Add vvp implementations for pop_back and pop_front methods. 2014-08-21 16:44:46 -07:00
Stephen Williams 8c2d51142b Elaborate pop_back/pop_front methods on dynamic arrays. 2014-08-21 16:44:46 -07:00
Stephen Williams 5ee253b03b Fix mis-spelled vpiStatisARray in sv_vpi_user.h header file 2014-08-21 16:44:46 -07:00
Stephen Williams c9ff48bd4e Add support for dynamic array/queue "last" index ($)
Internally, treat the "$" as a special expression type that takes
as an argument the signal that is being indexed. In the vvp target,
use the $last system function to implement this.
2014-08-21 16:44:45 -07:00
Stephen Williams 9b4681918b Array access to queue variables. 2014-08-21 16:44:45 -07:00
Stephen Williams 0894bc6409 Non-synthesis version of the devel-stub.sh by default. 2014-08-21 16:44:45 -07:00
Stephen Williams da63ef02d4 Implement the size method for queues.
This works by translating it to a $size() system function call.
The $size function is already implemented for dynamic queues and
it is easy enough to expand it for queues.
2014-08-21 16:44:45 -07:00
Stephen Williams a730572e37 Elaborate size method of darray/queue objects. 2014-08-21 16:44:45 -07:00
Stephen Williams d891285326 vvp code generation for push_back/push_front for queue objects. 2014-08-21 16:44:45 -07:00
Stephen Williams e8b8fcba57 Support declaring queue variables all the way to vvp.
Nothing actually useful happens here, but the declarations
are functional.
2014-08-21 16:44:45 -07:00
Stephen Williams 6d052d4ff7 Handle queue types and expressions at pform level. 2014-08-21 16:44:45 -07:00
Maciej Suminski 72ff9ac00b vhdlpp: Aggregate expression are elaborated if
they are used for Signal/Variable initalization.
2014-08-20 14:18:16 +02:00
Maciej Suminski c92dea77fc vhdlpp: Basic support for unbounded array types.
Once a signal/variable of unbounded array type becomes limited in its size, it
is emitted as a packed array. Therefore currently it works only for
bit/logic/reg/wire types.
2014-08-15 10:21:45 +02:00
Cary R 4ea512c4fd Require a space between the synthesis and translate_* key words 2014-08-11 15:05:03 -07:00
Martin Whitaker 89f1344288 Fix for GitHub issue #33 - Problem with multi-dimensional arrays.
normalize_variable_unpacked() was not correctly calculating the
minimum expression width required to calculate the canonical
index.
2014-08-11 20:23:29 +01:00
Stephen Williams 96414af721 Merge branch 'master' of github.com:steveicarus/iverilog 2014-08-09 08:04:46 -07:00
Stephen Williams 2d2a720ea8 Do a better job with synthesis translate pragmas. 2014-08-09 08:04:25 -07:00
Maciej Suminski 9031f392ba Convert string to bitstring in SigVarBase
constructor if applicable (vhdlpp).
2014-08-08 11:20:07 +02:00
Maciej Suminski 4786f80b0b Add the string terminator for binary bitstrings. 2014-08-08 09:52:57 +02:00
Cary R 0f294cb607 Merge branch 'master' of github.com:steveicarus/iverilog 2014-08-07 16:26:26 -07:00
Cary R f4c88b4a01 Add message that L-value concatenation is not supported in synthesis 2014-08-07 16:26:08 -07:00
Stephen Williams 374948ce1b Merge pull request #35 from orsonmmz/real
Removed ExpReal::evaluate().
2014-08-07 08:47:27 -07:00
Maciej Suminski 6a2b579fb0 Removed ExpReal::evaluate().Its signature does not match the one meant to be overridden. 2014-08-07 09:48:35 +02:00
Maciej Suminski d2ad7a4d28 Increase the output precision for floating point types. 2014-08-06 17:04:52 +02:00
Maciej Suminski 5830ecd67e Avoid freeing the primitive types classes. 2014-08-06 15:01:59 +02:00
Maciej Suminski 69b145e216 Minor cleaning for valgrind output. 2014-08-06 15:01:28 +02:00
Maciej Suminski 5ed60a151f Added support for real type in vhdlpp. 2014-08-06 15:00:35 +02:00
Stephen Williams c7a36722e3 Merge branch 'master' of github.com:steveicarus/iverilog 2014-08-04 20:38:33 -07:00
Maciej Suminski 66d31b02be Fixed vhdlpp segfault if it processes an entity without any ports declared. 2014-08-04 20:27:21 -07:00
Cary R 0a6d75f1db Fix some cppcheck warnings (format string vs argument mismatches) 2014-08-01 18:55:44 -07:00
Stephen Williams 6a2956c672 Prepare snapshot 20140801 2014-08-01 14:07:30 -07:00
Stephen Williams cdb1ea6264 Don't bother with cpp-precomp flag on OS/X. 2014-08-01 11:18:51 -07:00
Cary R df1d0a7b47 Enable signed compare warning in the C code since it is now clean. 2014-07-31 12:26:15 -07:00
Cary R 8d9ac35202 Update lz4 files to latest from GTKWave 2014-07-28 14:04:05 -07:00
Cary R 945584c310 Fix memory leak in VAMS $simparam$str call. 2014-07-28 10:46:23 -07:00
Cary R d6b6b76015 Update header files to use a more standard name to prevent rereading
This is from github report #16. There are likely a few more issues
that need to be addressed though this takes care of the major ones.
2014-07-23 13:42:56 -07:00
Cary R 0cbd6d99af SV: Add support for var decls in unnamed fork/join* blocks.
SystemVerilog allows variables to be declared in unnamed fork/join*
blocks. This patch adds support for this functionality.
2014-07-23 09:54:19 -07:00
Cary R 8e7e3c7493 Remove space issue 2014-07-22 18:59:58 -07:00
Cary R 588409389e SV: Add support for var decls in unnamed begin/end blocks.
SystemVerilog allows variables to be declared in unnamed begin/end
blocks. This patch adds support for this functionality.
2014-07-22 18:58:23 -07:00
Stephen Williams cc9d5f90e0 Merge branch 'master' of github.com:steveicarus/iverilog 2014-07-19 17:29:21 -07:00
Stephen Williams 714795709c Handle casez without default case.
casez statements without default cases can get their input from
the context. This handles that situation properly.
2014-07-19 17:22:33 -07:00
Stephen Williams 7b10570e11 Synthesis handle blocks of FF with unique CE
Like this:
  ... if (ce0) foo <= foo_in;
  ... if (ce1) bar <= bar_in;
Note that this is within a block, and represents multiple FF nodes
with different clock enables.
2014-07-19 15:17:53 -07:00
Stephen Williams cb381b3ee3 More robust Nexus::name() method.
This version handles some error conditions.
2014-07-18 20:16:17 -07:00
Cary R f5e01081d1 vlog95: Report that substitute LPMS are not translated 2014-07-17 17:35:09 -07:00
Cary R 9c5113194d Update LXT2 and FST files to latest from GTKWave 2014-07-17 16:17:22 -07:00
Stephen Williams 6bc3f98e0a Sizer target should ignore IVL_LPM_SUBSTITUTE devices. 2014-07-17 09:21:40 -07:00
Stephen Williams b99b4b0223 Trivial fix to main getopt string. 2014-07-17 08:17:55 -07:00
Stephen Williams fa38a8e08d Merge branch 'x-sizer6' 2014-07-17 08:17:05 -07:00
Stephen Williams 14f597acdd Add support for synthesis translate meta-comments. 2014-07-15 18:03:40 -07:00
Stephen Williams b991a991a7 Implement vpi_handle(vpiLeft/RightRange, ...) for signals.
This returns a constant object that can be treated like an
expression, so following the letter of the LRM.
2014-07-14 17:15:16 -07:00
Stephen Williams 515137c8c7 Imlement vpi_handle(vpiScope, 0) for NULL handles
This is not part of the standard, but it convenient, and may be
used by the libveriuser to implement some bits of PLI1.
2014-07-14 17:15:16 -07:00
Stephen Williams d26a081cbc Only get the vpiSysTfCall in getsimtime.c when needed. 2014-07-14 17:15:16 -07:00
Stephen Williams dff9953bc2 Implement the ivl_do_not_elide property 2014-07-14 17:15:16 -07:00
Stephen Williams d8f10e7aa2 Improbe vvp support for wide mux devices. 2014-07-14 16:46:58 -07:00
Stephen Williams d5fb0f4344 Handle some tricky conditions assignments to parts.
When for example assigning to foo[<x>] within a contitional, and
doing synthesis, we need to create a NetSubstitute device to manage
the l-value bit selects.
2014-07-14 16:46:58 -07:00
Stephen Williams c1e533d484 Add some debug convenience functions. 2014-07-14 16:46:57 -07:00
Cary R 58ec35a6af All the unused warnings are fixed so stop blocking that warning 2014-07-10 19:12:07 -07:00
Larry Doolittle ae6743cf69 Easy changes for -Wmissing-prototypes 2014-07-10 14:07:30 -07:00
Larry Doolittle 850d8c3ee9 Eliminate a few more easy warnings
Testing with 32-bit clang 3.3, with additional compiler flags
 -Wsign-compare -Wundef
this patch eliminates the following warnings:

config.h:100:6: warning: 'UINT64_T_AND_ULONG_SAME' is not defined, evaluates to 0 [-Wundef]
vcd_priv2.cc:233:12: warning: duplicate 'extern' declaration specifier [-Wduplicate-decl-specifier]
parse.cc:6496:9: warning: comparison of 0 <= unsigned expression is always true [-Wtautological-compare]
parse.cc:6499:13: warning: comparison of 0 <= unsigned expression is always true [-Wtautological-compare]
parse.cc:6502:9: warning: comparison of 0 <= unsigned expression is always true [-Wtautological-compare]
parse.cc:6510:53: warning: comparison of integers of different signs: 'const unsigned int' and 'int' [-Wsign-compare]

Changing the vlltype elements from unsigned to int reconciles their
type with the native bison YYLTYPE structure.
2014-07-10 12:30:08 -07:00
Cary R 467e8afc41 Another update of fstapi.c from GTKWave to fix compile warnings. 2014-07-09 16:46:01 -07:00
Cary R f17690ebde Update fst and lxt files to latest from GTKWave also update cppcheck file 2014-07-09 16:13:26 -07:00
Cary R 774d173d69 Remove missing parameter warnings 2014-07-09 14:16:57 -07:00
Cary R 9d99a64bf0 Remove warnings and -Wno-type-limits option since it is not always supported. 2014-07-09 11:04:43 -07:00
Larry Doolittle 00a9c69348 Fully initialize a couple structures
Caused missing-field-initializers warnings from clang, but
surprisingly not from gcc.
2014-07-09 10:28:30 -07:00
Cary R 8f7277a5ab Remove the unused parameter warnings in tgt-vlog 2014-07-09 09:34:44 -07:00
Larry Doolittle e221a8ced9 Rearrange compiler warning flags
Before this patch, WARNING_FLAGS applied to both C and C++,
and WARNING_FLAGS_CXX applied to C++ only.
This patch adds a WARNING_FLAGS_CC that applies to C only.
That change should be generally useful; in particular the C
code is almost ready for -Wstrict-prototypes, which does not
apply to C++.

-Wextra (or -W) used to only apply to C++ via WARNING_FLAGS_CXX.
This patch moves it to WARNING_FLAGS, to apply to both C and C++.
Unfortunately, that triggers a ton of warnings.

For now, cover most of the new warnings up by adding
-Wno-unused -Wno-sign-compare -Wno-type-limits
to WARNING_FLAGS_CC.  In the long run, I want to change the C coding
style, and take off these disable-warning flags.  But those changes
can dribble in as separate commits; this patch is big enough already.

Actually fix a couple missing-field-initializers in libveriuser/veriusertfs.c.
2014-07-09 09:04:17 -07:00
Larry Doolittle a575eeb29d More fussing with C function prototypes
Six more -Wstrict-prototypes updates that I missed on the first pass.
The remaining warnings of this type originate in the lz4 code base.
2014-07-08 16:38:25 -07:00
Cary R 0dc12676f0 Update LXT2 files from GTKWave 2014-07-08 14:14:39 -07:00
Larry Doolittle 6ebb57195b Fuss with C function prototypes
119 formal void parameters added to keep -Wstrict-prototypes happy.
Process found one real missing prototype in vpi/vcd_priv.h:
EXTERN void vcd_names_delete(struct vcd_names_list_s*tab);
8 such warnings left, all in Tony's code
2014-07-08 13:44:11 -07:00
Cary R 78cb0a7876 Add support for power operator in eval_const() 2014-07-07 18:17:45 -07:00
Cary R 47ddb18d54 vlog95: Note that casex (==?) and casez (synthesis) operators are not supported 2014-07-06 17:16:05 -07:00
Cary R 0611135758 Some more cppcheck cleanup/updates 2014-06-29 20:39:40 -07:00
Cary R 0ffd61a835 Remove some cppcheck warnings 2014-06-28 16:56:09 -07:00
Cary R 0728690df2 Fix a few cppcheck warnings. 2014-06-27 18:40:34 -07:00
Martin Whitaker e82bafcb84 Fix for GitHub issue #30 : failed assertion in eval_tree.cc
The root cause was the constant propagation done during elaboration
of a multiply operation, which didn't check for mixed real/logic
expressions.
2014-06-20 20:52:15 +01:00
Cary R 54f4c1147b C99 is now required for C files. 2014-06-17 12:59:57 -07:00
Larry Doolittle 642acb4082 Clean up some more sign-compare issues
The only known problems left are in files imported from gtkwave,
if not for them you could turn on -Wsign-compare.

Assumes c99 for c code, so the scope of for-loop indexes can be made sane.
2014-06-17 12:57:26 -07:00
Cary R 6101044bff Fix gcc compile warning 2014-06-17 10:47:25 -07:00
Stephen Williams c6e44f2da1 Fix argument ordering for synthesized casez compare. 2014-06-16 09:45:03 -07:00
Stephen Williams 3c0a982ab3 More flexible synthesis of DFF with asynchronous set/reset. 2014-06-15 19:10:09 -07:00
Stephen Williams 0f85bf0b9a Basic DFF asynchronous set/reset synthesis support. 2014-06-15 18:22:02 -07:00
Stephen Williams ccce9d9271 Merge branch 'master' into x-sizer5 2014-06-14 19:13:42 -07:00
Cary R 9c79e321ae Spell, etc. fixes 2014-06-14 14:19:46 -07:00
Stephen Williams 6d2fa6e579 case/x/z synthesis with constant case expression.
If the case expression is constant, then the guards probably are
not, and the synthesis should be handled differently.
2014-06-13 18:22:24 -07:00
Stephen Williams f8dc430fe5 Add synthesis support for casez statements.
This generates an EQZ LPM device that carries the case-z-ness to
the code generator.

Also add to the vvp code generator support for the EQZ device so
that the synthesis results can be simulated.

Account for the wildcard devices in the sizer.
2014-06-13 18:01:41 -07:00
Stephen Williams 26f71f2d94 Handle special case of missing condit inputs.
It shouldn't be possible, but sometimes is, that a NetCondit is
missing input nets during async synthesis. Handle this by generating
a place-holder net and printing a warning.
2014-06-12 17:50:44 -07:00
Cary R 7cd3bdb0d0 Add support for a single argument $urandom_range() call 2014-06-12 09:20:45 -07:00
Cary R 81947edaa5 A bit select is not the same as selecting part of a packed array
When adding the ability to select part of a multi-dimensional packed
array the sign and size information for a true bit select was broken.
2014-06-12 09:20:31 -07:00
Cary R 684e46a6c1 Update fstapi.c to latest from GTKWavE (remove some compile warnings) 2014-06-11 17:03:15 -07:00
Cary R 2bc9cb90dd Update fstapi files to latest ones from GTKWave 2014-06-11 08:39:04 -07:00
Larry Doolittle 1e18d43107 Tie up simple loose ends for need_result_buf()
vvp/ is now free of -Wcast-align errors
2014-06-10 12:08:01 -07:00
Larry Doolittle 6a45a0d570 Don't lie to the c++ about some pointer alignment
Second try cleaning up cast-alignment problems surrounding need_result_buf().
Clang gave a bunch of warnings like
vvp/vpi_const.cc:196:34: warning: cast from 'char *' to 'p_vpi_vecval' (aka 't_vpi_vecval *') increases required alignment from 1 to 4 [-Wcast-align]

This version is verbose and changes the prototype for need_result_buf().
But it is semantically (c++) correct, and makes need_result_buf() feel like malloc().
2014-06-10 09:27:49 -07:00
Martin Whitaker 529e029abd Fix for GitHub issue #28 - Insufficient string escaping in vvp script.
" characters in strings must be escaped when the compiler writes a
quoted string to a vvp script. This patch fixes up a few places where
this wasn't being done.
2014-06-09 22:40:26 +01:00
Larry Doolittle 855bf9cfe8 Pick some low-hanging const fruit
Makes more of the code const-correct; there are still plenty of difficult-to-fix const problems left.
No behavior change expected.
2014-06-09 10:47:28 -07:00
Larry Doolittle 35a8485a44 Fix some weird lint found by clang
Small stuff, no behavior change expected.
2014-06-09 10:44:48 -07:00
Cary R 12379ed26a Fix spacing issue. 2014-06-07 18:22:42 -07:00
Cary R 6323e6a0a5 Update files from GTKWave to the latest from SVN. 2014-06-07 18:22:32 -07:00
Stephen Williams 41ff18206a NetCase::synth_async gets a better handle on partly used inputs
Better handle the case where the output for some pins comes from
an earlier assignment. This allows for multiple ways to specify
default outputs for some cases: the default: case and pre-assignment.
2014-06-07 10:53:40 -07:00
Stephen Williams f104ffc133 Merge branch 'master' into x-sizer5 2014-06-02 17:07:02 -07:00
Stephen Williams ded1bd4949 Sanity check to prevent bad code getting through synth2 blending
When conditional ports are blending (by allowing NetPartSelects be
connected together to the outputs) make sure there isn't an accidental
overlap of drivers that invalidates the process.
2014-06-02 15:42:02 -07:00
Stephen Williams 579b59b8eb Sizer recognizes more LPM types. 2014-05-25 19:38:12 -07:00
Stephen Williams ef79f538d5 When making NetCondit objects, handle output part select.
When a mux (NetCondit) is only writing to a part of the output
vector (and using only a part of the inputs) then blend the mux
output with the previous statement output.
2014-05-25 18:33:26 -07:00
Stephen Williams 76883fa18c NetCondit synthesis accounts for smaller l-values
If both conditions of a NetCondit device assign to the same subset
of l-value bits, then generate a smaller NetMux device that only
switches the affected bits.
2014-05-24 20:08:48 -07:00
Martin Whitaker d05abf5ca4 Fix for GitHub issue 26 - compiler crash when module port has no internal net.
The compiler correctly reports an error when a module port has no
associated internal net/reg, but could crash when the module was
instantiated.
2014-05-23 22:36:28 +01:00
Martin Whitaker ff72782ec6 Merge branch 'master' of git://github.com/steveicarus/iverilog 2014-05-23 21:59:01 +01:00
Martin Whitaker d96e8872c1 Fix for GitHub issue 25 - compiler crash when function declared outside module.
This is an error in traditional Verilog and a unsupported feature in
SystemVerilog. Fail gracefully with a suitable error/sorry message.
Do the same for task declarations.
2014-05-23 21:55:46 +01:00
Cary R 6547fdee3d vlog95: for cppcheck the target functions are used by the compiler. 2014-05-21 09:04:49 -07:00
Martin Whitaker b7b77b2e75 Correct fix for GitHub issue 19. 2014-05-20 00:08:03 +01:00
Stephen Williams f16c67d45a synth2 NetForLoop synthesis works a lot like begin/end blocks.
Using the synth_async_block_substatement_ makes the for-loop
synthesis properly handle the chance that there are default
inputs.
2014-05-17 16:58:36 -07:00
Stephen Williams 020e280a98 nodangle functor accounts for NexusSet links
In a design, there may be lingering NexusSet objects, or the
nodangle may itself use NexusSet objects. This creates links,
and this should not confuse the functor.

While we are at it, clean up some handling of events structures.
2014-05-08 15:05:09 -07:00
Stephen Williams 109c5d895d Synthesis of assignment that is part of larger block.
It is possible for an assignment statement to be part of a
grander complex that has lots of outputs, not all handled
by this particular assignment. In that case, the assignment
may need to figure out which output it is supposed to bind to.
2014-05-08 15:05:08 -07:00
Stephen Williams ce864fc634 Synthesis of NetForLoop step that ahs compressed assignment operators. 2014-05-08 15:05:08 -07:00
Stephen Williams be0c61051d Add synthesis of for-loops
This required keeping for-loops as actual things through the
netlist form so that the synthesizer can get at and understand
the parts of the for-loop. This may improve vvp code generation
in the future, but for now continue to present to the vvp code
generation the block-while form.
2014-05-08 15:05:08 -07:00
Stephen Williams ec0c66ff25 Fix internal error elaborating types used in different scopes
Some types, i.e. vector types with parameterized dimensions,
may have different elaboration results in different scopes.
Handle those cases in the elaboration caches.
2014-05-08 15:05:08 -07:00
Stephen Williams 5893d13ea3 Don't connect NetFF CE pin if it is not needed
When the clock enable is not generated, don't try to hook it
up then detach it. That will make a mess that needs clean up.
Instead, leave unused ce pins (Enable) unconnected.
2014-05-08 15:05:08 -07:00
Stephen Williams 8d9f3a0920 Fix crashes scanning links.
Signals are collected in a link map that uses the Link class so that
it doesn't need to save Nexus objects. But naked uses of Link don't
set the node_ and pin_zero_ members. So initialize them to zero so
that Nexus scanners can skip these naked Links.
2014-05-08 15:05:08 -07:00
Stephen Williams 17be8e8c7c Handle special case of if inside of block.
If statements within blocks can confuse the synthesizer when there
are outputs that are assigned ahead of the if statement. This patch
handles that case.
2014-05-08 15:05:08 -07:00
Martin Whitaker c32610d135 Further fix for GitHub issue 19 : incorrect handling of large shift values.
Apply the same fix to vvp as was applied to the compiler. See commit
065c48527c for details.
2014-05-04 20:39:05 +01:00
Cary R be8df11217 Update fstapi.c to latest from GTKWave 2014-04-29 14:23:41 -07:00
Cary R 650cedb516 More SDF memory cleanup fixes 2014-04-27 17:57:43 -07:00
Cary R a1d65336d2 Add SDF warning message and release COND and CONDELSE memory 2014-04-27 17:27:10 -07:00
Cary R d6405f86d4 Fix space issue 2014-04-26 20:58:57 -07:00
Cary R 8c80193fc5 Ignore SDF COND and CONDELSE delay definitions. 2014-04-26 20:57:25 -07:00
Cary R e4476d544f Improve SDF warnings to separate name and scope
Some of the SDF warnings were mixing some of the scope path with the
instance name. These are now separated into just scope and instance name.
There was also a place where vpi_get_str() was being called twice in a
single print statement. This is illegal since vpi_get_str() uses a single
buffer and multiple calls will overwrite the buffer.
2014-04-25 13:56:01 -07:00
Cary R c6cbaf3076 Merge branch 'master' of github.com:steveicarus/iverilog 2014-04-17 16:27:22 -07:00
Cary R b687cc5f21 Remove cppcheck warnings in tgt-vvp 2014-04-17 16:26:51 -07:00
Stephen Williams 4d29df17b8 Merge branch 'master' of github.com:steveicarus/iverilog 2014-04-13 16:29:44 -07:00
Stephen Williams fdcb073c14 Fix a variety of bugs in vpi_handle_by_name.
This function was apparently not well tested, because any use of
acc_handle_object() triggered a use of vpi_handle_by_name that was
buggy.

The implementation was awkwardly written, to parts of it were redone.
2014-04-13 16:25:30 -07:00
Cary R 734d56ce25 Remove space issue. 2014-04-10 14:37:07 -07:00
Cary R a5423ce5ce Update FST and related files to match the latest from GTKWave 2014-04-10 14:34:39 -07:00
Cary R e336eca00f vlog95: Report that array ports are not supported. 2014-04-10 14:20:22 -07:00
Stephen Williams 3a77537ed8 Handle scaled time is acc functions for non-scope objects
The tf_igetlongtime function may pass in any kind of object, so the
scale() function may need to convert an object handle to the handle
for the objects parent scope.
2014-04-08 11:11:49 -07:00
Stephen Williams c8b20da4be Merge pull request #21 from toddstrader/master
package imports in module headers
2014-04-07 14:09:50 -07:00
Stephen Williams 97e1151388 Merge branch 'x-mil13' 2014-04-07 11:06:54 -07:00
Stephen Williams e6b394f825 Fix declaration of acc_fetch_paramtype 2014-04-07 09:24:30 -07:00
Stephen Williams f752007e9c Add some minor VPI/ACC fixes and updates
These were submitted.
2014-04-06 15:54:05 -07:00
Stephen Williams 40b36337e2 Fix some bugs with packed array dimensions.
The netparray_t::slice_dimensions bug was the most insidious and
caused all manner of confusion. Also fix some other packed array
and unpacked array (and mixed) indexing calculations.
2014-04-06 08:40:10 -07:00
Stephen Williams df4889ba3d Handle SEL_IDX_UP is some situations. 2014-04-06 08:40:09 -07:00
Stephen Williams 2e2317b7c7 Generalize the hname_t to handle n-dimensional scope arrays.
... Not that they actually exist yet. But this fixes some symbol
search issues and makes room for this support in the future.
2014-04-06 08:40:09 -07:00
Stephen Williams e2bad56a5c Fix overflow calculating packed offset in certain cases. 2014-04-06 08:40:09 -07:00
Stephen Williams 0accab6ec4 Handle non-overlapping assignments to unpacked arrays. 2014-04-06 08:40:09 -07:00
Stephen Williams e55e832ea0 Handle unpacked arrays as output ports. 2014-04-06 08:40:09 -07:00
Stephen Williams fc1f9ac6a5 Handle unpacked arrays as module input ports. 2014-04-06 08:40:09 -07:00
Stephen Williams 6caa41cc93 First pass at support for continuous assign of unpacked net arrays. 2014-04-06 08:40:09 -07:00
Stephen Williams 751f19cc46 Symbolic printout of PortType enumeration values. 2014-04-06 08:40:09 -07:00
Stephen Williams f8e33b12cd Clean up pform_module_define_port in preparation for new tricks.
Get rid of the data_type, signed_flag, and range arguments to the
pform_module_define_port because they add no value within the
parse.y parser. Cleaning these out will hopefully ease the addition
of new functionality.
2014-04-06 08:40:09 -07:00
Stephen Williams aaee9989c2 Handle for_variable_declaration
This can be handled entirely in the parser, where we rewrite the
syntax to me a begin/end block that contains the index variable
declaration and the for loop.
2014-04-06 08:40:08 -07:00
Stephen Williams a849249a86 Allow typedefs to override inherited type names. 2014-04-06 08:40:08 -07:00
Todd Strader ([email protected]) 849ba64cf7 package imports in module headers
See IEEE 1800-2012 A.1.2 module_nonansi_header and module_ansi_header
2014-04-03 20:11:57 -04:00
Cary R bb182cf3ce Update cppcheck suppression file. 2014-03-20 18:27:22 -07:00
Martin Whitaker bc9382eea3 Fix for GitHub issue 20 : confused about signed/unsigned in strange ?: example.
The root cause was that NetESignal::dup_exr() was not copying the calculated
type (signed/unsigned) of the expression.

In passing, found and fixed a similar issue when calculating a blended value
for a constant ternary expression.
2014-03-06 19:35:25 +00:00
Stephen Williams 88e4938074 Merge branch 'master' into vec4-stack 2014-03-04 19:08:56 -08:00
Stephen Williams e932c7a637 Support get of vpiIntVal from vec4 stack. 2014-03-04 19:02:21 -08:00
Stephen Williams b5e0099f28 Fix support for enum literals with undefined values. 2014-03-01 17:45:13 -08:00
Stephen Williams 1afe7476e3 Handle nested l-values in vec4-stack code generator. 2014-03-01 16:49:15 -08:00
Stephen Williams 4068570f43 Fix %pow and %pow/s to properly account for 'x operands. 2014-03-01 16:11:47 -08:00
Martin Whitaker 3e41a93f3e Fix for br948 : user-func call may return incorrect value in a CA context.
%exec_ufunc assumed that because a function can never block, a call to
vthread_run() on the function code would only return when the final %end
instruction had been executed. This is not true if the function contains
a named block, which will be executed via a %fork instruction, allowing
the main function thread to suspend after a %join instruction. The fix
is to break %exec_ufunc into two instructions, the first setting the
function inputs and executing the function code, the second collecting
the function result. This provides the opportunity for the parent thread
to suspend after the %exec_ufunc instruction until all its children have
completed.
2014-03-01 23:38:23 +00:00
Stephen Williams 7ceb18fb37 Merge branch 'master' into vec4-stack
Conflicts:
	netmisc.cc
	tgt-vvp/eval_expr.c
	vvp/vthread.cc
2014-03-01 09:02:14 -08:00
Stephen Williams d2ff77d56c More standard handling of unsized numbers as system task arguments. 2014-03-01 08:38:23 -08:00
Stephen Williams 3c660d04f3 Merge pull request #10 from kiteflyingmonkey/patch-1
Fixed homepage link
2014-02-28 19:50:09 -08:00
Cary R d0d421ebe2 Remove compile warning 2014-02-28 17:29:55 -08:00
Cary R 13c1925045 Fix space issue 2014-02-28 17:19:35 -08:00
Martin Whitaker c61d2151c1 Fix invalid optimisations in tgt-vvp.
The vvp code generator was optimising away adds and subtracts where one
operand was a constant zero. This is not valid for 4-state arithmetic.
It was also optimising away multiplies by a constant zero - but in this
case getting it wrong and effectively multiplying by 1.
2014-02-28 23:29:15 +00:00
Martin Whitaker 065c48527c Fix for GitHub issue 19 : incorrect handling of large shift values.
For shift operations evaluated at compile time, the compiler was converting
the right operand to a native unsigned long value. If the operand exceeded
the size of an unsigned long, excess bits were discarded, which could lead
to an incorrect result.

The fix I've chosen is to add an as_unsigned() function to the verinum class
which returns the maximum unsigned value if the internal verinum value is
wider than the native unsigned type. This then naturally gives the correct
result for shifts, as the verinum bit width is also an unsigned value.

I've changed the as_ulong() and as_ulong64() functions to do likewise, as
this is more likely to either give the correct behaviour or to give some
indication that an overflow has occurred where these functions are used.
2014-02-28 20:39:14 +00:00
Martin Whitaker ed2e339dd6 Fix for GitHub issue #18 : undef propagation of const multiplies is incorrect.
When an expression is elaborated, the compiler converts multiplies with
one constamt zero operand into a constant zero value. This is only valid
if the other operand is not a 4-state variable.
2014-02-27 19:30:28 +00:00
Martin Whitaker 5dcd2e8957 Added width cap for unsized expressions.
Unsized expressions can expand to extremely large widths. Usually this
is actually a mistake in the source code, but it can lead to the compiler
temporarily using extremely large amounts of memory, or in the worst
case, crashing. This adds a cap on the width of unsized expressions (by
default 65536 bits, but overridable by the user), and causes a warning
message to be output when the cap is reached.
2014-02-27 19:20:20 +00:00
Martin Whitaker 1f81d4c081 Fix for br947.
When performing the initial assignment for a procedural continuous
assignment, any previous continuous assignment to the destination
signal must be unlinked first, otherwise the initial value for the
assignment will propagate to any other nets that are driven by the
original source signal.
2014-02-26 08:39:33 +00:00
Martin Whitaker a3450bf856 Fixes for GitHub issues 13 and 15.
The verinum arithmetic operators now observe the standard Verilog
rules for calculating the result width if all operands are sized.
If any operand is unsized, the result is lossless, as before.
They also now all observe the standard rules for handling partially
undefined operands (if any operand bit is 'x', the entire result is
'x').

I've also added the unary '-' operator, and renamed v_not() to be
the unary '~' operator. This has allowed some simplification in
other parts of the compiler.
2014-02-25 20:39:21 +00:00
Stephen Williams 91b7c6ab55 Merge branch 'master' into vec4-stack
Conflicts:
	vvp/vthread.cc
2014-02-21 18:04:16 -08:00
Stephen Williams ebed793dec Merge branch 'master' into vec4-stack
Conflicts:
	vvp/vthread.cc

Signed-off-by: Stephen Williams <[email protected]>
2014-02-21 17:34:59 -08:00
Martin Whitaker 320f6d008c Output sorry message for missing procedural assign/force functionality.
A procedural continuous assignment is supposed to be updated any time
a variable on the RHS changes. Currently this only happens if the RHS
is a simple signal.
2014-02-21 23:02:05 +00:00
Martin Whitaker a76be3571d Fix for br946 - procedural continuous assignment causes vvp internal error.
In the case that the RHS of a procedural continuous assignment is a simple
vector that is wider than the LHS, changes to the RHS vector cause the
entire vector to be sent to port 1 of the LHS vvp_fun_signal object. This
vector needs to be coerced to the size of the LHS. Note that this is a
stopgap fix until vvp handles arbitrary expressions on the RHS of a
procedural continuous assignment.
2014-02-21 22:48:50 +00:00
Martin Whitaker 345c9cf21c Implement correct behaviour for signed vector power operations in vvp.
Signed vector power operations were being implemented using the double
pow() function. This gave inaccurate results when the operands or
result were not exactly representable by a 64-bit floating point number.
2014-02-19 20:11:57 +00:00
Martin Whitaker 5a06602af2 Fix for GitHub issue 14 : Bug in processing 1'b1 >= |1'bx.
During expression evaluation, the compiler attempts to optimise away
relational operations when one side is constant and all possible values
of the other side would result in the relation being true. This is not
a valid optimisation if the other side is a 4-state variable, as an
'x' or 'z' will result in the relation being unknown.
2014-02-18 21:22:19 +00:00
Stephen Williams 830083d99b Merge branch 'x-sizer3' 2014-02-16 17:05:53 -08:00
Stephen Williams 6902bf44e3 Improved error handling in parser around typedefs. 2014-02-16 17:04:52 -08:00
Stephen Williams 8f849a9944 Sorry message for unpacked array module ports. 2014-02-16 15:56:32 -08:00
Stephen Williams b1ef0997ed Merge branch 'x-sizer3' 2014-02-15 15:19:55 -08:00
Martin Whitaker ecce1d25bc Fix for GitHub issue 12 : Ternary lval-rval width mismatch.
A simple typing error that caused the expression to be incorrectly
evaluated as a real constant.
2014-02-15 23:05:41 +00:00
Stephen Williams f43080fbcb Detect proper support for missing else_ without latches (synthesis) 2014-02-15 14:54:58 -08:00
Stephen Williams 463407572f Sizer pay attention to ivl_synthesis_off attribute. 2014-02-15 14:44:55 -08:00
Stephen Williams 6b6574dd8a sizer support for simple LPM MUX devices. 2014-02-15 14:44:15 -08:00
Stephen Williams 4e81939eda Handle asynchronous if-without-else synthesis. 2014-02-15 14:16:22 -08:00
Martin Whitaker 66bdbb77ec Fix for GitHub issue 9 part 2 : Efficiency of the verinum pow() function.
This changes the verinum pow() function to use the more efficient algorithm
used in the vvp runtime. It will still be slow if the left operand is unsized
and the right operand is large, as it will expand the result vector to avoid
overflow.
2014-02-15 22:06:31 +00:00
Martin Whitaker 5853f7d867 Fix for GitHub issue 9 part 1 : Efficiency of vvp_vector2_t::pow() function.
The vvp_vector2_t::pow() function is recursive, and performs a multiplication
operation on each step. The multiplication operator was expanding the result
vector to accomodate the maximum possible result value for the given operand
vectors, thus causing the execution time of the power operation to be
exponentially proportional to the exponent value. Both in this case and
in general, it is unnecessary for the multiplication result vector to be
expanded, as the compiler has already determined the required vector width
during elaboration, and sizes the operand vectors to match.
2014-02-15 21:40:55 +00:00
Martin Whitaker 68f8de28af Fix for GitHub issue 7 : Undef propagation in power operator.
The vvp_vector2_t constructor that takes a vvp_vector4_t value was
documented as creating a NaN value if the supplied vector contained
any X or Z bits, but instead used the standard Verilog 4-state to
2-state conversion semantics (X or Z translate to 0). I've added an
optional second parameter to the constructor to allow the user to
choose which semantics they want, as both are needed.
2014-02-15 13:14:45 +00:00
Martin Whitaker ac3aee0172 Fix for GitHub issue 8 : Signedness of constant binary bitwise operations.
When doing constant evaluation of binary bitwise operations, the result
value must be signed if the expression type is signed.
2014-02-15 11:39:05 +00:00
Martin Whitaker 8135f369a5 Fix for GitHub issue 11 : Syntax error on operator attributes.
Attributes are allowed to be attached to unary, binary, and ternary
operators in expressions. For now just accept and discard them.
2014-02-14 23:29:22 +00:00
Stephen Williams be5bfeb172 Elaborate widths of parameters correctly for unsigned values
If there is no size in the parameter type declaration or on the
value itself, then give the parameter value a minimum width of
integer bits.
2014-02-11 18:24:12 -08:00
Stephen Williams 801e795112 Better job of matching adder operand sizes for vec4 code generator. 2014-02-10 18:06:56 -08:00
Stephen Williams e66fc7e5cc Port UWIRE assignments to vec4 branch. 2014-02-10 17:19:52 -08:00
Stephen Williams 1d63875e5d Merge branch 'master' into vec4-stack
Conflicts:
	elab_lval.cc
2014-02-10 16:26:22 -08:00
Stephen Williams be1130ddbf More robust case statement synthesis
Handle the cases that the case statement carries complet sub-
statements. This is just a generalization of what is already
there.
2014-02-09 17:30:30 -08:00
Stephen Williams 9f2b7d6553 Rearrange counters to me more realistic
Instead of counting gate types, convert to gate count estimates
and some other interesting statistics. Also handling the descent
into child scopes.
2014-02-09 08:59:51 -08:00
Stephen Williams f5041e6c09 Collect some actual sizer statistics. 2014-02-08 18:53:42 -08:00
Stephen Williams 959ac3229e Start a sizer backend. 2014-02-08 10:16:11 -08:00
Stephen Williams 554fb7ebdd Various internal vec4 size mismatches fixed. 2014-02-07 17:50:13 -08:00
Stephen Williams c9e8392dc7 Fix dangling vec4 stack when force assignment is suppressed.
Also improve the %debug/thr instruction.
2014-02-07 16:10:28 -08:00
Stephen Williams 60d37e1f53 More vec4 support for various things. 2014-02-07 11:24:41 -08:00
Colin e0ac4893f0 Fixed homepage link
The link was pointing to a page that said:

This page has been moved to http://iverilog.icarus.com, you will be forwarded there automatically in 3 seconds.
Please update your links.

So now it's updated
2014-02-07 12:22:53 +00:00
Stephen Williams 401fccdf6e vec4 handling of DARRAY of vec4 vectors. 2014-02-06 15:05:26 -08:00
Stephen Williams f5564a195f vec4 versions of compressed assignment statements. 2014-02-06 09:55:25 -08:00
Stephen Williams c7e61f3aa4 Merge branch 'master' into vec4-stack 2014-02-05 15:18:25 -08:00
Stephen Williams a012406ca4 Fix broken search where member names accidentally match variables. 2014-02-03 20:04:24 -08:00
Stephen Williams 52a9fdde8a Handle packed structs as module outputs. 2014-02-03 19:22:59 -08:00
Stephen Williams 4f1c43b690 Account for force l-values that are uwires. 2014-02-02 17:05:42 -08:00
Stephen Williams 7f59c51ca2 Handle proceedural writes to UWIRE objects.
The elaborator allows this only if it determines that the bits
that are procedural written are not also continuously written.
2014-02-02 16:43:48 -08:00
Stephen Williams 0be577cc44 Allow some behavioral assignments to unresolved wires.
If the l-value is an unresolved wire, then elaboration can allow
the assignment as long as it is to bits that are not otherwise
driven. Handle this in some simple cases.
2014-02-02 11:08:43 -08:00
Stephen Williams 49cf5556a2 Fix primitive table lexical analysis.
Sequences of digits in the table of a primitive may be matched
as decimal numbers instead of digits, and this breaks some
primitives.
2014-02-02 10:57:53 -08:00
Stephen Williams 1805598eae Fix some vec4 handling of putc, len, and other string methods. 2014-01-31 19:01:28 -08:00
Stephen Williams 0eca210722 Merge branch 'master' into vec4-stack 2014-01-30 17:07:54 -08:00
Larry Doolittle 3e95966d70 More spelling fixes
Mostly comments
Changs "initilzers" in a string visible with debug_elaborate.
Includes a few British->American changes in the root directory only.
2014-01-30 16:43:17 -08:00
Stephen Williams fdc9e8590d Merge branch 'master' into vec4-stack 2014-01-30 15:59:51 -08:00
Larry Doolittle f76d56beb8 Remove lint detected by clang
With this change, iverilog builds and runs with no extra warnings when using clang 3.0
2014-01-30 15:39:55 -08:00
Larry Doolittle be17bfc0e9 Spelling fixes
Mostly comments.
One user-visible string ("Evalutated to ") changed in the debug_eval_tree case.
2014-01-30 15:34:20 -08:00
Larry Doolittle 77a01f65d0 Remove fixable unused-parameter warnings
I see other warnings within vhdlpp/lexor.cc caused by a flex bug
(see http://sourceforge.net/p/flex/bugs/115/), which I won't try to work around.
2014-01-30 15:34:08 -08:00
Stephen Williams e497f63e29 Implement string compares for vec4 support. 2014-01-28 17:11:21 -08:00
Stephen Williams 75233a9bca vec4 implementation of auto-increment/decrement. 2014-01-28 16:24:26 -08:00
Stephen Williams 11197baf86 The vec4 %cvt/vr requires a <wid> 2014-01-28 15:51:29 -08:00
Stephen Williams 23ba0bc019 various vec4 fixes. 2014-01-25 19:25:21 -08:00
Stephen Williams 9cfb15a302 Implement assign/vec4/off/e 2014-01-23 18:39:29 -08:00
Stephen Williams 607b63a758 Merge pull request #5 from cliffordwolf/master
Added missing support for binary ^~ in eval_tree.cc
2014-01-23 17:12:05 -08:00
Stephen Williams 8bebe59e20 Fix vec4 abs() generating duplicat labels. 2014-01-22 17:15:26 -08:00
Stephen Williams 20d415463a vec4 non-blocking assign to array swapped delay and part offset! 2014-01-21 20:58:48 -08:00
Stephen Williams 9c1dcad994 vec4 vvp support for non-blocking assign with delay and part offset. 2014-01-21 19:37:05 -08:00
Stephen Williams 0e13726e83 fix broken call-out of real-valued system functions. 2014-01-21 13:31:49 -08:00
Stephen Williams 54346d7095 vec4 implementations of real ternary and vec4 to real casts. 2014-01-21 12:02:59 -08:00
Stephen Williams 0121fbc88c Remove useless assert. 2014-01-21 11:05:32 -08:00
Stephen Williams f1855eed0e Fix system function call in net types to get proper vector width.
This means using some of the new vec4 infrastructure to get at the
data, instead of using the old thread bit pointers. In the process,
remove the vbit and vwid members that pointed to thread bits. Those
bits no longer exist.
2014-01-20 19:07:11 -08:00
Stephen Williams 0f9828f179 Fix vec4 overflow of times when they are >32bits. 2014-01-19 14:28:39 -08:00
Stephen Williams d2c2d6d8dc vec4 versions of %cassign/vec4/off and %force/vec4/off send flags[4]. 2014-01-18 17:08:36 -08:00
Stephen Williams f94a655121 Yet again, try to fix vec4 calculation of n-dimensional array index. 2014-01-18 16:04:25 -08:00
Stephen Williams 078a3fd409 Was a little too aggressive with the lossless elab_and_eval
The index expressions ARE self-sized context, we just need to
force the EXPAND flag to make this work.
2014-01-17 18:22:11 -08:00
Stephen Williams dfaed128c0 Fix %store/vec4 overlap of vectors written with extreme indices. 2014-01-15 16:30:34 -08:00
Stephen Williams 1fc4093191 Fix possible overflow in calculation of canonical indices. 2014-01-15 14:26:53 -08:00
Stephen Williams ae1f8be277 Wrap up vpi access to vec4 stack items. 2014-01-14 17:10:03 -08:00
Stephen Williams d8533104b0 Cleanup vec4 handling of suppressed store/assign due to bad offset/index math. 2014-01-14 12:00:39 -08:00
Stephen Williams c6c697bdb7 WRap up vec4 support for system function calls. 2014-01-14 09:22:23 -08:00
Stephen Williams 660d59a7a9 vec4 versions of the %force instructions. 2014-01-13 18:57:03 -08:00
Stephen Williams 92a5e6a698 vec4 based calls to simple real system functions. 2014-01-13 17:46:39 -08:00
Stephen Williams aaa054a932 Fix botched implementations of vec4 based shift. 2014-01-13 17:46:14 -08:00
Stephen Williams 079065ea73 Remove some dead code in tgt-vvp. 2014-01-13 17:45:44 -08:00
Stephen Williams 1905264061 vec4 support for part select of memory word to VPI function. 2014-01-13 16:12:56 -08:00
Stephen Williams b0a9430e98 Wrap up vecc4 support for left/right shift expressions. 2014-01-13 16:11:47 -08:00
Stephen Williams f906384423 Elaborate r-vlaue packed struct members pads as needed. 2014-01-11 19:19:15 -08:00
Stephen Williams fc42f40770 Fix problem with enum types in re-used modules
When a module is instantiated multiple times, the enum
types contained within would cause trouble. This fixes
that by elaborating in proper scope context.
2014-01-11 19:19:15 -08:00
Stephen Williams 6ec31517a9 Implement $bits(type) to get the size of a type
In the process, I implemented a means to get at
previously elaborated types from the pform type
pointer.
2014-01-11 19:19:15 -08:00
Stephen Williams 8a4d769b3d Type name expressions down to elaboration. 2014-01-11 19:19:15 -08:00
Stephen Williams a3b29dd70b Handle enumeration literals that are in $root. 2014-01-11 19:19:14 -08:00
Stephen Williams b0491b9c54 Handle typedefs in $root scope. 2014-01-11 19:19:14 -08:00
Stephen Williams 6a93b6a7e4 Fix some subtle code generator bugs with wide literals and large r-values. 2014-01-07 18:46:35 -08:00
Stephen Williams ec6009dd8f Compile out the T<...> format in vvp.
This ifdef's the code out. Leave it in place for a little longer
for reference.
2014-01-06 20:36:26 -08:00
Stephen Williams 4820d46353 Implement some vpi_get_value formats for vec4 stack values. 2014-01-06 20:27:14 -08:00
Stephen Williams a2845cee70 Update %pow instructions to use vec4 stack. 2014-01-06 10:34:07 -08:00
Stephen Williams c897ca017c Update %div instruction to vec4 version. 2014-01-06 10:14:49 -08:00
Stephen Williams aee540d8bb Fix sort of %event command in vvp compile list.
The sort is important, the names must be sorted because the table is
searched using binary search.
2014-01-06 09:12:42 -08:00
Stephen Williams 19402aeef2 get vpiStringVal from vec4 stack positions. 2014-01-06 08:35:49 -08:00
Stephen Williams fcc0a6a203 vec4 string literal expressions 2014-01-06 08:35:23 -08:00
Clifford Wolf 2165905613 Merge branch 'master' of https://github.com/steveicarus/iverilog 2014-01-05 23:32:49 +01:00
Stephen Williams e5eb754150 vec4 versions of a bunch of unary operators. 2014-01-05 14:12:27 -08:00
Martin Whitaker d1c9dd554b Fix for github issue #6.
When creating a constant zero for implementing a unary minus operation
using a binary subtraction operator, the constant needs to be to exactly
the expression width.
2014-01-05 20:53:58 +00:00
Stephen Williams 063c6d6065 Add the %event instruction, remove %ix/get and %ix/get/s. 2014-01-05 12:39:52 -08:00
Stephen Williams 2fc8ce8a16 Implement vec4 basec %assign delay and event / vpiTimeVal for functions. 2014-01-05 12:04:16 -08:00
Stephen Williams 1a3adbe9cd Vec4 store to memories.
This also reworks the working of the %store/vec4 instruction to
take a part offset, and eliminate the %store/vec4/off instruction.
2014-01-05 10:30:59 -08:00
Stephen Williams 63fa44fa4a vec4 support for ufuncs and ligical AND. 2014-01-05 17:15:30 +00:00
Stephen Williams f89dbd48c8 Add vec4 support for bitwise or/nor/nand/xor/xnor. 2014-01-04 23:48:16 +00:00
Stephen Williams 9fc3e84e93 vec4 cassign to part selects. 2014-01-04 22:58:58 +00:00
Stephen Williams e708a5b59d Handle vec4 part selects / vec4 cassign / repeat statements
These features need to be adapted to the vec4 stack.
2014-01-04 22:11:07 +00:00
Stephen Williams d55e4c0552 Redesign support for system functions that return vec4
Redsign the handling of the return value, including a rework of
the %vpi_func syntax to carry the needed information.

Add a few more arithmetic operator instructions.
2014-01-04 22:06:58 +00:00
Clifford Wolf ef06bf7589 Added missing support for binary ^~ in eval_tree.cc 2013-12-30 11:53:44 +01:00
Stephen Williams 54926840e6 Handle vec4 stack version of concatenation. 2013-12-28 07:50:37 +02:00
Stephen Williams 5ef077fdf6 Start work on converting vec4 expressions to use stack.
Instead of using a bit4 space to hold thread vectors, create a
vec4 stack--much like the real, string, and object stacks--to
hold intermediate values.
2013-12-27 17:04:42 +02:00
Cary R 336b29955d vlog95: a zero width expression is special and is not a self determined context 2013-12-19 20:41:43 -08:00
Cary R 7fa2a4ccf3 vlog95: add support for emitting nested class L-values 2013-12-19 20:40:07 -08:00
Cary R e4fc5806c4 vlog95: spelling fixes 2013-12-19 20:39:58 -08:00
Cary R 4def0110b5 Fix compile warning. 2013-12-19 09:22:16 -08:00
Cary R 503a1bf6d7 Add support for the array querying function in a constant context
This patchs adds support for the $dimensions() and $unpacked_dimensions()
array functions. Since the argument is only used to get the type information
these functions can always be evaluated at compile time.

For the following functions if the dimension argument is constant or omitted
and the first argument is not dynamic (a string or dynamic array) they will
return the specified information.

  $left(), $right(), $high(), $low(), $increment() and $size()

Dynamic information and a variable second argument will be implement in a
future patch.
2013-12-18 19:04:22 -08:00
Cary R 92e4ca3a92 Report that vpi_handle_by_index() is not supported for a vpiNet 2013-12-12 17:10:26 -08:00
Martin Whitaker 9e25884f12 Fix for br942 - allow function declaration in VHDL architecture. 2013-12-11 23:00:58 +00:00
Stephen Williams 819770a6c4 Handle enumerations as packed struct/union members.
There were also some subtleties related to using enumerations
from typedefs and using them in multiple places. Fix various
bugs related to those issues.
2013-12-07 12:20:28 -08:00
Stephen Williams 7669a42cfb Handle some assertion syntax in the parser.
Implement some yacc rules for assertion syntax.

Add the -gassertions/-gno-assertions command-line flags to
enable or disable assertions.
2013-12-07 12:20:28 -08:00
Stephen Williams 0495d75fcb More relaxed handling of types of packed struct members as l-values. 2013-12-07 12:20:28 -08:00
Stephen Williams 0d6c15e45a Handle packed unions properly during elaboration.
This also gets r-value use of packed unions correct.
2013-12-07 12:20:28 -08:00
Stephen Williams 49756a8e7a Unions through pform. 2013-12-07 12:20:28 -08:00
Stephen Williams 0b4056817a Generalize struct member type 2013-12-07 12:20:28 -08:00
Stephen Williams aced587461 Macros with formal arguments can have default text for those arguments. 2013-12-07 12:20:28 -08:00
Cary R 077bd5b7ef Do not return a handle to a port when searching by name
The standard explicitly states that only object with a full name
can be searched for by name. A port does not have a full name and
hence should be skipped so that a different object (the signal,
etc.) can be returned. This patch adds code to skip ports when
searching for an object handle by name.
2013-12-06 18:28:02 -08:00
Cary R bf9781e8fd In tgt-blif the code must be linked with the C++ compiler 2013-12-06 15:09:56 -08:00
Cary R 40840368bb Fix two compile warnings under RHEL-5 with gcc 4.1.2-54 2013-12-04 16:45:43 -08:00
Cary R 5946fa46a6 Fix memory leak in %putc/str/v opcode. 2013-12-04 16:30:36 -08:00
Cary R 196df151aa Correctly cleanup class and string object when using valgrind 2013-12-04 16:28:28 -08:00
Stephen Williams c1566bc02b Merge branch 'master' of github.com:steveicarus/iverilog 2013-12-04 16:22:11 -08:00
Stephen Williams f349197df3 Describe the %putc/str/v vvp opcode. 2013-12-04 16:22:01 -08:00
Cary R 7e55babb62 Fix leaks in the object stack
This patch fixes some leaks in the object stack when getting various
class properties. With this fix an assert can be added to verify that
the object stack is clean when a thread is exiting.
2013-12-03 17:24:42 -08:00
Cary R 5a0f9f4604 Fix CXX variable in tgt-blif/Makefile.in 2013-12-03 10:12:08 -08:00
Cary R ae90da9951 Improve the classs cleanup code when using valgrind 2013-12-03 09:16:24 -08:00
Cary R 9544cb516d Fix some compile warnings 2013-11-24 14:35:44 -08:00
Stephen Williams fa8d35ae9c Support nested l-value objects
This allows for syntax like a.b.c where a is a class with member
b, which is a class with member c, and so on. The handling is mostly
for the support of compound objects like classes.
2013-11-22 19:54:42 -08:00
Stephen Williams 37ac1ed474 Clean up dead code in ivl_lval_t handling. 2013-11-22 12:02:03 -08:00
Stephen Williams 483d0534ae Merge branch 'master' of github.com:steveicarus/iverilog 2013-11-22 10:40:06 -08:00
Stephen Williams be7d763352 Sorry message for union declarations. 2013-11-22 10:39:48 -08:00
Cary R 04bab6b197 Fix a problem with reaping a thread with detached children
When a thread that has detached children is reaped the detached children
need to be fully detached so they can be reaped correctly. If they are not
fully detached then they may reference a parent that has already been
reaped (memory freed). Found with valgrind.
2013-11-20 18:01:35 -08:00
Cary R f47af361cd For default function arguments do not access an out of range real argument.
The code should only look at the real argument that exist any missing
arguments default to not being defined and hence needs to use the
default expression. Found with valgrind.
2013-11-20 16:52:17 -08:00
Cary R 676786a399 Remove compile warning 2013-11-20 11:29:59 -08:00
Stephen Williams 0692cd54e7 Support some simple class initialization assignments. 2013-11-16 17:04:14 -08:00
Stephen Williams 68d83383ff Elaborate nested l-values.
This gets nested l-values to (but just short of) the ivl_target API.
Now the elaborator can process nested l-values, but I haven't figured
out how to present that at the ivl_target.h API.
2013-11-16 16:27:05 -08:00
Stephen Williams 9bd9c8f301 Implement class extends arguments.
This implements constructor arguments right after the base class
name in the class extends syntax.
2013-11-10 18:03:19 -08:00
Stephen Williams f16fd03dab Elaborate PChainConstructor calls.
It is better to leave the handling of PChainConstructor calls to
the elaboration, instead of stripping them out early. This allows
for handling the arguments of the chain constructor in the correct
scope.
2013-11-10 18:03:19 -08:00
Stephen Williams a7d8c983ba Blend initializer statements into any explicit constructor.
If there is an explicit constructor, then blend all the statements
of the implicit constructor into it so that there is only one
constructor function.
2013-11-10 18:03:19 -08:00
Stephen Williams d192f545ac Chain class instance constructors with arguments. 2013-11-10 18:03:19 -08:00
Stephen Williams 0157a156fb Elaborate implicit chaining of constructors in class new. 2013-11-10 18:03:19 -08:00
Stephen Williams 9f83882bcc Parse/elaborate class derivation
This gets us down to working classes, but does not yet implement
calls to the parent constructor, implicitly or explicitly.
2013-11-10 18:03:19 -08:00
Martin Whitaker bfb14fbbc6 Fix memory leak in NetBlock::nex_input(). 2013-10-28 23:08:52 +00:00
Martin Whitaker be2595085f Reorder calls to test_width() on binary operands for efficiency.
It is more common to find an unsized number on the right hand side
of a binary operator than on the left hand side, particularly for
comparison operations (e.g. x < 10 rather than 10 > x), so testing
the width of the right operand first is less likely to result in
the width needing to be retested. Counting the number of times an
operand width is retested when running the test suite confirms this;
before this change an operand width was retested 4869 times, after
the change an operand width was retested 99 times.
2013-10-28 22:55:10 +00:00
Martin Whitaker 4625e7e2b6 Improvements to strict-expr-width mode.
Enable error reporting when an unsized number is used in a concatenation
operand. Allow greater pruning of expressions containing unsized numbers.
2013-10-28 22:07:09 +00:00
Martin Whitaker bb39d09d5e Eliminate spurious error message for array word lval in always @* block. 2013-10-26 23:49:43 +01:00
Martin Whitaker 36c91491cc Make tgt-vvp insert a BUFT for pulldown devices.
A BUFT is needed to allow a force to override the pull value. This had
already been done for pullup devices, so factor out the common code and
use for both pullup and pulldown.
2013-10-26 23:49:43 +01:00
Martin Whitaker d291e2b23d Fix errors in constant propagation.
Ensure undriven, multiply-driven, and forced nets are correctly handled
by the constant propagation optimisation pass.
2013-10-26 23:49:43 +01:00
Martin Whitaker 1814c24a90 Fix pullup/pulldown behaviour for tri1/tri0 nets.
Currently vvp only applies the pullup/pulldown for tri1/tri0 nets when
the net is not driven. The correct behaviour is to treat the pullup/
pulldown as an extra driver (with pull strength).
2013-10-26 23:49:43 +01:00
Cary R 92e08fdcd8 Only calculate the output set for a begin/end block when needed.
For synthesis we remove the output set of signals from the input set to
remove temporaries from the final sensitivity set. The @* construct also
uses the input sensitivity list, but because it can include statements
that cannot be synthesized we should not calculate the output set for this
case. Not find the output set is also a speed enhancement since the output
set was already being ignored later in the code for this case.
2013-10-26 15:34:07 -07:00
Cary R 7875880aa1 Add scope file/line information to the dump file 2013-10-25 15:10:44 -07:00
Cary R 383708fde8 Update FST files to latest from GTKWave 2013-10-25 15:07:00 -07:00
Cary R 4047ed7976 Add support for SV wait fork to the run time. 2013-10-22 16:00:29 -07:00
Cary R 3c7d7a7856 vlog95: Warn that array patterns cannot be converted. 2013-10-22 14:27:26 -07:00
Cary R d7c2118d10 Fix space issue 2013-10-22 09:47:49 -07:00
Cary R 97d06b107f Add support for wait fork to the compiler and code generators 2013-10-22 09:41:03 -07:00
Stephen Williams 61fbfb562e Merge branch 'x-mil11' 2013-10-21 08:55:13 -07:00
Martin Whitaker 7e82a37fa3 Extend -gstrict-expr-width to cover unsized numbers.
To be strictly compliant with the standard and compatible with other
EDA tools, unsized numbers should be treated as having a fixed size
(the same size as an integer). The -gstrict-expr-width option is
extended to allow the user to enable this behaviour.
2013-10-20 23:16:11 +01:00
Martin Whitaker 141a23690e Improved error message. 2013-10-20 23:01:26 +01:00
Martin Whitaker a024efb615 Add -compatible command line option to vvp.
This option is intended to make it easier to compare results from
Icarus with results from other simulators. For now, the only effect
it has is to change the default format for displaying real numbers
when no format string is supplied.
2013-10-20 22:59:53 +01:00
Stephen Williams e60804cf41 Handle initialized darray of strings
This includes adding support for returning strings from functions,
adding initializing new darray with array_pattern strings, and
assigning an array_pattern of strings to a preallocated darray.
Also fix up support for initializing array with simple string
expression.
2013-10-19 15:34:15 -07:00
Stephen Williams d5a0f2fc07 Add support for simple expression in darray new initializer. 2013-10-19 15:34:15 -07:00
Stephen Williams 2464582587 Handle number literals as real-valued r-values. 2013-10-19 15:34:15 -07:00
Stephen Williams 82ebf6372c Generate code to implement new element initializers. 2013-10-19 15:34:15 -07:00
Stephen Williams 3945b9df45 Elaborate darray new element initializer to ivl_target API 2013-10-19 15:34:15 -07:00
Stephen Williams 96813f76c1 Generate code to implement array_pattern assignment to darray
This implements the feature in the VVP code generator.
2013-10-19 15:34:14 -07:00
Stephen Williams 2030e06988 Parse/elaborate some array-patterns down to the ivl_target API. 2013-10-19 15:34:14 -07:00
Stephen Williams cd85a42acc Elaborate the null darray literal as a null expression.
This leads to the correct code being generated in the vvp
code generator.
2013-10-19 15:34:14 -07:00
Stephen Williams 18c338ad09 Handle array assignment patters through pform.
This gets us to elaboration. In the process also fix up ivl_type_t
type comparisons to do deep type comparison.
2013-10-19 15:34:14 -07:00
Stephen Williams 2355e1ed8e Clean up some NetNet variable type handling. 2013-10-19 15:34:14 -07:00
Stephen Williams 5494c9ae09 Support DARRAY objects as port arguments. 2013-10-19 15:34:14 -07:00
Martin Whitaker 20ad1ff261 Fix zero/sign extension of parameter values in expressions.
For sized parameters, the choice of zero or sign extension should
be based on the expression type, not the parameter type.
2013-10-19 13:14:39 +01:00
Cary R 589bb59268 Implement %disable/fork in run time. 2013-10-18 17:22:10 -07:00
Cary R e12d2b2f36 Explicitly instantiate coerce_to_width() for vvp_vector4_t 2013-10-18 14:38:38 -07:00
Cary R c64b8900ca Add support for disable fork to the compiler. 2013-10-17 19:34:57 -07:00
Cary R 1cd72d375c Fix the label count for the join_any and join_none cases 2013-10-17 15:43:01 -07:00
Cary R aa9a7435dd Start of support for %disable/fork opcode. 2013-10-17 15:10:58 -07:00
Cary R 12c588fc35 Mostly fix a portability problem in $rtoi (run time) 2013-10-11 17:32:58 -07:00
Cary R 8f0687adb7 Fix white space issue. 2013-10-11 11:27:46 -07:00
Cary R 281556e93d Fix another real to vpiIntVal conversion in the run time 2013-10-11 11:26:17 -07:00
Cary R a196af8e15 Rework constant system function code and add $rtoi and $itor 2013-10-11 10:52:02 -07:00
Cary R 7b07fca285 Fix $rtoi to correctly convert NaN and +/- infinity 2013-10-11 10:49:45 -07:00
Cary R 095cedb305 Fix real to vpiIntVal conversion in run time 2013-10-11 10:49:28 -07:00
Cary R d5823b3e55 update a copyright and fix the define order. 2013-10-07 16:51:48 -07:00
Jared Casper 51ca2d1243 Fix using array elements in expressions with an array element lval.
When you have an expression like this (extreme example):

a[idx[1]][idx[2]*4 +: 4] <= #(idx[3]) 4'ha;

where a is a reg array and idx is a reg or net array.  The retrieval
of idx[2] was clobbering index register 3, which was set before
evaluating the part offset expression, then used in the %set/av of the
array value.  (likewise for idx[1] and idx[3]])

To avoid this issue, this patch adds and uses a new instruction
%ix/mov which simply copies one indexed register to another.  When
necessary, expressions are first evaluated into temporary registers to
avoid clobbering, then moved in to place before the %*/av instruction.
2013-10-07 16:47:50 -07:00
Jared Casper ec8081f983 Handle ", \", and ` in macro definitions.
Implements page 644 of IEEE 1800-2012.

`` is now overloaded with the Icarus-specific "stringify" expansions.
It is now used as indicated in 1800-2012 when appearing inside a macro
definition, and the Icarus way when not.  To do so, it uses the fact
that istack->file is NULL iff we are processing expanded macro text,
which is a bit of hack but works as is.

`" and `\`" on the other hand are treated the same inside and outside
of macro definitions.
2013-10-07 16:16:00 -07:00
Martin Whitaker 34643d9628 Fix for br937.
When writing a string value, vpi_put_value cannot assume the target vector
is a multiple of 8 bits wide.
2013-09-28 17:17:38 +01:00
Cary R 68db6c5a65 The seed passed to $random() should not change the implicit seed. 2013-09-23 17:44:13 -07:00
Cary R d564e054e5 vlog95: translate most do/while loops 2013-09-23 17:31:39 -07:00
Cary R 8616e3d6fa Fix space/tab problem. 2013-09-23 10:32:54 -07:00
Cary R 2c2ab24c8f Fix problem when compiling with valgrind support 2013-09-23 10:29:45 -07:00
Stephen Williams d025c8aa93 Non-method tasks/functions support default arguments. 2013-09-20 20:44:57 -07:00
Stephen Williams 7534abe325 Allow void functions to be called in functions. 2013-09-20 20:44:57 -07:00
Stephen Williams 7bc94d7810 Support functions that return void. 2013-09-20 20:44:57 -07:00
Stephen Williams a9a1c50268 Support "this" for calling task methods. 2013-09-20 20:44:57 -07:00
Stephen Williams 5084a23417 Sorry messages for calls to superclass constructor. 2013-09-20 20:44:57 -07:00
Stephen Williams 46f551073e Handle default expressions anywhere in port expression list. 2013-09-20 20:44:57 -07:00
Stephen Williams d9e1bcf3d0 Handle task arguments with default expressions. 2013-09-20 20:44:57 -07:00
Stephen Williams 13bb927d8a Handle strings as arguments to automatic functions. 2013-09-20 20:44:56 -07:00
Stephen Williams 16414f921f Handle default arguments in class new functions. 2013-09-20 20:44:56 -07:00
Stephen Williams 9a116498a2 Handle task/function default expressions in parsing/pform.
This gets it to (but not through) the elaborator.
2013-09-20 20:44:56 -07:00
Cary R d8f945be23 Add support for SV do/while 2013-09-16 20:02:09 -07:00
Stephen Williams 8412d0d55f Automatic scope are OK in detached threads
...assuming certain conditions that should by definition be
true. So this patch amounts to improving an assert condition.
2013-09-09 19:47:22 -07:00
Cary R 07cc18284c Fix print token/argument mismatches and other cppcheck fixes 2013-09-09 13:34:38 -07:00
Stephen Williams 7d6d93e4e2 Handle synthesis l-values that are part selects. 2013-09-08 18:18:31 -07:00
Stephen Williams 64b2345cf2 eval_as_long takes in const NetExpr arguments.
It is not the same as eval_tree, in particular it doesn't
rewrite the expression tree. So the NetExpr argument can
be constant.
2013-08-31 18:48:32 -07:00
Stephen Williams 9b3987bf3c blif target supports wide LPM_PART_VP devices. 2013-08-31 16:43:37 -07:00
Stephen Williams 15cda5fef2 Fix subtle issues related to fork/join of tasks.
When a fork/join contains a task, the task completion may become
confused with the completion of another thread if any of the
threads are embedded in the main thread. So always create threads
for all the fork paths, and joins to match.
2013-08-29 20:31:26 -07:00
Stephen Williams a10e07908e Precompile vhdlpp/lexor_keyword.gperf in autoconf.sh 2013-08-28 14:53:29 -07:00
Stephen Williams c2c9e09a49 snapshot 20130827 2013-08-27 19:55:20 -07:00
Stephen Williams 1b79df810f Handle DFF with clock-enable in blif code generator
In the ASIC universe, it is (probably) OK to replace a DFF CE
with a mux of the D input with the Q output. The idea is that
if the CE is true, the DFF latches D, but if CE is false, the DFF
re-latches the current output.
2013-08-25 12:27:57 -07:00
Stephen Williams 9dde4b705d Detect and synthesize FF clock enables.
Too bad BLIF doesn't support 'em.
2013-08-25 12:27:57 -07:00
Stephen Williams 1abf4f1aa1 Rework synchronous statement synthesis.
This changes the flow of the NetProc::synth_sync method, and
implements the NetBlock::synth_sync better.
2013-08-25 12:27:57 -07:00
Stephen Williams a47447610f Replace svector with vector in synth_sync methods. 2013-08-25 12:27:56 -07:00
Stephen Williams d209d8ee39 blif support for IVL_LPM_FF devices. 2013-08-25 12:27:56 -07:00
Stephen Williams 8117f4b383 NetCase synth async measure width from map, not output.
Make sure the NetMux device has an output that is a net.
2013-08-25 12:27:56 -07:00
Stephen Williams 6b5ae5e4db Force calculation of blif_nex_data_t width for lib_mux_s1 devices. 2013-08-25 12:27:56 -07:00
Stephen Williams a40c8f6bca Cleanup/simplify mux synthesis
Do not create useless NetNet objects for the inputs to the mux.
The synthesizer should already be creating these objects.
2013-08-25 12:27:56 -07:00
Stephen Williams a6fb6be8b5 blif code generator support for arbitrary MUX devices. 2013-08-25 12:27:56 -07:00
Stephen Williams ec99faff05 synthesis support for case statements with default cases. 2013-08-25 12:27:56 -07:00
Stephen Williams 1352abfc98 Fix up NetCondit synthesis to handle complex if/else clauses. 2013-08-25 12:27:56 -07:00
Stephen Williams 687d0a928b Initial support for NetCondit synth_async. 2013-08-25 12:27:56 -07:00
Stephen Williams 947d642da7 Always turn on ivl synthesis for blif target. 2013-08-25 12:27:55 -07:00
Cary R 1cbd6c3a80 Expand the scope of the parent variable. 2013-08-23 15:28:54 -07:00
Stephen Williams 11be93ce55 Merge branch 'master' of github.com:steveicarus/iverilog 2013-08-12 19:50:52 -07:00
Stephen Williams aaf35ca6ab Fix blif handling of wide ligic gates. 2013-08-12 19:50:32 -07:00
Cary R 4294a47cec Merge branch 'master' of github.com:steveicarus/iverilog 2013-08-12 16:37:05 -07:00
Cary R b983d5546b Fix cppcheck call in tgt-blif (use .cc instead of .c) 2013-08-12 16:35:45 -07:00
Stephen Williams ed9a3c3b10 Merge branch 'master' of github.com:steveicarus/iverilog 2013-08-09 20:55:44 -07:00
Stephen Williams d8f4ff4b57 Remove eval_expr during PEBinary elaboration
Turns out that call to eval_expr is redundant, and in degenerate
situations can lead to so many wasteful calls to eval_expr that
elaboration performance suffers dramatically.
2013-08-09 20:55:18 -07:00
Cary R af29735f44 Update cppcheck suppression file to match latest fstapi.c 2013-08-09 11:34:29 -07:00
Cary R 638300045c Update to latest FST API files from GTKWave 2013-08-09 11:34:16 -07:00
Cary R 71552b7d1a Fix typo in verilog.spec it should be blif.tgt not blif.txt 2013-08-06 17:17:10 -07:00
Cary R 7c0a75cf0c tgt-blif is C++ so use the extra C++ warning flags 2013-08-06 17:10:52 -07:00
Cary R f054500fe2 Fix space issues in tgt-blif 2013-08-06 17:09:37 -07:00
Stephen Williams 6684b2db04 Add BLIF support for ternary (MUX) operators. 2013-08-01 17:28:04 -07:00
Stephen Williams 999a53ab75 Add blif LIB_RE_* gates support. 2013-08-01 17:28:04 -07:00
Stephen Williams 534d44ba55 blif support for bit selects. 2013-08-01 17:28:04 -07:00
Stephen Williams c7c10613d7 blif support for unsigned magnitude comparison. 2013-08-01 17:28:04 -07:00
Stephen Williams dfc44db0ef BLIF support for IVL_LPM_CMP_EQ and IVL_LPM_CMP_NE 2013-08-01 17:28:04 -07:00
Stephen Williams 7a6192b5c8 Generate blif code for IVL_LPM_SUB device. 2013-08-01 17:28:04 -07:00
Stephen Williams 05f90bcf55 Support blif emit of IVL_LPM_ADD device. 2013-08-01 17:28:04 -07:00
Stephen Williams 1be59d8ae7 Add blif target to RPM package. 2013-08-01 17:28:04 -07:00
Stephen Williams b4dbb81af7 Fix handling of certain constants in ivl_target.h API.
The construction of the ivl_design_t consts member was broken,
not properly handling the addition of new objects.
2013-08-01 17:28:04 -07:00
Stephen Williams e709849243 Add a README-BLIF.txt file for the blif target. 2013-08-01 17:28:04 -07:00
Stephen Williams 1b2fa39cdc Add some more basic logic gates to blif target. 2013-08-01 17:28:04 -07:00
Stephen Williams b4ec36ec78 blif nex_data_t collects name data early.
It is possible for the get_name_index() method to be called before
the get_name() method, so need to handle that case.
2013-08-01 17:28:04 -07:00
Stephen Williams dddaacc6fd Follow non-canonical bit numbering.
The signal bit numbering should be used for signals. This is
necessary for .model ports because the user specified numbers
are part of the interface, but once that is done, it is trivial
to follow it internally as well.
2013-08-01 17:28:03 -07:00
Stephen Williams e0c9efd129 Implement blif support for constants and some logic/lpm gates.
This starts the handling of various logic gates.
2013-08-01 17:28:03 -07:00
Stephen Williams 01b81e0dbc Implement the ivl_target ivl_scope_child functions.
These are a more convenient way of iterating through child scopes.
2013-08-01 17:28:03 -07:00
Stephen Williams d2034a6458 Initial BLIF code generator.
Add the -tblif code generator target, and include some basic
useful behavior.
2013-08-01 17:28:03 -07:00
Cary R c4edbda969 Warn that the SystemVerilog array querying functions are not supported. 2013-07-31 19:40:25 -07:00
Cary R f3917778bc vlog95: Add some support for $signed()/$unsigned() in a CA 2013-07-29 10:26:56 -07:00
Cary R 032f12af45 Fix some sign information in the CA code. 2013-07-29 10:26:49 -07:00
Cary R bb37b74f98 Fix for br884 (packed array access problems) 2013-07-28 13:24:57 -07:00
Cary R 817a38494c vlog95: add support for zero argument functions and better named block detect
Add support for translating a zero argument function by adding a dummy
argument and improve the code that looks for a named block in a process.
2013-07-24 19:41:59 -07:00
Cary R d6fe6ea936 Add support for calling a user functions as a task (SV) 2013-07-24 19:38:00 -07:00
Cary R af48acca14 Update tgt-pcb make clean target to remove lex/yacc generated file. 2013-07-22 10:30:39 -07:00
Cary R 11696e23d1 vlog95: Add support for translating a SV function return statement 2013-07-19 10:52:54 -07:00
Cary R 8b7dde0e41 vlog95: improve parameter select warning. 2013-07-18 17:44:45 -07:00
Cary R 54cb85adfc Add support for a generate scope to vvp and the vpi routines.
Instead of just translating a generate scope to a named begin/end scope
this patch creates a generate specific scope (vpiScopeGenerate) that is
of the vpiGenScope type. This may not match the standard 100%, but does
allow the FST dumper to denote generate scopes differently than the
other scope types. Most of the VPI code treats a vpiGenScope just like a
named block so only the FST dumper should have different behavior.
2013-07-17 10:57:02 -07:00
Cary R f636ffde48 Update some line numbers in the cppcheck suppression files 2013-07-16 11:27:37 -07:00
Cary R 87235b618b Update FST files to latest from GTkWave 2013-07-16 11:27:23 -07:00
Cary R e4cc12f3b9 Remove old comment and enclose sizeof value in parenthesis (vvp_vector8_t) 2013-07-12 10:57:39 -07:00
Cary R 9d1084d3c0 Remove reentrant support from tgt-pcb parsing
This is just extra overhead since the pcb target does not call the scanner
recursively. This also removes some compile warnings.
2013-07-11 19:19:22 -07:00
Cary R 21b24c7725 Fix more compile warnings and a minor bug 2013-07-11 19:10:25 -07:00
Cary R 3e75f8e41f Remove a compile warning 2013-07-11 18:03:00 -07:00
Cary R dec0fa622c Add CXX warning flag to tgt-pcb and tgt-vhdl and fix warnings 2013-07-11 17:40:57 -07:00
Cary R dbd05557ca Fix Makefile and scope.cc in tgt-pcb 2013-07-09 18:54:50 -07:00
Cary R e30334e527 Add ivl_parameter_width() function to ivl interface 2013-07-09 18:22:40 -07:00
Cary R 3e76f6d656 vlog95: more procedural $signed()/$unsigned() support
Add support for detecting when to add a $signed() or $unsigned() to
create a self-determined context. This makes the test in the test suite
pass, but there could still be issues
2013-07-09 17:55:21 -07:00
Cary R 91ad8a72c6 vlog95: Keep the scaling for a variable parameter indexed part select
The select expression scaling needs to be kept for a variable indexed
part select of a parameter since parameters are zero based in 1364-1995.
2013-07-05 17:23:28 -07:00
Cary R e2361fab29 vlog95: Better unsupported select warnings and variable parameter bit select
Since parameters are now passed by reference use that information to print
the parameter name in a select vs trying to figure it out by searching the
scope looking for a parameter with the same file, line and value information.

Only print the $signed() may need to be removed messages for a select
expression that will actually be cast to signed.

Use the actual parameter information to warn that -pallowsigned=1 is needed
for a parameter when the LSB > MSB.
2013-07-05 16:31:05 -07:00
Cary R f6b8d613ab Fix space issue. 2013-07-05 16:20:48 -07:00
Cary R 3a3cd8565d Add elaborate_expr_param_bit_ and pass param refs for variable selects
For variable parameter selects (indexed and bit) pass the value being
selected as a parameter reference instead of just a numeric constant
so it is easy to get the underlying parameter information.

Move the parameter bit select code into its own routine and cleanup
the remaining general code.

This should not effect the VVP code, but the ivl_expr_parameter(<expr>)
routine can be used to get at the actual parameter information in the
vlog95 target.
2013-07-05 16:16:54 -07:00
Cary R b9bcacd803 Update ivl.def file to include new routines and one missing routine
Add the new ivl_parameter routines (lsb, msb, signed) and add the
missing definition for ivl_parameter_scope.
2013-07-05 10:41:51 -07:00
Cary R cbd1b948a2 vlog95: emit an entire parameter reference by name instead of value. 2013-07-05 10:35:31 -07:00
Cary R d1c1997acf Add missing file/line information for a full parameter reference. 2013-07-04 16:50:26 -07:00
Cary R fcbb41c391 vlog95: Get sign info correct for procedural power to shift conversion 2013-07-04 14:33:39 -07:00
Cary R e736c022b1 Merge branch 'master' of github.com:steveicarus/iverilog 2013-07-04 11:30:02 -07:00
Cary R d08e0270e4 Add support for getting parameter MSB, LSB and sign from the ivl interface 2013-07-04 11:29:25 -07:00
Stephen Williams bb1d26f4f7 Fix warning/error finding static properties. 2013-07-03 20:07:58 -07:00
Stephen Williams 173577d5f7 Merge branch 'work14' 2013-07-03 20:00:22 -07:00
Stephen Williams 5326790932 Add support for class static properties.
Static properties are like variables in a named scope.
Detect these variables during elaboration so that the
code generator just sees them as variables.
2013-07-02 20:16:47 -07:00
Stephen Williams 4ef3ac5ca6 Implement const properties of classes.
This implementation works by detecting assignments
to constant properties in elaboration. Allow initializer
assignments to assign to the constant, error all other
assignments, and otherwise treat the constant like any
other property.
2013-07-02 20:16:47 -07:00
Stephen Williams cf47a759d1 Implement the "local" class member protection.
Test during elaboration that the member really is
accessible in the context where the elaboration
happens.
2013-07-02 20:16:47 -07:00
Stephen Williams 046535cfbb Blend implicit constructor with explicit constructor
Class types that have both implicit construction and
an explicit constructor can blend the implicit and
explicit construction into the "new" function defined
by the user. This doesn't change the behavior any, but
removes a function call and related scope.
2013-07-02 20:16:47 -07:00
Stephen Williams 637d43fb5a Add support for logic vector properties in classes.
This is similar to but not the same as bit(bool)
vector properties in classes.
2013-07-02 20:16:47 -07:00
Stephen Williams fbc5557a10 Handle properties that have arbitrary bit widths.
This fixes the run time handling of arbitrary width
bit vectors as class properties. The vvp code generator
already did the right things.
2013-07-02 20:16:47 -07:00
Stephen Williams 75b4b94061 Elaborate implicit initializers
Remaining pform fixup of property initializers, and
elaboration and code generation for implicit constructor.
2013-07-02 20:16:46 -07:00
Stephen Williams d346fb098f Collect initializer statements in the pform. 2013-07-02 20:16:46 -07:00
Cary R 633360a0f9 vlog95: More procedural $signed/$unsigned support/cleanup 2013-06-28 14:16:10 -07:00
Cary R 0e8a257ec2 vlog95: Fix the passing of the sign extend information in a CA 2013-06-27 19:44:17 -07:00
Cary R 7fa4cf5a34 vlog95: Fix a RS vs ARS in the CA code 2013-06-27 18:22:21 -07:00
Cary R eecc3312b7 vlog95: Add $signed/$unsigned support for signals
The actual signal code is trivial, but the emit expression code needed
to be enhanced to pass a flag that says if one of the arguments in a
binary (except the shifts) or ternary (excluding the condition) context
is unsigned. This information is used to prevent emitting an explicit
$unsigned() for a signal that is used in this context since it will be
implicitly cast to unsigned.
2013-06-27 13:31:40 -07:00
Cary R 11e5641089 A real task/function port is also signed. 2013-06-27 13:03:11 -07:00
Cary R f631cb6314 Add some support for procedural $signed/$unsigned.
This patch adds support for finding and adding $signed() and $unsigned()
to procedural expressions for the binary, unary and concatenation
operators. Selects have partial support. The select implementation
uncovered limitations in the compiler that need to be fixed before they
will work 100%. Most of the limitations currently generate a message
about the issue.
2013-06-26 21:46:02 -07:00
Cary R a586bfd1ec When finding the canonical address use a signed expression if needed. 2013-06-26 21:27:49 -07:00
Cary R 4dbd0442aa Add missing file/line information to a few expressions. 2013-06-26 21:25:27 -07:00
Cary R fa9a439bf1 Update fstap files to the latest from GTKWave 2013-06-14 16:35:22 -07:00
Cary R 11e394aacf Remove space error 2013-06-14 16:35:09 -07:00
Martin Whitaker 9af0811a1c Fix for br932 part 2 - make $fopen accept SV 'string' type.
The is_string_obj function in vpi/sys_priv.c needed to be updated to
recognise the vpiStringVar object type.
2013-06-14 21:00:39 +01:00
Martin Whitaker 503487e9ea Fix for br932 - support string types in task input ports. 2013-06-13 23:18:23 +01:00
Stephen Williams ca9616dc7b Better simple_expression parse rules. 2013-06-12 14:21:36 -07:00
Stephen Williams 24bd630cb2 Parse (to sorry messages) unbounded array definitions. 2013-06-12 14:21:36 -07:00
Stephen Williams 8487cb5616 Do a better job of figuring the vtype of an expression. 2013-06-12 14:21:36 -07:00
Stephen Williams d630e4dfe9 Elaborate VHDL entity port types/expressions.
We need to elaborate expressions so that function calls in
expressions (i.e. ranges) get bound to their proper scope.
This binding is in turn used to emit package scopes. This
is particularly interesting for ports of entities.
2013-06-12 14:21:35 -07:00
Stephen Williams 3d5765949e Some shorthand type marks in write_to_stream. 2013-06-12 14:21:35 -07:00
Stephen Williams 0fcd2d9db6 Handle rising_edge and falling_edge functions. 2013-06-12 14:21:35 -07:00
Stephen Williams 3446455055 Support compile-time evaluation of named blocks. 2013-06-12 14:21:35 -07:00
Stephen Williams af304fea65 Fix repeated use of disabled const functions.
If constant functions are exited by a return/disable, fix
the leaked "disable" flag that causes blocks in the next
try at the function to not work.

There are also a lot of debug messages added to help find
this and similar problems.
2013-06-12 14:09:08 -07:00
Stephen Williams bcaa6accec Fix evaluation wrong expression for const >= expressions. 2013-06-12 14:09:08 -07:00
Stephen Williams 5c00b96127 Handle constant functions from other scopes, i.e. packages. 2013-06-12 14:09:08 -07:00
Stephen Williams bfe3998eaa Lexor detects that excaped identifiers may be package names. 2013-06-12 14:09:08 -07:00
Stephen Williams 096e53dea4 Don't crash if function is not found. 2013-06-12 14:09:08 -07:00
Stephen Williams bc77a19059 Use $ivl_unsigned to implement VHDL to_unsigned function.
The VHDL to_unsigned function with to arguments is best handled
in the ivl elaborator, so have it generate an $ivlh_to_unsigned
function call in the vhdlpp code, and implement it in the ivl
core.

Also, implement the 'length attribute as a $bits() call for
similar reasons.
2013-06-12 14:09:08 -07:00
Stephen Williams 1b178d56b7 Add support for SystemVerilog return statements. 2013-06-12 14:09:07 -07:00
Stephen Williams dca6171f5f SV emit function ports in package subprograms. 2013-06-12 14:09:07 -07:00
Stephen Williams 164b5f9348 Fix SV emit of ForLoopStatement and ReturnStmt. 2013-06-12 14:09:07 -07:00
Stephen Williams e927960121 Implement subprogram bodies in package bodies. 2013-06-12 14:09:07 -07:00
Stephen Williams 6394a4d78d Rework scope types and constants so we can tell imported from local names.
The package emit of types and constants needs to know which names are
from the current type and which are imported from libraries. Rework
the scope handling of those names so that the information is preserved.
2013-06-12 14:09:07 -07:00
Stephen Williams 13be45bd73 Fix dump of primitive CHARACTER types. 2013-06-12 14:09:07 -07:00
Stephen Williams 7f7decde03 Basic structure for emitting packages. 2013-06-12 14:09:07 -07:00
Stephen Williams d9fea802da Function declarations in packages
This is still basic. Definitions are still not done.
2013-06-12 14:09:07 -07:00
Martin Whitaker 34f6e25b4e Revised fix for bug 931.
We can't directly determine that a %fork operation is a task or function
call, so need to infer this by comparing the parent and child scopes.
2013-05-27 20:17:44 +01:00
Martin Whitaker afe1e79338 Update a few comments for changes to thread fork/join behaviour. 2013-05-27 10:12:30 +01:00
Martin Whitaker cbaf36d4b8 Fix for br931.
Task and function calls are handled in vvp using the fork/join
instructions. The join instruction after a call must reap the
task/function thread.
2013-05-27 09:34:44 +01:00
Martin Whitaker 6f8eede371 Handle out-of range and undefined LHS bit/part selects in assignments.
For constant bit/part selects, issue a warning if the select is out
of range or an undefined value. In any case, the RHS value should be
discarded, and the actual assignment should be skipped.
2013-05-21 21:44:31 +01:00
Martin Whitaker c693930595 Fix compiler crash when an attribute value is invalid. 2013-05-19 11:07:37 +01:00
Martin Whitaker 6364aba975 Fix for br930 - support attributes on old-style port declarations. 2013-05-19 09:16:24 +01:00
Martin Whitaker 10ec58703f Fix vvp memory leak for VPI call with no calltf.
If a VPI call with real arguments has no calltf function, we still
need to pop the arguments off the vthread stack. Similarly, if it
has a real result, we need to push a value onto the vthread stack.
2013-05-18 21:22:44 +01:00
Martin Whitaker 9a69fcff7b Handle out-of-bounds and undefined word indices in constant functions. 2013-05-18 19:39:24 +01:00
Martin Whitaker 26dc6d68cd Handle out-of range and undefined LHS word indices in assignments.
For constant word indices, issue a warning if the index is out of
range or an undefined value. In any case, the RHS value should be
discarded, and the actual assignment should be skipped.
2013-05-18 19:21:37 +01:00
Martin Whitaker 0aca19356c Added thread stack memory leak check to vvp.
When a vvp thread terminates, its real and string stacks should be empty.
Adding assertions to this effect catches some code generator bugs.
2013-05-18 19:02:36 +01:00
Cary R 5e94554d72 Don't run final blocks if there was a compiletf, etc error. 2013-05-14 17:45:27 -07:00
Cary R 7d26515bc4 A $finish in a final block should end processing of all final blocks 2013-05-14 16:55:51 -07:00
Cary R 71c6193ff1 Finish adding support for end labels in SystemVerilog 2013-05-14 15:01:54 -07:00
Cary R b0b6be0d23 Class properties are optional 2013-05-14 14:59:31 -07:00
Cary R 7c1638652a Add support for closing a procedural begin/fork block with a name 2013-05-08 18:34:16 -07:00
Cary R 1b1aa06dee Remove some more cppcheck warnings and a valgrind compile warning 2013-04-30 18:35:30 -07:00
Cary R 51d3c03922 A time variable is always unsigned and pass the integer property 2013-04-30 14:05:19 -07:00
Cary R 431d62185b vlog95: Emit a new doing a shallow copy as an error. 2013-04-30 11:52:52 -07:00
Cary R c55eb37148 Add support to free an automatic object (valgrind)
Add missing code to free an object that is used in an automatic context.

Also remove one compiler warning.
2013-04-30 11:47:19 -07:00
Stephen Williams de6c57d661 Elaborate classes in lexical order so that mutual references work. 2013-04-28 16:28:24 -07:00
Stephen Williams ac78ba588f Code generation and runtime for class shallow copy. 2013-04-28 10:10:36 -07:00
Stephen Williams 8e559e4e91 Support shallow copy as far as the ivl_target API. 2013-04-27 19:54:13 -07:00
Stephen Williams eff6e7a441 Parse to pform shallow copy "new" expressions. 2013-04-21 19:27:57 -07:00
Stephen Williams 8994ef1483 Implement class constructors.
Class constructors are the "new" method in a class description.
Elaborate the constructor as an ordinary method, but the only
way to access this method is to implicitly call it. The elaborator
will take the constructor call and generate a naked "new" expression
and implicit constructor method call with the object itself as the
return value.
2013-04-20 16:38:35 -07:00
Stephen Williams 20ee350601 Generalize user defined function return type handling.
I'm gonna need functions to return class objects, so generalize
the output types of user defined functions.
2013-04-20 16:38:35 -07:00
Martin Whitaker c4257ecfc9 Add support for array variables inside constant user functions. 2013-04-19 22:08:59 +01:00
Martin Whitaker a91840c15d Support concatenations in LHS of assignments in constant user functions. 2013-04-19 22:08:59 +01:00
Cary R a748736d10 Update COPYING to match FSF version and update tgt-vlog95/Makefile.in
The changes in COPYING are mostly cosmetic and use <year> vs 19xx, etc.
Also update the tgt-vlog95/Makefile.in copyright to match the formatting
in the FSF version.
2013-04-19 12:14:37 -07:00
Stephen Williams 11682fc7eb Harmless cleanup of comments / initialization warnings. 2013-04-18 18:18:40 -07:00
Cary R 255922e545 vlog95: add support for emitting logic pull devices in a CA
If a logical pull device is converted into a CA then it is an assignment
with strength, so just emit the appropriate constant to get the correct
functionality (e.g. 1'b1 for a pull up and 1'b0 for a pull down).

Also add missing file/line information.
2013-04-18 17:38:30 -07:00
Cary R 98694f15ce vlog95: A valid task output can have a cast.
When looking for a task call with arguments the output port assignments can
also come from a cast of a simple signal in the task.
2013-04-18 12:40:13 -07:00
Cary R 36b04748d4 Update tgt-vvp to not use deprecated function calls.
There was one section of code in the tgt-vvp back end that was using
deprecated functions. This patch fixes that. The functionality is still
missing (force/assign to part of a vector), but the code now compiles
cleanly (no warnings).
2013-04-18 10:50:37 -07:00
Cary R d2928d500d Remove a few more compile error messages from RHEL5 2013-04-17 17:46:05 -07:00
Cary R 15379f1750 Remove some compile warnings 2013-04-17 17:13:22 -07:00
Cary R 0a4d8acefb vlog95: Add support for translating a package as a module with a special name
This patch finishes the code needed to translate a SystemVerilog package to a
module with a special name. It also adds code to report that class scopes are
not supported and treats both a class and package as a top level scope.
2013-04-17 10:43:04 -07:00
Stephen Williams 632fd006c5 Merge branch 'master' of github.com:steveicarus/iverilog 2013-04-16 16:56:14 -07:00
Stephen Williams 256c0986bb Merge branch 'work13b' 2013-04-16 16:47:37 -07:00
Cary R db7fbba08e Update fstapi.c to latest from SVN. 2013-04-16 15:00:25 -07:00
Cary R f536a43e92 Add support for timeunit <time_val> / <time_val> 2013-04-16 14:40:35 -07:00
Cary R 283ae6e538 Fix some cppcheck warnings in vvp. 2013-04-15 12:28:35 -07:00
Cary R fbafb915d2 Fix some cppcheck warnings 2013-04-15 11:54:15 -07:00
Martin Whitaker 4c52f66f5d Fix VHDL code generator crash when a ternary operator has a real operand. 2013-04-12 23:46:06 +01:00
Martin Whitaker 46f63db746 Fix VHDL code generator crash when code contains a real-valued parameter. 2013-04-12 23:41:52 +01:00
Stephen Williams 4ad556d464 Update some copyright notices. 2013-04-08 18:35:37 -07:00
Stephen Williams 4dffd97d28 Handle tasks in packages. 2013-04-08 18:20:39 -07:00
Stephen Williams b1d853bf9b Fix handling of struct members for variables imported from packages. 2013-04-08 18:20:39 -07:00
Stephen Williams eba3d407ca packages can contain variables. 2013-04-08 18:20:39 -07:00
Stephen Williams 44cd9158e8 Elaborate parameters, tasks and functions in packages.
Get the elaboration to happen all the way to the ivl_target
interface.
2013-04-08 18:20:39 -07:00
Stephen Williams b122ec2a1a parameter table in ivl_scope_s uses vector instead of C arrays. 2013-04-08 18:20:39 -07:00
Stephen Williams bae0f1d3a7 Parse more package items
Rework lexical support for PACKAGE_IDENTIFIER so that the lexor
can help with package scoped identifiers.

Pform package types and package functions up to elaboration.
2013-04-08 18:20:39 -07:00
Martin Whitaker 23dbfabb1e Further support for constant functions.
Add support for case, forever, and repeat statements in constant
functions. Also fix a bug in the constant function implementation
of NetESelect when used for zero/sign extension.
2013-04-07 19:13:30 +01:00
Martin Whitaker 6da71fdf56 Fix type/width for case and case item expressions.
The compiler was treating case and case item expressions as
self-determined. They should be context-sensitive, just like
the operands of a comparison operation.
2013-04-07 12:30:25 +01:00
Cary R bdfd5b9b55 Add -g2012 flag and keywords for IEEE 1800-2012. 2013-04-02 14:41:44 -07:00
Stephen Williams 64dffa5745 Support member functions with arguments. 2013-03-24 15:12:35 -07:00
Stephen Williams b9011d89ae Allow objects to work in automatic functions. 2013-03-24 15:12:35 -07:00
Stephen Williams 3b3a4d3ddc vvp code generation for class methods in class scope. 2013-03-24 15:12:35 -07:00
Stephen Williams b1613e99e6 Elaborate function methods' this argument. 2013-03-24 15:12:35 -07:00
Stephen Williams d0f2a9e961 Elaborate task methods as tasks with this arguments.
Generate the code to treat "this" as a hidden argument and have
elaborate assign to that argument.
2013-03-24 15:12:35 -07:00
Stephen Williams fb23493a98 Class methods down to the code generator
Emit the elaborated class methods. Also generate root scopes to
represent the classes in order to hold the methods. These scopes
can also in the future be used to implement static properties.
2013-03-24 15:12:35 -07:00
Stephen Williams 17330a3073 Elaborate class task and function methods.
The parse of class methods already works, this patch forms
the methods into their own scopes, and elaborates those scopes.
The "this"
2013-03-24 15:12:35 -07:00
Stephen Williams fac5cbca43 Handle this as special identifier strings. / Organize pform class member binding 2013-03-24 15:03:52 -07:00
Stephen Williams 670601bc2a Mark class method pforms with their pform class. 2013-03-24 15:03:52 -07:00
Stephen Williams 25b48fa790 Remove svector template from port handling. 2013-03-24 15:03:52 -07:00
Stephen Williams dd5fb47c6c pform dump class methods. 2013-03-24 15:03:52 -07:00
Martin Whitaker b80401e1ee Improved error reporting for constant user functions. 2013-03-24 14:43:10 -07:00
Martin Whitaker 1bcd3a97ad Support disable statements and system task calls in constant functions.
This patch implements the evaluate_function method for the NetDisable
and NetSTask classes. It also makes the checks for a function being
constant work when the function contains nested scopes (named blocks).
2013-03-24 14:42:59 -07:00
Martin Whitaker 09f90ab4e1 Add control to enable function evaluation at compile time.
Pure functions with constant operands can be evaluated at compile
time rather than at run time. This patch provides a global control
to enable this optimisation. Until constant function support is
complete, by default it is disabled.
2013-03-24 14:42:05 -07:00
Martin Whitaker 5929a00845 Handle uninitialised variables in constant user functions. 2013-03-24 14:40:44 -07:00
Martin Whitaker 5d7558b5e0 Fix assigned vector size in constant user functions.
When assigning to a bit/logic variable, the RHS expression value
must be trimmed to match the size of the variable.
2013-03-24 14:40:10 -07:00
Martin Whitaker ee71ade720 Handle implicit cast when short-circuiting ternary expression.
If a ternary expression with mixed logic and real operands is
short-circuited and the logic value is selected, that value
should be cast to a real value.
2013-03-24 14:24:42 -07:00
Martin Whitaker e437321ea7 Fix implicit casts in assignments (part 6).
IVL_VT_NO_TYPE is now used to signal an untyped LHS in a parameter
declaration. The parser function that handles specparam declarations
needs to do this too. Also, although it should never happen, make
sure we don't set the expression width in a NetECast object to a
negative number. Make constant evaluation of NetECast objects
observe the expression width.
2013-03-24 13:51:10 -07:00
Martin Whitaker 6da610fe1e Fix implicit casts in assignments (part 5).
This patch removes some code that has been made redundant by the
more general handling of implicit casts.
2013-03-24 13:51:02 -07:00
Martin Whitaker e8d4039175 Fix implicit casts in assignments (part 4).
This patch fixes a few issues/bugs that showed up when testing the
fixes for implicit casts:

1. Make the compile-time implementation of $abs, $min, and $max match
   the run-time behaviour (system functions can't be polymorphic).

2. Correctly set the type (signed/unsigned) of the result of an
   assignment inside a constant user function (the LHS should not
   inherit the type of the RHS).

3. Fix a bug in the verinum(double) constructor (insufficient bits
   were allocated in the case where the double value rounded up to
   the next power of two).
2013-03-24 13:50:59 -07:00
Martin Whitaker faece5816c Fix implicit casts in assignments (part 3).
This patch adds support for bool/bit vector types on the LHS of
a parameter declaration and ensures implicit casts in parameter
declarations are performed where necessary.
2013-03-24 13:50:53 -07:00
Martin Whitaker bc2a4c01c9 Fix implicit casts in assignments (part 2).
This patch adds support for implicit casts in module port connections
and in user task output assignments.
2013-03-24 10:17:17 -07:00
Martin Whitaker 22769afd20 Fix implicit casts in assignments (part 1).
This patch adds support for implicit casts to the elaborate_rval_expr()
function. This will handle the majority of cases where an implicit cast
can occur.
2013-03-24 10:14:07 -07:00
Cary R 03ebd2f98d vlog95: Emit a package as a module with a special name. 2013-03-11 10:46:13 -07:00
Cary R b378dccbe9 Update parameter add code to correctly handle a non-Module scope
A package can have parameters, but it does not have specparams or
keep the order the parameters are defined. This patch skips these
items if the scope is not a Module.
2013-03-08 10:04:46 -08:00
Cary R 1f9489a65d vlog95: report that package scopes are not supported. 2013-03-07 10:38:48 -08:00
Cary R f436b5d18e Fix comparison vs assignment in new code. 2013-03-07 10:02:32 -08:00
Stephen Williams 64401ab815 Merge branch 'work13a' 2013-03-04 08:59:50 -08:00
Stephen Williams 952169ded9 Merge branch 'master' of github.com:steveicarus/iverilog 2013-02-24 08:36:23 -08:00
Cary R 1b36aa5560 vlog95: Add code to output specify block path delays.
There are limitations with this since the compiler does not pass all
the information that was present in the original source, but it is enough
to get a valid simulation result. It is not enough for timing analysis!
specparams are also incorrectly translated to parameters so they show up
in the wrong place.
2013-02-23 14:32:49 -08:00
Cary R 69705ef32b vlog95: a sign extend can have an out of scope reference.
If modules instantiations were always handled correctly this would not be
needed, but for now looking for the nexus driver outside the scope is
needed to make some of the tests work.
2013-02-21 19:34:06 -08:00
Cary R 2e86c208d1 vlog95: Add support for variable packed array accesses 2013-02-20 22:10:00 -08:00
Cary R 27b8738d06 vlog95: convert real Verilog-A abs/min/max to $abs/$min/$max
Converting these Verilog-A functions to use the $ version allows nan
to be handled correct. This still needs to be done for the LPM code.
2013-02-19 20:05:34 -08:00
Stephen Williams 8fa79ceb30 Properly implement import <pkg>::<name>
This was temporarily implemented to just copy definitions to the
local scope, but the better method is to create a PEIdent that has
the package attached to it.
2013-02-17 17:00:15 -08:00
Stephen Williams 60cb78e4ab Add packages and their own scope.
This makes <pkg>::<name> work properly, and also makes the
package descriptions available through VPI.
2013-02-17 17:00:15 -08:00
Stephen Williams 97f3a01dc5 Support import if single items. 2013-02-17 16:59:21 -08:00
Stephen Williams 99b8086ad2 Import parameters from packages. 2013-02-17 16:59:21 -08:00
Cary R c4386da666 vlog95: Emit initial blocks for tasks or functions.
In SystemVerilog a task or function can initialize a variable in a task or
function. In Icarus this is done by creating an initial block that does
the assignment. We can translate this by emitting the initial block in the
enclosing module scope. This is not 100% correct since SystemVerilog
requires the initialization to be done before the other initial/always
blocks are processed. For SystemVerilog the current Icarus behavior is
incorrect, but even if it had a new process type that ran before the other
ones the best I can do for vlog95 is emit it before the normal module
processes which currently works.
2013-02-15 19:43:32 -08:00
Cary R 51112131ad vlog95: Emit if using signed and add the number of errors to the output
In the starting comment say if the conversion was done with signed support.
If there were errors then add a comment at the end of the file that says
how many errors occurred and add a line after this that prevents the file
from running with out an error. This requires the user to see that errors
occurred and remove the offending line if they want to use the file anyway.
2013-02-15 19:43:19 -08:00
Cary R 8808cd9514 For a LPM constant pass the sign information and one other fix
For a LPM constant we need to pass the sign information so that the vlog95
code generator can create the correct constant. Also when using the
sub_net_from() routine the numeric constant should have the same sign as
the signal so that it can also be displayed correctly.
2013-02-15 11:59:25 -08:00
Cary R 890589191c When duplicating a select keep the sign information
Make the duplicate select signed if the original was signed.
2013-02-14 18:57:31 -08:00
Stephen Williams 75c78c7c5b Merge branch 'master' of github.com:steveicarus/iverilog 2013-02-13 19:51:31 -08:00
Stephen Williams 69de1da172 Handle ranges of slices. 2013-02-13 19:50:05 -08:00
Cary R 28bc333cba vlog95: block generating a concat-Z LPM device in the compiler.
Since the vlog95 code generator needs the strength information we do
not want to hide it behind a concat-Z optimization. For now we abort
the optimization, but in the future we could add parts of this back
in (e.g. all the drivers have matching strength then replace with a
normal concat and a buf-Z if the strength are not both strong. The
original buf-Z should be removed to reduce the number of LPM devices).
2013-02-13 19:19:21 -08:00
Cary R 8b4dc05ff8 vlog95: for a part/pv look for the strength at the driver
A part/pv passes strength information so we need to use the real driver
to get the appropriate drive information.
2013-02-12 19:38:28 -08:00
Cary R 6de80adbe8 Fix space issue 2013-02-12 18:38:33 -08:00
Cary R fdcef3cbc4 A concatenation may also need a BUFZ to hold the drive strength
Just like a select a concatenation needs a BUFZ to hold the drive strength.
2013-02-12 18:36:39 -08:00
Cary R 41c7aa9e83 vlog95: translate darray and class assignments/references
These are not supported in vlog95, but they are easy to translate into
something that looks correct.
2013-02-08 19:16:24 -08:00
Cary R 1929cfc4f9 Fix space issues 2013-02-08 11:24:11 -08:00
Martin Whitaker 8b70fefa59 Refactor eval_tree debug code.
This just pulls the eval_tree debug message generation into one place.
2013-02-08 11:22:49 -08:00
Martin Whitaker af91920a17 Add support for system function calls in constant functions. 2013-02-08 11:19:26 -08:00
Martin Whitaker 89244e0f70 Add support for concatenation operations in constant functions.
Also fix a compiler crash when attempting to evaluate a function
which has no valid statement(s) (due to earlier compilation errors).
2013-02-08 11:19:17 -08:00
Cary R 5abd939655 vlog95: fix bug in min/max translation code 2013-02-08 11:18:49 -08:00
Cary R 06ce23d9c2 vlog95: Add support for Verilog-A abs(), min(), max() and some SV types.
The Verilog-A abs(), min() and max() functions can be converted if the
expressions do not have side effects. Also note the new, null and class
property operators from SystemVerilog are not supported.
2013-02-07 19:53:10 -08:00
Cary R a581e0ef0e vlog95: Report zero argument functions are not supported. 2013-02-07 17:08:59 -08:00
Cary R b6ec138644 vlog95: Add support for recognizing a call to an automatic task.
Automatic tasks are not supported by 1364-1995, but the converter should
be able to correctly convert a call to an automatic task.
2013-02-07 17:08:43 -08:00
Cary R dc387ad9d1 vlog95: Add a messge that ** (power) is not supported in a CA. 2013-02-07 10:21:04 -08:00
Cary R 48b186576e Report in SV that Icarus cannot currently call a function like a task.
SystemVerilog allows a function to be called without an assignment for
the return value. This patch adds a warning that Icarus does not currently
support this and provides a place to add this functionality later.
2013-02-06 12:41:42 -08:00
Cary R 15b0946fc4 vlog95: Add support for the new CONCATZ LPM type. 2013-02-06 10:05:12 -08:00
Cary R 5830e65829 Fix space issues. 2013-02-04 12:17:41 -08:00
Martin Whitaker f3a51fdfd1 Factor out some common eval_tree code.
The eval_tree() function is identical in most of the NetEBinary and
NetEUnary sub-classes.
2013-02-04 12:17:29 -08:00
Martin Whitaker afd23d13d5 Add support for unary operators in constant user functions.
This patch implements the evaluate_function method for the NetEUnary
and NetEUReduce classes.
2013-02-04 12:17:05 -08:00
Martin Whitaker 11f479e028 Add support for all binary operators in constant user functions.
This patch implements the evaluate_function method for the NetEBBits,
NetEBDiv, NetEBLogic, NetEBMinMax, and NetEBPow classes. It also
factors out some common code into the NetEBinary class.
2013-02-04 12:16:51 -08:00
Cary R 838f6ce862 Minor fixes to br916 patch. 2013-02-04 11:45:22 -08:00
Martin Whitaker e99d53b80b Stopgap fix for br916.
Currently, when a variable expression is passed to a system task,
the expression value is stored in thread memory. Values stored
in thread memory cannot safely be passed to $strobe or $monitor,
because the thread memory may get reused or deallocated before
the $strobe or $monitor task actually executes. As a temporary
measure, we just trap this case and terminate with a "sorry"
message. A proper fix would require the expression value to be
calculated at the time the $strobe or $monitor executes, not at
the time it is called.
2013-02-04 11:45:11 -08:00
Stephen Williams 1d314faf97 bool .net8 objects?
This is rather a pointless sort of thing, but it does turn from
from time to time, for example when constant literals (with no x or
z bits) are given strengths. So handle .net8/2s and .net8/2u the
same as .net8.s and .net8 objects.
2013-02-02 17:38:24 -08:00
Stephen Williams 751587e112 PV-to-concat belnding should use a strength-aware concat. 2013-02-02 10:44:16 -08:00
Stephen Williams 673675fecd Properly handle class properties what are wider then native.
Fix a bug where if a class property were wider then a native long
it would get truncated.
2013-01-31 18:13:36 -08:00
Stephen Williams ee58fd749c Merge branch 'x-mil6' 2013-01-30 17:03:19 -08:00
Cary R bcc7973792 Update LDFLAGS usage in tgt-pal and tgt-pcb to match the other directories 2013-01-29 17:28:42 -08:00
Martin Whitaker b176a6410d Fix logic value returned for unambiguous HiZ1 strength.
If a strength aware net has an unambiguous HiZ1 strength, VVP treats
it as a logic '1'. It should be treated as a logic 'z'. An ambiguous
HiZ1/HiZ0 strength should also be treated as a logic 'z'.
2013-01-28 19:06:59 -08:00
Stephen Williams d8592b1444 Allow for class objects an class properties. 2013-01-27 20:10:25 -08:00
Stephen Williams 4568766cff Add support for darrays as class properties. 2013-01-27 20:10:25 -08:00
Stephen Williams c49b21115a Handle strings as class object properties.
While we are at it, fix a handling of null strings in
string expressions.
2013-01-27 20:10:25 -08:00
Stephen Williams 106850ca7d Handle real value class properties.
As a side effect, this also adds support for 64bit integers.
2013-01-27 20:10:25 -08:00
Stephen Williams 2ea5919a4a Get signed-ness of property correct in certain situations. 2013-01-27 20:10:25 -08:00
Stephen Williams 0375ff3923 Handle some different integral types is class properties. 2013-01-27 20:10:25 -08:00
Cary R 59ce217ce2 vlog95: Add support for undefined selects. 2013-01-25 12:46:55 -08:00
Cary R 350369f3fc Handle undefined L-value selects
L-value bit selects were incorrectly converting an undefined index to 0.

L-value part selects were asserting if an undefined index was given.

This patch unifies how all these are handle (including indexed part selects).

The base is set to an undefined value and an appropriate width is used.
A warning message is always printed since this is not a simple out of
range issue. It is the responsibility of the code generator to skip the
assignment, but we always want to execute the R-value since it could have
a side effect.
2013-01-25 10:32:36 -08:00
Cary R d9c400ac0c A scope port can be a uwire for some cases. 2013-01-24 18:28:04 -08:00
Cary R 922b74be9e Fix uninitialized buffer when drawing a real VPI argument 2013-01-22 09:22:50 -08:00
Martin Whitaker cd239a9857 Fix display of net array words when data type is signed.
When VVP compiles a .array statement for a net array, it does not
know the data type, so initialises the array signed_flag to false.
We need to set the signed_flag to the correct value once we know
the data type, to allow the VPI routines to correctly format the
data.
2013-01-21 18:46:48 -08:00
Cary R 8e515a9a64 Merge branch 'master' of github.com:steveicarus/iverilog 2013-01-11 15:10:17 -08:00
Martin Whitaker 45bb1313e7 Correctly handle negative genvar values.
During expression elaboration, genvar values were being erroneously
cast to unsigned values when creating a verinum for use in expression
evaluation.
2013-01-11 15:09:20 -08:00
Stephen Williams d04aa4b234 Merge branch 'master' of github.com:steveicarus/iverilog 2013-01-05 16:40:14 -08:00
Stephen Williams 074055bc58 Implement static arrays of strings.
This means extending the vvp to add .array/str objects and
include instructions to access the array. Also add the parser
and code generator support.
2013-01-05 15:57:58 -08:00
Stephen Williams d6726f62fc Implement substring method for string expressions. 2013-01-05 11:40:12 -08:00
Stephen Williams bc9e31a444 Cleanup of v2009.vpoi module. 2013-01-05 11:39:17 -08:00
Cary R f682d9cad1 Clean up some more memory when using valgrind
When checking with valgrind clean up the following:

  The arguments for invalid task/function calls.

  The simulation callback queues (only needed when the runtime aborts).

  Call pthread_exit(NULL) just before exiting to cleanup dynamic loading.
2013-01-03 17:57:15 -08:00
Cary R 1305d7659c Remoce space issues. 2013-01-03 16:21:24 -08:00
Cary R 502a0708ea Merge branch 'master' of github.com:steveicarus/iverilog 2013-01-03 16:19:18 -08:00
Cary R c64407f7cf Cleanup new darray in array structure
The valsr real array support was switched to a dynamic array vals. This
patch updates teh valgrind cleanup code to use the correct name.
2013-01-03 16:18:59 -08:00
Stephen Williams cdbfe28c4e Merge branch 'master' of github.com:steveicarus/iverilog 2013-01-03 11:49:50 -08:00
Stephen Williams fbd2843cad Runtime support for arrays of atom2 types.
This handles all of the atom integer types in unpacked arrays.
2013-01-03 11:33:47 -08:00
Cary R 10b5a82904 Remove redundent map clear. 2013-01-02 19:18:37 -08:00
Stephen Williams 1527b87595 Remove useless vvp_realarray_t
The vvp_darray_real class cal be used for static arrays as well
and this is a more general solution anyhow. Kill the now useless
vvp_realarray_t class.
2013-01-02 19:02:02 -08:00
Cary R 4407bc1d50 Fix memory leak when displaying a SV string variable. 2013-01-02 18:31:54 -08:00
Cary R 927edf03d6 Clean up SV class definition when using valgrind.
Also fix a memory leak when compiling class properties.
2013-01-02 17:00:49 -08:00
Cary R f5717a6e87 Update the valgrind cleanup code to handle most tri constructs 2013-01-02 09:54:44 -08:00
Cary R 84a24f2a34 Remove a cppcheck warning and update suppression file 2013-01-01 16:56:58 -08:00
Cary R 60b1ade52d Add support for valgrind cleanup of APV in task call. 2013-01-01 16:54:04 -08:00
Cary R 81ba40456f Fix uninitialized value error in netvector_t constructor 2012-12-30 09:18:26 -08:00
Stephen Williams 1b684a4846 Fix build error for tgt-pcb on non-mac systems. 2012-12-26 15:58:12 -08:00
Stephen Williams 3b43fcfc21 Fix pcb.tgt build error. 2012-12-24 17:42:01 -08:00
Stephen Williams 4b3ef8a314 Merge branch 'master' of github.com:steveicarus/iverilog 2012-12-23 12:18:05 -08:00
Stephen Williams 679ef3a380 Collapse concatenation of constants into concatenated constant. 2012-12-20 11:02:29 -08:00
Stephen Williams 367d7bf94b Blend NetPartSelect(PV) objects into NetConcat
If a signal s driven by multiple non-overlapping NetPartSelect(PV)
objects, then combine them into a single NetConcat object. This
eliminates the need for resolvers in the target.
2012-12-19 19:01:22 -08:00
Stephen Williams a90e264ed7 Merge branch 'master' of github.com:steveicarus/iverilog 2012-12-18 12:47:34 -08:00
Stephen Williams eaa315fc69 Prepare for snapshot 20121218 2012-12-18 12:40:09 -08:00
Cary R b098e31cc7 Fix cppcheck warning and update suppression file 2012-12-18 11:54:26 -08:00
Cary R c104586760 Merge branch 'master' of github.com:steveicarus/iverilog 2012-12-18 11:10:46 -08:00
Cary R 3fa7b3f05a Remove some valgrind warnings and a few errors
Cleanup a few more of the new constructs and fix free/delete mismatches.
2012-12-18 11:10:16 -08:00
Stephen Williams 3ab3828aaf Merge branch 'master' of github.com:steveicarus/iverilog 2012-12-18 10:43:24 -08:00
Stephen Williams 6cc1010281 Handle part select of packed struct members.
This fixes the case of part select of struct members
in continuous assignment l-values.
2012-12-18 10:43:07 -08:00
Cary R 317e53e784 The object ref count must be initialized in the constructor 2012-12-17 18:00:54 -08:00
Cary R 4019525580 Remove space issue in elab_lval.cc (spave before EOL) 2012-12-17 17:26:19 -08:00
Cary R 4b28694509 Remove vlog95 compile warning 2012-12-17 17:14:40 -08:00
Cary R 26193ea8bd Fix compile on cygwin/MinGW 2012-12-17 17:04:44 -08:00
Stephen Williams 9a7155a1fa Merge branch 'master' of github.com:steveicarus/iverilog 2012-12-17 09:13:30 -08:00
Cary R 620b00b322 Update fstapi.c to latest from GTKWave 2012-12-11 11:10:33 -08:00
Stephen Williams 860419a346 Draft run-time support for SystemVerilog class objects.
This provides the ivl_target.h interface for class definitions
and expressions, the vvp code generator support for class objects
and properties, and the vvp run time support. Trivial class objects
now seem to work.
2012-12-10 19:20:02 -08:00
Stephen Williams 70dff035a2 ivl_target API for class types with properties. 2012-12-10 19:20:02 -08:00
Stephen Williams 318a4033b8 Flesh out class type elaboration
Add properties to the classes, and elaborate expressions that
have class properties. Describe class object property references
all the way down to the stub target.
2012-12-10 19:20:02 -08:00
Stephen Williams f7033ca19a Handle class-type identifier expressions. 2012-12-10 19:13:44 -08:00
Stephen Williams 79903ecadd Handle null objects in general. 2012-12-10 19:13:44 -08:00
Stephen Williams e7c6829512 Create a stub vvp_cobject class. 2012-12-10 19:13:43 -08:00
Stephen Williams a186e5ad31 Garbage collection of DARRAY and CLASS objects.
While we're at it, provide a stub class_new runtime.
2012-12-10 19:13:43 -08:00
Stephen Williams b6eb86d696 Blend new_darray and new_class expression nodes. 2012-12-10 19:13:43 -08:00
Stephen Williams 7a2ad01f2e Class new expressions, down to the ivl_target.h API. 2012-12-10 19:13:43 -08:00
Stephen Williams 3e7adbeda0 Stub class object variables.
Create stub class objects at the vvp level and generate the code
to invoke that stub. Implement the routines needed to implement
a test for null object references.
2012-12-10 19:13:43 -08:00
Stephen Williams 6278a5760c Rationalize the vvp_object_t stack API to match other types. 2012-12-10 19:13:43 -08:00
Stephen Williams 77d24cd095 Elaborate class_new and (null) expressions
This gets the types right for class_new and null expressions, and
elaborate them down to the ivl_target.h API.
2012-12-10 19:13:43 -08:00
Stephen Williams 55bebc8c39 Stub to pform class properties and null expressions. 2012-12-10 19:13:43 -08:00
Cary R 80fe66b224 Update cppcheck suppression file to match new fstapi.c 2012-11-27 09:28:45 -08:00
Cary R cb1d4ab359 Update fstapi.c from GTKWave to fix MinGW compile. 2012-11-27 09:19:18 -08:00
Cary R 397054d5fc Update cppcheck suppressions in fst/lxt2 files. 2012-11-15 15:32:36 -08:00
Cary R afdc1fa923 Update fstapi.c and lxt2_write.c to latest from GTKWave
This just fixes warnings in cppcheck
2012-11-15 15:32:29 -08:00
Cary R f01a106c25 Remove a space issue 2012-11-12 18:15:33 -08:00
Cary R 15fb58f8e4 Remove some cppcheck warnings, etc. 2012-11-12 18:15:25 -08:00
Martin Whitaker 78128dd95d Fix for pr3582052.
The code that calculated the canonical index for a multi-dimensional
array access did not correctly estimate the index expression width
in the case that the first index value was a constant zero. This
patch fixes the problem, and, in passing, also makes the expression
calculation more efficient if any of the indices are constant zeroes.
2012-11-03 10:30:17 -07:00
Stephen Williams bad8ed39c1 Parse VHDL subprogram bodies and return statements. 2012-11-03 09:54:07 -07:00
Stephen Williams 0ccb1b4990 Delect class_new and print "sorry" message. 2012-11-03 08:40:03 -07:00
Stephen Williams 5651e6e001 Improve error handling. 2012-11-02 19:30:12 -07:00
Cary R b32e1bcbcb Fix space before EOL in vvp/vthread.cc 2012-10-25 10:37:08 -07:00
Cary R e72852d53f Fix make check in vvp and windows (cygwin) compile 2012-10-25 09:59:06 -07:00
Stephen Williams 222b683849 Clean up invokations of the vector4_to_value template. 2012-10-25 09:13:09 -07:00
Stephen Williams 559d965681 Merge branch 'x-mil4'
Conflicts:
	tgt-vvp/eval_real.c
	vvp/codes.h
	vvp/compile.cc
	vvp/opcodes.txt
2012-10-23 14:48:25 -07:00
Stephen Williams 9d3548798c Clean up the API for the string stack. 2012-10-22 17:37:51 -07:00
Stephen Williams a5fd5363b3 Rewire real value expressions to use a stack instead of register space.
This will hopefully improve performance slightly, but also this
intended as a model for what to do when I get around to doing the
same thing to other data types.
2012-10-22 17:20:43 -07:00
Stephen Williams 0339f5ed57 Parse package import declarations. 2012-10-21 15:06:23 -07:00
Stephen Williams 62be9c5b46 Parse (with sorry message) package declarations. 2012-10-21 11:42:19 -07:00
Stephen Williams 0059fb1ec7 Support for dynamic arrays of strings.
Strings, when put into dynamic arrays, are treated as first class
types much line reals. Add the code generator and vvp support for
this situation. Also fix a bug distinguishing between character
selects from strings and select form arrays of strings.
2012-10-14 17:16:47 -07:00
Stephen Williams d6efece5dd Handle DARRAYs of real variables
This involves working out the code to get the base type of a select
expression of a darray. Also added the runtime support for darrays
with real value elements.
2012-10-14 17:16:47 -07:00
Stephen Williams 1326f9aef1 Handle darray objects of all integral atom types.
Clean up the vector4_to_value to use templates and explicit
instantiations. This makes the interface much cleaner for a
wider variety of integral types.
2012-10-14 17:16:47 -07:00
Stephen Williams e071bd81ee Handle select of darray signals in general expressions. 2012-10-14 17:16:47 -07:00
Stephen Williams a2d980540d Get some type information to the "new" expression for darrays. 2012-10-14 17:16:47 -07:00
Stephen Williams 1aa21aa9e8 ivl_target interface to packed type details.
The darray in particular needs to know about the subtype info.
In the process, clean up some of the type information.
2012-10-14 17:16:47 -07:00
Stephen Williams 914ebeca4a Some rework to allow for nested packed types.
This also simplifies the NetNet set of contructors and generalizes
the types that are supported, especially packed types.
2012-10-14 17:16:47 -07:00
Stephen Williams 4e76912331 ivl_target access to type information. 2012-10-14 17:16:47 -07:00
Stephen Williams 494dc876a5 Move net vector properties to netvector_t object. 2012-10-14 17:16:47 -07:00
Stephen Williams 997274b98f Cleaner netdarray_t implementation. 2012-10-14 17:16:47 -07:00
Stephen Williams 92313654ec Rework the way vectors are represented in NetNet objects. 2012-10-14 17:16:47 -07:00
Cary R 5347217b56 A signal can be an enumeration variable.
An enumeration variable can be a R-value in an enumeration assignment so
pass on this attribute.
2012-10-10 18:28:21 -07:00
Cary R f957deeca7 Get the vvp code to compile with the valgrind hooks again.
This patch updates the vvp code so it will compile with the valgrind hooks
again. There are still new constructs that need to be cleaned up correctly
and some old constructs were changed enough that the old code no longer
works, but the rest of this can be done as an incremental improvement.
2012-10-08 18:53:55 -07:00
Cary R e0f82981e7 Remove some compiler warnings 2012-09-24 10:28:17 -07:00
Cary R 016d64e443 Remove spacing errors. 2012-09-24 09:57:28 -07:00
Stephen Williams 6137566385 Merge branch 'work12' 2012-09-14 17:28:50 -07:00
Cary R daa12ec2b3 Update line numbers for cppcheck suppressions 2012-09-13 12:44:39 -07:00
Stephen Williams c14134aa2e Handle genvar variables in expressions.
In generate for blocks, there is a genvar that can be used in
expressions within the generate block. Generate this genvar in
the generated output, matched to the generate scope.
2012-09-07 15:14:48 -07:00
Cary R f5407824ba Add %u support to the scanf routines. 2012-09-05 14:24:01 -07:00
Cary R a3f3f7ae58 Add support for %z to the scanf() routines 2012-09-04 18:46:24 -07:00
Stephen Williams 9cca1378bb Handle continuous assign to packed member of packed array of struct.
This still requires that the index expression is constant.
2012-09-03 16:00:10 -07:00
Stephen Williams b8093be42f Rework parse rules to handle more net types.
This makes the rules for types to be more in line with IEEE1800.
2012-09-03 16:00:10 -07:00
Stephen Williams f24d6b055d Use data_type_t instead of raw type bits. 2012-09-03 16:00:10 -07:00
Stephen Williams 85e000ed0c Handle prefix expressions that include array index expressions. 2012-09-03 16:00:10 -07:00
Stephen Williams 7fad717a1e Redesign selected_name rule to better handle complex prefixes
Prefixes of hierarchical names are complex and cannot be handled
by simple strings, to the rules must be reworked.
2012-09-03 16:00:10 -07:00
Stephen Williams a14b8c517c Clean up Design::find_scope method use. 2012-09-03 16:00:10 -07:00
Stephen Williams 174177d437 Rework symbol search to work incrementally.
This is necessary to handle paths that turn out to end with
member names instead of symbol names.
2012-09-03 16:00:10 -07:00
Stephen Williams 0bdabab4fb Rework packed dimensions handling
Make packed structs more obviously parts of a vector.
Handle arrays of structs in certain cases.
2012-09-03 16:00:10 -07:00
Stephen Williams b4cc9d14a5 Handle packed arrays of packed struct in l-value expressions. 2012-09-03 16:00:09 -07:00
Stephen Williams 3d9ed1f0f8 Clean up PWire handling of wire data type. / Reword packed type handling 2012-09-03 16:00:09 -07:00
Cary R adff837399 Remove some new cppcheck warnings in tgt-vlog95 2012-09-03 11:58:43 -07:00
Cary R 29ade50cab Remove some cppcheck warnings in the main and vvp diretory. 2012-08-31 18:22:59 -07:00
Cary R cb9e1ee37e Remove a few more cppcheck warnings in the tgt-* directories. 2012-08-31 18:18:12 -07:00
Cary R 4cd295cbba Fix printf opcode argument mismatches in tgt-vvp (cppcheck) 2012-08-31 12:36:55 -07:00
Cary R 1a82287f1e Remove some cppcheck reduce scope warnings. 2012-08-31 12:12:08 -07:00
Cary R 882d059c1d Windows (mingw) _vsnprintf() returns -1 not the required size on overflow.
Windows and hence mingw does not follow the standard regarding the return
value of vsnprintf(). The mingw code needs to iteratively search for a
buffer large enough to print the output.
2012-08-31 10:57:24 -07:00
Cary R 7adb30f383 Cleanup after the va_copy()
I missed that va_end() needs to be called on the new ap created by va_copy().
2012-08-31 09:22:23 -07:00
Cary R 0278f513c5 Save the va_list so it can be reused if needed.
The second call to vsnprintf() needs to have a copy of the argument list
so it can run correctly. On some system vsnprintf() destorys the original
argument list.
2012-08-30 20:04:18 -07:00
Cary R 16d569eb3f Fix new/free mismatch in vvp. 2012-08-30 19:33:25 -07:00
Cary R faf456ee7e Allocate a string buffer as needed in the code generator and vvp display code
When sending a string to a system task/function allocate the space needed
to avoid truncating the string vs using a large fixed buffer.

In vvp allocate and use an exactly sized buffer for the MCD print routine if
the fixed buffer is not large enough. Using a fixed buffer keeps normal
printing fast.
2012-08-30 19:12:11 -07:00
Arun Persaud f5aafc32f9 updated FSF-address 2012-08-29 10:12:10 -07:00
Martin Whitaker 1f152aa838 Fix for pr3557493.
defparam assignments found inside a generate block were being stored
in the enclosing module scope. They should be stored in the generate
block scope.

Also removed the genvar list from the PGenerate class, as this is
already declared in the base LexicalScope class.
2012-08-21 17:46:34 -07:00
Cary R 83fff3adf7 Remove more CVS stuff
Remove the CVS information in the documentation and the remaining
tgt-* directories.
2012-08-16 15:15:26 -07:00
Cary R 2989cebaa5 Update lxt, lxt2 and fst files to latest from GTKWave 2012-08-16 14:56:01 -07:00
Cary R 4313fbbf1f Fix space errors in various files 2012-08-16 11:13:32 -07:00
Cary R 0d61f7384d Remove CVS remnants for libveriuser files. 2012-08-16 10:51:29 -07:00
Cary R 3e9f831026 Reduce scope to avoid cppcheck warning.
This patch reduces the scope of the str variable to avoid a cppcheck
warning. It also sets the end pointer to NULL since it is not used/needed.
2012-08-16 10:51:18 -07:00
Cary R 69c5d6f5ce Update uninstall include directory rule 2012-08-13 17:10:55 -07:00
Cary R 3af34263ab Fix a bug where top level module ports were double elaborated 2012-08-08 13:34:26 -07:00
Cary R bc85385f13 Change duplicate msb_ to be lsb_ 2012-08-08 12:23:14 -07:00
Cary R 0f1523e15d vlog95: minor tweak for array index calculation 2012-08-08 11:59:11 -07:00
Cary R 87ea093b4e Remove some cppcheck warnings in vvp directory 2012-08-08 11:43:26 -07:00
Cary R 7ce8a9b01c Fix some cppcheck warnings in the main directory 2012-08-08 11:28:20 -07:00
Cary R 429babf831 vlog95: Translate some assignment with opcode statements.
This patch updates the code to translate the SystemVerilog assignments with
an opcode to the appropriate vlog95. This includes ++ and -- when used in
a statement context. The ++ and -- operators are not currently translated
in an expression context. This translation only occurs in two places:
A simple assignment statement (foo += 2;) and the increment of a for
statement. I still need to check if there are other places where these
operators are allowed.
2012-08-07 16:45:21 -07:00
Cary R 331c9ef64a Fix mistake in post incr/decr warning messages. 2012-08-07 16:22:29 -07:00
Cary R e26dbfefe7 Minor spelling fix 2012-08-07 16:20:29 -07:00
Cary R 0faaa79bae Remove two duplicate typedef statements.
These two typedefs exactly matched earlier ones in the same scope and
gcc was complaining that they were shadowing the previous definitions.
Since the definitions matched exactly just deleting the second
typedef was acceptable.
2012-08-07 10:52:24 -07:00
Cary R 8158153ea4 vlog95: Add checks for missing assignments with opcodes
SystemVerilog supports using assignments with opcodes (e.g. +=). This
patch checks for these in a few common places and prints a warning
that they are not currently supported. Eventually the simple cases
will be converted.
2012-08-06 19:19:02 -07:00
Cary R 62412700aa vlog95: Add an error message that SV strings and darrays are not supported
We can not convert SystemVerilog strings or dynamic arrays to valid vlog95.
This patch adds an error message that they are not supported. There are still
issues with converting some of the dynamic array constructs (the compiler
crashes), but the message is printed before the crash.
2012-08-06 18:20:14 -07:00
Cary R 1749d10966 Fix some clang/bison compile warnings. 2012-08-06 15:49:11 -07:00
Martin Whitaker 34719c3163 Fix time scaling in PLI TF routines for MinGW.
When built with MinGW, pow() may not always generate an exact integer
result when supplied with integer operands. Converting the result to an
integer before we use it seems to be enough to work round this issue.
2012-08-06 13:38:14 -07:00
Martin Whitaker 4af8b03e9d Fix premature memory delete and missing DLL export definition.
A couple of errors that showed up in a MinGW build.
2012-08-06 13:31:03 -07:00
Cary R 7179274bde vlog95: Add support for some more SV constructs and add some sorry messages
This patch adds support for SystemVerilog packed arrays and adds sorry
messages for generate blocks as well as the new SV final and
fork/join_any/join_none statements.
2012-08-06 10:16:35 -07:00
Martin Whitaker 5aa97b379d Add missing semi-colons in parser rules.
Plus a few minor spelling/formatting fixes.
2012-08-01 15:38:36 -07:00
Stephen Williams 813f548a4b Merge branch 'x-mil3'
Conflicts:
	vpi/Makefile.in
	vpi/sys_table.c
2012-07-30 17:02:57 -07:00
Stephen Williams 082418d73b Add missing netdarray.h header file. 2012-07-29 16:25:26 -07:00
Martin Whitaker ebe81f7059 Eliminate duplicate error messages for indexed part selects.
This patch stops the compiler generating duplicate error messages
when an indexed part select has an illegal width.
2012-07-27 18:42:53 -07:00
Martin Whitaker c4ff8300d3 Handle error case of zero width in indexed part select.
The compiler doesn't currently check that the width of an indexed
part select is non-zero. If code contains this erroneous case, the
compiler can crash (with an assertion failure). This patch causes
the compiler to output a suitable error message and recover. It
also fixes a potential crash if an illegal expresson is encountered.
2012-07-27 18:42:43 -07:00
Martin Whitaker a5a512758e Allow a UDP instance to have a simple real delay.
The parser does not distinguish between module and UDP instances, so
a UDP delay is handled by the rules used for parsing module parameter
overrides. Although these rules had been relaxed to accept the case of
a simple decimal value (e.g. #10), they did not allow a simple real
value (e.g. #0.1).
2012-07-27 18:30:09 -07:00
Larry Doolittle befff82655 Spelling fixes
Comments and debug messages.
2012-07-27 18:25:32 -07:00
Martin Whitaker dd284ee582 Additional support for $countdrivers.
This patch extends the implementation of $countdrivers to handle wires
connected to islands.
2012-07-27 18:09:41 -07:00
Martin Whitaker 6836068a16 Initial support for $countdrivers.
This patch implements the $countdrivers system function. It does not
yet support wires connected to islands (and outputs a suitable "sorry"
message when this is detected).
2012-07-27 18:09:32 -07:00
Martin Whitaker a290c58a2e Rework of vvp resolver networks to support $countdrivers.
To implement the $countdrivers system function, we need to be able to
find all the driver values for a given wire. Currently, if a wire has
has more than four drivers, the compiler builds a resolver tree out
of 4-input nodes to resolve the driven values, and there is no way at
run time to work back from the output node to the original driver
values. This patch moves the implementation of the resolver tree into
a single vvp functor (using a mechanism similar to wide functors to
support more than 4 inputs), thus gathering all the driver values into
a single place.
2012-07-27 18:09:25 -07:00
Stephen Williams 94e217f02b vvp support for dynamic arrays.
This words completely for single-dimension dynamic arrays of
32bit integers. These changes also act as a stub for other
target types.
2012-07-22 10:52:07 -07:00
Stephen Williams fdc92ea464 Elaborate dynamic array expressions (lval/rval) down to ivl_target.h 2012-07-22 10:52:07 -07:00
Stephen Williams 18714e2efd Support the delete method for objects. 2012-07-22 10:52:06 -07:00
Stephen Williams d0e6b24ca2 Support the new[] operator for arrays
Implement through the ivl core to the ivl_target.h API.
Also draft implementation of creating and storing arrays
in the vvp runtime and code generator.
2012-07-22 10:52:06 -07:00
Stephen Williams 14f229de30 Parse support for dynamic arrays.
This includes limited support for dynamic arrays down to the code
generator, and some stubs in the vvp code generator and vvp run time.
2012-07-22 10:52:06 -07:00
Stephen Williams a337a9388b Handle string[x] in l-values and system function arguments
When string[x] is an l-value, generate code to implement something
like the string.putc(x, ...) method.

Also handle when string[x] is the argument of a system task. In that
case resort to treating it as a calculated 8-bit vector, because that
is what it is.
2012-07-22 10:52:06 -07:00
Stephen Williams 2bef6b8624 Detect and implement string.len() method, and string[index] expressions
Implement the string.len() method in the system.vpi, and implement
the string[index] method in vvp.
2012-07-22 10:52:06 -07:00
Stephen Williams f77bdf7e38 Handle concatenation of SystemVerilog strings. 2012-07-22 10:52:06 -07:00
Stephen Williams 2bd3d9ed5d Allow strings to be constructed formats in $display et al. 2012-07-22 10:52:06 -07:00
Stephen Williams cf1b83b8f0 Implement comparison operators for strings. 2012-07-22 10:52:06 -07:00
Stephen Williams dc39714d65 Support string literal strings in the vvp runtime.
This also advances support for string expressions in general.
Handle assignments to string variables in the code generator by
trying to calculate a string expression. This involves the new
string object thread details.
2012-07-22 10:52:06 -07:00
Stephen Williams d48362b861 First pass at getting strings to work.
In vvp, create the .var/str variable for representing strings, and
handle strings in the $display system task.

Add to vvp threads the concept of a stack of strings. This is going to
be how complex objects are to me handled in the future: forth-like
operation stacks. Also add the first two instructions to minimally get
strings to work.

In the parser, handle the variable declaration and make it available
to the ivl_target.h code generator. The vvp code generator can use this
information to generate the code for new vvp support.
2012-07-22 10:52:06 -07:00
Cary R ea420d94ac Fix for pr3539372.
This patch matches what was proposed in pr3539372 to fix ivlpp to correctly
handle an escapped \ at the end of a string.
2012-07-09 11:42:28 -07:00
Cary R a35ca1d70b Remove debug message in vvp/vpi_signal.cc 2012-07-09 10:30:36 -07:00
Martin Whitaker bef59e0b6c Fix for pr3534333.
The parser had been changed to support null statements in sequential
and parallel blocks (a feature introduced in SystemVerilog), but was
not supported in elaboration, leading to a compiler crash. This patch
fixes this by discarding the null statements during parsing.
2012-07-01 12:23:47 -07:00
Martin Whitaker 0d0e6d7845 Fix elaboration order in generate blocks.
Currently, localparam declarations inside generate blocks are
elaborated after any nested generate constructs are elaborated.
This prevents the localparams being used by the nested constructs.
Reversing the elaboration order fixes this bug.
2012-07-01 12:07:49 -07:00
Cary R f36faa8ab3 Mingw needs to use Sleep vs sleep (also seconds go to ms) 2012-06-07 10:01:12 -07:00
Cary R c46823e280 Update ivl.def to support new ivl interface functions 2012-06-07 09:42:36 -07:00
Andrew Stevens 9b3d20239a Extend VPI and build to for SIMetrix cosimulation
Added: basic vpiPort VPI Objects for vpiModulkes
    vpiDirection, vpiPortIndex,   vpiName, vpiSize attributes

   Since ports do not exist as net-like entities (nets either side
   module instance boundaries are in effect connect directly in
   the language front-ends internal representation) the port information
   is effectively just meta-data passed through t-dll  interface and
   output as a additional annotation of module scopes in vvp.

Added: vpiLocalParam attribute for vpiParameter VPI objects

Added: support build for 32-bit target on 64-bit host (--with-m32
   option to configure.in and minor tweaks to Makefiles and systemc-vpi).
2012-06-07 08:00:02 -07:00
Martin Whitaker 3354d83391 Support if statements and function calls in constant functions. 2012-06-06 19:34:08 -07:00
Stephen Williams cec68cfc61 Merge branch 'x-mil2' 2012-06-06 19:17:27 -07:00
Stephen Williams 62b67c1843 More expression types supported during constant function evaluation. 2012-05-29 17:59:29 -07:00
Stephen Williams a5a7050120 More expression types work in constant functions. 2012-05-29 13:56:16 -07:00
Stephen Williams def9d0ea1d Basic infrastructure for compile-time function evaluation. 2012-05-29 10:02:10 -07:00
Stephen Williams d10e4bca4c Remove some uses of the svector class. 2012-05-28 16:49:41 -07:00
Stephen Williams 25f72e31d4 Re-implement fork/join in vvp
The fork/join list did not adequately support the tree of processes
that can happen in Verilog, so this patch reworks that support to
make it all more natural.
2012-05-27 18:26:54 -07:00
Stephen Williams 3b7619b46c Implement fork-join_none in vvp. 2012-05-27 18:26:54 -07:00
Stephen Williams 47ddf5220c Fix assertion settin join type is PBlock statements. 2012-05-27 18:26:53 -07:00
Stephen Williams 6a57764e0e Elaborate fork-join_none and fork-join_any statements. 2012-05-27 18:26:53 -07:00
Stephen Williams c0f35cbe62 Disallow modules/gates in program blocks. 2012-05-27 18:26:53 -07:00
Stephen Williams 8154ce2a4a Reword how we enforce program block constraints
Making the scope type NESTED_MODULE was just plain wrong, because
it didn't really encapsulate the meaning of program blocks OR
nested modules. So instead create nested_module() and program_block()
flags and use those to test scope constraints.
2012-05-27 18:26:53 -07:00
Stephen Williams dfe7beec31 Allow modules (and program blocks in particular) to nest.
An important advantage of program blocks is its ability to nest
within a module. This winds up also allowing modules to nest, which
is legal but presumably less used feature.
2012-05-27 18:26:53 -07:00
Stephen Williams 580c44c015 Prevent non-blocking assignment in program blocks. 2012-05-27 18:26:53 -07:00
Stephen Williams 0833d9e37a Basic support for program blocks. 2012-05-27 18:26:53 -07:00
Stephen Williams 342646264e Merge branch 'pei1' 2012-05-25 16:32:12 -07:00
Stephen Williams 6e8aef8262 Get unpacked arrays working. 2012-05-25 15:58:29 -07:00
Stephen Williams ceaa60d2f4 Parse (to "sorry") arrays of named types. 2012-05-22 17:31:27 -07:00
Stephen Williams 621c09105c Sort the typedef emits so that types are emitted in the order used.
It is common for typedefs of complex types to use further typedefs.
Emit the type definitions depth first so that the types that are used
are defined first. This reduces the need for pre-declaration of types.
2012-05-22 17:31:27 -07:00
Stephen Williams 369a0b9eca VHDL named types work in more places. 2012-05-22 17:31:27 -07:00
Stephen Williams 2443884779 Parse/sorry nets of named type. 2012-05-22 17:31:27 -07:00
Stephen Williams 4748f0cb5e Handle incomplete type declarations
Use these in the package library to allow for arbitrary mixing
of type declaration and use. This makes writing libraries much
easier.
2012-05-22 17:31:27 -07:00
Stephen Williams 315ac4f179 support part select of struct members that are packed arrays. 2012-05-22 17:31:26 -07:00
Stephen Williams 039e6014fe Rework VType::emit_def methods / use packed arrays to implement arrays.
VHDL arrays are more like SV packed arrays, so use packed arrays
to implement them.
2012-05-22 17:31:26 -07:00
Stephen Williams e7a974347e Handle packed array slices at module ports. 2012-05-22 17:31:26 -07:00
Stephen Williams 63b7fe059d Reword concat to handle aggregate arguments.
When concatenation expressions have aggregate arguments, we need to
get the type of the result down to the aggregate expressions so that
it can know how to interpret the elements.
2012-05-22 17:31:26 -07:00
Stephen Williams 247f6a4ecf Handle properly parsed structs in module ports. 2012-05-22 17:31:26 -07:00
Stephen Williams 67af96fee7 Module output ports use data_type_or_implicit
This cleans up the parsing of module output ports, allows for more
complex types on the ports, and fixes some bugs.
2012-05-22 17:31:26 -07:00
Stephen Williams b7b633b613 module output ports use data_type_t types.
This is in place of ad hoc type information passed to the
pform_module_define_port function.
2012-05-22 17:31:26 -07:00
Stephen Williams 7e202bb5ca Fix emit of struct ports/declarations. 2012-05-22 17:31:26 -07:00
Stephen Williams c7366e65cd Rework port input and inout to use data_type_or_implicit rule for types. 2012-05-22 17:31:26 -07:00
Stephen Williams 71d2401221 Handle VHDL records.
Elaborate records and emit them as packed SV records. Also handle
record members so handle name prefixes.

While we are at it, handle some cases of array aggregate expressions.
2012-05-22 17:31:26 -07:00
Stephen Williams ae06863db1 Elaborate prefix names which may be structure variables. 2012-05-22 17:31:26 -07:00
Stephen Williams a5458828cd Some vhdl parser error handling. 2012-05-22 17:31:26 -07:00
Stephen Williams 021d944a30 Probe type of ExpName with a record prefix. 2012-05-22 17:31:25 -07:00
Stephen Williams 7eb89c5548 Parse name prefix syntax for record member reference.
When signals/variables are records, they are often referenced by
their members, using a prefix.name syntax. Parse that syntax and
generate "sorry" messages in elaboration.
2012-05-22 17:31:25 -07:00
Stephen Williams 5e7f61ea42 VHDL process sensitivities go to the end of each iteration 2012-05-22 17:31:25 -07:00
Stephen Williams 78b0b49a4e Support struct members that are packed arrays. 2012-05-22 17:31:25 -07:00
Stephen Williams 9b816f6478 Add support for nested when/else expressions. 2012-05-22 17:31:25 -07:00
Stephen Williams 1249b5dd32 Initial support for if_generate syntax. 2012-05-22 17:31:25 -07:00
Stephen Williams 0775e36a67 Properly elaborate argument types for binary relation expressions.
The argument types of binary relation expressions are decoupled
from the return type for the expression itself.
2012-05-22 17:31:25 -07:00
Stephen Williams ed3da959f3 Support types in packages.
Types declared in packages should be written into the package library.
2012-05-22 17:31:25 -07:00
Stephen Williams 79435924f2 Move some VType::show methods to ::write_to_stream methods. 2012-05-22 17:31:25 -07:00
Stephen Williams 9ed56a6354 Parse record types, and some new aggregate types. 2012-05-22 17:31:25 -07:00
Martin Whitaker f7ba954ef7 Fix for pr3527022.
This patch adds support for an explicit range or type in a parameter
declaration that is part of a module parameter port list.
2012-05-18 13:30:28 -07:00
Stephen Williams 2d0c786bfb Remove excess evaluate_parameters method calls. 2012-05-18 08:07:27 -07:00
Larry Doolittle 84f14dbc81 Spelling fixes to vhdlpp tree
Mostly comments as usual, but one error message is changed.
2012-05-17 16:42:03 -07:00
Martin Whitaker 509ec1dcb1 Simplify parameter handling in the elaborated netlist.
A NetScope object currently has two lists of parameters, 'parameters'
and 'localparams'. However, user-declared localparams are stored in
the 'parameters' list, and 'localparams' is only used for adding
genvar values to the parameter list. There seems no good reason to
maintain separate lists, as the lists are merged before being passed
to the target DLL. This is most likely a hang-over from older code.
2012-05-17 16:29:06 -07:00
Martin Whitaker 5cbdac2a46 Add missing semi-colons in main compiler parse.y
This fixes some warnings from Bison.
2012-05-17 16:25:28 -07:00
Martin Whitaker 44c5a37ab8 Allow specparam declarations outside specify blocks.
This patch extends the compiler to support all specparam declarations
allowed by the 1364-2005 standard. For compatibility with other
simulators, it allows specparam values to be used in any constant
expression, but outputs a warning message and disables run-time
annotation of a specparam if it is used in an expression that must
be evaluated at compile time.
2012-05-17 16:18:38 -07:00
Stephen Williams e5f84002b1 Merge branch 'master' of github.com:steveicarus/iverilog 2012-05-13 18:32:55 -07:00
Stephen Williams 5d05d97eb0 Repair handling of attributes attached to variables. 2012-05-09 10:56:52 -07:00
Stephen Williams c3f25c3c6c Prepare for 2012-05-01 snapshot 2012-05-01 08:50:07 -07:00
Stephen Williams 2013addd22 Fix check for SV continuous assign to variable.
SystemVerilog allows a variable to be used as a variable OR
as an unresolved wire. The detection of this case was checking
the references to the affected value, instead of the l-value
references.
(cherry picked from commit cceeaa30f27260cd444015cb39b04353cb858768)
2012-04-30 17:04:45 -07:00
Martin Whitaker 75b12151a4 Disable width minimisation of literal numbers passed to system tasks.
The final step of expression elaboration is to reduce the width of
lossless/unsized constant expressions to the minimum needed to hold
the resulting constant value. This leads to unexpected results if
the user supplies a literal number with redundant digits that gets
passed to a system task that is sensitive to the width (e.g. $display).
This patch prevents width reduction occurring in this case.
2012-04-30 16:39:30 -07:00
Stephen Williams fb3969b5b8 Add command line control over anachronism warnings. 2012-04-30 16:30:24 -07:00
Stephen Williams 69c10c4722 Handle case generate under a conditional generate that is unnamed.
When a conditional statement is unnamed, it doesn't create a scope
and we get into "direct" generate scheme elaboration. This direct
elaboration needs to handle case generate schemes.
2012-04-30 16:00:25 -07:00
Stephen Williams 8ea1e49768 Improve net bit select calculations. 2012-04-30 11:48:33 -07:00
Stephen Williams abf8274e4b Fixup parse of attributes attached to statements. 2012-04-27 18:22:25 -07:00
Gordon McGregor ae901f3285 adding vpi_mode_flag controls around callbacks in vpiNextSimTime 2012-04-27 17:24:13 -07:00
Martin Whitaker 39ee49b252 Improved behaviour of tranif when control is 'x' or 'z'.
The IEEE standard does not specify the behaviour of a tranif primitive
when its control input is an 'x' or 'z'. vvp currently treats these as
if the tran was turned off, but it would be better to propagate the
uncertainty to the tran bi-directional ports. For compatibility with
other simulators, we adopt the behaviour specified for MOS primitives.
2012-04-27 17:08:38 -07:00
Stephen Williams f926cbcc59 Merge branch 'master' of github.com:steveicarus/iverilog 2012-04-26 09:03:20 -07:00
Cary R 568db8c06e Merge branch 'master' of github.com:steveicarus/iverilog 2012-04-11 09:13:36 -07:00
Cary R 761a38d0a8 Spelling fix 2012-04-11 09:13:14 -07:00
Stephen Williams e55af496e5 Merge branch 'master' of github.com:steveicarus/iverilog 2012-04-10 15:31:32 -07:00
Stephen Williams 13348ba7ac Ranges are ranges, not expression lists.
This is a cleanup in preparation for better support of range lists.
(cherry picked from commit 8f7cf3255acad55841f8b3725e3786ef49daad68)

Conflicts:

	PTask.h
	elab_scope.cc
	elab_sig.cc
	parse.y
	pform.cc
	pform.h
	pform_types.h

Signed-off-by: Stephen Williams <[email protected]>
2012-04-10 14:29:28 -07:00
Larry Doolittle bb1036b55c Spelling refresh 2012-04-09 16:19:02 -07:00
Cary R 2b5c82d141 SystemVerilog unbased literals cannot take a size.
The SystemVerilog unbased literals (e.g. '0, '1, etc.) are expected to be
used standalone and cannot take a size. This patch modifies the parsing
code to give a good error message when this is done.
2012-04-09 16:01:25 -07:00
Stephen Williams cf0b45702f Merge branch 'master' of github.com:steveicarus/iverilog 2012-04-03 07:57:02 -07:00
Cary R 42239a8498 Add code to test the width of individual structure elements.
This patch adds code to correctly set the type and width of individual
structure elements. Note the sign information is not currently available.
2012-04-02 19:53:47 -07:00
Stephen Williams 09493a198f Merge branch 'master' of github.com:steveicarus/iverilog 2012-04-02 19:22:40 -07:00
Stephen Williams 3657b15428 Merge branch 'x-ms1' 2012-04-02 19:22:31 -07:00
Cary R c222169608 Update vecval size calculation in vvp and vpi code.
The standard specifies that the size of a vecval should be calculated as
(size - 1)/32 + 1. When size is a PLI_INT32 this is needed to prevent an
overflow, but when the size is unsigned this can be simplified to
(size + 31)/32 since the size must fit into an integer, but we have an
extra significant bit in an unsigned so no overflow can happen.

This patch changes the code to use the correct version of the equation
depending on the context.

The previous patch does this in vvp/vpi_priv.cc
2012-04-02 08:18:46 -07:00
Cary R b85e7efca8 For a delayed vpi_put_value() copy any pointer data members.
When vpi_put_value() is asked to delay the assignment any pointer data
needs to be duplicated so that the caller can clean up the locally
allocated memory without causing memory access problems.

Also update word calculation to match the next patch.
2012-04-02 08:18:32 -07:00
Martin Whitaker 327194cd40 Fix for pr3499807.
If a tranif gate has a delay, the vvp code generator needs to generate
a unique label for the island port used for the tranif enable, to
prevent a name collision if the undelayed signal is also connected
to the island.

Also add an assertion in vvp to catch bugs like this.
2012-03-12 09:03:53 -07:00
Stephen Williams 5dbe688296 Allow variable initialization in any scope.
This is a SystemVerilog feature, so only allow it when
compiling SystemVerilog files.
2012-03-11 15:08:42 -07:00
Stephen Williams b0d61813b2 Get the scope of class methods right
Class methods belong in a class scope, not the containing module.
So create a lexical scope that carries tasks and functions and
create a PClass to represent classes.
2012-03-11 13:18:24 -07:00
Stephen Williams b80afdf1f1 SystemVerilog randomize method syntax. 2012-03-10 10:27:02 -08:00
Stephen Williams dbc6f0cff2 Parse SystemVerilog syntax for task calls.
Tasks call arguments may be dropped in favor of default values.
Allow for that in the syntax. This requires a little handling
of the non-SystemVerilog case during elaboration.
2012-03-10 09:50:41 -08:00
Stephen Williams da743c3b2c Bunches more SystemVerilog syntax. 2012-03-09 18:54:05 -08:00
Stephen Williams 8c2e4a0892 Support tasks with no behavioral statements (System Verilog) 2012-03-04 20:04:07 -08:00
Stephen Williams 0e01dcf2b9 Miscellaneous SystemVerilog syntax.
... and sorry messages.
2012-03-04 19:33:16 -08:00
Stephen Williams 31d4aa9a77 Handle complexities of class name pre-declarations
Class names can be declared early, before definitions, so that the
name can be used as a type name. This thus allows class definitions
to be separate from the declaration. This creates some complexity in
the parser, since the lexor knows about the class names.
2012-03-02 21:16:53 -08:00
Stephen Williams f749867369 Rework rules for variable_dimensions, and support more syntax. 2012-03-02 18:34:43 -08:00
Stephen Williams 64ea328823 Parse dynamic array declarations. 2012-03-01 18:48:16 -08:00
Stephen Williams dbc58838d5 Parse class extends syntax and property qualifiers. 2012-03-01 18:17:52 -08:00
Stephen Williams 68eab8c664 Parse function declarations in classes.
Also add support for function end names when parsing SystemVerilog.
2012-02-26 19:16:10 -08:00
Stephen Williams f33086fed4 Parse dynamic_array_new statements. 2012-02-26 18:45:22 -08:00
Stephen Williams ebda9777cc Parse foreach loops. 2012-02-26 11:28:44 -08:00
Stephen Williams 481a9dec69 More rework to canonicalize tf_port_item rules. 2012-02-26 10:57:03 -08:00
Stephen Williams 410350ae5a Rework data_type parsing to bring integer vectors into data_type_t method.
This adds the vector_type_t and real_type_t types to handle
vector and real types in tf_port items. This cleans up a lot
of the parsing for these items.
2012-02-25 22:05:00 -08:00
Stephen Williams dd3a7411cd Parse SystemVerilog ref ports. 2012-02-25 10:19:48 -08:00
Stephen Williams d000147392 Parse for declarations, implement for_step statements.
for-statement declarations still generate a "sorry" message, but
the for_step statements work in general now.
2012-02-25 09:28:20 -08:00
Stephen Williams cad7c74680 System Verilog supports closing names after endtask keyword. 2012-02-24 17:04:49 -08:00
Cary R bae02433b7 Remove some more warnings in pform.cc Ubuntu 11.10 (gcc/clang)
Remove a few more warnings from the gcc and clang compilers on
Ubuntu 11.10.
2012-02-22 17:27:27 -08:00
Cary R 952b84fba3 Fix signed/unsigned compare warning
Fix a signed/unsigned comparison warning on RHEL 5.
2012-02-22 15:11:01 -08:00
Cary R 51ef541969 Fix compile on cygwin and fix a few compile warnings.
This patch fixes a few compile warnings and adds the new packed routines
to the ivl.def file so that this links correctly on cygwin.
2012-02-22 10:20:49 -08:00
Stephen Williams f8e346f108 Implement increment/decrement statements.
During parse/pform processing, convert increment statements to
the equivalent compressed assignment statement. This is less weird
for elaboration processing and better expresses what is going on.
2012-02-19 18:54:58 -08:00
Stephen Williams 6b4251626b Parse array literals / rearrange task declaration rules. 2012-02-19 17:31:15 -08:00
Stephen Williams 8456252c0c More class syntax
Part of ongoing parser work to support SystemVerilog classes.
2012-02-19 10:29:50 -08:00
Stephen Williams 5880a3ad8f Parse program blocks / Fix module end-name syntax. 2012-02-18 10:02:54 -08:00
Larry Doolittle 0aefcf9b48 Trivial fixes to grammar, spelling, whitespace 2012-02-17 16:18:22 -08:00
Stephen Williams 8b9fdbc55b Merge branch 'master' of github.com:steveicarus/iverilog 2012-02-17 08:21:49 -08:00
Stephen Williams fec1c1efde Handle r-value constant slice selects. 2012-02-12 16:19:58 -08:00
Stephen Williams 77f168cf28 Support non-constant indexed part select of packed arrays. 2012-02-12 14:52:47 -08:00
Cary R 391073a750 Update __vpiNamedEvent to remove struct and remove extra class statements
The clang compiler does not like using struct to reference a class object.
This patch removes all the struct keywords for __vpiNamedEvent objects
since they are now a class and can be called without a struct/class
qualifier.

This patch also removes all the extra class qualifiers from the rest of
the source code.
2012-02-12 13:22:32 -08:00
Stephen Williams 5e067bd651 Handle constant indexed part selects. 2012-02-12 12:03:43 -08:00
Stephen Williams c1b73c83f4 Respond better to some error/sorry situations. 2012-02-12 11:16:31 -08:00
Stephen Williams 6eeef8311f Handle indexed bit select of packed arrays.
This handles a few cases where the non-constant bit selects are
in the final index. This doesn't handle all the cases of packed
arrays, but it handles some common cases.
2012-02-12 10:13:20 -08:00
Stephen Williams 4287fc4b50 Handle l-value part select of packed arrays. 2012-02-10 18:48:12 -08:00
Stephen Williams 3e4f8b625f Get packed signals working through to simulation in some situations.
When dynamic indexing of early dimensions is not needed, we can get
pretty far with getting packed arrays to work.
2012-02-10 17:17:59 -08:00
Stephen Williams e5c49022b4 The NetNet class carries multiple packed dimensions. 2012-02-06 17:47:53 -08:00
Stephen Williams ae11010707 Evaluate packed ranges for signals. 2012-02-05 17:41:11 -08:00
Stephen Williams 950e7a632c Parse multi-dimension packed arrays to pform. 2012-02-04 16:19:27 -08:00
Stephen Williams 5d35ad8a0d Support uwire resolved writes to non-overlapping parts
The individual bits of an unresolved wire may be assigned in
different continuous assignments without generating an error.
2012-02-02 16:18:50 -08:00
Stephen Williams 764b38bb3b Use user defined types in the syntax.
Given that the syntax is already parsed and elaborated, it is a
simple matter to bind that typedef'ed type to the instances that
use it.
2012-02-02 16:18:50 -08:00
Stephen Williams 42b3e6f268 Implement simple typedefs, and parse type identifiers.
This gets me to the point where the parser stashes a defined type,
and the lexical analyzer uses the type names to differentiate
IDENTIFIER and TYPE_IDENTIFIER.
2012-02-02 16:18:50 -08:00
Stephen Williams e14628193a Parse simple typedefs
Parse typedefs with structs and enums, but give a sorry message,
because they are not yet supported. Rearrange some of the parse
rules for variables in order to increase comonality with the
typedef rules.
2012-02-02 16:18:50 -08:00
Stephen Williams 124314576d Packed struct members in behavioral assign l-values. 2012-02-02 16:18:49 -08:00
Stephen Williams d2c3ff7999 Handle struct members in continuous assign l-values. 2012-02-02 16:18:49 -08:00
Stephen Williams e9e2fb33e9 Handle nets that are packed structures. 2012-02-02 16:18:49 -08:00
Stephen Williams 3a2866b57c Handle members of packed struct as implicit part selects.
Packed struct members are synonymous with part selects, but in a
much more convenient form, so get them to work that way.
2012-02-02 16:18:49 -08:00
Stephen Williams d362c8dba0 Parse support for struct variables. 2012-02-02 16:18:49 -08:00
Stephen Williams 5677efdfe6 Filter callbacks of value changes to array words.
When looking for a value change on a part select of an array word,
the callback handle has to save the current value and test it with
the new value to see if there is an actual change. If not, then
suppress the callback.
2012-02-02 10:49:59 -08:00
Stephen Williams c7a54891c4 Properly handle value change callbacks on part selects.
cbValueChange callbacks on part selects have to go through some extra
effort to make sure the value they are watching really is changing.
2012-01-30 19:12:20 -08:00
Stephen Williams 53585c9209 Derived classes for different callback types. 2012-01-29 17:31:19 -08:00
Stephen Williams 289b1d1bce Merge branch 'master' of github.com:steveicarus/iverilog 2012-01-25 17:48:22 -08:00
Cary R e9d68098d5 Fix the formatting of time values that are less than 1
This patch is a modification of a user contributed patch that fixes the
time formatting when the time is less than 1 and $timeformat() is used.
2012-01-23 18:52:11 -08:00
Stephen Williams d3df962b2a Cleaner __vpiCallback construction. 2012-01-22 20:37:01 -08:00
Cary R bb58ace6d6 Update __vpiHandle to use class vs struct
The clang compiler does not like mixing class and struct references. This
patch updates all the struct __vpiHandle, etc. to use class since that is
how they are now defined.
2012-01-21 14:50:27 -08:00
Stephen Williams 2bba7ebbda Trivial fix of compiler warning. 2012-01-21 12:01:57 -08:00
Stephen Williams d6fca81058 More cleanup of __vpiHandle classes. 2012-01-21 11:59:49 -08:00
Stephen Williams 43e11574e1 General cleanup of the __vpiHandle class work. 2012-01-20 17:16:42 -08:00
Stephen Williams d6dba0456c Fully remove the __vpirt structure
All the methods that this structure supported are now pulled
into the __vpiHandle class as virtual methods. This includes
the vpi_free_object_ method, which required some extra trickery.
2012-01-20 14:15:26 -08:00
Stephen Williams c07c4509e4 Move all vpirt functions to __vpiHandle virtual methods.
This takes care of all the functions accept the delete methood, which
will need special treatment.
2012-01-20 11:39:48 -08:00
Stephen Williams ac2b68fc1b Implement __vpiHandle::get_type_code pure virtual method. 2012-01-19 15:04:51 -08:00
Stephen Williams a48c9c3b4a Reword __vpiHandle objects to create a class structure.
Instead of C-like data structures where the __vpiHandle base is a
leading member, make the __vpiHandle a derived class. Give the base
class a virtual destructor so that dynamic_cast works reliably, and
now pretty much all of the junk for testing if an object really is
of the derived class goes away. Also, problems with casting up to
a vpiHandle become trivial non-issues.
2012-01-19 10:16:39 -08:00
Stephen Williams a20bac6a66 support parameters declared with atom2 types. 2012-01-16 11:04:02 -08:00
Stephen Williams b3ef8171e2 Short circuit propagation of part selects when possible
Full vector assigns are able to short circuit the propagation of
the value if it finds that there are no value changes. This patch
supports that behavior in writes to parts as well. Put this change
to use in logic devices as well.
2012-01-14 11:01:54 -08:00
Stephen Williams e1c0fa5feb Merge branch 'master' of github.com:steveicarus/iverilog 2012-01-10 18:23:33 -08:00
Stephen Williams 6662a3f78a Better VPI reference to part of array word.
Create the &APV<> token in vvp that create a VPI handle for a
part of an array word. This works better with things like $monitor.
2012-01-10 18:22:52 -08:00
Cary R ea065a674d Use the identifier to get the correct line information
Using the closing ')' was not giving the correct line number.
2012-01-09 19:14:02 -08:00
Stephen Williams 498bfcd24b Trivial optimizer cleanup. 2012-01-07 10:23:07 -08:00
Martin Whitaker e485ac9981 Fix for pr3465541.
vvp_net_t::send_vec8_pv() needs to call the output filter if one is
present, and vvp_wire_vec4::filter_vec8() needs to support part selects.
2012-01-07 09:19:38 -08:00
Cary R d5b5fbd274 vlog95: Don't emit the \n, \t, \" or \\ values as octal constants.
1364-1995 Verilog allows the \n, \t, \" or \\ string escape sequences
so use them when emitting a string.
2012-01-06 19:34:28 -08:00
Cary R 8563218cd2 Register Icarus vpi debug routine as a system function. 2012-01-05 19:22:19 -08:00
Cary R 62b7c52329 Fix a few cppcheck issues and update some suppressions 2012-01-05 18:55:00 -08:00
Cary R fc7e7640ed Remove some MinGW32-w64 compile warnings. 2012-01-05 17:26:08 -08:00
Cary R 9c99bce054 Update lex/yacc builds to be consistent and to support parallel builds
Not all the lex/yacc (flex/bison) targets were using a consistent syntax.
This patch fixes that and explicitly serializes the *.c/*.cc and *.h build.
Not doing this was causing problem when using make -j. The issue appears to
be that if two targets are specified for a rule (e.g. file.cc file.h: file.y)
make does not realize they are both built by the same call so the rule is
executed twice. Once for the .cc target and once for the .h target. This is
not a problem for a serial build. To work around this only use the .c/.cc
file in the main target and then make the .h file depend on the .c/.cc file
as a sub-target.
2012-01-04 18:21:40 -08:00
Cary R f22b42c2cd Update tgt-pcb Makefile to handle/clean up config header
This change matches what is in other header files.
2012-01-03 16:35:03 -08:00
Cary R 7f4246a916 Fix tgt-fpga Makefile target 2012-01-03 16:14:10 -08:00
Cary R dab982f39b vlog95: Major rework of nexus emitting code, etc.
Rework the nexus emitting code to correctly translate most I/O ports.
Fix a few other expression issues uncovered when port translation was
done correctly. Ignore and warn that the SV ++/-- operators and enum
types are not translatable. More updates of the nexus debug code.
2012-01-02 11:29:42 -08:00
Cary R a433fa3fcd Update the Makefiles to use more override able values.
Update the various Makefiles to use override able constants.
2012-01-02 10:27:38 -08:00
Cary R ba4137d1e8 Keep the width information for all the tran gates.
Update the compiler to keep the actual width information for all the
tran gates.
2012-01-02 10:25:46 -08:00
Cary R 142f661737 Fix the compiler to keep the original file/line information.
For a parameter we want to keep the base definition file/line information
not the file/line information for the override.
2012-01-02 10:23:08 -08:00
Stephen Williams 5451a4830f Basic support in tgt-pcb for reading footprint files.
When a black-box item requests a specific footprint, we need to
read a file (<footprint>.fp) that contains the actual details
about that footprint. Support parse of that file and use the
loaded Element to generate the footprint for the item.
2011-12-26 23:05:52 -08:00
Cary R 965c77525c A C++ function passed to C should be declared extern "C" 2011-12-24 11:23:19 -08:00
Cary R 4b96b63166 Fix more tgt-pcb compile problems.
On some systems having both %.o: %.c and %.o: %.cc rules confused the
make system. This is directory only has C++ code so remove the %o: %.c
rule. Also the C++ compiler should be used to link C++ object code.
2011-12-24 10:03:15 -08:00
Cary R 37017334af Fix build issues in tgt-pcb
On Ubunto 10.10 (32 bit) tgt-pcb would not build because there were
include file issues. This patch fixes those and uses the C++ include
version where appropriate.
2011-12-24 09:32:19 -08:00
Stephen Williams a95d64b7de Add a pcb-s.conf file compatible with the -S flag. 2011-12-24 10:39:41 -05:00
Stephen Williams cd76a504ac Merge branch 'master' of github.com:steveicarus/iverilog 2011-12-24 10:31:49 -05:00
Stephen Williams a57ce2a709 Add ability to write out Elements in a PCB file.
The main .pcb file contains elements, and basic PCB status.
Write out a .pcb file with stub Elements for each of the devices
in the design.

Rearrange the way the files are reported to the code generator
so that we can sensibly express where the output files are.
2011-12-23 17:06:55 -05:00
Stephen Williams 9075326bb7 Introduce PCB code generator. 2011-12-20 14:16:54 -06:00
Stephen Williams 9ba6ab49ac Fix compressed assign to memory word.
This is a pretty trivial fix for the code generation of compressed
assign to a memory word. We generated incorect code for the stash
of the calculated word index, causing the assign of the result to
not work properly.
2011-12-18 17:56:41 -08:00
Cary R 0553250997 Use the correct space in the a.out file.
We use four spaces before most opcodes in the a.out file.
2011-12-18 16:45:42 -08:00
Cary R aedbda5a75 Identifiers need to be deleted with delete[]
This patch fixes a mismatch in the delete style.
2011-12-18 16:45:08 -08:00
Cary R ed13de131d Use mkdir() instead of _mkdir() for MinGW
MinGW-w64 requires the use of mkdir() and MinGW-w32 appears to support
both so use mkdir() to allow compilation to work with both versions.
2011-12-18 11:43:35 -08:00
Cary R d8bdea11c5 To reduce error divide by an integer vs multiple by a fraction.
This same change was done in the vpi directory. This patch fixes the
issues in the libveriuser directory. This fixed a fail in the vpi
timescale test under MinGW.
2011-12-16 19:04:11 -08:00
Cary R 5d150c3151 Update and localize HOST compile information. 2011-12-16 09:15:01 -08:00
Cary R 0dc9ed2b5d Remove one MinGW compile warning. 2011-12-15 19:03:55 -08:00
Cary R 76c835a00e Update configure and Makefiles for cross compiling.
There are still a couple issues with cross compiling, but this patch
addresses most of the issues.
2011-12-15 19:03:48 -08:00
Cary R 8df745a281 Remove SV include file and vhdlpp with make uninstall 2011-12-14 18:39:27 -08:00
Cary R d198a57d99 The _vpiNexusId property must return zero when undefined
This was created by a user contributed patch. It resulted in all objects
that cannot have aliases being aliased.
2011-12-14 18:39:16 -08:00
Martin Whitaker 831b6d3ad6 Fix for crash when real value assigned to signed type parameter.
A declaration of the form "parameter signed a = 1.0" causes a
compiler crash. The standard is somewhat contradictory on what
type "a" should have, but testing with other compilers shows a
majority in favour of it being a real value.
2011-12-13 15:04:10 -08:00
Cary R 670efb38d9 Document that vpiFullName is supported in the generic routine. 2011-12-06 11:35:37 -08:00
Cary R 15a3f8ef2a For now treat vpiFullName the same as vpiName for a signal.
This needs to be fixed, but for now this prevents a seg. fault in
the VCD dumpers, etc.
2011-12-06 10:17:41 -08:00
Martin Whitaker 37be84483c Add support for parameter declarations with type but no range.
The standard allows a parameter (or localparam) declaration of the
form "parameter signed my_param = ...". The parser currently rejects
this. A small adjustment is also required in the parameter evaluation
code to correctly apply the type.
2011-12-06 09:42:29 -08:00
Cary R 95e25ad40f Apply a slightly modified user patch. 2011-12-05 19:54:50 -08:00
Cary R 46af6667dd Update line numbers in cppcheck suppression file.
A recent update shifted the lines that we are trying to suppress.
2011-12-01 10:37:32 -08:00
Stephen Williams 540e0ab2d1 Fix lexor parse of keywords declaration that includes '.'. 2011-11-29 15:17:34 -08:00
Stephen Williams eeca366092 Handle part selects in l-values of compressed assignments. 2011-11-28 16:41:50 -08:00
Stephen Williams 7a812fbe39 Rework vvp code generator for compressed assignments
Now we have a code generator that can handle compressed assignments
as they have been re-imagined in elaboration. There are some cases
that are not yet supported, we'll patch them up in due course.
2011-11-28 15:29:53 -08:00
Stephen Williams 3dabb2970d Get compressed assignment opcodes through to the ivl_target API. 2011-11-27 16:46:02 -08:00
Stephen Williams 21732a58c9 Merge branch 'master' into compressed-assign 2011-11-27 12:08:01 -08:00
Stephen Williams cc9bbff78d Rework parse of compression assignments. 2011-11-27 11:16:39 -08:00
641 changed files with 66108 additions and 27069 deletions
+8
View File
@@ -13,6 +13,7 @@ tags
TAGS
cscope.*
*.patch
*.orig
# Object files and libraries
*.[oa]
@@ -28,6 +29,11 @@ Makefile
/_pli_types.h
config.h
/tgt-pcb/pcb_config.h
/tgt-pcb/fp.cc
/tgt-pcb/fp.h
/tgt-pcb/fp.output
/tgt-pcb/fp_lex.cc
/tgt-vvp/vvp_config.h
/tgt-vhdl/vhdl_config.h
/vpi/vpi_config.h
@@ -45,6 +51,8 @@ dep
*.vpi
/cadpli/cadpli.vpl
/tgt-blif/Makefile
# lex, yacc and gperf output
/driver/cflexor.c
/driver/cfparse.c
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
+5 -5
View File
@@ -1,7 +1,7 @@
#ifndef __AStatement_H
#define __AStatement_H
#ifndef IVL_AStatement_H
#define IVL_AStatement_H
/*
* Copyright (c) 2008 Stephen Williams ([email protected])
* Copyright (c) 2008-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include <map>
@@ -82,4 +82,4 @@ class AProcess : public LineInfo {
AProcess& operator= (const AProcess&);
};
#endif
#endif /* IVL_AStatement_H */
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
+5 -5
View File
@@ -1,7 +1,7 @@
#ifndef __Attrib_H
#define __Attrib_H
#ifndef IVL_Attrib_H
#define IVL_Attrib_H
/*
* Copyright (c) 2000-2009 Stephen Williams ([email protected])
* Copyright (c) 2000-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "StringHeap.h"
@@ -57,4 +57,4 @@ class Attrib {
Attrib& operator= (const Attrib&);
};
#endif
#endif /* IVL_Attrib_H */
+21 -21
View File
@@ -1,12 +1,12 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
@@ -225,7 +225,7 @@ impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -303,16 +303,16 @@ the "copyright" line and a pointer to where the full notice is found.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
@@ -335,5 +335,5 @@ necessary. Here is a sample; alter the names:
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
+52 -24
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2010 Stephen Williams ([email protected])
* Copyright (c) 2001-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -22,30 +22,32 @@
# include <iostream>
# include <cstring>
# include <cstdlib>
# include <climits>
using namespace std;
hname_t::hname_t()
{
number_ = INT_MIN;
}
hname_t::hname_t(perm_string text)
: name_(text)
{
name_ = text;
number_ = INT_MIN;
}
hname_t::hname_t(perm_string text, int num)
: name_(text), number_(1)
{
number_[0] = num;
}
hname_t::hname_t(perm_string text, vector<int>&nums)
: name_(text), number_(nums)
{
name_ = text;
number_ = num;
}
hname_t::hname_t(const hname_t&that)
: name_(that.name_), number_(that.number_)
{
name_ = that.name_;
number_ = that.number_;
}
hname_t& hname_t::operator = (const hname_t&that)
@@ -55,24 +57,50 @@ hname_t& hname_t::operator = (const hname_t&that)
return *this;
}
bool operator < (const hname_t&l, const hname_t&r)
bool hname_t::operator < (const hname_t&r) const
{
int cmp = strcmp(l.peek_name(), r.peek_name());
int cmp = strcmp(name_, r.name_);
if (cmp < 0) return true;
if (cmp > 0) return false;
if (l.has_number() && r.has_number())
return l.peek_number() < r.peek_number();
else
return false;
// The text parts are equal, so compare then number
// parts. Finish as soon as we find one to be less or more
// than the other.
size_t idx = 0;
while (number_.size() > idx || r.number_.size() > idx) {
// Ran out of l numbers, so less.
if (number_.size() <= idx)
return true;
// Ran out of r numbers, so greater.
if (r.number_.size() <= idx)
return false;
if (number_[idx] < r.number_[idx])
return true;
if (number_[idx] > r.number_[idx])
return false;
idx += 1;
}
// Fall-through means that we are equal, including all the
// number parts, so not less.
return false;
}
bool operator == (const hname_t&l, const hname_t&r)
bool hname_t::operator == (const hname_t&r) const
{
if (l.peek_name() == r.peek_name()) {
if (l.has_number() && r.has_number())
return l.peek_number() == r.peek_number();
else
return true;
if (name_ == r.name_) {
if (number_.size() != r.number_.size())
return false;
for (size_t idx = 0 ; idx < number_.size() ; idx += 1)
if (number_[idx] != r.number_[idx]) return false;
return true;
}
return false;
@@ -86,8 +114,8 @@ ostream& operator<< (ostream&out, const hname_t&that)
}
out << that.peek_name();
if (that.has_number())
out << "[" << that.peek_number() << "]";
for (size_t idx = 0 ; idx < that.number_.size() ; idx += 1)
out << "[" << that.number_[idx] << "]";
return out;
}
+22 -20
View File
@@ -1,7 +1,7 @@
#ifndef __HName_H
#define __HName_H
#ifndef IVL_HName_H
#define IVL_HName_H
/*
* Copyright (c) 2001-2010 Stephen Williams ([email protected])
* Copyright (c) 2001-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,18 +16,15 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include <iostream>
# include <list>
# include <vector>
# include "StringHeap.h"
# include <climits>
#ifdef __GNUC__
#if __GNUC__ > 2
using namespace std;
#endif
#endif
# include <cassert>
/*
* This class represents a component of a Verilog hierarchical name. A
@@ -39,27 +36,33 @@ using namespace std;
class hname_t {
friend ostream& operator<< (ostream&out, const hname_t&that);
public:
hname_t ();
explicit hname_t (perm_string text);
explicit hname_t (perm_string text, int num);
explicit hname_t (perm_string text, std::vector<int>&nums);
hname_t (const hname_t&that);
~hname_t();
hname_t& operator= (const hname_t&);
bool operator == (const hname_t&that) const;
bool operator < (const hname_t&that) const;
// Return the string part of the hname_t.
perm_string peek_name(void) const;
bool has_number() const;
int peek_number() const;
size_t has_numbers() const;
int peek_number(size_t idx) const;
private:
perm_string name_;
// If the number is anything other than INT_MIN, then this is
// the numeric part of the name. Otherwise, it is not part of
// the name at all.
int number_;
std::vector<int> number_;
private: // not implemented
};
@@ -73,18 +76,17 @@ inline perm_string hname_t::peek_name(void) const
return name_;
}
inline int hname_t::peek_number() const
inline int hname_t::peek_number(size_t idx) const
{
return number_;
assert(number_.size() > idx);
return number_[idx];
}
inline bool hname_t::has_number() const
inline size_t hname_t::has_numbers() const
{
return number_ != INT_MIN;
return number_.size();
}
extern bool operator < (const hname_t&, const hname_t&);
extern bool operator == (const hname_t&, const hname_t&);
extern ostream& operator<< (ostream&, const hname_t&);
inline bool operator != (const hname_t&l, const hname_t&r)
@@ -102,4 +104,4 @@ inline ostream& operator<< (ostream&out, const list<hname_t>&ll)
return out;
}
#endif
#endif /* IVL_HName_H */
+42 -28
View File
@@ -12,9 +12,8 @@
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc.,
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
SHELL = /bin/sh
@@ -39,7 +38,7 @@ srcdir = @srcdir@
datarootdir = @datarootdir@
SUBDIRS = ivlpp vhdlpp vvp vpi libveriuser cadpli tgt-null tgt-stub tgt-vvp \
tgt-vhdl tgt-vlog95 driver
tgt-vhdl tgt-vlog95 tgt-pcb tgt-blif tgt-sizer driver
# Only run distclean for these directories.
NOTUSED = tgt-fpga tgt-pal tgt-verilog
@@ -67,9 +66,13 @@ mandir = @mandir@
dllib=@DLLIB@
CC = @CC@
# For a cross compile these defines will need to be set accordingly.
HOSTCC = @CC@
HOSTCFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@
CC = @CC@
CXX = @CXX@
DLLTOOL = @DLLTOOL@
INSTALL = @INSTALL@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -83,14 +86,15 @@ GIT = @GIT@
ifeq (@srcdir@,.)
INCLUDE_PATH = -I. -Ilibmisc
else
INCLUDE_PATH = -I. -Ilibmisc -I$(srcdir) -I$(srcdir)/libmisc
INCLUDE_PATH = -I. -I$(srcdir) -I$(srcdir)/libmisc
endif
CPPFLAGS = @DEFS@ $(INCLUDE_PATH) @CPPFLAGS@
CFLAGS = @WARNING_FLAGS@ @CFLAGS@
CFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@
CXXFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CXX@ @CXXFLAGS@
PICFLAGS = @PICFLAG@
LDFLAGS = @rdynamic@ @LDFLAGS@
CTARGETFLAGS = @CTARGETFLAGS@
# Source files in the libmisc directory
M = LineInfo.o StringHeap.o
@@ -100,16 +104,21 @@ FF = cprop.o nodangle.o synth.o synth2.o syn-rules.o
O = main.o async.o design_dump.o discipline.o dup_expr.o elaborate.o \
elab_expr.o elaborate_analog.o elab_lval.o elab_net.o \
elab_scope.o elab_sig.o elab_sig_analog.o emit.o eval.o eval_attrib.o \
elab_scope.o elab_sig.o elab_sig_analog.o elab_type.o \
emit.o eval.o eval_attrib.o \
eval_tree.o expr_synth.o functor.o lexor.o lexor_keyword.o link_const.o \
load_module.o netlist.o netmisc.o net_analog.o net_assign.o net_design.o \
netenum.o net_event.o net_expr.o net_func.o net_link.o net_modulo.o \
load_module.o netlist.o netmisc.o nettypes.o net_analog.o net_assign.o \
net_design.o netclass.o netdarray.o \
netenum.o netparray.o netqueue.o netscalar.o netstruct.o netvector.o \
net_event.o net_expr.o net_func.o \
net_func_eval.o net_link.o net_modulo.o \
net_nex_input.o net_nex_output.o net_proc.o net_scope.o net_tran.o \
net_udp.o pad_to_width.o parse.o parse_misc.o pform.o pform_analog.o \
pform_disciplines.o pform_dump.o pform_types.o \
pform_disciplines.o pform_dump.o pform_package.o pform_pclass.o \
pform_class_type.o pform_string_type.o pform_struct_type.o pform_types.o \
symbol_search.o sync.o sys_funcs.o verinum.o verireal.o target.o \
Attrib.o HName.o Module.o PDelays.o PEvent.o PExpr.o PGate.o \
PGenerate.o PScope.o PSpec.o PTask.o PUdp.o PFunction.o PWire.o \
Attrib.o HName.o Module.o PClass.o PDelays.o PEvent.o PExpr.o PGate.o \
PGenerate.o PPackage.o PScope.o PSpec.o PTask.o PUdp.o PFunction.o PWire.o \
Statement.o AStatement.o $M $(FF) $(TT)
all: dep config.h _pli_types.h version_tag.h ivl@EXEEXT@ version.exe iverilog-vpi.man
@@ -120,7 +129,7 @@ all: dep config.h _pli_types.h version_tag.h ivl@EXEEXT@ version.exe iverilog-vp
ifeq (@MINGW32@,yes)
all: dosify.exe
dosify.exe: $(srcdir)/dosify.c
$(CC) -o dosify.exe $(srcdir)/dosify.c
$(HOSTCC) $(HOSTCFLAGS) -o dosify.exe $(srcdir)/dosify.c
endif
# This rule rules the compiler in the trivial hello.vl program to make
@@ -146,8 +155,8 @@ endif
clean:
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true
rm -f *.o parse.cc parse.h lexor.cc
rm -f ivl.exp iverilog-vpi.man iverilog-vpi.pdf iverilog-vpi.ps parse.output
rm -f syn-rules.output dosify.exe ivl@EXEEXT@ check.vvp
rm -f ivl.exp iverilog-vpi.man iverilog-vpi.pdf iverilog-vpi.ps
rm -f parse.output syn-rules.output dosify.exe ivl@EXEEXT@ check.vvp
rm -f lexor_keyword.cc libivl.a libvpi.a iverilog-vpi syn-rules.cc
rm -rf dep
rm -f version.exe
@@ -165,8 +174,10 @@ endif
rm -rf autom4te.cache
cppcheck: $(O:.o=.cc) $(srcdir)/dosify.c $(srcdir)/version.c
cppcheck --enable=all -f --suppressions $(srcdir)/cppcheck.sup \
$(INCLUDE_PATH) $^
cppcheck --enable=all -f --suppressions-list=$(srcdir)/cppcheck.sup \
-UYYPARSE_PARAM -UYYPRINT -Ushort -Usize_t -Uyyoverflow \
-UYYTYPE_INT8 -UYYTYPE_INT16 -UYYTYPE_UINT8 -UYYTYPE_UINT16 \
--relative-paths=$(srcdir) $(INCLUDE_PATH) $^
cppcheck-all:
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) cppcheck && ) true
@@ -203,7 +214,7 @@ ifeq (@WIN32@,yes)
# that really exports the things that the import library imports.
ivl@EXEEXT@: $O $(srcdir)/ivl.def
$(CXX) -o ivl@EXEEXT@ $O $(dllib) @EXTRALIBS@
dlltool --dllname ivl@EXEEXT@ --def $(srcdir)/ivl.def \
$(DLLTOOL) --dllname ivl@EXEEXT@ --def $(srcdir)/ivl.def \
--output-lib libivl.a --output-exp ivl.exp
$(CXX) $(LDFLAGS) -o ivl@EXEEXT@ ivl.exp $O $(dllib) @EXTRALIBS@
else
@@ -221,13 +232,14 @@ iverilog-vpi: $(srcdir)/iverilog-vpi.sh Makefile
-e 's;@IVCXX@;$(CXX);' \
-e 's;@IVCFLAGS@;$(CFLAGS);' \
-e 's;@IVCXXFLAGS@;$(CXXFLAGS);' \
-e 's;@IVCTARGETFLAGS@;$(CTARGETFLAGS);' \
-e 's;@INCLUDEDIR@;$(includedir);' \
-e 's;@LIBDIR@;@libdir@;' $< > $@
chmod +x $@
endif
version.exe: $(srcdir)/version.c $(srcdir)/version_base.h version_tag.h
$(HOSTCC) @WARNING_FLAGS@ -o version.exe -I. -I$(srcdir) $(srcdir)/version.c
$(HOSTCC) $(HOSTCFLAGS) -o version.exe -I. -I$(srcdir) $(srcdir)/version.c
%.o: %.cc config.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) @DEPENDENCY_FLAG@ -c $< -o $*.o
@@ -240,20 +252,22 @@ lexor.o: lexor.cc parse.h
parse.o: parse.cc
parse.cc parse.h: $(srcdir)/parse.y
$(YACC) --verbose -t -p VL -d -o parse.cc $(srcdir)/parse.y
mv parse.cc.h parse.h 2>/dev/null || mv parse.hh parse.h
# Build this in two steps to avoid parallel build issues (see pr3462585)
parse.cc: $(srcdir)/parse.y
$(YACC) --verbose -t -p VL -d -o $@ $<
parse.h: parse.cc
mv parse.cc.h $@ 2>/dev/null || mv parse.hh $@
syn-rules.cc: $(srcdir)/syn-rules.y
$(YACC) --verbose -p syn_ -o syn-rules.cc $(srcdir)/syn-rules.y
$(YACC) --verbose -t -p syn_ -o $@ $<
lexor.cc: $(srcdir)/lexor.lex
$(LEX) -s -olexor.cc $(srcdir)/lexor.lex
$(LEX) -s -t $< > $@
lexor_keyword.o: lexor_keyword.cc parse.h
lexor_keyword.cc: $(srcdir)/lexor_keyword.gperf
gperf -o -i 7 -C -k 1-4,6,9,$$ -L ANSI-C -H keyword_hash -N check_identifier -t $(srcdir)/lexor_keyword.gperf > lexor_keyword.cc || (rm -f lexor_keyword.cc ; false)
gperf -o -i 7 -C -k 1-4,6,9,$$ -H keyword_hash -N check_identifier -t $(srcdir)/lexor_keyword.gperf > lexor_keyword.cc || (rm -f lexor_keyword.cc ; false)
iverilog-vpi.man: $(srcdir)/iverilog-vpi.man.in version.exe
./version.exe `head -1 $(srcdir)/iverilog-vpi.man.in`'\n' > $@
@@ -368,9 +382,9 @@ uninstall:
-rmdir "$(DESTDIR)$(libdir)/ivl$(suffix)"
for f in verilog$(suffix) iverilog-vpi$(suffix) gverilog$(suffix)@EXEEXT@; \
do rm -f "$(DESTDIR)$(bindir)/$$f"; done
for f in ivl_target.h vpi_user.h _pli_types.h acc_user.h veriuser.h; \
for f in ivl_target.h vpi_user.h _pli_types.h sv_vpi_user.h acc_user.h veriuser.h; \
do rm -f "$(DESTDIR)$(includedir)/$$f"; done
-test X$(suffix) = X || rmdir "$(DESTDIR)/$(includedir)"
-test X$(suffix) = X || rmdir "$(DESTDIR)$(includedir)"
rm -f "$(DESTDIR)$(mandir)/man1/iverilog-vpi$(suffix).1" "$(DESTDIR)$(prefix)/iverilog-vpi$(suffix).pdf"
+20 -3
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -27,11 +27,12 @@
list<Module::named_expr_t> Module::user_defparms;
/* n is a permallocated string. */
Module::Module(perm_string n)
: PScope(n)
Module::Module(LexicalScope*parent, perm_string n)
: PScopeExtra(n, parent)
{
library_flag = false;
is_cell = false;
program_block = false;
uc_drive = UCD_NONE;
timescale_warn_done = false;
time_unit = 0;
@@ -89,6 +90,22 @@ unsigned Module::find_port(const char*name) const
return ports.size();
}
perm_string Module::get_port_name(unsigned idx) const
{
assert(idx < ports.size());
if (ports[idx] == 0) {
/* It is possible to have undeclared ports. These
are ports that are skipped in the declaration,
for example like so: module foo(x ,, y); The
port between x and y is unnamed and thus
inaccessible to binding by name. */
return perm_string::literal("");
}
return ports[idx]->name;
}
PGate* Module::get_gate(perm_string name)
{
+24 -15
View File
@@ -1,7 +1,7 @@
#ifndef __Module_H
#define __Module_H
#ifndef IVL_Module_H
#define IVL_Module_H
/*
* Copyright (c) 1998-2010 Stephen Williams ([email protected])
* Copyright (c) 1998-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
@@ -49,7 +49,7 @@ class NetScope;
* therefore the handle for grasping the described circuit.
*/
class Module : public PScope, public LineInfo {
class Module : public PScopeExtra, public LineInfo {
/* The module ports are in general a vector of port_t
objects. Each port has a name and an ordered list of
@@ -65,7 +65,7 @@ class Module : public PScope, public LineInfo {
public:
/* The name passed here is the module name, not the instance
name. This make must be a permallocated string. */
explicit Module(perm_string name);
explicit Module(LexicalScope*parent, perm_string name);
~Module();
/* Initially false. This is set to true if the module has been
@@ -76,13 +76,18 @@ class Module : public PScope, public LineInfo {
bool is_cell;
/* This is true if the module represents a program block
instead of a module/cell. Program blocks have content
restrictions and slightly modify scheduling semantics. */
bool program_block;
enum UCDriveType { UCD_NONE, UCD_PULL0, UCD_PULL1 };
UCDriveType uc_drive;
/* specparams are simpler than other params, in that they have
no type information. They are merely constant
expressions. */
map<perm_string,PExpr*>specparams;
/* specparams are simpler than other parameters, in that they
can have a range, but not an explicit type. The restrictions
are enforced by the parser. */
map<perm_string,param_expr_t>specparams;
/* The module also has defparam assignments which don't create
new parameters within the module, but may be used to set
@@ -112,14 +117,14 @@ class Module : public PScope, public LineInfo {
bool time_from_timescale;
bool timescale_warn_done;
/* Task definitions within this module */
map<perm_string,PTask*> tasks;
map<perm_string,PFunction*> funcs;
/* The module has a list of generate schemes that appear in
the module definition. These are used at elaboration time. */
list<PGenerate*> generate_schemes;
/* Nested modules are placed here, and are not elaborated
unless they are instantiated, implicitly or explicitly. */
std::map<perm_string,Module*> nested_modules;
list<PSpecPath*> specify_paths;
// The mod_name() is the name of the module type.
@@ -131,6 +136,9 @@ class Module : public PScope, public LineInfo {
const vector<PEIdent*>& get_port(unsigned idx) const;
unsigned find_port(const char*name) const;
// Return port name ("" for undeclared port)
perm_string get_port_name(unsigned idx) const;
PGate* get_gate(perm_string name);
const list<PGate*>& get_gates() const;
@@ -144,6 +152,7 @@ class Module : public PScope, public LineInfo {
bool elaborate_sig(Design*, NetScope*scope) const;
private:
void dump_specparams_(ostream&out, unsigned indent) const;
list<PGate*> gates_;
private: // Not implemented
@@ -151,4 +160,4 @@ class Module : public PScope, public LineInfo {
Module& operator= (const Module&);
};
#endif
#endif /* IVL_Module_H */
+30
View File
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2012 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "PClass.h"
PClass::PClass(perm_string name, LexicalScope*parent)
: PScopeExtra(name, parent), type(0)
{
}
PClass::~PClass()
{
}
+47
View File
@@ -0,0 +1,47 @@
#ifndef IVL_PClass_H
#define IVL_PClass_H
/*
* Copyright (c) 2012-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "PScope.h"
# include "LineInfo.h"
# include "StringHeap.h"
# include <iostream>
class PChainConstructor;
/*
* SystemVerilog supports class declarations with their own lexical
* scope, etc. The parser arranges for these to be created and
* collected.
*/
class PClass : public PScopeExtra, public LineInfo {
public:
explicit PClass (perm_string name, LexicalScope*parent);
~PClass();
void dump(std::ostream&out, unsigned indent) const;
public:
class_type_t*type;
};
#endif /* IVL_PClass_H */
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
+5 -5
View File
@@ -1,7 +1,7 @@
#ifndef __PDelays_H
#define __PDelays_H
#ifndef IVL_PDelays_H
#define IVL_PDelays_H
/*
* Copyright (c) 1999-2010 Stephen Williams ([email protected])
* Copyright (c) 1999-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "svector.h"
@@ -72,4 +72,4 @@ class PDelays {
ostream& operator << (ostream&o, const PDelays&);
#endif
#endif /* IVL_PDelays_H */
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
+5 -5
View File
@@ -1,7 +1,7 @@
#ifndef __PEvent_H
#define __PEvent_H
#ifndef IVL_PEvent_H
#define IVL_PEvent_H
/*
* Copyright (c) 2000-2004 Stephen Williams ([email protected])
* Copyright (c) 2000-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "LineInfo.h"
@@ -51,4 +51,4 @@ class PEvent : public LineInfo {
PEvent& operator= (const PEvent&);
};
#endif
#endif /* IVL_PEvent_H */
+133 -11
View File
@@ -1,5 +1,6 @@
/*
* Copyright (c) 1998-2011 Stephen Williams <[email protected]>
* Copyright (c) 1998-2012 Stephen Williams <[email protected]>
* Copyright CERN 2013 / Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -76,6 +77,44 @@ bool PExpr::is_collapsible_net(Design*, NetScope*) const
return false;
}
const char* PExpr::width_mode_name(width_mode_t mode)
{
switch (mode) {
case PExpr::SIZED:
return "sized";
case PExpr::UNSIZED:
return "unsized";
case PExpr::EXPAND:
return "expand";
case PExpr::LOSSLESS:
return "lossless";
case PExpr::UPSIZE:
return "upsize";
default:
return "??";
}
}
PEAssignPattern::PEAssignPattern()
{
}
PEAssignPattern::PEAssignPattern(const list<PExpr*>&p)
: parms_(p.size())
{
size_t idx = 0;
for (list<PExpr*>::const_iterator cur = p.begin()
; cur != p.end() ; ++cur) {
parms_[idx] = *cur;
idx += 1;
}
}
PEAssignPattern::~PEAssignPattern()
{
}
PEBinary::PEBinary(char op, PExpr*l, PExpr*r)
: op_(op), left_(l), right_(r)
{
@@ -107,6 +146,15 @@ PECastSize::~PECastSize()
{
}
PECastType::PECastType(data_type_t*t, PExpr*b)
: target_(t), base_(b)
{
}
PECastType::~PECastType()
{
}
PEBComp::PEBComp(char op, PExpr*l, PExpr*r)
: PEBinary(op, l, r)
{
@@ -156,7 +204,12 @@ PEBShift::~PEBShift()
}
PECallFunction::PECallFunction(const pform_name_t&n, const vector<PExpr *> &parms)
: path_(n), parms_(parms)
: package_(0), path_(n), parms_(parms)
{
}
PECallFunction::PECallFunction(PPackage*pkg, const pform_name_t&n, const vector<PExpr *> &parms)
: package_(pkg), path_(n), parms_(parms)
{
}
@@ -168,19 +221,29 @@ static pform_name_t pn_from_ps(perm_string n)
return tmp;
}
PECallFunction::PECallFunction(PPackage*pkg, perm_string n, const list<PExpr *> &parms)
: package_(pkg), path_(pn_from_ps(n)), parms_(parms.size())
{
int tmp_idx = 0;
assert(parms_.size() == parms.size());
for (list<PExpr*>::const_iterator idx = parms.begin()
; idx != parms.end() ; ++idx)
parms_[tmp_idx++] = *idx;
}
PECallFunction::PECallFunction(perm_string n, const vector<PExpr*>&parms)
: path_(pn_from_ps(n)), parms_(parms)
: package_(0), path_(pn_from_ps(n)), parms_(parms)
{
}
PECallFunction::PECallFunction(perm_string n)
: path_(pn_from_ps(n))
: package_(0), path_(pn_from_ps(n))
{
}
// NOTE: Anachronism. Try to work all use of svector out.
PECallFunction::PECallFunction(const pform_name_t&n, const list<PExpr *> &parms)
: path_(n), parms_(parms.size())
: package_(0), path_(n), parms_(parms.size())
{
int tmp_idx = 0;
assert(parms_.size() == parms.size());
@@ -190,7 +253,7 @@ PECallFunction::PECallFunction(const pform_name_t&n, const list<PExpr *> &parms)
}
PECallFunction::PECallFunction(perm_string n, const list<PExpr*>&parms)
: path_(pn_from_ps(n)), parms_(parms.size())
: package_(0), path_(pn_from_ps(n)), parms_(parms.size())
{
int tmp_idx = 0;
assert(parms_.size() == parms.size());
@@ -281,6 +344,14 @@ PExpr* PEEvent::expr() const
return expr_;
}
PENull::PENull(void)
{
}
PENull::~PENull()
{
}
PEFNumber::PEFNumber(verireal*v)
: value_(v)
{
@@ -297,16 +368,21 @@ const verireal& PEFNumber::value() const
}
PEIdent::PEIdent(const pform_name_t&that)
: path_(that), no_implicit_sig_(false)
: package_(0), path_(that), no_implicit_sig_(false)
{
}
PEIdent::PEIdent(perm_string s, bool no_implicit_sig)
: no_implicit_sig_(no_implicit_sig)
: package_(0), no_implicit_sig_(no_implicit_sig)
{
path_.push_back(name_component_t(s));
}
PEIdent::PEIdent(PPackage*pkg, const pform_name_t&that)
: package_(pkg), path_(that), no_implicit_sig_(true)
{
}
PEIdent::~PEIdent()
{
}
@@ -346,7 +422,7 @@ void PEIdent::declare_implicit_nets(LexicalScope*scope, NetNet::Type type)
PWire*net = new PWire(name, type, NetNet::NOT_A_PORT, IVL_VT_LOGIC);
net->set_file(get_file());
net->set_lineno(get_lineno());
net->set_range(0, 0, SR_NET, true);
net->set_range_scalar(SR_NET);
scope->wires[name] = net;
if (warn_implicit) {
cerr << get_fileline() << ": warning: implicit "
@@ -363,7 +439,7 @@ bool PEIdent::has_aa_term(Design*des, NetScope*scope) const
const NetExpr*ex1, *ex2;
scope = symbol_search(0, des, scope, path_, net, par, eve, ex1, ex2);
scope = symbol_search(this, des, scope, path_, net, par, eve, ex1, ex2);
if (scope)
return scope->is_auto();
@@ -371,6 +447,43 @@ bool PEIdent::has_aa_term(Design*des, NetScope*scope) const
return false;
}
PENewArray::PENewArray(PExpr*size_expr, PExpr*init_expr)
: size_(size_expr), init_(init_expr)
{
}
PENewArray::~PENewArray()
{
delete size_;
}
PENewClass::PENewClass(void)
{
}
PENewClass::PENewClass(const list<PExpr*>&p)
: parms_(p.size())
{
size_t tmp_idx = 0;
for (list<PExpr*>::const_iterator cur = p.begin()
; cur != p.end() ; ++ cur) {
parms_[tmp_idx++] = *cur;
}
}
PENewClass::~PENewClass()
{
}
PENewCopy::PENewCopy(PExpr*src)
: src_(src)
{
}
PENewCopy::~PENewCopy()
{
}
PENumber::PENumber(verinum*vp)
: value_(vp)
{
@@ -436,6 +549,15 @@ bool PETernary::has_aa_term(Design*des, NetScope*scope) const
|| fal_->has_aa_term(des, scope);
}
PETypename::PETypename(data_type_t*dt)
: data_type_(dt)
{
}
PETypename::~PETypename()
{
}
PEUnary::PEUnary(char op, PExpr*ex)
: op_(op), expr_(ex)
{
+318 -39
View File
@@ -1,7 +1,8 @@
#ifndef __PExpr_H
#define __PExpr_H
#ifndef IVL_PExpr_H
#define IVL_PExpr_H
/*
* Copyright (c) 1998-2011 Stephen Williams <[email protected]>
* Copyright (c) 1998-2014 Stephen Williams <[email protected]>
* Copyright CERN 2013 / Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include <string>
@@ -33,6 +34,7 @@ class LexicalScope;
class NetNet;
class NetExpr;
class NetScope;
class PPackage;
/*
* The PExpr class hierarchy supports the description of
@@ -43,12 +45,17 @@ class NetScope;
class PExpr : public LineInfo {
public:
enum width_mode_t { SIZED, EXPAND, LOSSLESS, UNSIZED };
// Mode values used by test_width() (see below for description).
enum width_mode_t { SIZED, UNSIZED, EXPAND, LOSSLESS, UPSIZE };
// Flag values that can be passed to elaborate_expr.
// Flag values that can be passed to elaborate_expr().
static const unsigned NO_FLAGS = 0x0;
static const unsigned NEED_CONST = 0x1;
static const unsigned SYS_TASK_ARG = 0x2;
static const unsigned ANNOTATABLE = 0x4;
// Convert width mode to human-readable form.
static const char*width_mode_name(width_mode_t mode);
PExpr();
virtual ~PExpr();
@@ -76,33 +83,42 @@ class PExpr : public LineInfo {
// without changing the result. This allows the expression width to
// be pruned when not all bits of the result are used.
//
// Normally mode should be initialised to SIZED before starting to
// Normally mode should be initialized to SIZED before starting to
// test the width of an expression. In SIZED mode the expression
// width will be calculated strictly according to the IEEE standard
// rules for expression width.
// If the expression contains an unsized literal, mode will be
// changed to LOSSLESS. In LOSSLESS mode the expression width will
// be calculated as the minimum width necessary to avoid arithmetic
// overflow or underflow.
// If the expression both contains an unsized literal and contains
// an operation that coerces a vector operand to a different type
// (signed <-> unsigned), mode is changed to UNSIZED. UNSIZED mode
// is the same as LOSSLESS, except that the final expression width
// will be forced to be at least integer_width. This is necessary
// to ensure compatibility with the IEEE standard, which requires
// unsized literals to be treated as having the same width as an
// integer. The lossless width calculation is inadequate in this
// case because coercing an operand to a different type means that
// the expression no longer obeys the normal rules of arithmetic.
//
// If mode is initialised to EXPAND instead of SIZED, the expression
// If the expression is found to contain an unsized literal number
// and gn_strict_expr_width_flag is set, mode will be changed to
// UNSIZED. In UNSIZED mode the expression width will be calculated
// exactly as in SIZED mode - the change in mode simply flags that
// the expression contains an unsized numbers.
//
// If the expression is found to contain an unsized literal number
// and gn_strict_expr_width_flag is not set, mode will be changed
// to LOSSLESS. In LOSSLESS mode the expression width will be
// calculated as the minimum width necessary to avoid arithmetic
// overflow or underflow.
//
// Once in LOSSLESS mode, if the expression is found to contain
// an operation that coerces a vector operand to a different type
// (signed <-> unsigned), mode will be changed to UPSIZE. UPSIZE
// mode is the same as LOSSLESS, except that the final expression
// width will be forced to be at least integer_width. This is
// necessary to ensure compatibility with the IEEE standard, which
// requires unsized numbers to be treated as having the same width
// as an integer. The lossless width calculation is inadequate in
// this case because coercing an operand to a different type means
// that the expression no longer obeys the normal rules of arithmetic.
//
// If mode is initialized to EXPAND instead of SIZED, the expression
// width will be calculated as the minimum width necessary to avoid
// arithmetic overflow or underflow, even if it contains no unsized
// literals. mode will be changed LOSSLESS or UNSIZED as described
// literals. mode will be changed LOSSLESS or UPSIZE as described
// above. This supports a non-standard mode of expression width
// calculation.
//
// When the final value of mode is UNSIZED, the width returned by
// When the final value of mode is UPSIZE, the width returned by
// this method is the calculated lossless width, but the width
// returned by a subsequent call to the expr_width method will be
// the final expression width.
@@ -120,6 +136,13 @@ class PExpr : public LineInfo {
// to be propagated down to any context-dependant operands.
void cast_signed(bool flag) { signed_flag_ = flag; }
// This is the more generic form of the elaborate_expr method
// below. The plan is to replace the simpler elaborate_expr
// method with this version, which can handle more advanced
// types. But for now, this is only implemented in special cases.
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
// Procedural elaboration of the expression. The expr_width is
// the required width of the expression.
//
@@ -141,11 +164,12 @@ class PExpr : public LineInfo {
// Expressions that can be in the l-value of procedural
// assignments can be elaborated with this method. If the
// is_force flag is true, then the set of valid l-value types
// is slightly modified to accommodate the Verilog force
// statement
// is_cassign or is_force flags are true, then the set of
// valid l-value types is slightly modified to accommodate
// the Verilog procedural continuous assignment statements.
virtual NetAssign_* elaborate_lval(Design*des,
NetScope*scope,
bool is_cassign,
bool is_force) const;
// This attempts to evaluate a constant expression, and return
@@ -180,6 +204,29 @@ class PExpr : public LineInfo {
ostream& operator << (ostream&, const PExpr&);
class PEAssignPattern : public PExpr {
public:
explicit PEAssignPattern();
explicit PEAssignPattern(const std::list<PExpr*>&p);
~PEAssignPattern();
void dump(std::ostream&) const;
virtual unsigned test_width(Design*des, NetScope*scope, width_mode_t&mode);
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
unsigned expr_wid,
unsigned flags) const;
private:
NetExpr* elaborate_expr_darray_(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
private:
std::vector<PExpr*>parms_;
};
class PEConcat : public PExpr {
public:
@@ -198,11 +245,16 @@ class PEConcat : public PExpr {
virtual NetNet* elaborate_lnet(Design*des, NetScope*scope) const;
virtual NetNet* elaborate_bi_net(Design*des, NetScope*scope) const;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
virtual NetAssign_* elaborate_lval(Design*des,
NetScope*scope,
bool is_cassign,
bool is_force) const;
virtual bool is_collapsible_net(Design*des, NetScope*scope) const;
private:
@@ -264,6 +316,8 @@ class PEFNumber : public PExpr {
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
ivl_type_t type, unsigned flags) const;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
@@ -278,6 +332,7 @@ class PEIdent : public PExpr {
public:
explicit PEIdent(perm_string, bool no_implicit_sig=false);
explicit PEIdent(PPackage*pkg, const pform_name_t&name);
explicit PEIdent(const pform_name_t&);
~PEIdent();
@@ -302,15 +357,23 @@ class PEIdent : public PExpr {
// Identifiers are also allowed as procedural assignment l-values.
virtual NetAssign_* elaborate_lval(Design*des,
NetScope*scope,
bool is_cassign,
bool is_force) const;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
// Elaborate the PEIdent as a port to a module. This method
// only applies to Ident expressions.
NetNet* elaborate_port(Design*des, NetScope*sc) const;
NetNet* elaborate_subport(Design*des, NetScope*sc) const;
// Elaborate the identifier allowing for unpacked arrays. This
// method only applies to Ident expressions because only Ident
// expressions can can be unpacked arrays.
NetNet* elaborate_unpacked_net(Design*des, NetScope*sc) const;
verinum* eval_const(Design*des, NetScope*sc) const;
@@ -319,6 +382,7 @@ class PEIdent : public PExpr {
const pform_name_t& path() const { return path_; }
private:
PPackage*package_;
pform_name_t path_;
bool no_implicit_sig_;
@@ -328,6 +392,8 @@ class PEIdent : public PExpr {
// elaborate/calculate, or false if there is some sort of
// source error.
bool calculate_bits_(Design*, NetScope*, long&msb, bool&defined) const;
// The calculate_parts_ method calculates the range
// expressions of a part select for the current object. The
// part select expressions are elaborated and evaluated, and
@@ -343,40 +409,71 @@ class PEIdent : public PExpr {
bool calculate_up_do_width_(Design*, NetScope*, unsigned long&wid) const;
// Evaluate the prefix indices. All but the final index in a
// chain of indices must be a single value and must evaluate
// to constants at compile time. For example:
// [x] - OK
// [1][2][x] - OK
// [1][x:y] - OK
// [2:0][x] - BAD
// [y][x] - BAD
// Leave the last index for special handling.
bool calculate_packed_indices_(Design*des, NetScope*scope, NetNet*net,
std::list<long>&prefix_indices) const;
private:
NetAssign_*elaborate_lval_net_word_(Design*, NetScope*, NetNet*) const;
bool elaborate_lval_net_bit_(Design*, NetScope*, NetAssign_*) const;
NetAssign_*elaborate_lval_method_class_member_(Design*, NetScope*) const;
NetAssign_*elaborate_lval_net_word_(Design*, NetScope*, NetNet*,
bool need_const_idx) const;
bool elaborate_lval_net_bit_(Design*, NetScope*, NetAssign_*,
bool need_const_idx) const;
bool elaborate_lval_net_part_(Design*, NetScope*, NetAssign_*) const;
bool elaborate_lval_net_idx_(Design*, NetScope*, NetAssign_*,
index_component_t::ctype_t) const;
index_component_t::ctype_t,
bool need_const_idx) const;
NetAssign_*elaborate_lval_net_class_member_(Design*, NetScope*,
NetNet*,
const perm_string&) const;
bool elaborate_lval_net_packed_member_(Design*, NetScope*,
NetAssign_*,
const perm_string&) const;
bool elaborate_lval_darray_bit_(Design*, NetScope*,
NetAssign_*) const;
private:
NetExpr*elaborate_expr_param_(Design*des,
NetScope*scope,
const NetExpr*par,
NetScope*found,
NetScope*found_in,
const NetExpr*par_msb,
const NetExpr*par_lsb,
unsigned expr_wid,
unsigned flags) const;
NetExpr*elaborate_expr_param_bit_(Design*des,
NetScope*scope,
const NetExpr*par,
NetScope*found_in,
const NetExpr*par_msb,
const NetExpr*par_lsb,
bool need_const) const;
NetExpr*elaborate_expr_param_part_(Design*des,
NetScope*scope,
const NetExpr*par,
NetScope*found,
NetScope*found_in,
const NetExpr*par_msb,
const NetExpr*par_lsb,
unsigned expr_wid) const;
NetExpr*elaborate_expr_param_idx_up_(Design*des,
NetScope*scope,
const NetExpr*par,
NetScope*found,
NetScope*found_in,
const NetExpr*par_msb,
const NetExpr*par_lsb,
bool need_const) const;
NetExpr*elaborate_expr_param_idx_do_(Design*des,
NetScope*scope,
const NetExpr*par,
NetScope*found,
NetScope*found_in,
const NetExpr*par_msb,
const NetExpr*par_lsb,
bool need_const) const;
@@ -412,15 +509,118 @@ class PEIdent : public PExpr {
NetESignal*net,
NetScope*found,
bool need_const) const;
NetExpr*elaborate_expr_net_bit_last_(Design*des,
NetScope*scope,
NetESignal*net,
NetScope*found,
bool need_const) const;
NetExpr*elaborate_expr_class_member_(Design*des,
NetScope*scope,
unsigned expr_wid,
unsigned flags) const;
unsigned test_width_method_(Design*des, NetScope*scope, width_mode_t&mode);
NetExpr*elaborate_expr_method_(Design*des,
NetScope*scope,
unsigned expr_wid,
unsigned flags) const;
private:
NetNet* elaborate_lnet_common_(Design*des, NetScope*scope,
bool bidirectional_flag) const;
NetAssign_*scan_lname_for_nested_members_(Design*des, NetScope*scope,
const pform_name_t&path) const;
bool eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
long&midx, long&lidx) const;
};
class PENewArray : public PExpr {
public:
explicit PENewArray (PExpr*s, PExpr*i);
~PENewArray();
virtual void dump(ostream&) const;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
private:
PExpr*size_;
PExpr*init_;
};
class PENewClass : public PExpr {
public:
// New without (or with default) constructor
explicit PENewClass ();
// New with constructor arguments
explicit PENewClass (const std::list<PExpr*>&p);
~PENewClass();
virtual void dump(ostream&) const;
// Class objects don't have a useful width, but the expression
// is IVL_VT_CLASS.
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
// Note that class (new) expressions only appear in context
// that uses this form of the elaborate_expr method. In fact,
// the type argument is going to be a netclass_t object.
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
private:
NetExpr* elaborate_expr_constructor_(Design*des, NetScope*scope,
const netclass_t*ctype,
NetExpr*obj, unsigned flags) const;
private:
std::vector<PExpr*>parms_;
};
class PENewCopy : public PExpr {
public:
explicit PENewCopy(PExpr*src);
~PENewCopy();
virtual void dump(ostream&) const;
// Class objects don't have a useful width, but the expression
// is IVL_VT_CLASS.
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
// Note that class (new) expressions only appear in context
// that uses this form of the elaborate_expr method. In fact,
// the type argument is going to be a netclass_t object.
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
private:
PExpr*src_;
};
class PENull : public PExpr {
public:
explicit PENull();
~PENull();
virtual void dump(ostream&) const;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
virtual NetExpr*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid,
unsigned flags) const;
};
class PENumber : public PExpr {
public:
@@ -433,10 +633,13 @@ class PENumber : public PExpr {
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
virtual NetExpr *elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
virtual NetEConst*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid, unsigned) const;
virtual NetAssign_* elaborate_lval(Design*des,
NetScope*scope,
bool is_cassign,
bool is_force) const;
virtual verinum* eval_const(Design*des, NetScope*sc) const;
@@ -466,6 +669,9 @@ class PEString : public PExpr {
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
virtual NetEConst*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
virtual NetEConst*elaborate_expr(Design*des, NetScope*,
unsigned expr_wid, unsigned) const;
verinum* eval_const(Design*, NetScope*) const;
@@ -474,6 +680,23 @@ class PEString : public PExpr {
char*text_;
};
class PETypename : public PExpr {
public:
explicit PETypename(data_type_t*data_type);
~PETypename();
virtual void dump(ostream&) const;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
ivl_type_t type, unsigned flags) const;
inline data_type_t* get_type() const { return data_type_; }
private:
data_type_t*data_type_;
};
class PEUnary : public PExpr {
public:
@@ -494,6 +717,10 @@ class PEUnary : public PExpr {
unsigned flags) const;
virtual verinum* eval_const(Design*des, NetScope*sc) const;
public:
inline char get_op() const { return op_; }
inline PExpr*get_expr() const { return expr_; }
private:
NetExpr* elaborate_expr_bits_(NetExpr*operand, unsigned expr_wid) const;
@@ -650,7 +877,7 @@ class PETernary : public PExpr {
private:
NetExpr* elab_and_eval_alternative_(Design*des, NetScope*scope,
PExpr*expr, unsigned expr_wid,
unsigned flags) const;
unsigned flags, bool short_cct) const;
private:
PExpr*expr_;
@@ -666,11 +893,18 @@ class PETernary : public PExpr {
class PECallFunction : public PExpr {
public:
explicit PECallFunction(const pform_name_t&n, const vector<PExpr *> &parms);
// Call function defined in package.
explicit PECallFunction(PPackage*pkg, perm_string n, const std::vector<PExpr *> &parms);
explicit PECallFunction(PPackage*pkg, perm_string n, const std::list<PExpr *> &parms);
// Used to convert a user function called as a task
explicit PECallFunction(PPackage*pkg, const pform_name_t&n, const std::vector<PExpr *> &parms);
// Call of system function (name is not hierarchical)
explicit PECallFunction(perm_string n, const vector<PExpr *> &parms);
explicit PECallFunction(perm_string n);
// svector versions. Should be removed!
// std::list versions. Should be removed!
explicit PECallFunction(const pform_name_t&n, const list<PExpr *> &parms);
explicit PECallFunction(perm_string n, const list<PExpr *> &parms);
@@ -690,13 +924,26 @@ class PECallFunction : public PExpr {
width_mode_t&mode);
private:
PPackage*package_;
pform_name_t path_;
vector<PExpr *> parms_;
std::vector<PExpr *> parms_;
bool check_call_matches_definition_(Design*des, NetScope*dscope) const;
NetExpr* cast_to_width_(NetExpr*expr, unsigned wid) const;
NetExpr*elaborate_expr_pkg_(Design*des, NetScope*scope,
unsigned expr_wid, unsigned flags)const;
NetExpr*elaborate_expr_method_(Design*des, NetScope*scope,
unsigned expr_wid,
bool add_this_flag = false) const;
#if 0
NetExpr*elaborate_expr_string_method_(Design*des, NetScope*scope) const;
NetExpr*elaborate_expr_enum_method_(Design*des, NetScope*scope,
unsigned expr_wid) const;
#endif
NetExpr* elaborate_sfunc_(Design*des, NetScope*scope,
unsigned expr_wid,
unsigned flags) const;
@@ -704,6 +951,16 @@ class PECallFunction : public PExpr {
unsigned expr_wid) const;
unsigned test_width_sfunc_(Design*des, NetScope*scope,
width_mode_t&mode);
unsigned test_width_method_(Design*des, NetScope*scope,
width_mode_t&mode);
NetExpr*elaborate_base_(Design*des, NetScope*scope, NetScope*dscope,
unsigned expr_wid, unsigned flags) const;
unsigned elaborate_arguments_(Design*des, NetScope*scope,
NetFuncDef*def, bool need_const,
std::vector<NetExpr*>&parms,
unsigned parm_off) const;
};
/*
@@ -729,6 +986,28 @@ class PECastSize : public PExpr {
PExpr* base_;
};
/*
* Support the SystemVerilog cast to a different type.
*/
class PECastType : public PExpr {
public:
explicit PECastType(data_type_t*target, PExpr*base);
~PECastType();
void dump(ostream &out) const;
virtual NetExpr*elaborate_expr(Design*des, NetScope*scope,
unsigned expr_wid, unsigned flags) const;
virtual unsigned test_width(Design*des, NetScope*scope,
width_mode_t&mode);
private:
data_type_t* target_;
PExpr* base_;
};
/*
* This class is used for error recovery. All methods do nothing and return
* null or default values.
@@ -744,4 +1023,4 @@ class PEVoid : public PExpr {
unsigned flags) const;
};
#endif
#endif /* IVL_PExpr_H */
+47 -13
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2008,2010 Stephen Williams ([email protected])
* Copyright (c) 1999-2013 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,30 +14,26 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
#include "PTask.h"
# include "PTask.h"
# include "Statement.h"
# include <cassert>
# include "ivl_assert.h"
PFunction::PFunction(perm_string name, LexicalScope*parent, bool is_auto__)
: PScope(name, parent), ports_(0), statement_(0)
: PTaskFunc(name, parent), statement_(0)
{
is_auto_ = is_auto__;
return_type_.type = PTF_NONE;
return_type_ = 0;
}
PFunction::~PFunction()
{
}
void PFunction::set_ports(svector<PWire *>*p)
{
assert(ports_ == 0);
ports_ = p;
}
void PFunction::set_statement(Statement*s)
{
assert(s != 0);
@@ -45,7 +41,45 @@ void PFunction::set_statement(Statement*s)
statement_ = s;
}
void PFunction::set_return(PTaskFuncArg t)
void PFunction::push_statement_front(Statement*stmt)
{
// This can only happen after the statement is initially set.
ivl_assert(*this, statement_);
// Get the PBlock of the statement. If it is not a PBlock,
// then create one to wrap the existing statement and the new
// statement that we're pushing.
PBlock*blk = dynamic_cast<PBlock*> (statement_);
if (blk == 0) {
PBlock*tmp = new PBlock(PBlock::BL_SEQ);
tmp->set_line(*this);
vector<Statement*>tmp_list(1);
tmp_list[0] = statement_;
tmp->set_statement(tmp_list);
statement_ = tmp;
blk = tmp;
}
// Now do the push.
blk->push_statement_front(stmt);
}
void PFunction::set_return(data_type_t*t)
{
return_type_ = t;
}
PChainConstructor* PFunction::extract_chain_constructor()
{
PChainConstructor*res = 0;
if ((res = dynamic_cast<PChainConstructor*> (statement_))) {
statement_ = 0;
} else if (PBlock*blk = dynamic_cast<PBlock*>(statement_)) {
res = blk->extract_chain_constructor();
}
return res;
}
+10 -6
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2010 Stephen Williams ([email protected])
* Copyright (c) 1999-2013 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -260,18 +260,22 @@ const char* PGBuiltin::gate_name() const
}
PGModule::PGModule(perm_string type, perm_string name, list<PExpr*>*pins)
: PGate(name, pins), overrides_(0), pins_(0),
: PGate(name, pins), bound_type_(0), type_(type), overrides_(0), pins_(0),
npins_(0), parms_(0), nparms_(0), msb_(0), lsb_(0)
{
type_ = type;
}
PGModule::PGModule(perm_string type, perm_string name,
named<PExpr*>*pins, unsigned npins)
: PGate(name, 0), overrides_(0), pins_(pins),
: PGate(name, 0), bound_type_(0), type_(type), overrides_(0), pins_(pins),
npins_(npins), parms_(0), nparms_(0), msb_(0), lsb_(0)
{
type_ = type;
}
PGModule::PGModule(Module*type, perm_string name)
: PGate(name, 0), bound_type_(type), overrides_(0), pins_(0),
npins_(0), parms_(0), nparms_(0), msb_(0), lsb_(0)
{
}
PGModule::~PGModule()
+10 -5
View File
@@ -1,7 +1,7 @@
#ifndef __PGate_H
#define __PGate_H
#ifndef IVL_PGate_H
#define IVL_PGate_H
/*
* Copyright (c) 1998-2011 Stephen Williams ([email protected])
* Copyright (c) 1998-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "svector.h"
@@ -124,6 +124,7 @@ class PGAssign : public PGate {
virtual bool elaborate_sig(Design*des, NetScope*scope) const;
private:
void elaborate_unpacked_array_(Design*des, NetScope*scope, NetNet*lval) const;
};
@@ -201,6 +202,9 @@ class PGModule : public PGate {
explicit PGModule(perm_string type, perm_string name,
named<PExpr*>*pins, unsigned npins);
// If the module type is known by design, then use this
// constructor.
explicit PGModule(Module*type, perm_string name);
~PGModule();
@@ -223,6 +227,7 @@ class PGModule : public PGate {
perm_string get_type() const;
private:
Module*bound_type_;
perm_string type_;
list<PExpr*>*overrides_;
named<PExpr*>*pins_;
@@ -255,4 +260,4 @@ class PGModule : public PGate {
NetNet::PortType dir, bool as_signed) const;
};
#endif
#endif /* IVL_PGate_H */
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "PGenerate.h"
+9 -8
View File
@@ -1,7 +1,7 @@
#ifndef __PGenerate_H
#define __PGenerate_H
#ifndef IVL_PGenerate_H
#define IVL_PGenerate_H
/*
* Copyright (c) 2006-2010 Stephen Williams ([email protected])
* Copyright (c) 2006-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "LineInfo.h"
@@ -80,6 +80,10 @@ class PGenerate : public LineInfo, public LexicalScope {
// test value.
std::valarray<PExpr*> item_test;
// defparam assignments found in this scope.
typedef pair<pform_name_t,PExpr*> named_expr_t;
list<named_expr_t>defparms;
list<PGate*> gates;
void add_gate(PGate*);
@@ -87,9 +91,6 @@ class PGenerate : public LineInfo, public LexicalScope {
map<perm_string,PTask*> tasks;
map<perm_string,PFunction*>funcs;
// genvars declared within this scheme.
map<perm_string,LineInfo*> genvars;
// Generate schemes can contain further generate schemes.
list<PGenerate*> generate_schemes;
// PGenerate*parent;
@@ -138,4 +139,4 @@ class PGenerate : public LineInfo, public LexicalScope {
extern std::ostream& operator << (std::ostream&, PGenerate::scheme_t);
#endif
#endif /* IVL_PGenerate_H */
+30
View File
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2012 Stephen Williams ([email protected])
* Copyright CERN 2013 / Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "PPackage.h"
PPackage::PPackage(perm_string name, LexicalScope*parent)
: PScopeExtra(name, parent)
{
}
PPackage::~PPackage()
{
}
+47
View File
@@ -0,0 +1,47 @@
#ifndef IVL_PPackage_H
#define IVL_PPackage_H
/*
* Copyright (c) 2012-2014 Stephen Williams ([email protected])
* Copyright CERN 2013 / Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "PScope.h"
# include "LineInfo.h"
# include "StringHeap.h"
# include <iostream>
/*
* SystemVerilog supports class declarations with their own lexical
* scope, etc. The parser arranges for these to be created and
* collected.
*/
class PPackage : public PScopeExtra, public LineInfo {
public:
explicit PPackage (perm_string name, LexicalScope*parent);
~PPackage();
bool elaborate_scope(Design*des, NetScope*scope);
bool elaborate_sig(Design*des, NetScope*scope) const;
bool elaborate(Design*des, NetScope*scope) const;
void pform_dump(std::ostream&out) const;
};
#endif /* IVL_PPackage_H */
+19 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "PScope.h"
@@ -31,6 +31,9 @@ PScope::PScope(perm_string n)
PScope::~PScope()
{
for(map<perm_string, data_type_t*>::iterator it = typedefs.begin();
it != typedefs.end(); ++it)
delete it->second;
}
PWire* LexicalScope::wires_find(perm_string name)
@@ -41,3 +44,18 @@ PWire* LexicalScope::wires_find(perm_string name)
else
return (*cur).second;
}
PScopeExtra::PScopeExtra(perm_string n, LexicalScope*parent)
: PScope(n, parent)
{
}
PScopeExtra::PScopeExtra(perm_string n)
: PScope(n)
{
}
PScopeExtra::~PScopeExtra()
{
}
+48 -6
View File
@@ -1,7 +1,7 @@
#ifndef __PScope_H
#define __PScope_H
#ifndef IVL_PScope_H
#define IVL_PScope_H
/*
* Copyright (c) 2008,2010 Stephen Williams ([email protected])
* Copyright (c) 2008-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "LineInfo.h"
@@ -24,11 +24,17 @@
# include "pform_types.h"
# include "ivl_target.h"
# include <map>
# include <set>
# include <vector>
class PEvent;
class PExpr;
class PFunction;
class PPackage;
class AProcess;
class PProcess;
class PClass;
class PTask;
class PWire;
class Design;
@@ -83,9 +89,16 @@ class LexicalScope {
map<perm_string,param_expr_t>parameters;
map<perm_string,param_expr_t>localparams;
// Defined types in the scope.
map<perm_string,data_type_t*>typedefs;
// Named events in the scope.
map<perm_string,PEvent*>events;
// Symbols that are imported. Bind the imported name to the
// package from which the name is imported.
std::map<perm_string,PPackage*>imports;
// Nets and variables (wires) in the scope
map<perm_string,PWire*>wires;
PWire* wires_find(perm_string name);
@@ -100,11 +113,13 @@ class LexicalScope {
list<AProcess*> analog_behaviors;
// Enumeration sets.
list<enum_type_t*> enum_sets;
std::set<enum_type_t*> enum_sets;
LexicalScope* parent_scope() const { return parent_; }
protected:
void dump_typedefs_(ostream&out, unsigned indent) const;
void dump_parameters_(ostream&out, unsigned indent) const;
void dump_localparams_(ostream&out, unsigned indent) const;
@@ -145,4 +160,31 @@ class PScope : public LexicalScope {
perm_string name_;
};
#endif
/*
* Some scopes can carry definitions. These include Modules and PClass
* scopes. These derive from PScopeExtra so that they hold the maps of
* extra definitions.
*/
class PScopeExtra : public PScope {
public:
PScopeExtra(perm_string, LexicalScope*parent);
PScopeExtra(perm_string);
~PScopeExtra();
/* Task definitions within this module */
std::map<perm_string,PTask*> tasks;
std::map<perm_string,PFunction*> funcs;
/* class definitions within this module. */
std::map<perm_string,PClass*> classes;
/* This is the lexical order of the classes, and is used by
elaboration to choose an elaboration order. */
std::vector<PClass*> classes_lexical;
protected:
void dump_classes_(ostream&out, unsigned indent) const;
void dump_tasks_(ostream&out, unsigned indent) const;
void dump_funcs_(ostream&out, unsigned indent) const;
};
#endif /* IVL_PScope_H */
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "PSpec.h"
+5 -5
View File
@@ -1,7 +1,7 @@
#ifndef __PSpec_H
#define __PSpec_H
#ifndef IVL_PSpec_H
#define IVL_PSpec_H
/*
* Copyright (c) 2006-2011 Stephen Williams <steve@icarus.com>
* Copyright (c) 2006-2014 Stephen Williams <steve@icarus.com>
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "LineInfo.h"
@@ -84,4 +84,4 @@ class PSpecPath : public LineInfo {
std::vector<class PExpr*>delays;
};
#endif
#endif /* IVL_PSpec_H */
+35 -9
View File
@@ -14,15 +14,47 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
# include "PTask.h"
# include <cassert>
PTaskFunc::PTaskFunc(perm_string n, LexicalScope*p)
: PScope(n,p), this_type_(0), ports_(0)
{
}
PTaskFunc::~PTaskFunc()
{
}
void PTaskFunc::set_ports(vector<pform_tf_port_t>*p)
{
assert(ports_ == 0);
ports_ = p;
}
void PTaskFunc::set_this(class_type_t*type, PWire*this_wire)
{
assert(this_type_ == 0);
this_type_ = type;
// Push a synthethis argument that is the "this" value.
if (ports_==0)
ports_ = new vector<pform_tf_port_t>;
size_t use_size = ports_->size();
ports_->resize(use_size + 1);
for (size_t idx = use_size ; idx > 0 ; idx -= 1)
ports_->at(idx) = ports_->at(idx-1);
ports_->at(0) = pform_tf_port_t(this_wire);
}
PTask::PTask(perm_string name, LexicalScope*parent, bool is_auto__)
: PScope(name, parent), ports_(0), statement_(0)
: PTaskFunc(name, parent), statement_(0)
{
is_auto_ = is_auto__;
}
@@ -31,12 +63,6 @@ PTask::~PTask()
{
}
void PTask::set_ports(svector<PWire*>*p)
{
assert(ports_ == 0);
ports_ = p;
}
void PTask::set_statement(Statement*s)
{
assert(statement_ == 0);
+57 -28
View File
@@ -1,7 +1,7 @@
#ifndef __PTask_H
#define __PTask_H
#ifndef IVL_PTask_H
#define IVL_PTask_H
/*
* Copyright (c) 1999-2008,2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,49 +16,69 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "LineInfo.h"
# include "PScope.h"
# include "svector.h"
# include "StringHeap.h"
# include <string>
# include <vector>
# include <list>
class Design;
class NetExpr;
class NetNet;
class NetScope;
class PChainConstructor;
class PWire;
class Statement;
class PExpr;
enum PTaskFuncEnum {
PTF_NONE,
PTF_REG,
PTF_REG_S,
PTF_INTEGER,
PTF_REAL,
PTF_REALTIME,
PTF_TIME,
PTF_ATOM2,
PTF_ATOM2_S
};
struct PTaskFuncArg {
PTaskFuncEnum type;
vector<PExpr*>*range;
class PTaskFunc : public PScope, public LineInfo {
public:
PTaskFunc(perm_string name, LexicalScope*parent);
~PTaskFunc();
void set_ports(std::vector<pform_tf_port_t>*p);
void set_this(class_type_t*use_type, PWire*this_wire);
// If this task is a method of a class, this returns a pointer
// to the class type.
inline class_type_t* method_of() const { return this_type_; }
virtual void elaborate_sig(Design*des, NetScope*scope) const =0;
virtual void elaborate(Design*des, NetScope*scope) const =0;
virtual void dump(std::ostream&, unsigned) const =0;
protected:
// Elaborate the ports list. Write into the ports vector the
// NetNet pointers for the ports, and write into the pdefs the
// default value expressions, if any.
void elaborate_sig_ports_(Design*des, NetScope*scope,
std::vector<NetNet*>&ports,
std::vector<NetExpr*>&pdefs) const;
void dump_ports_(std::ostream&out, unsigned ind) const;
private:
class_type_t*this_type_;
std::vector<pform_tf_port_t>*ports_;
};
/*
* The PTask holds the parsed definitions of a task.
*/
class PTask : public PScope, public LineInfo {
class PTask : public PTaskFunc {
public:
explicit PTask(perm_string name, LexicalScope*parent, bool is_auto);
~PTask();
void set_ports(svector<PWire *>*p);
void set_statement(Statement *s);
// Tasks introduce scope, to need to be handled during the
@@ -78,7 +98,6 @@ class PTask : public PScope, public LineInfo {
void dump(ostream&, unsigned) const;
private:
svector<PWire*>*ports_;
Statement*statement_;
bool is_auto_;
@@ -94,15 +113,26 @@ class PTask : public PScope, public LineInfo {
*
* The output value is not elaborated until elaborate_sig.
*/
class PFunction : public PScope, public LineInfo {
class PFunction : public PTaskFunc {
public:
explicit PFunction(perm_string name, LexicalScope*parent, bool is_auto);
~PFunction();
void set_ports(svector<PWire *>*p);
void set_statement(Statement *s);
void set_return(PTaskFuncArg t);
void set_return(data_type_t*t);
inline Statement* get_statement() { return statement_; }
// Push this statement to the front of the existing
// definition. If the statement is a simple statement, make a
// block to contain the statements.
void push_statement_front(Statement*stmt);
// This is only used if this function is a constructor. In
// that case, this method looks for a PChainConstructor in the
// statement and extracts it if found.
PChainConstructor*extract_chain_constructor();
void elaborate_scope(Design*des, NetScope*scope) const;
@@ -117,10 +147,9 @@ class PFunction : public PScope, public LineInfo {
void dump(ostream&, unsigned) const;
private:
PTaskFuncArg return_type_;
svector<PWire *> *ports_;
data_type_t* return_type_;
Statement *statement_;
bool is_auto_;
};
#endif
#endif /* IVL_PTask_H */
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "PUdp.h"
+5 -5
View File
@@ -1,7 +1,7 @@
#ifndef __PUdp_H
#define __PUdp_H
#ifndef IVL_PUdp_H
#define IVL_PUdp_H
/*
* Copyright (c) 1998-2011 Stephen Williams (steve@picturel.com)
* Copyright (c) 1998-2014 Stephen Williams (steve@picturel.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include <map>
@@ -76,4 +76,4 @@ class PUdp : public LineInfo {
PUdp& operator= (const PUdp&);
};
#endif
#endif /* IVL_PUdp_H */
+77 -25
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2012 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -28,9 +28,9 @@ PWire::PWire(perm_string n,
ivl_variable_type_t dt)
: name_(n), type_(t), port_type_(pt), data_type_(dt),
signed_(false), isint_(false),
port_msb_(0), port_lsb_(0), port_set_(false),
net_msb_(0), net_lsb_(0), net_set_(false), is_scalar_(false),
error_cnt_(0), lidx_(0), ridx_(0), enum_type_(0), discipline_(0)
port_set_(false), net_set_(false), is_scalar_(false),
error_cnt_(0), set_data_type_(0),
discipline_(0)
{
if (t == NetNet::INTEGER) {
type_ = NetNet::REG;
@@ -120,6 +120,7 @@ bool PWire::set_data_type(ivl_variable_type_t dt)
assert(data_type_ == IVL_VT_NO_TYPE);
data_type_ = dt;
return true;
}
@@ -140,7 +141,14 @@ bool PWire::get_signed() const
bool PWire::get_isint() const
{
return isint_;
if (isint_)
return true;
if (vector_type_t*tmp = dynamic_cast<vector_type_t*>(set_data_type_)) {
return tmp->integer_flag;
}
return false;
}
bool PWire::get_scalar() const
@@ -148,8 +156,9 @@ bool PWire::get_scalar() const
return is_scalar_;
}
void PWire::set_range(PExpr*m, PExpr*l, PWSRType type, bool is_scalar)
void PWire::set_range_scalar(PWSRType type)
{
is_scalar_ = true;
switch (type) {
case SR_PORT:
if (port_set_) {
@@ -157,10 +166,7 @@ void PWire::set_range(PExpr*m, PExpr*l, PWSRType type, bool is_scalar)
<< "'' has already been declared a port." << endl;
error_cnt_ += 1;
} else {
port_msb_ = m;
port_lsb_ = l;
port_set_ = true;
is_scalar_ = is_scalar;
}
return;
@@ -170,10 +176,7 @@ void PWire::set_range(PExpr*m, PExpr*l, PWSRType type, bool is_scalar)
<< "'' has already been declared." << endl;
error_cnt_ += 1;
} else {
net_msb_ = m;
net_lsb_ = l;
net_set_ = true;
is_scalar_ = is_scalar;
}
return;
@@ -190,34 +193,83 @@ void PWire::set_range(PExpr*m, PExpr*l, PWSRType type, bool is_scalar)
error_cnt_ += 1;
}
} else {
port_msb_ = m;
port_lsb_ = l;
port_set_ = true;
net_msb_ = m;
net_lsb_ = l;
net_set_ = true;
is_scalar_ = is_scalar;
}
return;
}
}
void PWire::set_memory_idx(PExpr*ldx, PExpr*rdx)
void PWire::set_range(const list<pform_range_t>&rlist, PWSRType type)
{
if (lidx_ != 0 || ridx_ != 0) {
switch (type) {
case SR_PORT:
if (port_set_) {
cerr << get_fileline() << ": error: Port ``" << name_
<< "'' has already been declared a port." << endl;
error_cnt_ += 1;
} else {
port_ = rlist;
port_set_ = true;
is_scalar_ = false;
}
return;
case SR_NET:
if (net_set_) {
cerr << get_fileline() << ": error: Net ``" << name_
<< "'' has already been declared." << endl;
error_cnt_ += 1;
} else {
net_ = rlist;
net_set_ = true;
is_scalar_ = false;
}
return;
case SR_BOTH:
if (port_set_ || net_set_) {
if (port_set_) {
cerr << get_fileline() << ": error: Port ``" << name_
<< "'' has already been declared a port." << endl;
error_cnt_ += 1;
}
if (net_set_) {
cerr << get_fileline() << ": error: Net ``" << name_
<< "'' has already been declared." << endl;
error_cnt_ += 1;
}
} else {
port_ = rlist;
port_set_ = true;
net_ = rlist;
net_set_ = true;
is_scalar_ = false;
}
return;
}
}
void PWire::set_unpacked_idx(const list<pform_range_t>&ranges)
{
if (! unpacked_.empty()) {
cerr << get_fileline() << ": error: Array ``" << name_
<< "'' has already been declared." << endl;
error_cnt_ += 1;
} else {
lidx_ = ldx;
ridx_ = rdx;
unpacked_ = ranges;
}
}
void PWire::set_enumeration(enum_type_t*enum_type)
void PWire::set_data_type(data_type_t*type)
{
assert(enum_type_ == 0);
enum_type_ = enum_type;
assert(set_data_type_ == 0);
set_data_type_ = type;
if (vector_type_t*tmp = dynamic_cast<vector_type_t*>(type)) {
if (tmp->integer_flag)
isint_ = true;
}
}
void PWire::set_discipline(ivl_discipline_t d)
+23 -18
View File
@@ -1,7 +1,7 @@
#ifndef __PWire_H
#define __PWire_H
#ifndef IVL_PWire_H
#define IVL_PWire_H
/*
* Copyright (c) 1998-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,13 +16,13 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "netlist.h"
# include "LineInfo.h"
# include <list>
# include <map>
# include "svector.h"
# include "StringHeap.h"
#ifdef HAVE_IOSFWD
@@ -33,6 +33,7 @@ class ostream;
class PExpr;
class Design;
class netdarray_t;
/*
* The different type of PWire::set_range() calls.
@@ -75,11 +76,12 @@ class PWire : public LineInfo {
bool set_data_type(ivl_variable_type_t dt);
ivl_variable_type_t get_data_type() const;
void set_range(PExpr*msb, PExpr*lsb, PWSRType type, bool is_scalar);
void set_range_scalar(PWSRType type);
void set_range(const std::list<pform_range_t>&ranges, PWSRType type);
void set_memory_idx(PExpr*ldx, PExpr*rdx);
void set_unpacked_idx(const std::list<pform_range_t>&ranges);
void set_enumeration(enum_type_t*enum_type);
void set_data_type(data_type_t*type);
void set_discipline(ivl_discipline_t);
ivl_discipline_t get_discipline(void) const;
@@ -100,22 +102,25 @@ class PWire : public LineInfo {
bool isint_; // original type of integer
// These members hold expressions for the bit width of the
// wire. If they do not exist, the wire is 1 bit wide.
PExpr*port_msb_;
PExpr*port_lsb_;
// wire. If they do not exist, the wire is 1 bit wide. If they
// do exist, they represent the packed dimensions of the
// bit. The first item in the list is the first range, and so
// on. For example "reg [3:0][7:0] ..." will contains the
// range_t object for [3:0] first and [7:0] last.
std::list<pform_range_t>port_;
bool port_set_;
PExpr*net_msb_;
PExpr*net_lsb_;
std::list<pform_range_t>net_;
bool net_set_;
bool is_scalar_;
unsigned error_cnt_;
// If this wire is actually a memory, these indices will give
// me the size and address range of the memory.
PExpr*lidx_;
PExpr*ridx_;
// me the size and address ranges of the memory.
std::list<pform_range_t>unpacked_;
enum_type_t*enum_type_;
// This is the complex type of the wire. the data_type_ may
// modify how this is interpreted.
data_type_t*set_data_type_;
ivl_discipline_t discipline_;
@@ -124,4 +129,4 @@ class PWire : public LineInfo {
PWire& operator= (const PWire&);
};
#endif
#endif /* IVL_PWire_H */
+2 -2
View File
@@ -8,7 +8,7 @@ Icarus Verilog is intended to compile ALL of the Verilog HDL as
described in the IEEE-1364 standard. Of course, it's not quite there
yet. It does currently handle a mix of structural and behavioral
constructs. For a view of the current state of Icarus Verilog, see its
home page at <http://www.icarus.com/eda/verilog>.
home page at <http://iverilog.icarus.com/>.
Icarus Verilog is not aimed at being a simulator in the traditional
sense, but a compiler that generates code employed by back-end
@@ -64,7 +64,7 @@ on a UNIX-like system:
- termcap
The readline library in turn uses termcap.
If you are building from CVS, you will also need software to generate
If you are building from git, you will also need software to generate
the configure scripts.
- autoconf 2.53
+112 -13
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2008,2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2013 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,13 +14,14 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
# include "Statement.h"
# include "PExpr.h"
# include "ivl_assert.h"
Statement::~Statement()
{
@@ -51,22 +52,27 @@ PAssign_::~PAssign_()
}
PAssign::PAssign(PExpr*lval__, PExpr*ex)
: PAssign_(lval__, ex, false)
: PAssign_(lval__, ex, false), op_(0)
{
}
PAssign::PAssign(PExpr*lval__, char op, PExpr*ex)
: PAssign_(lval__, ex, false), op_(op)
{
}
PAssign::PAssign(PExpr*lval__, PExpr*d, PExpr*ex)
: PAssign_(lval__, d, ex)
: PAssign_(lval__, d, ex), op_(0)
{
}
PAssign::PAssign(PExpr*lval__, PExpr*cnt, PEventStatement*d, PExpr*ex)
: PAssign_(lval__, cnt, d, ex)
: PAssign_(lval__, cnt, d, ex), op_(0)
{
}
PAssign::PAssign(PExpr*lval__, PExpr*ex, bool is_constant)
: PAssign_(lval__, ex, is_constant)
: PAssign_(lval__, ex, is_constant), op_(0)
{
}
@@ -109,13 +115,57 @@ PBlock::~PBlock()
delete list_[idx];
}
PChainConstructor* PBlock::extract_chain_constructor()
{
if (list_.empty())
return 0;
if (PChainConstructor*res = dynamic_cast<PChainConstructor*> (list_[0])) {
for (size_t idx = 0 ; idx < list_.size()-1 ; idx += 1)
list_[idx] = list_[idx+1];
list_.resize(list_.size()-1);
return res;
}
return 0;
}
void PBlock::set_join_type(PBlock::BL_TYPE type)
{
assert(bl_type_ == BL_PAR);
assert(type==BL_PAR || type==BL_JOIN_NONE || type==BL_JOIN_ANY);
bl_type_ = type;
}
void PBlock::set_statement(const vector<Statement*>&st)
{
list_ = st;
}
void PBlock::push_statement_front(Statement*that)
{
ivl_assert(*this, bl_type_==BL_SEQ);
list_.resize(list_.size()+1);
for (size_t idx = list_.size()-1 ; idx > 0 ; idx -= 1)
list_[idx] = list_[idx-1];
list_[0] = that;
}
PCallTask::PCallTask(const pform_name_t&n, const list<PExpr*>&p)
: path_(n), parms_(p.size())
: package_(0), path_(n), parms_(p.size())
{
list<PExpr*>::const_iterator cur = p.begin();
for (size_t idx = 0 ; idx < parms_.size() ; idx += 1) {
parms_[idx] = *cur;
++cur;
}
assert(cur == p.end());
}
PCallTask::PCallTask(PPackage*pkg, const pform_name_t&n, const list<PExpr*>&p)
: package_(pkg), path_(n), parms_(p.size())
{
list<PExpr*>::const_iterator cur = p.begin();
for (size_t idx = 0 ; idx < parms_.size() ; idx += 1) {
@@ -126,7 +176,7 @@ PCallTask::PCallTask(const pform_name_t&n, const list<PExpr*>&p)
}
PCallTask::PCallTask(perm_string n, const list<PExpr*>&p)
: parms_(p.size())
: package_(0), parms_(p.size())
{
list<PExpr*>::const_iterator cur = p.begin();
for (size_t idx = 0 ; idx < parms_.size() ; idx += 1) {
@@ -171,6 +221,21 @@ PCAssign::~PCAssign()
delete expr_;
}
PChainConstructor::PChainConstructor(const list<PExpr*>&parms)
: parms_(parms.size())
{
list<PExpr*>::const_iterator cur = parms.begin();
for (size_t idx = 0 ; idx < parms_.size() ; idx += 1) {
parms_[idx] = *cur;
++cur;
}
assert(cur == parms.end());
}
PChainConstructor::~PChainConstructor()
{
}
PCondit::PCondit(PExpr*ex, Statement*i, Statement*e)
: expr_(ex), if_(i), else_(e)
{
@@ -212,6 +277,17 @@ PDisable::~PDisable()
{
}
PDoWhile::PDoWhile(PExpr*ex, Statement*st)
: cond_(ex), statement_(st)
{
}
PDoWhile::~PDoWhile()
{
delete cond_;
delete statement_;
}
PEventStatement::PEventStatement(const svector<PEEvent*>&ee)
: expr_(ee), statement_(0)
{
@@ -260,6 +336,20 @@ PForce::~PForce()
delete expr_;
}
PForeach::PForeach(perm_string av, const list<perm_string>&ix, Statement*s)
: array_var_(av), index_vars_(ix.size()), statement_(s)
{
size_t idx = 0;
for (list<perm_string>::const_iterator cur = ix.begin()
; cur != ix.end() ; ++cur)
index_vars_[idx++] = *cur;
}
PForeach::~PForeach()
{
delete statement_;
}
PForever::PForever(Statement*s)
: statement_(s)
{
@@ -271,9 +361,8 @@ PForever::~PForever()
}
PForStatement::PForStatement(PExpr*n1, PExpr*e1, PExpr*cond,
PExpr*n2, PExpr*e2, Statement*st)
: name1_(n1), expr1_(e1), cond_(cond), name2_(n2), expr2_(e2),
statement_(st)
Statement*step, Statement*st)
: name1_(n1), expr1_(e1), cond_(cond), step_(step), statement_(st)
{
}
@@ -307,6 +396,16 @@ PRepeat::~PRepeat()
delete statement_;
}
PReturn::PReturn(PExpr*e)
: expr_(e)
{
}
PReturn::~PReturn()
{
delete expr_;
}
PTrigger::PTrigger(const pform_name_t&e)
: event_(e)
{
@@ -316,8 +415,8 @@ PTrigger::~PTrigger()
{
}
PWhile::PWhile(PExpr*e1, Statement*st)
: cond_(e1), statement_(st)
PWhile::PWhile(PExpr*ex, Statement*st)
: cond_(ex), statement_(st)
{
}
+123 -25
View File
@@ -1,7 +1,7 @@
#ifndef __Statement_H
#define __Statement_H
#ifndef IVL_Statement_H
#define IVL_Statement_H
/*
* Copyright (c) 1998-2008 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include <string>
@@ -31,6 +31,8 @@
# include "HName.h"
# include "LineInfo.h"
class PExpr;
class PChainConstructor;
class PPackage;
class Statement;
class PEventStatement;
class Design;
@@ -104,8 +106,13 @@ class PAssign_ : public Statement {
protected:
NetAssign_* elaborate_lval(Design*, NetScope*scope) const;
NetExpr* elaborate_rval_(Design*, NetScope*, unsigned lv_width,
ivl_variable_type_t type) const;
NetExpr* elaborate_rval_(Design*, NetScope*, ivl_type_t lv_net_type,
ivl_variable_type_t lv_type,
unsigned lv_width) const;
NetExpr* elaborate_rval_(Design*, NetScope*, ivl_type_t ntype) const;
NetExpr* elaborate_rval_obj_(Design*, NetScope*,
ivl_variable_type_t type) const;
PExpr* delay_;
PEventStatement*event_;
@@ -120,7 +127,12 @@ class PAssign_ : public Statement {
class PAssign : public PAssign_ {
public:
// lval - assignment l-value
// ex - assignment r-value
// op - compressed assignment operator (i.e. '+', '-', ...)
// de - delayed assignment delay expression
explicit PAssign(PExpr*lval, PExpr*ex);
explicit PAssign(PExpr*lval, char op, PExpr*ex);
explicit PAssign(PExpr*lval, PExpr*de, PExpr*ex);
explicit PAssign(PExpr*lval, PExpr*cnt, PEventStatement*de, PExpr*ex);
explicit PAssign(PExpr*lval, PExpr*ex, bool is_constant);
@@ -130,6 +142,8 @@ class PAssign : public PAssign_ {
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
private:
NetProc* elaborate_compressed_(Design*des, NetScope*scope) const;
char op_;
};
class PAssignNB : public PAssign_ {
@@ -158,7 +172,7 @@ class PAssignNB : public PAssign_ {
class PBlock : public PScope, public Statement {
public:
enum BL_TYPE { BL_SEQ, BL_PAR };
enum BL_TYPE { BL_SEQ, BL_PAR, BL_JOIN_NONE, BL_JOIN_ANY };
// If the block has a name, it is a scope and also has a parent.
explicit PBlock(perm_string n, LexicalScope*parent, BL_TYPE t);
@@ -168,39 +182,41 @@ class PBlock : public PScope, public Statement {
BL_TYPE bl_type() const { return bl_type_; }
// This is only used if this block is the statement list for a
// constructor. We look for a PChainConstructor as the first
// statement, and if it is there, extract it.
PChainConstructor*extract_chain_constructor();
// If the bl_type() is BL_PAR, it is possible to replace it
// with JOIN_NONE or JOIN_ANY. This is to help the parser.
void set_join_type(BL_TYPE);
void set_statement(const std::vector<Statement*>&st);
// Copy the statement from that block to the front of this
// block.
void push_statement_front(Statement*that);
virtual void dump(ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
private:
const BL_TYPE bl_type_;
BL_TYPE bl_type_;
std::vector<Statement*>list_;
};
class PCallTask : public Statement {
public:
explicit PCallTask(PPackage*pkg, const pform_name_t&n, const list<PExpr*>&parms);
explicit PCallTask(const pform_name_t&n, const list<PExpr*>&parms);
explicit PCallTask(perm_string n, const list<PExpr*>&parms);
~PCallTask();
const pform_name_t& path() const;
unsigned nparms() const { return parms_.size(); }
PExpr*&parm(unsigned idx)
{ assert(idx < parms_.size());
return parms_[idx];
}
PExpr* parm(unsigned idx) const
{ assert(idx < parms_.size());
return parms_[idx];
}
virtual void dump(ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
@@ -208,6 +224,19 @@ class PCallTask : public Statement {
NetProc* elaborate_sys(Design*des, NetScope*scope) const;
NetProc* elaborate_usr(Design*des, NetScope*scope) const;
NetProc*elaborate_method_(Design*des, NetScope*scope,
bool add_this_flag = false) const;
NetProc*elaborate_function_(Design*des, NetScope*scope) const;
NetProc*elaborate_build_call_(Design*des, NetScope*scope,
NetScope*task, NetExpr*use_this) const;
NetProc*elaborate_sys_task_method_(Design*des, NetScope*scope,
NetNet*net,
perm_string method_name,
const char*sys_task_name) const;
bool test_task_calls_ok_(Design*des, NetScope*scope) const;
PPackage*package_;
pform_name_t path_;
vector<PExpr*> parms_;
};
@@ -253,6 +282,26 @@ class PCAssign : public Statement {
PExpr*expr_;
};
/*
* This represents the syntax "super.new(...)". This is not really an
* executable statement, but the elaborator will handle these
* specially and will remove them from the statement stream. If any
*/
class PChainConstructor : public Statement {
public:
PChainConstructor(const list<PExpr*>&parms);
~PChainConstructor();
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(ostream&out, unsigned ind) const;
inline const std::vector<PExpr*>& chain_args(void) const
{ return parms_; }
private:
std::vector<PExpr*> parms_;
};
class PCondit : public Statement {
public:
@@ -320,6 +369,22 @@ class PDisable : public Statement {
pform_name_t scope_;
};
class PDoWhile : public Statement {
public:
PDoWhile(PExpr*ex, Statement*st);
~PDoWhile();
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(ostream&out, unsigned ind) const;
private:
PExpr*cond_;
Statement*statement_;
};
/*
* The event statement represents the event delay in behavioral
* code. It comes from such things as:
@@ -356,6 +421,7 @@ class PEventStatement : public Statement {
NetProc* elaborate_st(Design*des, NetScope*scope, NetProc*st) const;
NetProc* elaborate_wait(Design*des, NetScope*scope, NetProc*st) const;
NetProc* elaborate_wait_fork(Design*des, NetScope*scope) const;
private:
svector<PEEvent*>expr_;
@@ -378,6 +444,26 @@ class PForce : public Statement {
PExpr*expr_;
};
class PForeach : public Statement {
public:
explicit PForeach(perm_string var, const std::list<perm_string>&ix, Statement*stmt);
~PForeach();
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void elaborate_sig(Design*des, NetScope*scope) const;
virtual void dump(ostream&out, unsigned ind) const;
private:
NetProc* elaborate_static_array_(Design*des, NetScope*scope,
const std::vector<netrange_t>&dims) const;
private:
perm_string array_var_;
std::vector<perm_string> index_vars_;
Statement*statement_;
};
class PForever : public Statement {
public:
explicit PForever(Statement*s);
@@ -396,7 +482,7 @@ class PForStatement : public Statement {
public:
PForStatement(PExpr*n1, PExpr*e1, PExpr*cond,
PExpr*n2, PExpr*e2, Statement*st);
Statement*step, Statement*body);
~PForStatement();
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
@@ -410,8 +496,7 @@ class PForStatement : public Statement {
PExpr*cond_;
PExpr* name2_;
PExpr* expr2_;
Statement*step_;
Statement*statement_;
};
@@ -451,6 +536,19 @@ class PRelease : public Statement {
PExpr*lval_;
};
class PReturn : public Statement {
public:
explicit PReturn(PExpr*e);
~PReturn();
NetProc* elaborate(Design*des, NetScope*scope) const;
virtual void dump(std::ostream&out, unsigned ind) const;
private:
PExpr*expr_;
};
/*
* The PTrigger statement sends a trigger to a named event. Take the
* name here.
@@ -471,7 +569,7 @@ class PTrigger : public Statement {
class PWhile : public Statement {
public:
PWhile(PExpr*e1, Statement*st);
PWhile(PExpr*ex, Statement*st);
~PWhile();
virtual NetProc* elaborate(Design*des, NetScope*scope) const;
@@ -484,4 +582,4 @@ class PWhile : public Statement {
Statement*statement_;
};
#endif
#endif /* IVL_Statement_H */
+5 -5
View File
@@ -1,7 +1,7 @@
#ifndef PLI_TYPES
#define PLI_TYPES
#ifndef PLI_TYPES_H
#define PLI_TYPES_H
/*
* Copyright (c) 2003 Stephen Williams ([email protected])
* Copyright (c) 2003-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# undef HAVE_INTTYPES_H
@@ -85,4 +85,4 @@ typedef char PLI_BYTE8;
typedef unsigned char PLI_UBYTE8;
#endif
#endif
#endif /* PLI_TYPES_H */
+6 -5
View File
@@ -1,7 +1,7 @@
#ifndef __acc_user_H
#define __acc_user_H
#ifndef ACC_USER_H
#define ACC_USER_H
/*
* Copyright (c) 2002 Stephen Williams (steve@icarus.com)
* Copyright (c) 2002-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
@@ -228,6 +228,7 @@ extern PLI_INT32 acc_fetch_size(handle obj);
extern PLI_INT32 acc_fetch_type(handle obj);
extern PLI_INT32 acc_fetch_fulltype(handle obj);
extern PLI_INT32 acc_fetch_paramtype(handle obj);
extern PLI_INT32 acc_fetch_range(handle object, int *msb, int *lsb);
extern const char* acc_fetch_type_str(PLI_INT32 type);
@@ -270,4 +271,4 @@ extern char* acc_version(void);
EXTERN_C_END
#endif
#endif /* ACC_USER_H */
Vendored
-11
View File
@@ -218,17 +218,6 @@ AC_SUBST(strip_dynamic)
# AC_MSG_RESULT($strip_dynamic)
])# AX_LD_RDYNAMIC
# AX_CPP_PRECOMP
# --------------
AC_DEFUN([AX_CPP_PRECOMP],
[# Darwin requires -no-cpp-precomp
case "${host}" in
*-*-darwin*)
CPPFLAGS="-no-cpp-precomp $CPPFLAGS"
CFLAGS="-no-cpp-precomp $CFLAGS"
;;
esac
])# AX_CPP_PRECOMP
# AX_C99_STRTOD
# -------------
+3 -3
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -50,8 +50,8 @@ bool NetEvWait::is_asynchronous()
level sensitive, but the nex_async_ method takes care of
that test. */
NexusSet*sense = new NexusSet;
for (unsigned idx = 0 ; idx < nevents_ ; idx += 1) {
NexusSet*tmp = event(idx)->nex_async_();
for (unsigned idx = 0 ; idx < events_.size() ; idx += 1) {
NexusSet*tmp = events_[idx]->nex_async_();
if (tmp == 0) {
delete sense;
return false;
+7 -4
View File
@@ -2,12 +2,15 @@
#
# This shell script exists to run autoconf on source distributions
# that are pulled from CVS. The configure scripts are not included
# in CVS, and there are several configure.in files, so it is easiest
# to just run this script to autoconf wherever needed.
# that are pulled from git The configure script is not included
# in git, so it is easiest to just run this script whenever needed
# to generate the configure script.
#
echo "Autoconf in root..."
autoconf -f
echo "Precompiling lexor_keyword.gperf"
gperf -o -i 7 -C -k 1-4,6,9,\$ -L ANSI-C -H keyword_hash -N check_identifier -t ./lexor_keyword.gperf > lexor_keyword.cc
gperf -o -i 7 -C -k 1-4,6,9,\$ -H keyword_hash -N check_identifier -t ./lexor_keyword.gperf > lexor_keyword.cc
echo "Precompiling vhdlpp/lexor_keyword.gperf"
(cd vhdlpp ; gperf -o -i 7 --ignore-case -C -k 1-4,6,9,\$ -H keyword_hash -N check_identifier -t ./lexor_keyword.gperf > lexor_keyword.cc )
+4 -7
View File
@@ -12,9 +12,8 @@
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc.,
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
SHELL = /bin/sh
@@ -44,11 +43,9 @@ INCLUDE_PATH = -I. -I.. -I$(srcdir) -I$(srcdir)/..
endif
CPPFLAGS = $(INCLUDE_PATH) @CPPFLAGS@ @DEFS@ @PICFLAG@
CFLAGS = @WARNING_FLAGS@ @CFLAGS@
CFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@
LDFLAGS = @LDFLAGS@
SHARED = @shared@
O = cadpli.o
all: dep cadpli.vpl $(ALL32)
@@ -80,7 +77,7 @@ ifeq (@MINGW32@,yes)
endif
cadpli.vpl: $O ../vvp/libvpi.a ../libveriuser/libveriuser.o
$(CC) @shared@ -o $@ $O ../libveriuser/libveriuser.o $(SYSTEM_VPI_LDFLAGS)
$(CC) @shared@ $(LDFLAGS) -o $@ $O ../libveriuser/libveriuser.o $(SYSTEM_VPI_LDFLAGS)
install: all installdirs $(vpidir)/cadpli.vpl
+2 -2
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include <vpi_user.h>
@@ -79,7 +79,7 @@ static void thunker_register(void)
}
}
void (*vlog_startup_routines[])() = {
void (*vlog_startup_routines[])(void) = {
thunker_register,
0
};
+5 -5
View File
@@ -1,7 +1,7 @@
#ifndef __ivl_dlfcn_H
#define __ivl_dlfcn_H
#ifndef IVL_ivl_dlfcn_H
#define IVL_ivl_dlfcn_H
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#if defined(__MINGW32__)
@@ -91,4 +91,4 @@ static __inline__ const char*dlerror(void)
{ return strerror( errno ); }
#endif
#endif
#endif /* IVL_ivl_dlfcn_H */
+42 -7
View File
@@ -1,7 +1,7 @@
#ifndef __compiler_H
#define __compiler_H
#ifndef IVL_compiler_H
#define IVL_compiler_H
/*
* Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include <list>
@@ -36,6 +36,11 @@
*/
extern unsigned integer_width;
/*
* The width_cap is the width limit for unsized expressions.
*/
extern unsigned width_cap;
/*
* This is the maximum number of recursive module loops allowed within
* a generate block.
@@ -92,18 +97,35 @@ extern bool warn_inf_loop;
extern bool warn_sens_entire_vec;
extern bool warn_sens_entire_arr;
/* Warn about level-appropriate anachronisms. */
extern bool warn_anachronisms;
/* This is true if verbose output is requested. */
extern bool verbose_flag;
extern bool debug_scopes;
extern bool debug_eval_tree;
extern bool debug_elaborate;
extern bool debug_emit;
extern bool debug_synth2;
extern bool debug_optimizer;
/* Control evaluation of functions at compile time:
* 0 = only for functions in constant expressions
* 1 = only for automatic functions
* 2 = for all functions
* Level 2 should only be used if the user can guarantee that a
* function's local variables are never accessed from outside the
* function. */
extern unsigned opt_const_func;
/* Possibly temporary flag to control virtualization of pin arrays */
extern bool disable_virtual_pins;
/* The vlog95 code generator does not want the compiler to generate concat-Z
* LPM objects so this flag is used to block them from being generated. */
extern bool disable_concatz_generation;
/* Limit to size of devirtualized arrays */
extern unsigned long array_size_limit;
@@ -124,6 +146,7 @@ enum generation_t {
GN_VER2005 = 4,
GN_VER2005_SV = 5,
GN_VER2009 = 6,
GN_VER2012 = 7,
GN_DEFAULT = 4
};
@@ -139,6 +162,10 @@ extern bool gn_icarus_misc_flag;
is false, then skip elaboration of specify behavior. */
extern bool gn_specify_blocks_flag;
/* If this flag is true, then elaborate assertions. If this flag is
false, then stub out assertion statements. */
extern bool gn_assertions_flag;
/* If this flag is true, then support/elaborate Verilog-AMS. */
extern bool gn_verilog_ams_flag;
@@ -161,7 +188,8 @@ extern bool gn_strict_expr_width_flag;
static inline bool gn_var_can_be_uwire(void)
{
if (generation_flag == GN_VER2005_SV ||
generation_flag == GN_VER2009)
generation_flag == GN_VER2009 ||
generation_flag == GN_VER2012)
return true;
return false;
}
@@ -169,11 +197,17 @@ static inline bool gn_var_can_be_uwire(void)
static inline bool gn_system_verilog(void)
{
if (generation_flag == GN_VER2005_SV ||
generation_flag == GN_VER2009)
generation_flag == GN_VER2009 ||
generation_flag == GN_VER2012)
return true;
return false;
}
static inline bool gn_modules_nest(void)
{
return gn_system_verilog();
}
/* The bits of these GN_KEYWORDS_* constants define non-intersecting
sets of keywords. The compiler enables groups of keywords by setting
lexor_keyword_mask with the OR of the bits for the keywords to be
@@ -185,6 +219,7 @@ enum { GN_KEYWORDS_1364_1995 = 0x0001,
GN_KEYWORDS_VAMS_2_3 = 0x0010,
GN_KEYWORDS_1800_2005 = 0x0020,
GN_KEYWORDS_1800_2009 = 0x0040,
GN_KEYWORDS_1800_2012 = 0x0080,
GN_KEYWORDS_ICARUS = 0x8000
};
extern int lexor_keyword_mask;
@@ -248,4 +283,4 @@ extern void cleanup_sys_func_table();
*/
extern ivl_sfunc_as_task_t def_sfunc_as_task;
#endif
#endif /* IVL_compiler_H */
+7 -5
View File
@@ -1,7 +1,7 @@
#ifndef __config_H /* -*- c++ -*- */
#define __config_H
#ifndef IVL_config_H /* -*- c++ -*- */
#define IVL_config_H
/*
* Copyright (c) 2001-2010 Stephen Williams ([email protected])
* Copyright (c) 2001-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#if defined(__cplusplus)
@@ -53,6 +53,8 @@
/* These two are needed by the lxt and lxt2 files (copied from GTKWave). */
# undef HAVE_ALLOCA_H
# undef HAVE_FSEEKO
/* And this is needed by the fst files (copied from GTKWave). */
# undef HAVE_LIBPTHREAD
/*
* Define this if you want to compile vvp with memory freeing and
@@ -60,4 +62,4 @@
*/
# undef CHECK_WITH_VALGRIND
#endif /* __config_H */
#endif /* IVL_config_H */
+33 -13
View File
@@ -8,20 +8,21 @@ AC_CONFIG_HEADER(vpi/vpi_config.h)
AC_CONFIG_HEADER(libveriuser/config.h)
AC_CONFIG_HEADER(tgt-vvp/vvp_config.h)
AC_CONFIG_HEADER(tgt-vhdl/vhdl_config.h)
AC_CONFIG_HEADER(tgt-pcb/pcb_config.h)
AC_CANONICAL_HOST
dnl Checks for programs.
AC_PROG_CC
# AC_PROG_CC_C99 is only available in autoconf version 2.60 and later.
# If you must use an older version then comment out the following two
# lines, but be warned that there could be issues with finding the
# nan(), etc. functions. It is really best to upgrade to a supported
# version of autoconf.
AC_PREREQ([2.60])
AC_PROG_CC_C99
AC_PROG_CXX
AC_PROG_RANLIB
AC_CHECK_TOOL(LD, ld, false)
AC_CHECK_TOOL(AR, ar, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(STRIP, strip, true)
AC_CHECK_TOOL(WINDRES,windres,false)
AC_CHECK_PROGS(XGPERF,gperf,none)
AC_CHECK_PROGS(MAN,man,none)
AC_CHECK_PROGS(PS2PDF,ps2pdf,none)
@@ -31,7 +32,7 @@ then
echo ""
echo "*** Warning: No suitable gperf found. ***"
echo " The gperf package is essential for building ivl from"
echo " CVS sources, or modifying the parse engine of ivl itself."
echo " git sources, or modifying the parse engine of ivl itself."
echo " You can get away without it when simply building from"
echo " snapshots or major releases."
echo ""
@@ -80,12 +81,27 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
CFLAGS="$iverilog_temp_cflags"
AC_SUBST(DEPENDENCY_FLAG, [-MD])
AC_SUBST(WARNING_FLAGS, ["-Wall -Wshadow"])
AC_SUBST(WARNING_FLAGS_CXX, ["$iverilog_wextra_flag"])
AC_SUBST(WARNING_FLAGS, ["-Wall $iverilog_wextra_flag -Wshadow"])
AC_SUBST(WARNING_FLAGS_CC, [""])
AC_SUBST(WARNING_FLAGS_CXX, [""])
fi
AC_LANG(C++)
AC_ARG_WITH([m32], [AC_HELP_STRING([--with-m32], [Compile 32-bit on x86_64])],
[ with_m32=yes ],[ with_m32=no ])
AS_IF( [test "x$with_m32" = xyes],
[ AC_MSG_NOTICE([Compiling for 32-bit environment - needs gcc on x86_64])
LDTARGETFLAGS="-m elf_i386"
CTARGETFLAGS="-m32"
],
[])
CFLAGS="$CTARGETFLAGS $CFLAGS"
CXXFLAGS="$CTARGETFLAGS $CXXFLAGS"
LDFLAGS="$CTARGETFLAGS $LDFLAGS"
# Check that we are using either the GNU compilers or the Sun compilers
# but not a mixture of the two (not currently supported).
AC_CHECK_DECL(__SUNPRO_CC, using_sunpro_cc=1, using_sunpro_cc=0)
@@ -106,7 +122,11 @@ else
fi
fi
iverilog_temp_cxxflags="$CXXFLAGS"
CXXFLAGS="-DHAVE_DECL_BASENAME $CXXFLAGS"
AC_CHECK_HEADERS(getopt.h inttypes.h libiberty.h iosfwd sys/wait.h)
CXXFLAGS="$iverilog_temp_cxxflags"
AC_CHECK_SIZEOF(unsigned long long)
AC_CHECK_SIZEOF(unsigned long)
@@ -173,6 +193,11 @@ if test -z "$DLLIB" ; then
AC_CHECK_LIB(dld,shl_load,[DLLIB=-ldld])
fi
AC_SUBST(DLLIB)
AC_SUBST(LDRELOCFLAGS)
AC_SUBST(CTARGETFLAGS)
AC_SUBST(LDTARGETFLAGS)
AC_PROG_INSTALL
@@ -189,9 +214,6 @@ AX_LD_EXTRALIBS
# CFLAGS inherited by cadpli/Makefile?
AX_C_PICFLAG
# may modify CPPFLAGS and CFLAGS
AX_CPP_PRECOMP
# may modify LDFLAGS
AX_C99_STRTOD
@@ -297,6 +319,4 @@ AC_MSG_ERROR(cannot configure white space in libdir: $libdir)
fi
AC_MSG_RESULT(ok)
# XXX disable tgt-fpga for the moment
AC_OUTPUT(Makefile ivlpp/Makefile vhdlpp/Makefile vvp/Makefile vpi/Makefile driver/Makefile driver-vpi/Makefile cadpli/Makefile libveriuser/Makefile tgt-null/Makefile tgt-stub/Makefile tgt-vvp/Makefile tgt-vhdl/Makefile tgt-fpga/Makefile tgt-verilog/Makefile tgt-pal/Makefile tgt-vlog95/Makefile)
AC_OUTPUT(Makefile ivlpp/Makefile vhdlpp/Makefile vvp/Makefile vpi/Makefile driver/Makefile driver-vpi/Makefile cadpli/Makefile libveriuser/Makefile tgt-null/Makefile tgt-stub/Makefile tgt-vvp/Makefile tgt-vhdl/Makefile tgt-fpga/Makefile tgt-verilog/Makefile tgt-pal/Makefile tgt-vlog95/Makefile tgt-pcb/Makefile tgt-blif/Makefile tgt-sizer/Makefile)
+2 -2
View File
@@ -1,3 +1,3 @@
// These are correct and are used to find the base (zero) pin.
thisSubtraction:netlist.h:4164
thisSubtraction:netlist.h:4173
thisSubtraction:netlist.h:4938
thisSubtraction:netlist.h:4947
+189 -10
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2013 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,18 +14,19 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
# include <algorithm>
# include <vector>
# include <cstdlib>
# include "netlist.h"
# include "netmisc.h"
# include "functor.h"
# include "compiler.h"
# include "ivl_assert.h"
# include <vector>
/*
@@ -42,11 +43,14 @@ struct cprop_functor : public functor_t {
virtual void signal(Design*des, NetNet*obj);
virtual void lpm_add_sub(Design*des, NetAddSub*obj);
virtual void lpm_compare(Design*des, NetCompare*obj);
virtual void lpm_compare_eq_(Design*des, NetCompare*obj);
virtual void lpm_concat(Design*des, NetConcat*obj);
virtual void lpm_ff(Design*des, NetFF*obj);
virtual void lpm_logic(Design*des, NetLogic*obj);
virtual void lpm_mux(Design*des, NetMux*obj);
};
virtual void lpm_part_select(Design*des, NetPartSelect*obj);
void lpm_compare_eq_(Design*des, NetCompare*obj);
};
void cprop_functor::signal(Design*, NetNet*)
{
@@ -74,6 +78,50 @@ void cprop_functor::lpm_compare_eq_(Design*, NetCompare*)
{
}
void cprop_functor::lpm_concat(Design*des, NetConcat*obj)
{
// Sorry, I don't know how to constant-propagate through
// transparent concatenations.
if (obj->transparent())
return;
verinum result (verinum::Vz, obj->width());
unsigned off = 0;
for (unsigned idx = 1 ; idx < obj->pin_count() ; idx += 1) {
Nexus*nex = obj->pin(idx).nexus();
// If there are non-constant drivers, then give up.
if (! nex->drivers_constant())
return;
verinum tmp = nex->driven_vector();
result.set(off, tmp);
off += tmp.len();
}
if (debug_optimizer)
cerr << obj->get_fileline() << ": cprop_functor::lpm_concat: "
<< "Replace NetConcat with " << result << "." << endl;
NetScope*scope = obj->scope();
// Create a NetConst object to carry the result. Give it the
// same name as the Concat object that we are replacing, and
// link the NetConst to the NetConcat object. Then delete the
// concat that is now replaced.
NetConst*result_obj = new NetConst(scope, obj->name(), result);
result_obj->set_line(*obj);
des->add_node(result_obj);
connect(obj->pin(0), result_obj->pin(0));
// Note that this will leave the const inputs to dangle. They
// will be reaped by other passes of cprop_functor.
delete obj;
count += 1;
}
void cprop_functor::lpm_ff(Design*, NetFF*obj)
{
// Look for and count unlinked FF outputs. Note that if the
@@ -115,11 +163,6 @@ void cprop_functor::lpm_mux(Design*des, NetMux*obj)
if (! sel_nex->drivers_constant())
return;
// If the select input is assigned or forced, then again there
// is nothing we can do here.
if (sel_nex->assign_lval())
return;
// If the constant select is 'bz or 'bx, then give up.
verinum::V sel_val = sel_nex->driven_value();
if (sel_val == verinum::Vz || sel_val == verinum::Vx)
@@ -150,6 +193,142 @@ void cprop_functor::lpm_mux(Design*des, NetMux*obj)
count += 1;
}
static bool compare_base(NetPartSelect*a, NetPartSelect*b)
{
return a->base() < b->base();
}
/*
* This optimization searches for Nexa that are driven only by
* NetPartSelect(PV) outputs. These might turn from Verilog input that
* looks like this:
* wire [7:0] foo
* assign foo[7:4] = a;
* assign foo[3:0] = b;
* The idea is to convert the part selects of the above to a single
* concatenation that looks like this:
* assign foo = {a, b};
*/
void cprop_functor::lpm_part_select(Design*des, NetPartSelect*obj)
{
if (obj->dir() != NetPartSelect::PV)
return;
NetScope*scope = obj->scope();
Nexus*nex = obj->pin(1).nexus();
vector<NetPartSelect*> obj_set;
for (Link*cur = nex->first_nlink() ; cur ; cur = cur->next_nlink()) {
// If this is an input (or passive) then ignore it.
if (cur->get_dir() != Link::OUTPUT)
continue;
// Check to see if this is the output of a
// NetPartSelect::PV. If not, then give up on the blend.
NetPins*tmp_obj = cur->get_obj();
unsigned tmp_pin = cur->get_pin();
NetPartSelect*cur_obj = dynamic_cast<NetPartSelect*> (tmp_obj);
if (cur_obj == 0)
return;
if (cur_obj->dir() != NetPartSelect::PV)
return;
if (tmp_pin != 1)
return;
obj_set.push_back(cur_obj);
}
if (obj_set.size() < 2)
return;
if (debug_optimizer)
cerr << obj->get_fileline() << ": cprop::lpm_part_select: "
<< "Found " << obj_set.size() << " NetPartSelect(PV) objects."
<< endl;
// Sort by increasing base offset.
sort(obj_set.begin(), obj_set.end(), compare_base);
// Check and make sure there are no overlaps. If there are,
// then give up on this optimization.
for (size_t idx = 1 ; idx < obj_set.size() ; idx += 1) {
unsigned top = obj_set[idx-1]->base() + obj_set[idx-1]->width();
if (top > obj_set[idx]->base()) {
if (debug_optimizer)
cerr << obj->get_fileline() << ": cprop::lpm_part_select: "
<< "Range [" << obj_set[idx-1]->base()
<< " " << top << ") overlaps PV starting at "
<< obj_set[idx]->base() << ". Give up." << endl;
return;
}
}
// Check if the tail runs off the end of the target. If so it
// should be possible to replace it with a bit select to
// shorten the object for the target, but for now just give up.
unsigned sig_width = nex->vector_width();
if (obj_set.back()->base() + obj_set.back()->width() > sig_width) {
if (debug_optimizer)
cerr << obj->get_fileline() << ": cprop::lpm_part_select: "
<< "Range [" << obj_set.back()->base()
<< ":" << (obj_set.back()->base() + obj_set.back()->width() - 1)
<< "] runs off the end of target." << endl;
return;
}
// Figure out how many components we are going to need.
unsigned part_count = 0;
unsigned off = 0;
for (size_t idx = 0 ; idx < obj_set.size() ; idx += 1) {
if (obj_set[idx]->base() > off) {
off = obj_set[idx]->base();
part_count += 1;
}
off += obj_set[idx]->width();
part_count += 1;
}
if (off < sig_width)
part_count += 1;
NetConcat*concat = new NetConcat(scope, scope->local_symbol(),
sig_width, part_count);
concat->set_line(*obj);
des->add_node(concat);
connect(concat->pin(0), obj->pin(1));
off = 0;
size_t concat_pin = 1;
for (size_t idx = 0 ; idx < obj_set.size() ; idx += 1) {
NetPartSelect*cobj = obj_set[idx];
if (cobj->base() > off) {
NetNet*zzz = make_const_z(des, scope, cobj->base()-off);
connect(concat->pin(concat_pin), zzz->pin(0));
concat_pin += 1;
off = cobj->base();
}
connect(concat->pin(concat_pin), cobj->pin(0));
concat_pin += 1;
off += cobj->width();
}
if (off < sig_width) {
NetNet*zzz = make_const_z(des, scope, sig_width-off);
connect(concat->pin(concat_pin), zzz->pin(0));
concat_pin += 1;
}
ivl_assert(*obj, concat_pin == concat->pin_count());
for (size_t idx = 0 ; idx < obj_set.size() ; idx += 1) {
delete obj_set[idx];
}
count += 1;
}
/*
* This functor looks to see if the constant is connected to nothing
* but signals. If that is the case, delete the dangling constant and
+418 -88
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -28,6 +28,10 @@
# include "netlist.h"
# include "compiler.h"
# include "discipline.h"
# include "netclass.h"
# include "netdarray.h"
# include "netqueue.h"
# include "netvector.h"
# include "ivl_assert.h"
# include "PExpr.h"
@@ -40,6 +44,12 @@ static ostream& operator<< (ostream&o, NetBlock::Type t)
case NetBlock::PARA:
o << "fork";
break;
case NetBlock::PARA_JOIN_NONE:
o << "fork-join_none";
break;
case NetBlock::PARA_JOIN_ANY:
o << "fork-join_any";
break;
}
return o;
}
@@ -98,6 +108,15 @@ ostream& operator << (ostream&o, ivl_variable_type_t val)
case IVL_VT_STRING:
o << "string";
break;
case IVL_VT_DARRAY:
o << "darray";
break;
case IVL_VT_CLASS:
o << "class";
break;
case IVL_VT_QUEUE:
o << "queue";
break;
}
return o;
}
@@ -130,6 +149,93 @@ ostream& operator << (ostream&o, ivl_switch_type_t val)
return o;
}
ostream& operator << (ostream&fd, PortType::Enum val)
{
switch (val) {
case PortType::NOT_A_PORT:
fd << "NOT_A_PORT";
break;
case PortType::PIMPLICIT:
fd << "PIMPLICIT";
break;
case PortType::PINPUT:
fd << "PINPUT";
break;
case PortType::POUTPUT:
fd << "POUTPUT";
break;
case PortType::PINOUT:
fd << "PINOUT";
break;
case PortType::PREF:
fd << "PREF";
break;
default:
fd << "PortType::Enum::?";
break;
}
return fd;
}
ostream& operator << (ostream&fd, NetCaseCmp::kind_t that)
{
switch (that) {
case NetCaseCmp::EEQ:
fd << "===";
break;
case NetCaseCmp::NEQ:
fd << "!==";
break;
case NetCaseCmp::XEQ:
fd << "==?";
break;
case NetCaseCmp::ZEQ:
fd << "==z?";
break;
}
return fd;
}
ostream& ivl_type_s::debug_dump(ostream&o) const
{
o << typeid(*this).name();
return o;
}
ostream& netclass_t::debug_dump(ostream&fd) const
{
fd << "class " << name_ << "{";
for (size_t idx = 0 ; idx < property_table_.size() ; idx += 1) {
if (idx != 0) fd << "; ";
if (property_table_[idx].type)
property_table_[idx].type->debug_dump(fd);
else
fd << "NO_TYPE";
fd << " " << property_table_[idx].name;
}
fd << "}";
return fd;
}
ostream& netdarray_t::debug_dump(ostream&o) const
{
o << "dynamic array of " << *element_type();
return o;
}
ostream& netqueue_t::debug_dump(ostream&fd) const
{
fd << "queue of " << *element_type();
return fd;
}
ostream& netvector_t::debug_dump(ostream&o) const
{
o << type_ << (signed_? " signed" : " unsigned") << packed_dims_;
return o;
}
static inline void dump_scope_path(ostream&o, const NetScope*scope)
{
const NetScope*parent = scope->parent();
@@ -137,10 +243,7 @@ static inline void dump_scope_path(ostream&o, const NetScope*scope)
dump_scope_path(o, parent);
o << ".";
}
const hname_t name = scope->fullname();
o << name.peek_name();
if (name.has_number())
o << "[" << name.peek_number() << "]";
o << scope->fullname();
}
ostream& operator <<(ostream&o, struct __ScopePathManip marg)
@@ -150,6 +253,77 @@ ostream& operator <<(ostream&o, struct __ScopePathManip marg)
return o;
}
ostream& operator <<(ostream&o, struct __ObjectPathManip marg)
{
if (marg.obj != 0) {
dump_scope_path(o, marg.obj->scope());
o << "." << marg.obj->name();
}
return o;
}
ostream& operator <<(ostream&fd, Link::DIR dir)
{
switch (dir) {
case Link::PASSIVE:
fd << "PASSIVE";
break;
case Link::INPUT:
fd << "INPUT";
break;
case Link::OUTPUT:
fd << "OUTPUT";
break;
default:
fd << "<" << (int)dir << ">";
break;
}
return fd;
}
void NetPins::show_type(ostream&fd) const
{
fd << typeid(*this).name();
}
void NetObj::show_type(ostream&fd) const
{
fd << typeid(*this).name() << "[" << scope_path(scope_) << "." << name_ << "]";
}
struct __ShowTypeManip { const NetPins*pins; };
inline __ShowTypeManip show_type(const NetPins*pins)
{ __ShowTypeManip tmp; tmp.pins = pins; return tmp; }
inline ostream& operator << (ostream&fd, __ShowTypeManip man)
{
if (man.pins == 0)
fd << "NexusSet";
else
man.pins->show_type(fd);
return fd;
}
void Link::dump_link(ostream&fd, unsigned ind) const
{
const Link*cur;
const Nexus*nex = nexus();
if (nex == 0) {
fd << setw(ind) << "" << "<unlinked>" << endl;
return;
}
for (cur = nex->first_nlink() ; cur; cur = cur->next_nlink()) {
const NetPins*obj = cur->get_obj();
unsigned pin = cur->get_pin();
fd << setw(ind) << "" << "Pin " << pin
<< " of " << show_type(obj)
<< ", dir=" << cur->dir_ << endl;
}
}
void NetBranch::dump(ostream&o, unsigned ind) const
{
static const char*pin_names[2] = {
@@ -187,16 +361,42 @@ void NetDelaySrc::dump(ostream&o, unsigned ind) const
dump_node_pins(o, ind+4);
}
static inline ostream&operator<<(ostream&out, const netrange_t&that)
{
if (that.defined())
out << "[" << that.get_msb() << ":" << that.get_lsb() << "]";
else
out << "[]";
return out;
}
ostream&operator<<(ostream&out, const list<netrange_t>&rlist)
{
for (list<netrange_t>::const_iterator cur = rlist.begin()
; cur != rlist.end() ; ++cur) {
out << *cur;
}
return out;
}
ostream&operator<<(ostream&out, const vector<netrange_t>&rlist)
{
for (vector<netrange_t>::const_iterator cur = rlist.begin()
; cur != rlist.end() ; ++cur) {
out << *cur;
}
return out;
}
/* Dump a net. This can be a wire or register. */
void NetNet::dump_net(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << type() << ": " << name()
<< "[" << s0_ << ":" << e0_ << " count=" << pin_count() << "]";
<< unpacked_dims_ << " unpacked dims=" << unpacked_dimensions();
o << " pin_count=" << pin_count();
if (local_flag_)
o << " (local)";
o << " " << data_type_;
if (signed_)
o << " signed";
switch (port_type_) {
case NetNet::NOT_A_PORT:
break;
@@ -212,11 +412,16 @@ void NetNet::dump_net(ostream&o, unsigned ind) const
case NetNet::PINOUT:
o << " inout";
break;
case NetNet::PREF:
o <<" ref";
break;
}
if (ivl_discipline_t dis = get_discipline())
o << " discipline=" << dis->name();
if (net_type_) o << " " << *net_type_;
o << " (eref=" << peek_eref() << ", lref=" << peek_lref() << ")";
if (scope())
o << " scope=" << scope_path(scope());
@@ -382,8 +587,12 @@ void NetCompare::dump_node(ostream&o, unsigned ind) const
void NetConcat::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "NetConcat: "
<< name();
if (transparent_)
o << setw(ind) << "" << "NetConcat8: ";
else
o << setw(ind) << "" << "NetConcat: ";
o << name();
if (rise_time())
o << " #(" << *rise_time()
<< "," << *fall_time() << "," << *decay_time() << ")";
@@ -446,19 +655,14 @@ void NetBUFZ::dump_node(ostream&o, unsigned ind) const
void NetCaseCmp::dump_node(ostream&o, unsigned ind) const
{
if (eeq_)
o << setw(ind) << "" << "case compare === : " << name() << endl;
else
o << setw(ind) << "" << "case compare !== : " << name() << endl;
o << setw(ind) << "" << "case compare " << kind_ << ": " << name() << endl;
dump_node_pins(o, ind+4);
}
void NetConst::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "constant " << width_ << "'b";
for (unsigned idx = width_ ; idx > 0 ; idx -= 1)
o << value_[idx-1];
o << setw(ind) << "" << "constant " << value_;
o << ": " << name();
if (rise_time())
o << " #(" << *rise_time()
@@ -599,6 +803,21 @@ void NetPartSelect::dump_node(ostream&o, unsigned ind) const
dump_obj_attr(o, ind+4);
}
void NetSubstitute::dump_node(ostream&fd, unsigned ind) const
{
fd << setw(ind) << "" << "NetSubstitute: "
<< name();
if (rise_time())
fd << " #(" << *rise_time()
<< "," << *fall_time()
<< "," << *decay_time() << ")";
else
fd << " #(.,.,.)";
fd << " width=" << wid_ << " base=" << off_ <<endl;
dump_node_pins(fd, ind+4);
dump_obj_attr(fd, ind+4);
}
void NetReplicate::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "NetReplicate: "
@@ -680,12 +899,13 @@ void NetUserFunc::dump_node(ostream&o, unsigned ind) const
void NetTaskDef::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "task " << scope_path(scope_) << ";" << endl;
o << setw(ind) << "" << "task " << scope_path(scope()) << ";" << endl;
for (unsigned idx = 0 ; idx < ports_.count() ; idx += 1) {
for (unsigned idx = 0 ; idx < port_count() ; idx += 1) {
const NetNet*pnet = port(idx);
o << setw(ind+4) << "";
assert(ports_[idx]);
switch (ports_[idx]->port_type()) {
assert(pnet);
switch (pnet->port_type()) {
case NetNet::PINPUT:
o << "input ";
break;
@@ -699,10 +919,13 @@ void NetTaskDef::dump(ostream&o, unsigned ind) const
o << "NOT_A_PORT ";
break;
}
o << ports_[idx]->name() << ";" << endl;
o << pnet->name() << ";" << endl;
}
proc_->dump(o, ind+4);
if (proc_)
proc_->dump(o, ind+4);
else
o << setw(ind+4) << "" << "MISSING PROCEDURAL CODE" << endl;
o << setw(ind) << "" << "endtask" << endl;
}
@@ -792,16 +1015,18 @@ void NetAlloc::dump(ostream&o, unsigned ind) const
void NetAssign_::dump_lval(ostream&o) const
{
if (sig_) {
o << sig_->name();
if (word_) {
o << "[word=" << *word_ << "]";
}
if (base_) {
o << "[" << *base_ << " +: " << lwid_ << "]";
}
} else {
o << "";
if (sig_) o << sig_->name();
else if (nest_) nest_->dump_lval(o);
else o << "<?>";
if (! member_.nil()) {
o << "." << member_;
}
if (word_) {
o << "[word=" << *word_ << "]";
}
if (base_) {
o << "[" << *base_ << " +: " << lwid_ << "]";
}
}
@@ -824,7 +1049,10 @@ void NetAssign::dump(ostream&o, unsigned ind) const
o << setw(ind) << "";
dump_lval(o);
o << " = ";
if (op_)
o << " " << op_ << "= ";
else
o << " = ";
if (const NetExpr*de = get_delay())
o << "#(" << *de << ") ";
@@ -893,7 +1121,7 @@ void NetCase::dump(ostream&o, unsigned ind) const
break;
}
for (unsigned idx = 0 ; idx < nitems_ ; idx += 1) {
for (unsigned idx = 0 ; idx < items_.size() ; idx += 1) {
o << setw(ind+2) << "";
if (items_[idx].guard)
o << *items_[idx].guard << ":";
@@ -951,8 +1179,17 @@ void NetDeassign::dump(ostream&o, unsigned ind) const
void NetDisable::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "disable " << scope_path(target_) << "; "
<< "/* " << get_fileline() << " */" << endl;
o << setw(ind) << "" << "disable ";
if (target_) o << scope_path(target_);
else o << "fork";
o << "; " << "/* " << get_fileline() << " */" << endl;
}
void NetDoWhile::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "do" << endl;
proc_->dump(o, ind+3);
o << setw(ind) << "" << "while (" << *cond_ << ");" << endl;
}
void NetEvProbe::dump_node(ostream&o, unsigned ind) const
@@ -983,7 +1220,15 @@ void NetEvTrig::dump(ostream&o, unsigned ind) const
void NetEvWait::dump(ostream&o, unsigned ind) const
{
o << setw(ind) <<"" << "@(";
o << setw(ind) << "";
/* Check for a wait fork. */
if ((nevents() == 1) && (event(0) == 0)) {
o << "wait fork;";
return;
}
o << "@(";
if (nevents() > 0)
o << event(0)->name();
@@ -1007,6 +1252,12 @@ ostream& operator << (ostream&out, const NetEvWait&obj)
void NetEvWait::dump_inline(ostream&o) const
{
/* Check for a wait fork. */
if ((nevents() == 1) && (event(0) == 0)) {
o << "wait fork;";
return;
}
o << "@(";
if (nevents() > 0)
@@ -1031,6 +1282,13 @@ void NetForever::dump(ostream&o, unsigned ind) const
statement_->dump(o, ind+2);
}
void NetForLoop::dump(ostream&fd, unsigned ind) const
{
fd << setw(ind) << "" << "FOR LOOP index=" << index_->name() << endl;
statement_->dump(fd, ind+4);
step_statement_->dump(fd, ind+4);
}
void NetFree::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "// free storage : " << scope_path(scope_) << endl;
@@ -1038,12 +1296,11 @@ void NetFree::dump(ostream&o, unsigned ind) const
void NetFuncDef::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "function definition for " << scope_path(scope_) << endl;
o << setw(ind) << "" << "function definition for " << scope_path(scope()) << endl;
if (result_sig_) {
o << setw(ind+2) << "" << "Return signal: ";
if (result_sig_->get_signed()) o << "+";
o << result_sig_->name() << "[" << result_sig_->msb() << ":"
<< result_sig_->lsb() << "]" << endl;
o << result_sig_->name() << endl;
}
o << setw(ind+2) << "" << "Arguments: ";
if (port_count() == 0) o << "<none>";
@@ -1065,13 +1322,12 @@ void NetFuncDef::dump(ostream&o, unsigned ind) const
break;
}
if (port(idx)->get_signed()) o << "+";
o << port(idx)->name() << "[" << port(idx)->msb() << ":"
<< port(idx)->lsb() << "]" << endl;
o << port(idx)->name() << endl;
}
if (statement_)
statement_->dump(o, ind+2);
if (proc_)
proc_->dump(o, ind+2);
else
o << setw(ind+2) << "" << "// NO STATEMENT" << endl;
o << setw(ind+2) << "" << "MISSING PROCEDURAL CODE" << endl;
}
void NetPDelay::dump(ostream&o, unsigned ind) const
@@ -1104,6 +1360,11 @@ void NetRepeat::dump(ostream&o, unsigned ind) const
statement_->dump(o, ind+2);
}
void netclass_t::dump_scope(ostream&fd) const
{
class_scope_->dump(fd);
}
void NetScope::dump(ostream&o) const
{
/* This is a constructed hierarchical name. */
@@ -1112,7 +1373,10 @@ void NetScope::dump(ostream&o) const
print_type(o);
if (is_auto()) o << " (automatic)";
if (is_cell()) o << " (cell)";
o << endl;
if (nested_module()) o << " (nested)";
if (program_block()) o << " (program)";
o << " " << children_.size() << " children, "
<< classes_.size() << " classes" << endl;
for (unsigned idx = 0 ; idx < attr_cnt() ; idx += 1)
o << " (* " << attr_key(idx) << " = "
@@ -1126,7 +1390,10 @@ void NetScope::dump(ostream&o) const
map<perm_string,param_expr_t>::const_iterator pp;
for (pp = parameters.begin()
; pp != parameters.end() ; ++ pp ) {
o << " parameter ";
if ((*pp).second.is_annotatable)
o << " specparam ";
else
o << " parameter ";
o << pp->second.type << " ";
@@ -1173,12 +1440,6 @@ void NetScope::dump(ostream&o) const
o << ";" << endl;
}
for (pp = localparams.begin()
; pp != localparams.end() ; ++ pp ) {
o << " localparam " << (*pp).first << " = " <<
*(*pp).second.val << ";" << endl;
}
}
/* Dump the saved defparam assignments here. */
@@ -1203,9 +1464,9 @@ void NetScope::dump(ostream&o) const
o << " enum sets {" << endl;
/* Dump the enumerations and enum names in this scope. */
for (list<netenum_t*>::const_iterator cur = enum_sets_.begin()
for (map<const enum_type_t*,netenum_t*>::const_iterator cur = enum_sets_.begin()
; cur != enum_sets_.end() ; ++ cur) {
o << " " << *cur << endl;
o << " " << cur->second << endl;
}
o << " }" << endl;
@@ -1230,27 +1491,6 @@ void NetScope::dump(ostream&o) const
cur->second->dump_net(o, 4);
}
// Dump specparams
typedef map<perm_string,spec_val_t>::const_iterator specparam_it_t;
for (specparam_it_t cur = specparams.begin()
; cur != specparams.end() ; ++ cur ) {
o << " specparam " << (*cur).first
<< " = ";
spec_val_t value = (*cur).second;
switch (value.type) {
case IVL_VT_REAL:
o << "R:" << value.real_val;
break;
case IVL_VT_BOOL:
o << "I:" << value.integer;
break;
default:
o << "<bad type>";
break;
}
o << endl;
}
switch (type_) {
case FUNC:
if (func_def())
@@ -1272,18 +1512,23 @@ void NetScope::dump(ostream&o) const
for (map<hname_t,NetScope*>::const_iterator cur = children_.begin()
; cur != children_.end() ; ++ cur )
cur->second->dump(o);
for (map<perm_string,netclass_t*>::const_iterator cur = classes_.begin()
; cur != classes_.end() ; ++ cur ) {
cur->second->dump_scope(o);
}
}
void NetSTask::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << name_;
if (parms_.count() > 0) {
if (! parms_.empty()) {
o << "(";
if (parms_[0])
parms_[0]->dump(o);
for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) {
for (unsigned idx = 1 ; idx < parms_.size() ; idx += 1) {
o << ", ";
if (parms_[idx])
parms_[idx]->dump(o);
@@ -1329,6 +1574,19 @@ void NetEAccess::dump(ostream&o) const
o << ")";
}
void NetEArrayPattern::dump(ostream&fd) const
{
fd << "'{";
if (items_.size() >= 1) {
if (items_[0]) fd << *items_[0];
}
for (size_t idx = 1 ; idx < items_.size() ; idx += 1) {
fd << ", ";
if (items_[idx]) fd << *items_[idx];
}
fd << "}";
}
void NetEBinary::dump(ostream&o) const
{
if (op_ == 'm' || op_ == 'M') {
@@ -1403,6 +1661,16 @@ void NetEBinary::dump(ostream&o) const
o << ")";
}
void NetECast::dump(ostream&fd) const
{
if (op_=='2')
fd << "bool<" << expr_width() << ">(" << *expr_ << ")";
else if (op_=='4')
fd << "logic<" << expr_width() << ">(" << *expr_ << ")";
else
NetEUnary::dump(fd);
}
void NetEConcat::dump(ostream&o) const
{
if (repeat_ != 1)
@@ -1413,7 +1681,7 @@ void NetEConcat::dump(ostream&o) const
else
o << "{";
for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) {
for (unsigned idx = 1 ; idx < parms_.size() ; idx += 1) {
if (parms_[idx])
o << ", " << *parms_[idx];
else
@@ -1461,11 +1729,40 @@ void NetEEvent::dump(ostream&o) const
o << "<event=" << event_->name() << ">";
}
void NetELast::dump(ostream&fd) const
{
fd << "<last of " << sig_->name() << ">";
}
void NetENetenum::dump(ostream&o) const
{
o << "<netenum=" << netenum_ << ">";
}
void NetENew::dump(ostream&o) const
{
o << "new <type> [";
if (size_) size_->dump(o);
o << "]";
if (init_val_) {
o << "(";
init_val_->dump(o);
o << ")";
}
}
void NetENull::dump(ostream&o) const
{
o << "<null>";
}
void NetEProperty::dump(ostream&o) const
{
o << net_->name() << ".<" << pidx_ << ">";
if (index_)
o << "[" << *index_ << "]";
}
void NetEScope::dump(ostream&o) const
{
o << "<scope=" << scope_path(scope_) << ">";
@@ -1487,7 +1784,14 @@ void NetESelect::dump(ostream&o) const
else
o << "(0)";
o << "+:" << expr_width() << "]>";
o << "+:" << expr_width() << "]";
if (ivl_type_t nt = net_type()) {
o << " net_type=(" << *nt << ")";
} else {
o << " expr_type=" << expr_type();
}
o << ">";
}
void NetESFunc::dump(ostream&o) const
@@ -1500,13 +1804,19 @@ void NetESFunc::dump(ostream&o) const
o << ")";
}
void NetEShallowCopy::dump(ostream&o) const
{
o << "<ShallowCopy, " << *arg1_ << " <-- " << *arg2_ << ">";
}
void NetESignal::dump(ostream&o) const
{
if (has_sign())
o << "+";
o << name();
if (word_) o << "[word=" << *word_ << "]";
o << "[" << msi()<<":"<<lsi() << "]";
vector<netrange_t>tmp = net_->net_type()->slice_dimensions();
o << tmp;
}
void NetETernary::dump(ostream&o) const
@@ -1517,10 +1827,10 @@ void NetETernary::dump(ostream&o) const
void NetEUFunc::dump(ostream&o) const
{
o << func_->basename() << "(";
if (parms_.count() > 0) {
o << scope_path(func_) << "(";
if (! parms_.empty()) {
parms_[0]->dump(o);
for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) {
for (unsigned idx = 1 ; idx < parms_.size() ; idx += 1) {
o << ", ";
parms_[idx]->dump(o);
}
@@ -1572,10 +1882,30 @@ void NetEUnary::dump(ostream&o) const
void Design::dump(ostream&o) const
{
o << "DESIGN TIME PRECISION: 10e" << get_precision() << endl;
o << "PACKAGES:" << endl;
for (map<perm_string,NetScope*>::const_iterator cur = packages_.begin()
; cur != packages_.end() ; ++cur) {
cur->second->dump(o);
}
o << "$ROOT CLASSESS:" << endl;
for (map<perm_string,netclass_t*>::const_iterator cur = classes_.begin()
; cur != classes_.end() ; ++cur) {
cur->second->dump_scope(o);
}
o << "$ROOT TASKS/FUNCTIONS:" << endl;
for (map<NetScope*,PTaskFunc*>::const_iterator cur = root_tasks_.begin()
; cur != root_tasks_.end() ; ++ cur) {
cur->first->dump(o);
}
o << "SCOPES:" << endl;
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
scope != root_scopes_.end(); ++ scope )
scope != root_scopes_.end(); ++ scope ) {
(*scope)->dump(o);
}
o << "ELABORATED NODES:" << endl;
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "discipline.h"
+5 -5
View File
@@ -1,7 +1,7 @@
#ifndef __discipline_H
#define __discipline_H
#ifndef IVL_discipline_H
#define IVL_discipline_H
/*
* Copyright (c) 2008-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
@@ -74,4 +74,4 @@ extern map<perm_string,ivl_discipline_t> disciplines;
// Map access function name to the nature that it accesses.
extern map<perm_string,ivl_nature_t> access_function_nature;
#endif
#endif /* IVL_discipline_H */
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
+5 -5
View File
@@ -12,9 +12,8 @@
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc.,
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
SHELL = /bin/sh
@@ -37,6 +36,7 @@ mandir = @mandir@
dllib=@DLLIB@
CC = @CC@
WINDRES = @WINDRES@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
@@ -48,7 +48,7 @@ INCLUDE_PATH = -I. -I.. -I$(srcdir) -I$(srcdir)/..
endif
CPPFLAGS = $(INCLUDE_PATH) @CPPFLAGS@ @DEFS@
CFLAGS = @WARNING_FLAGS@ @CFLAGS@
CFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@
LDFLAGS = @LDFLAGS@
O = main.o res.o
@@ -88,7 +88,7 @@ res.rc: $(srcdir)/res.rc.in ../version.exe
$(srcdir)/res.rc.in > $@
res.o: res.rc
windres -i res.rc -o res.o
$(WINDRES) -i res.rc -o res.o
#
install: all installdirs $(bindir)/iverilog-vpi$(suffix)@EXEEXT@
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
+14 -9
View File
@@ -12,9 +12,8 @@
#
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc.,
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
SHELL = /bin/sh
@@ -50,7 +49,7 @@ INCLUDE_PATH = -I. -I.. -I$(srcdir) -I$(srcdir)/..
endif
CPPFLAGS = $(INCLUDE_PATH) @CPPFLAGS@ @DEFS@
CFLAGS = @WARNING_FLAGS@ @CFLAGS@
CFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@
LDFLAGS = @LDFLAGS@
O = main.o substit.o cflexor.o cfparse.o
@@ -68,7 +67,11 @@ distclean: clean
rm -f Makefile config.log
cppcheck: $(O:.o=.c)
cppcheck --enable=all -f $(INCLUDE_PATH) $^
cppcheck --enable=all -f \
-UYY_USER_INIT \
-UYYPARSE_PARAM -UYYPRINT -Ushort -Uyyoverflow \
-UYYTYPE_INT8 -UYYTYPE_INT16 -UYYTYPE_UINT8 -UYYTYPE_UINT16 \
$(INCLUDE_PATH) $^
Makefile: $(srcdir)/Makefile.in ../config.status
cd ..; ./config.status --file=driver/$@
@@ -79,11 +82,13 @@ dep:
iverilog@EXEEXT@: $O
$(CC) $(LDFLAGS) $O -o iverilog@EXEEXT@ @EXTRALIBS@
cflexor.c: cflexor.lex
$(LEX) -s -ocflexor.c $(srcdir)/cflexor.lex
cflexor.c: $(srcdir)/cflexor.lex
$(LEX) -s -t $< > $@
cfparse.h cfparse.c: cfparse.y
$(YACC) --verbose -t -d -o cfparse.c --name-prefix=cf $(srcdir)/cfparse.y
# Build this in two steps to avoid parallel build issues (see pr3462585)
cfparse.c: $(srcdir)/cfparse.y
$(YACC) --verbose -t -p cf -d -o $@ $<
cfparse.h: cfparse.c
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) @DEPENDENCY_FLAG@ -c $< -o $*.o
+6 -4
View File
@@ -4,7 +4,7 @@
%{
/*
* Copyright (c) 2001-2009 Stephen Williams ([email protected])
* Copyright (c) 2001-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -19,7 +19,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "cfparse.h"
@@ -92,6 +92,8 @@ int cmdfile_stack_ptr = 0;
"+vhdl-libdir+" { BEGIN(PLUS_ARGS); return TOK_VHDL_LIBDIR; }
"+width-cap+" { BEGIN(PLUS_ARGS); return TOK_WIDTH_CAP; }
/* If it is not any known plus-flag, return the generic form. */
"+"[^\n \t\b\f\r+]* {
cflval.text = strdup(yytext);
@@ -195,7 +197,6 @@ int yywrap()
void switch_to_command_file(const char *file)
{
char path[4096];
char *cp;
if (cmdfile_stack_ptr >= MAX_CMDFILE_DEPTH) {
fprintf(stderr, "Error: command files nested too deeply (%d) "
@@ -213,6 +214,7 @@ void switch_to_command_file(const char *file)
* file name.
*/
if (file[0] != '/') {
char *cp;
strcpy(path, current_file);
cp = strrchr(path, '/');
if (cp == 0) strcpy(path, file); /* A base file. */
@@ -245,7 +247,7 @@ void cfreset(FILE*fd, const char*path)
/*
* Modern version of flex (>=2.5.9) can clean up the scanner data.
*/
void destroy_lexor()
void destroy_lexor(void)
{
# ifdef FLEX_SCANNER
# if YY_FLEX_MAJOR_VERSION >= 2 && YY_FLEX_MINOR_VERSION >= 5
+12 -3
View File
@@ -1,6 +1,6 @@
%{
/*
* Copyright (c) 2001-2011 Stephen Williams ([email protected])
* Copyright (c) 2001-2014 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "globals.h"
@@ -61,6 +61,7 @@ static void translate_file_name(char*text)
%token TOK_Da TOK_Dc TOK_Dv TOK_Dy
%token TOK_DEFINE TOK_INCDIR TOK_INTEGER_WIDTH TOK_LIBDIR TOK_LIBDIR_NOCASE
%token TOK_LIBEXT TOK_PARAMETER TOK_TIMESCALE TOK_VHDL_WORK TOK_VHDL_LIBDIR
%token TOK_WIDTH_CAP
%token <text> TOK_PLUSARG TOK_PLUSWORD TOK_STRING
%%
@@ -191,6 +192,13 @@ item
free(tmp);
}
| TOK_WIDTH_CAP TOK_PLUSARG
{ char*tmp = substitutions($2);
free($2);
width_cap = strtoul(tmp,0,10);
free(tmp);
}
/* The +<word> tokens that are not otherwise matched, are
ignored. The skip_args rule arranges for all the argument words
to be consumed. */
@@ -213,7 +221,7 @@ item
}
| error
{ fprintf(stderr, "Error: unable to parse line %d in "
{ fprintf(stderr, "Error: unable to parse line %u in "
"%s.\n", cflloc.first_line, current_file);
return 1;
}
@@ -262,5 +270,6 @@ skip_arg : TOK_PLUSARG
int yyerror(const char*msg)
{
(void)msg; /* Parameter is not used. */
return 0;
}
+6 -6
View File
@@ -1,7 +1,7 @@
#ifndef __cfparse_misc_H
#define __cfparse_misc_H
#ifndef IVL_cfparse_misc_H
#define IVL_cfparse_misc_H
/*
* Copyright (c) 2001-2009 Picture Elements, Inc.
* Copyright (c) 2001-2014 Picture Elements, Inc.
* Stephen Williams (steve@picturel.com)
*
* This source code is free software; you can redistribute it
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
@@ -38,7 +38,7 @@ int cflex(void);
int cferror(const char *);
int cfparse(void);
void switch_to_command_file(const char *);
void destroy_lexor();
void destroy_lexor(void);
char *current_file;
#endif
#endif /* IVL_cfparse_misc_H */
+8 -5
View File
@@ -1,7 +1,7 @@
#ifndef __globals_H
#define __globals_H
#ifndef IVL_globals_H
#define IVL_globals_H
/*
* Copyright (c) 2000-2009 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include <stddef.h>
@@ -24,6 +24,9 @@
/* This is the integer-width argument that will be passed to ivl. */
extern unsigned integer_width;
/* This is the width-cap argument that will be passed to ivl. */
extern unsigned width_cap;
extern const char*vhdlpp_work;
extern const char**vhdlpp_libdir;
extern unsigned vhdlpp_libdir_cnt;
@@ -51,4 +54,4 @@ extern void process_parameter(const char*name);
/* Set the default timescale for the simulator. */
extern void process_timescale(const char*ts_string);
#endif
#endif /* IVL_globals_H */
+15 -6
View File
@@ -1,4 +1,4 @@
.TH iverilog 1 "February 27th, 2011" "" "Version %M.%m.%n %E"
.TH iverilog 1 "February 26th, 2014" "" "Version %M.%m.%n %E"
.SH NAME
iverilog - Icarus Verilog compiler
@@ -6,7 +6,7 @@ iverilog - Icarus Verilog compiler
.B iverilog
[\-ESVv] [\-Bpath] [\-ccmdfile|\-fcmdfile] [\-Dmacro[=defn]]
[\-Pparameter=value] [\-pflag=value]
[\-dname] [\-g1995|\-g2001|\-g2005|\-g2005-sv|\-g2009|\-g<feature>]
[\-dname] [\-g1995|\-g2001|\-g2005|\-g2005-sv|\-g2009|\-g2012|\-g<feature>]
[\-Iincludedir] [\-mmodule] [\-M[mode=]file] [\-Nfile] [\-ooutputfilename]
[\-stopmodule] [\-ttype] [\-Tmin/typ/max] [\-Wclass] [\-ypath] sourcefile
@@ -61,10 +61,11 @@ is the Verilog input, but with file inclusions and macro references
expanded and removed. This is useful, for example, to preprocess
Verilog source for use by other compilers.
.TP 8
.B -g1995\fI|\fP-g2001\fI|\fP-g2001-noconfig\fI|\fP-g2005\fI|\fP-g2005-sv\fI|\fP-g2009
.B -g1995\fI|\fP-g2001\fI|\fP-g2001-noconfig\fI|\fP-g2005\fI|\fP-g2005-sv\fI|\fP-g2009\fI|\fP-g2012
Select the Verilog language \fIgeneration\fP to support in the compiler.
This selects between \fIIEEE1364\-1995\fP, \fIIEEE1364\-2001\fP,
\fIIEEE1364\-2005\fP, \fIIEEE1800\-2005\fP, or \fIIEEE1800\-2009\fP.
\fIIEEE1364\-2005\fP, \fIIEEE1800\-2005\fP, \fIIEEE1800\-2009\fP, or
\fIIEEE1800\-2012\fP.
Icarus Verilog currently defaults to the \fIIEEE1364\-2005\fP generation
of the language. This flag is used to restrict the language to a set of
keywords/features, this allows simulation of older Verilog code that may
@@ -128,7 +129,9 @@ standard compliant behavior (with some loss in performance).
.B -gstrict-expr-width\fI|\fP-gno-strict-expr-width
Enable or disable (default) strict compliance with the standard rules
for determining expression bit lengths. When disabled, the RHS of a
parameter assignment is evaluated as a lossless expression.
parameter assignment is evaluated as a lossless expression, as is any
expression containing an unsized constant number, and unsized constant
numbers are not truncated to integer width.
.TP 8
.B -I\fIincludedir\fP
Append directory \fIincludedir\fP to list of directories searched
@@ -459,6 +462,12 @@ This allows the programmer to select the width for integer variables
in the Verilog source. The default is 32, the value can be any desired
integer value.
.TP 8
.B +width-cap+\fIvalue\fP
This allows the programmer to select the width cap for unsized expressions.
If the calculated width for an unsized expression exceeds this value, the
compiler will issue a warning and limit the expression width to this value.
.SH "VARIABLES IN COMMAND FILES"
In certain cases, iverilog supports variables in command files. These
@@ -512,7 +521,7 @@ Tips on using, debugging, and developing the compiler can be found at
.SH COPYRIGHT
.nf
Copyright \(co 2002\-2011 Stephen Williams
Copyright \(co 2002\-2014 Stephen Williams
This document can be freely redistributed according to the terms of the
GNU General Public License version 2.0
+46 -18
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -39,7 +39,7 @@ const char NOTICE[] =
const char HELP[] =
"Usage: iverilog [-ESvV] [-B base] [-c cmdfile|-f cmdfile]\n"
" [-g1995|-g2001|-g2005|-g2005-sv|-g2009] [-g<feature>]\n"
" [-g1995|-g2001|-g2005|-g2005-sv|-g2009|-g2012] [-g<feature>]\n"
" [-D macro[=defn]] [-I includedir]\n"
" [-M [mode=]depfile] [-m module]\n"
" [-N file] [-o filename] [-p flag=value]\n"
@@ -71,7 +71,7 @@ const char HELP[] =
#endif
#include <fcntl.h>
#if HAVE_GETOPT_H
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
@@ -122,6 +122,7 @@ char depmode = 'a';
const char*generation = "2005";
const char*gen_specify = "no-specify";
const char*gen_assertions = "assertions";
const char*gen_xtypes = "xtypes";
const char*gen_icarus = "icarus-misc";
const char*gen_io_range_error = "io-range-error";
@@ -136,10 +137,12 @@ int gen_std_include = 1;
of the include list. */
int gen_relative_include = 0;
char warning_flags[16] = "";
char warning_flags[16] = "n";
unsigned integer_width = 32;
unsigned width_cap = 65536;
char*mod_list = 0;
char*command_filename = 0;
@@ -185,7 +188,7 @@ static const char** defparm_base = 0;
static int defparm_size = 0;
/* Function to add a command file name to the FIFO. */
void add_cmd_file(const char* filename)
static void add_cmd_file(const char* filename)
{
p_command_file new;
@@ -202,7 +205,7 @@ void add_cmd_file(const char* filename)
}
/* Function to return the top command file name from the FIFO. */
char *get_cmd_file()
static char *get_cmd_file(void)
{
char *filename;
@@ -399,7 +402,7 @@ static int t_preprocess_only(void)
* needed to run the command from the configuration file (which is
* already parsed for us) so we can handle must of the generic cases.
*/
static int t_compile()
static int t_compile(void)
{
unsigned rc;
@@ -491,11 +494,15 @@ static int t_compile()
static void process_warning_switch(const char*name)
{
if (strcmp(name,"all") == 0) {
process_warning_switch("anachronisms");
process_warning_switch("implicit");
process_warning_switch("portbind");
process_warning_switch("select-range");
process_warning_switch("timescale");
process_warning_switch("sensitivity-entire-array");
} else if (strcmp(name,"anachronisms") == 0) {
if (! strchr(warning_flags, 'n'))
strcat(warning_flags, "n");
} else if (strcmp(name,"implicit") == 0) {
if (! strchr(warning_flags, 'i'))
strcat(warning_flags, "i");
@@ -519,6 +526,12 @@ static void process_warning_switch(const char*name)
} else if (strcmp(name,"sensitivity-entire-array") == 0) {
if (! strchr(warning_flags, 'a'))
strcat(warning_flags, "a");
} else if (strcmp(name,"no-anachronisms") == 0) {
char*cp = strchr(warning_flags, 'n');
if (cp) while (*cp) {
cp[0] = cp[1];
cp += 1;
}
} else if (strcmp(name,"no-implicit") == 0) {
char*cp = strchr(warning_flags, 'i');
if (cp) while (*cp) {
@@ -612,7 +625,7 @@ void process_file_name(const char*name, int lib_flag)
}
}
int process_generation(const char*name)
static int process_generation(const char*name)
{
if (strcmp(name,"1995") == 0)
generation = "1995";
@@ -632,6 +645,9 @@ int process_generation(const char*name)
else if (strcmp(name,"2009") == 0)
generation = "2009";
else if (strcmp(name,"2012") == 0)
generation = "2012";
else if (strcmp(name,"1") == 0) { /* Deprecated: use 1995 */
generation = "1995";
gen_xtypes = "no-xtypes";
@@ -665,6 +681,12 @@ int process_generation(const char*name)
else if (strcmp(name,"no-specify") == 0)
gen_specify = "no-specify";
else if (strcmp(name,"assertions") == 0)
gen_assertions = "assertions";
else if (strcmp(name,"no-assertions") == 0)
gen_assertions = "no-assertions";
else if (strcmp(name,"std-include") == 0)
gen_std_include = 1;
@@ -710,6 +732,7 @@ int process_generation(const char*name)
" 2005 -- IEEE1364-2005\n"
" 2005-sv -- IEEE1800-2005\n"
" 2009 -- IEEE1800-2009\n"
" 2012 -- IEEE1800-2012\n"
"Other generation flags:\n"
" specify | no-specify\n"
" verilog-ams | no-verilog-ams\n"
@@ -727,7 +750,7 @@ int process_generation(const char*name)
return 0;
}
int process_depfile(const char*name)
static int process_depfile(const char*name)
{
const char*cp = strchr(name, '=');
if (cp) {
@@ -761,7 +784,7 @@ int process_depfile(const char*name)
/*
* If it exists add the SFT file for the given module.
*/
void add_sft_file(const char *module)
static void add_sft_file(const char *module)
{
char *file;
@@ -776,7 +799,7 @@ int main(int argc, char **argv)
{
int e_flag = 0;
int version_flag = 0;
int opt, idx;
int opt;
#ifdef __MINGW32__
/* Calculate the ivl_root from the path to the command. This
@@ -884,7 +907,7 @@ int main(int argc, char **argv)
}
}
while ((opt = getopt(argc, argv, "B:c:D:d:Ef:g:hI:M:m:N::o:P:p:Ss:T:t:vVW:y:Y:")) != EOF) {
while ((opt = getopt(argc, argv, "B:c:D:d:Ef:g:hI:M:m:N:o:P:p:Ss:T:t:vVW:y:Y:")) != EOF) {
switch (opt) {
case 'B':
@@ -1021,7 +1044,7 @@ int main(int argc, char **argv)
if (version_flag || verbose_flag) {
printf("Icarus Verilog version " VERSION " (" VERSION_TAG ")\n\n");
printf("Copyright 1998-2011 Stephen Williams\n\n");
printf("Copyright 1998-2013 Stephen Williams\n\n");
puts(NOTICE);
}
@@ -1047,10 +1070,11 @@ int main(int argc, char **argv)
fprintf(iconfig_file, "sys_func:%s%csystem.sft\n", base, sep);
fprintf(iconfig_file, "sys_func:%s%cvhdl_sys.sft\n", base, sep);
/* If verilog-2005/9 is enabled or icarus-misc or verilog-ams,
/* If verilog-2005/09/12 is enabled or icarus-misc or verilog-ams,
* then include the v2005_math library. */
if (strcmp(generation, "2005") == 0 ||
strcmp(generation, "2009") == 0 ||
strcmp(generation, "2012") == 0 ||
strcmp(gen_icarus, "icarus-misc") == 0 ||
strcmp(gen_verilog_ams, "verilog-ams") == 0) {
fprintf(iconfig_file, "sys_func:%s%cv2005_math.sft\n", base, sep);
@@ -1066,7 +1090,8 @@ int main(int argc, char **argv)
/* If verilog-2009 (SystemVerilog) is enabled, then include the
v2009 module. */
if (strcmp(generation, "2005-sv") == 0 ||
strcmp(generation, "2009") == 0) {
strcmp(generation, "2009") == 0 ||
strcmp(generation, "2012") == 0) {
fprintf(iconfig_file, "sys_func:%s%cv2009.sft\n", base, sep);
fprintf(iconfig_file, "module:v2009\n");
}
@@ -1074,6 +1099,7 @@ int main(int argc, char **argv)
if (mtm != 0) fprintf(iconfig_file, "-T:%s\n", mtm);
fprintf(iconfig_file, "generation:%s\n", generation);
fprintf(iconfig_file, "generation:%s\n", gen_specify);
fprintf(iconfig_file, "generation:%s\n", gen_assertions);
fprintf(iconfig_file, "generation:%s\n", gen_xtypes);
fprintf(iconfig_file, "generation:%s\n", gen_io_range_error);
fprintf(iconfig_file, "generation:%s\n", gen_strict_ca_eval);
@@ -1116,7 +1142,7 @@ int main(int argc, char **argv)
vhdlpp_work = "ivl_vhdl_work";
fprintf(defines_file, "vhdlpp:%s%cvhdlpp\n", vhdlpp_dir, sep);
fprintf(defines_file, "vhdlpp-work:%s\n", vhdlpp_work);
for (idx = 0 ; idx < vhdlpp_libdir_cnt ; idx += 1)
for (unsigned idx = 0 ; idx < vhdlpp_libdir_cnt ; idx += 1)
fprintf(defines_file, "vhdlpp-libdir:%s\n", vhdlpp_libdir[idx]);
/* Process parameter definition from command line. The last
@@ -1130,7 +1156,7 @@ int main(int argc, char **argv)
/* Finally, process all the remaining words on the command
line as file names. */
for (idx = optind ; idx < argc ; idx += 1)
for (int idx = optind ; idx < argc ; idx += 1)
process_file_name(argv[idx], 0);
/* If the use of a default include directory is not
@@ -1168,6 +1194,8 @@ int main(int argc, char **argv)
fprintf(iconfig_file, "iwidth:%u\n", integer_width);
fprintf(iconfig_file, "widthcap:%u\n", width_cap);
/* Write the preprocessor command needed to preprocess a
single file. This may be used to preprocess library
files. */
+2 -1
View File
@@ -14,13 +14,14 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include <string.h>
# include <stdlib.h>
# include <stdio.h>
# include "ivl_alloc.h"
# include "globals.h"
char* substitutions(const char*str)
+51 -6
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2013 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -32,6 +32,17 @@ NetEAccess* NetEAccess::dup_expr() const
return tmp;
}
NetEArrayPattern*NetEArrayPattern::dup_expr() const
{
vector<NetExpr*>tmp (items_.size());
for (size_t idx = 0 ; idx < tmp.size() ; idx += 1)
tmp[idx] = items_[idx]->dup_expr();
NetEArrayPattern*res = new NetEArrayPattern(net_type(), tmp);
res->set_line(*this);
return res;
}
NetEBinary* NetEBinary::dup_expr() const
{
ivl_assert(*this, 0);
@@ -110,10 +121,10 @@ NetEBShift* NetEBShift::dup_expr() const
NetEConcat* NetEConcat::dup_expr() const
{
NetEConcat*dup = new NetEConcat(parms_.count(), repeat_);
NetEConcat*dup = new NetEConcat(parms_.size(), repeat_, expr_type_);
ivl_assert(*this, dup);
dup->set_line(*this);
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1)
for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1)
if (parms_[idx]) {
NetExpr*tmp = parms_[idx]->dup_expr();
ivl_assert(*this, tmp);
@@ -171,12 +182,38 @@ NetEEvent* NetEEvent::dup_expr() const
return 0;
}
NetELast* NetELast::dup_expr() const
{
NetELast*tmp = new NetELast(sig_);
ivl_assert(*this, tmp);
tmp->set_line(*this);
return tmp;
}
NetENetenum* NetENetenum::dup_expr() const
{
ivl_assert(*this, 0);
return 0;
}
NetENew* NetENew::dup_expr() const
{
ivl_assert(*this, 0);
return 0;
}
NetENull* NetENull::dup_expr() const
{
ivl_assert(*this, 0);
return 0;
}
NetEProperty* NetEProperty::dup_expr() const
{
ivl_assert(*this, 0);
return 0;
}
NetEScope* NetEScope::dup_expr() const
{
ivl_assert(*this, 0);
@@ -189,6 +226,7 @@ NetESelect* NetESelect::dup_expr() const
base_? base_->dup_expr() : 0,
expr_width(), sel_type_);
ivl_assert(*this, tmp);
tmp->cast_signed(has_sign());
tmp->set_line(*this);
return tmp;
}
@@ -208,11 +246,18 @@ NetESFunc* NetESFunc::dup_expr() const
return tmp;
}
NetEShallowCopy* NetEShallowCopy::dup_expr() const
{
ivl_assert(*this, 0);
return 0;
}
NetESignal* NetESignal::dup_expr() const
{
NetESignal*tmp = new NetESignal(net_, word_);
ivl_assert(*this, tmp);
tmp->expr_width(expr_width());
tmp->cast_signed(has_sign());
tmp->set_line(*this);
return tmp;
}
@@ -232,9 +277,9 @@ NetETernary* NetETernary::dup_expr() const
NetEUFunc* NetEUFunc::dup_expr() const
{
NetEUFunc*tmp;
svector<NetExpr*> tmp_parms (parms_.count());
vector<NetExpr*> tmp_parms (parms_.size());
for (unsigned idx = 0 ; idx < tmp_parms.count() ; idx += 1) {
for (unsigned idx = 0 ; idx < tmp_parms.size() ; idx += 1) {
ivl_assert(*this, parms_[idx]);
tmp_parms[idx] = parms_[idx]->dup_expr();
}
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
+2559 -495
View File
File diff suppressed because it is too large Load Diff
+863 -119
View File
File diff suppressed because it is too large Load Diff
+355 -98
View File
@@ -1,5 +1,6 @@
/*
* Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2014 Stephen Williams (steve@icarus.com)
* Copyright CERN 2012 / Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -22,6 +23,8 @@
# include "PExpr.h"
# include "netlist.h"
# include "netmisc.h"
# include "netstruct.h"
# include "netvector.h"
# include "compiler.h"
# include <cstdlib>
@@ -96,12 +99,12 @@ NetNet* PEConcat::elaborate_lnet_common_(Design*des, NetScope*scope,
concat operator from most significant to least significant,
which is the order they are given in the concat list. */
netvector_t*tmp2_vec = new netvector_t(nets[0]->data_type(),width-1,0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, width);
NetNet::IMPLICIT, tmp2_vec);
/* Assume that the data types of the nets are all the same, so
we can take the data type of any, the first will do. */
osig->data_type(nets[0]->data_type());
osig->local_flag(true);
osig->set_line(*this);
@@ -152,8 +155,6 @@ NetNet* PEConcat::elaborate_lnet_common_(Design*des, NetScope*scope,
assert(width == 0);
}
osig->data_type(nets[0]->data_type());
osig->local_flag(true);
return osig;
}
@@ -199,11 +200,15 @@ bool PEConcat::is_collapsible_net(Design*des, NetScope*scope) const
bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
long&midx, long&lidx) const
{
list<long> prefix_indices;
bool rc = calculate_packed_indices_(des, scope, sig, prefix_indices);
ivl_assert(*this, rc);
const name_component_t&name_tail = path_.back();
// Only treat as part/bit selects any index that is beyond the
// word selects for an array. This is not an array, then
// dimensions==0 and any index is treated as a select.
if (name_tail.index.size() <= sig->array_dimensions()) {
if (name_tail.index.size() <= sig->unpacked_dimensions()) {
midx = sig->vector_width()-1;
lidx = 0;
return true;
@@ -242,7 +247,7 @@ bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
if (warn_ob_select) {
cerr << get_fileline() << ": warning: "
<< sig->name();
if (sig->array_dimensions() > 0) cerr << "[]";
if (sig->unpacked_dimensions() > 0) cerr << "[]";
cerr << "['bx";
if (index_tail.sel ==
index_component_t::SEL_IDX_UP) {
@@ -250,20 +255,20 @@ bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
} else {
cerr << "-:";
}
cerr << wid << "] is always outside vector."
cerr << wid << "] is always outside the vector."
<< endl;
}
return false;
}
long midx_val = tmp->value().as_long();
midx = sig->sb_to_idx(midx_val);
midx = sig->sb_to_idx(prefix_indices, midx_val);
delete tmp_ex;
if (index_tail.sel == index_component_t::SEL_IDX_UP)
lidx = sig->sb_to_idx(midx_val+wid-1);
lidx = sig->sb_to_idx(prefix_indices, midx_val+wid-1);
else
lidx = sig->sb_to_idx(midx_val-wid+1);
lidx = sig->sb_to_idx(prefix_indices, midx_val-wid+1);
if (midx < lidx) {
long tmpx = midx;
@@ -274,7 +279,7 @@ bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
/* Warn about an indexed part select that is out of range. */
if (warn_ob_select && (lidx < 0)) {
cerr << get_fileline() << ": warning: " << sig->name();
if (sig->array_dimensions() > 0) cerr << "[]";
if (sig->unpacked_dimensions() > 0) cerr << "[]";
cerr << "[" << midx_val;
if (index_tail.sel == index_component_t::SEL_IDX_UP) {
cerr << "+:";
@@ -285,7 +290,7 @@ bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
}
if (warn_ob_select && (midx >= (long)sig->vector_width())) {
cerr << get_fileline() << ": warning: " << sig->name();
if (sig->array_dimensions() > 0) {
if (sig->unpacked_dimensions() > 0) {
cerr << "[]";
}
cerr << "[" << midx_val;
@@ -310,10 +315,21 @@ bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
long msb, lsb;
bool part_defined_flag;
/* bool flag = */ calculate_parts_(des, scope, msb, lsb, part_defined_flag);
ivl_assert(*this, part_defined_flag);
long lidx_tmp = sig->sb_to_idx(lsb);
long midx_tmp = sig->sb_to_idx(msb);
/* We have an undefined index and that is out of range. */
if (!part_defined_flag) {
if (warn_ob_select) {
cerr << get_fileline() << ": warning: "
<< sig->name();
if (sig->unpacked_dimensions() > 0) cerr << "[]";
cerr << "['bx] is always outside the vector."
<< endl;
}
return false;
}
long lidx_tmp = sig->sb_to_idx(prefix_indices, lsb);
long midx_tmp = sig->sb_to_idx(prefix_indices, msb);
/* Detect reversed indices of a part select. */
if (lidx_tmp > midx_tmp) {
cerr << get_fileline() << ": error: Part select "
@@ -332,16 +348,11 @@ bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
if (midx_tmp >= (long)sig->vector_width() || lidx_tmp < 0) {
cerr << get_fileline() << ": warning: Part select "
<< sig->name();
if (sig->array_dimensions() > 0) {
if (sig->unpacked_dimensions() > 0) {
cerr << "[]";
}
cerr << "[" << msb << ":" << lsb
<< "] is out of range." << endl;
#if 0
midx_tmp = sig->vector_width() - 1;
lidx_tmp = 0;
des->errors += 1;
#endif
}
/* This is completely out side the signal so just skip it. */
if (lidx_tmp >= (long)sig->vector_width() || midx_tmp < 0) {
@@ -354,30 +365,43 @@ bool PEIdent::eval_part_select_(Design*des, NetScope*scope, NetNet*sig,
}
case index_component_t::SEL_BIT:
if (name_tail.index.size() > sig->array_dimensions()) {
verinum*mval = index_tail.msb->eval_const(des, scope);
if (mval == 0) {
cerr << get_fileline() << ": error: Index of " << path_ <<
" needs to be constant in this context." <<
endl;
cerr << get_fileline() << ": : Index expression is: "
<< *index_tail.msb << endl;
cerr << get_fileline() << ": : Context scope is: "
<< scope_path(scope) << endl;
des->errors += 1;
if (name_tail.index.size() > sig->unpacked_dimensions()) {
long msb;
bool bit_defined_flag;
/* bool flag = */ calculate_bits_(des, scope, msb, bit_defined_flag);
/* We have an undefined index and that is out of range. */
if (!bit_defined_flag) {
if (warn_ob_select) {
cerr << get_fileline() << ": warning: "
<< sig->name();
if (sig->unpacked_dimensions() > 0) cerr << "[]";
cerr << "['bx] is always outside the vector."
<< endl;
}
return false;
}
assert(mval);
midx = sig->sb_to_idx(mval->as_long());
if (midx >= (long)sig->vector_width()) {
cerr << get_fileline() << ": error: Index " << sig->name()
<< "[" << mval->as_long() << "] is out of range."
<< endl;
des->errors += 1;
midx = 0;
if (prefix_indices.size()+2 <= sig->packed_dims().size()) {
long tmp_loff;
unsigned long tmp_lwid;
bool rcl = sig->sb_to_slice(prefix_indices, msb,
tmp_loff, tmp_lwid);
ivl_assert(*this, rcl);
midx = tmp_loff + tmp_lwid - 1;
lidx = tmp_loff;
} else {
midx = sig->sb_to_idx(prefix_indices, msb);
if (midx >= (long)sig->vector_width()) {
cerr << get_fileline() << ": error: Index " << sig->name()
<< "[" << msb << "] is out of range."
<< endl;
des->errors += 1;
midx = 0;
}
lidx = midx;
}
lidx = midx;
} else {
cerr << get_fileline() << ": internal error: "
@@ -405,6 +429,7 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
NetNet* sig = 0;
const NetExpr*par = 0;
NetEvent* eve = 0;
perm_string method_name;
symbol_search(this, des, scope, path_, sig, par, eve);
@@ -416,6 +441,35 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
return 0;
}
// Break the path_ into the tail name and the prefix. For
// example, a name "a.b.c" is broken into name_tail="c" and
// path_prefix="a.b".
const name_component_t&path_tail = path_.back();
pform_name_t path_prefix = path_;
path_prefix.pop_back();
/* If the signal is not found, check to see if this is a
member of a struct. Take the name of the form "a.b.member",
remove the member and store it into method_name, and retry
the search with "a.b". */
if (sig == 0 && path_.size() >= 2) {
if (debug_elaborate) {
cerr << get_fileline() << ": PEIdent::elaborate_lnet_common_: "
"Symbol not found, try again with path_prefix=" << path_prefix
<< " and method_name=" << path_tail.name << endl;
}
method_name = path_tail.name;
symbol_search(this, des, scope, path_prefix, sig, par, eve);
// Whoops, not a struct signal, so give up on this avenue.
if (sig && sig->struct_type() == 0) {
cerr << get_fileline() << ": XXXXX: sig=" << sig->name()
<< " is found, but not a struct with member " << method_name << endl;
method_name = perm_string();
sig = 0;
}
}
if (sig == 0) {
cerr << get_fileline() << ": error: Net " << path_
<< " is not defined in this context." << endl;
@@ -430,17 +484,10 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
wire. */
if (gn_var_can_be_uwire()
&& (sig->type() == NetNet::REG)
&& (sig->peek_eref() == 0) ) {
&& (sig->peek_lref() == 0) ) {
sig->type(NetNet::UNRESOLVED_WIRE);
}
if (sig->type() == NetNet::UNRESOLVED_WIRE && sig->pin(0).is_linked()) {
cerr << get_fileline() << ": error: Unresolved net/uwire "
<< sig->name() << " cannot have multiple drivers." << endl;
des->errors += 1;
return 0;
}
/* Don't allow registers as assign l-values. */
if (sig->type() == NetNet::REG) {
cerr << get_fileline() << ": error: reg " << sig->name()
@@ -454,59 +501,193 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
unsigned midx = sig->vector_width()-1, lidx = 0;
// The default word select is the first.
long widx = 0;
// The widx_val is the word select as entered in the source
// code. It's used for error messages.
long widx_val = 0;
// Set this to true if we calculate the word index. This is
// used to distinguish between unpacked array assignment and
// array word assignment.
bool widx_flag = false;
const name_component_t&name_tail = path_.back();
list<long> unpacked_indices_const;
if (sig->array_dimensions() > 0) {
const netstruct_t*struct_type = 0;
if ((struct_type = sig->struct_type()) && !method_name.nil()) {
if (name_tail.index.empty()) {
cerr << get_fileline() << ": error: array " << sig->name()
<< " must be used with an index." << endl;
// Detect the variable is a structure and there was a
// method name detected. We've already found that
// the path_ is <>.sig.method_name and signal
// (NetNet). We also know that sig is struct_type(), so
// look for a method named method_name.
if (debug_elaborate)
cerr << get_fileline() << ": PEIdent::elaborate_lnet_common_: "
<< "Signal " << sig->name() << " is a structure, "
<< "try to match member " << method_name << endl;
unsigned long member_off = 0;
const struct netstruct_t::member_t*member = struct_type->packed_member(method_name, member_off);
ivl_assert(*this, member);
if (debug_elaborate) {
cerr << get_fileline() << ": PEIdent::elaborate_lnet_common_: "
<< "Member " << method_name
<< " has type " << *member->net_type << "." << endl;
cerr << get_fileline() << ": : "
<< "Tail name has " << path_tail.index.size() << " indices." << endl;
}
// Rewrite a member select of a packed structure as a
// part select of the base variable.
lidx = member_off;
midx = lidx + member->net_type->packed_width() - 1;
// The dimensions of the tail of the prefix must match
// the dimensions of the signal at this point. (The sig
// has a packed dimension for the packed struct size.)
// For example, if the path_=a[<m>][<n>].member, then
// sig must have 3 packed dimensions: one for the struct
// members and two actual packed dimensions.
ivl_assert(*this, path_prefix.back().index.size()+1 == sig->packed_dimensions());
// Elaborate an expression from the packed indices and
// the member offset (into the structure) to get a
// canonical expression into the packed signal vector.
NetExpr*packed_base = 0;
if (sig->packed_dimensions() > 1) {
list<index_component_t>tmp_index = path_prefix.back().index;
index_component_t member_select;
member_select.sel = index_component_t::SEL_BIT;
member_select.msb = new PENumber(new verinum(member_off));
tmp_index.push_back(member_select);
packed_base = collapse_array_indices(des, scope, sig, tmp_index);
if (debug_elaborate) {
cerr << get_fileline() << ": PEIdent::elaborate_lnet_common_: "
<< "packed_base=" << *packed_base
<< ", member_off=" << member_off << endl;
}
}
long tmp;
if (packed_base && eval_as_long(tmp, packed_base)) {
lidx = tmp;
midx = lidx + member->net_type->packed_width() - 1;
delete packed_base;
packed_base = 0;
}
// Currently, only support const dimensions here.
ivl_assert(*this, packed_base == 0);
// Now the lidx/midx values get us to the member. Next
// up, deal with bit/part selects from the member
// itself.
//XXXXivl_assert(*this, member->packed_dims.size() <= 1);
ivl_assert(*this, path_tail.index.size() <= 1);
if (! path_tail.index.empty()) {
long tmp_off;
unsigned long tmp_wid;
const index_component_t&tail_sel = path_tail.index.back();
ivl_assert(*this, tail_sel.sel == index_component_t::SEL_PART || tail_sel.sel == index_component_t::SEL_BIT);
bool rc = calculate_part(this, des, scope, tail_sel, tmp_off, tmp_wid);
ivl_assert(*this, rc);
if (debug_elaborate)
cerr << get_fileline() << ": PEIdent::elaborate_lnet_common_: "
<< "tmp_off=" << tmp_off << ", tmp_wid=" << tmp_wid << endl;
lidx += tmp_off;
midx = lidx + tmp_wid - 1;
}
} else if (gn_system_verilog() && sig->unpacked_dimensions() > 0 && path_tail.index.empty()) {
// In this case, we are doing a continuous assignment to
// an unpacked array. The NetNet representation is a
// NetNet with a pin for each array element, so there is
// nothing more needed here.
//
// This can come up from code like this:
// logic [...] data [0:3];
// assign data = ...;
// In this case, "sig" is "data", and sig->pin_count()
// is 4 to account for the unpacked size.
if (debug_elaborate) {
cerr << get_fileline() << ": PEIdent::elaborate_lnet_common_: "
<< "Net assign to unpacked array \"" << sig->name()
<< "\" with " << sig->pin_count() << " elements." << endl;
}
} else if (sig->unpacked_dimensions() > 0) {
// Make sure there are enough indices to address an array element.
if (path_tail.index.size() < sig->unpacked_dimensions()) {
cerr << get_fileline() << ": error: Array " << path()
<< " needs " << sig->unpacked_dimensions() << " indices,"
<< " but got only " << path_tail.index.size() << ". (net)" << endl;
des->errors += 1;
return 0;
}
const index_component_t&index_head = name_tail.index.front();
if (index_head.sel == index_component_t::SEL_PART) {
cerr << get_fileline() << ": error: cannot perform a part "
<< "select on array " << sig->name() << "." << endl;
// Evaluate all the index expressions into an
// "unpacked_indices" array.
list<NetExpr*>unpacked_indices;
indices_flags flags;
indices_to_expressions(des, scope, this,
path_tail.index, sig->unpacked_dimensions(),
true, sig->unpacked_count(),
flags,
unpacked_indices,
unpacked_indices_const);
if (flags.invalid) {
return 0;
} else if (flags.variable) {
cerr << get_fileline() << ": error: array '" << sig->name()
<< "' index must be a constant in this context." << endl;
des->errors += 1;
return 0;
}
ivl_assert(*this, index_head.sel == index_component_t::SEL_BIT);
NetExpr*tmp_ex = elab_and_eval(des, scope, index_head.msb, -1, true);
NetEConst*tmp = dynamic_cast<NetEConst*>(tmp_ex);
if (!tmp) {
cerr << get_fileline() << ": error: array " << sig->name()
<< " index must be a constant in this context." << endl;
des->errors += 1;
return 0;
}
widx_val = tmp->value().as_long();
if (sig->array_index_is_valid(widx_val))
widx = sig->array_index_to_address(widx_val);
else
} else if (flags.undefined) {
cerr << get_fileline() << ": warning: "
<< "ignoring undefined l-value array access "
<< sig->name() << as_indices(unpacked_indices)
<< "." << endl;
widx = -1;
delete tmp_ex;
widx_flag = true;
} else {
NetExpr*canon_index = 0;
ivl_assert(*this, unpacked_indices_const.size() == sig->unpacked_dimensions());
canon_index = normalize_variable_unpacked(sig, unpacked_indices_const);
if (canon_index == 0) {
cerr << get_fileline() << ": warning: "
<< "ignoring out of bounds l-value array access "
<< sig->name() << as_indices(unpacked_indices_const)
<< "." << endl;
widx = -1;
widx_flag = true;
} else {
NetEConst*canon_const = dynamic_cast<NetEConst*>(canon_index);
ivl_assert(*this, canon_const);
widx = canon_const->value().as_long();
widx_flag = true;
delete canon_index;
}
}
if (debug_elaborate)
cerr << get_fileline() << ": debug: Use [" << widx << "]"
<< " to index l-value array." << endl;
/* The array has a part/bit select at the end. */
if (name_tail.index.size() > sig->array_dimensions()) {
if (path_tail.index.size() > sig->unpacked_dimensions()) {
if (sig->get_scalar()) {
cerr << get_fileline() << ": error: "
<< "can not select part of ";
if (sig->data_type() == IVL_VT_REAL) cerr << "real";
else cerr << "scalar";
cerr << " array word: " << sig->name()
<< "[" << widx_val << "]" << endl;
<< as_indices(unpacked_indices_const) << endl;
des->errors += 1;
return 0;
}
@@ -525,7 +706,18 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
midx = midx_tmp;
lidx = lidx_tmp;
}
} else if (!name_tail.index.empty()) {
} else if (!path_tail.index.empty()) {
if (debug_elaborate) {
cerr << get_fileline() << ": PEIdent::elaborate_lnet_common_: "
<< "path_tail.index.size()=" << path_tail.index.size()
<< endl;
}
// There are index expressions on the name, so this is a
// bit/slice select of the name. Calculate a canonical
// part select.
if (sig->get_scalar()) {
cerr << get_fileline() << ": error: "
<< "can not select part of ";
@@ -553,21 +745,40 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
unsigned subnet_wid = midx-lidx+1;
if (sig->pin_count() > 1) {
if (widx < 0 || widx >= (long) sig->pin_count()) {
cerr << get_fileline() << ": warning: ignoring out of "
"bounds l-value array access "
<< sig->name() << "[" << widx_val << "]." << endl;
return 0;
/* Check if the l-value bits are double-driven. */
if (sig->type() == NetNet::UNRESOLVED_WIRE && sig->test_and_set_part_driver(midx,lidx, widx_flag? widx : 0)) {
cerr << get_fileline() << ": error: Unresolved net/uwire "
<< sig->name() << " cannot have multiple drivers." << endl;
if (debug_elaborate) {
cerr << get_fileline() << ": : Overlap in "
<< "[" << midx << ":" << lidx << "] (canonical)"
<< ", widx=" << (widx_flag? widx : 0)
<< ", vector width=" << sig->vector_width()
<< endl;
}
des->errors += 1;
return 0;
}
if (sig->pin_count() > 1 && widx_flag) {
if (widx < 0 || widx >= (long) sig->pin_count())
return 0;
netvector_t*tmp2_vec = new netvector_t(sig->data_type(),
sig->vector_width()-1,0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
sig->type(), sig->vector_width());
sig->type(), tmp2_vec);
tmp->set_line(*this);
tmp->local_flag(true);
tmp->data_type( sig->data_type() );
connect(sig->pin(widx), tmp->pin(0));
sig = tmp;
} else if (sig->pin_count() > 1) {
// If this turns out to be an l-value unpacked array,
// then let the caller handle it. It will probably be
// converted into an array of assignments.
return sig;
}
/* If the desired l-value vector is narrower than the
@@ -589,10 +800,11 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
<< " wid=" << subnet_wid <<"]"
<< endl;
netvector_t*tmp2_vec = new netvector_t(sig->data_type(),
subnet_wid-1,0);
NetNet*subsig = new NetNet(sig->scope(),
sig->scope()->local_symbol(),
NetNet::WIRE, subnet_wid);
subsig->data_type( sig->data_type() );
NetNet::WIRE, tmp2_vec);
subsig->local_flag(true);
subsig->set_line(*this);
@@ -642,9 +854,9 @@ NetNet* PEIdent::elaborate_bi_net(Design*des, NetScope*scope) const
* instantiation (PGModule::elaborate_mod_) to get NetNet objects for
* the port.
*/
NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
NetNet* PEIdent::elaborate_subport(Design*des, NetScope*scope) const
{
assert(scope->type() == NetScope::MODULE);
ivl_assert(*this, scope->type() == NetScope::MODULE);
NetNet*sig = des->find_signal(scope, path_);
if (sig == 0) {
cerr << get_fileline() << ": error: no wire/reg " << path_
@@ -659,6 +871,7 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
case NetNet::PINPUT:
case NetNet::POUTPUT:
case NetNet::PINOUT:
case NetNet::PREF:
break;
/* If the name matches, but the signal is not a port,
@@ -688,6 +901,33 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
long midx;
long lidx;
if (debug_elaborate) {
cerr << get_fileline() << ": PEIdent::elaborate_subport: "
<< "path_ = \"" << path_
<< "\", unpacked_dimensions=" << sig->unpacked_dimensions()
<< ", port_type()=" << sig->port_type() << endl;
}
if (sig->unpacked_dimensions() && !gn_system_verilog()) {
cerr << get_fileline() << ": error: "
<< "Ports cannot be unpacked arrays. Try enabling SystemVerilog support." << endl;
des->errors += 1;
return 0;
}
// There cannot be parts to an unpacked array, so process this
// simply as an unpacked array.
if (sig->unpacked_dimensions()) {
if (debug_elaborate) {
cerr << get_fileline() << ": PEIdent::elaborate_subport: "
<< "path_=\"" << path_
<< "\" is an unpacked array with " << sig->pin_count()
<< " elements." << endl;
}
scope->add_module_port_net(sig);
return sig;
}
/* Evaluate the part/bit select expressions, to get the part
select of the signal that attaches to the port. Also handle
range and direction checking here. */
@@ -698,17 +938,17 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
/* If this is a part select of the entire signal (or no part
select at all) then we're done. */
if ((lidx == 0) && (midx == (long)sig->vector_width()-1)) {
scope->add_module_port(sig);
scope->add_module_port_net(sig);
return sig;
}
unsigned swid = abs(midx - lidx) + 1;
ivl_assert(*this, swid > 0 && swid < sig->vector_width());
netvector_t*tmp2_vec = new netvector_t(sig->data_type(),swid-1,0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, swid);
NetNet::WIRE, tmp2_vec);
tmp->port_type(sig->port_type());
tmp->data_type(sig->data_type());
tmp->set_line(*this);
tmp->local_flag(true);
NetNode*ps = 0;
@@ -726,6 +966,9 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
sig = tmp;
break;
case NetNet::PREF:
// For the purposes of module ports, treat ref ports
// just like inout ports.
case NetNet::PINOUT:
ps = new NetTran(scope, scope->local_symbol(), sig->vector_width(),
swid, lidx);
@@ -742,7 +985,21 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
ps->set_line(*this);
des->add_node(ps);
scope->add_module_port(sig);
scope->add_module_port_net(sig);
return sig;
}
NetNet*PEIdent::elaborate_unpacked_net(Design*des, NetScope*scope) const
{
NetNet* sig = 0;
const NetExpr*par = 0;
NetEvent* eve = 0;
perm_string method_name;
symbol_search(this, des, scope, path_, sig, par, eve);
ivl_assert(*this, sig);
return sig;
}
+577 -91
View File
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2000-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com)
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -33,16 +34,21 @@
*/
# include "Module.h"
# include "PEvent.h"
# include "PClass.h"
# include "PExpr.h"
# include "PEvent.h"
# include "PClass.h"
# include "PGate.h"
# include "PGenerate.h"
# include "PPackage.h"
# include "PTask.h"
# include "PWire.h"
# include "Statement.h"
# include "AStatement.h"
# include "netlist.h"
# include "netclass.h"
# include "netenum.h"
# include "parse_api.h"
# include "util.h"
# include <typeinfo>
# include <cassert>
@@ -51,7 +57,9 @@
typedef map<perm_string,LexicalScope::param_expr_t>::const_iterator mparm_it_t;
static void collect_parm_item_(Design*des, NetScope*scope, perm_string name,
const LexicalScope::param_expr_t&cur)
const LexicalScope::param_expr_t&cur,
bool is_annotatable,
bool local_flag)
{
NetScope::range_t*range_list = 0;
for (LexicalScope::range_t*range = cur.range ; range ; range = range->next) {
@@ -87,8 +95,9 @@ static void collect_parm_item_(Design*des, NetScope*scope, perm_string name,
range_list = tmp;
}
scope->set_parameter(name, cur.expr, cur.type, cur.msb, cur.lsb,
cur.signed_flag, range_list, cur);
scope->set_parameter(name, is_annotatable, cur.expr, cur.type, cur.msb,
cur.lsb, cur.signed_flag, local_flag, range_list, cur);
}
static void collect_scope_parameters_(Design*des, NetScope*scope,
@@ -106,7 +115,7 @@ static void collect_scope_parameters_(Design*des, NetScope*scope,
des->errors += 1;
}
collect_parm_item_(des, scope, (*cur).first, (*cur).second);
collect_parm_item_(des, scope, (*cur).first, (*cur).second, false, false);
}
}
@@ -125,17 +134,41 @@ static void collect_scope_localparams_(Design*des, NetScope*scope,
des->errors += 1;
}
collect_parm_item_(des, scope, (*cur).first, (*cur).second);
collect_parm_item_(des, scope, (*cur).first, (*cur).second, false, true);
}
}
static void collect_scope_specparams_(Design*des, NetScope*scope,
const map<perm_string,LexicalScope::param_expr_t>&specparams)
{
for (mparm_it_t cur = specparams.begin()
; cur != specparams.end() ; ++ cur ) {
// A specparam can not have the same name as a genvar.
if (scope->find_genvar((*cur).first)) {
cerr << cur->second.get_fileline()
<< ": error: specparam and genvar in '"
<< scope->fullname() << "' have the same name '"
<< (*cur).first << "'." << endl;
des->errors += 1;
}
collect_parm_item_(des, scope, (*cur).first, (*cur).second, true, false);
}
}
/*
* Elaborate the enumeration into the given scope. If scope==0, then
* the enumeration goes into $root instead of a scope.
*/
static void elaborate_scope_enumeration(Design*des, NetScope*scope,
enum_type_t*enum_type)
{
bool rc_flag;
assert(enum_type->range->size() == 2);
NetExpr*msb_ex = elab_and_eval(des, scope, enum_type->range->front(), -1);
NetExpr*lsb_ex = elab_and_eval(des, scope, enum_type->range->back(), -1);
assert(enum_type->range->size() == 1);
pform_range_t&range = enum_type->range->front();
NetExpr*msb_ex = elab_and_eval(des, scope, range.first, -1);
NetExpr*lsb_ex = elab_and_eval(des, scope, range.second, -1);
long msb = 0;
rc_flag = eval_as_long(msb, msb_ex);
@@ -144,34 +177,44 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
rc_flag = eval_as_long(lsb, lsb_ex);
assert(rc_flag);
netenum_t*use_enum = new netenum_t(enum_type->base_type, enum_type->signed_flag,
msb, lsb, enum_type->names->size());
netenum_t*use_enum = new netenum_t(enum_type->base_type,
enum_type->signed_flag,
enum_type->integer_flag, msb, lsb,
enum_type->names->size(),
enum_type);
use_enum->set_line(enum_type->li);
scope->add_enumeration_set(use_enum);
if (scope)
scope->add_enumeration_set(enum_type, use_enum);
else
des->add_enumeration_set(enum_type, use_enum);
verinum cur_value (0);
verinum one_value (1);
size_t name_idx = 0;
// Find the minimum and maximum allowed enumeration values.
// Find the enumeration width.
long raw_width = use_enum->packed_width();
assert(raw_width > 0);
unsigned enum_width = (unsigned)raw_width;
// Define the default start value and the increment value to be the
// correct type for this enumeration.
verinum cur_value ((uint64_t)0, enum_width);
cur_value.has_sign(enum_type->signed_flag);
verinum one_value ((uint64_t)1, enum_width);
one_value.has_sign(enum_type->signed_flag);
// Find the maximum allowed enumeration value.
verinum min_value (0);
verinum max_value (0);
if (enum_type->signed_flag) {
min_value = v_not((pow(verinum(2),
verinum(use_enum->base_width()-1)))) +
one_value;
max_value = pow(verinum(2), verinum(use_enum->base_width()-1)) -
one_value;
min_value = -pow(verinum(2), verinum(enum_width-1));
max_value = pow(verinum(2), verinum(enum_width-1)) - one_value;
} else {
max_value = pow(verinum(2), verinum(use_enum->base_width())) -
one_value;
max_value = pow(verinum(2), verinum(enum_width)) - one_value;
}
min_value.has_sign(true);
max_value.has_sign(enum_type->signed_flag);
// Process the enumeration definition.
for (list<named_pexpr_t>::const_iterator cur = enum_type->names->begin()
; cur != enum_type->names->end() ; ++ cur, name_idx += 1) {
// Check to see if the enumeration name has a value given.
if (cur->parm) {
// There is an explicit value. elaborate/evaluate
// the value and assign it to the enumeration name.
@@ -179,37 +222,140 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
NetEConst*val_const = dynamic_cast<NetEConst*> (val);
if (val_const == 0) {
cerr << use_enum->get_fileline()
<< ": error: Enumeration expression is not "
"constant." << endl;
<< ": error: Enumeration expression for "
<< cur->name <<" is not an integer constant."
<< endl;
des->errors += 1;
continue;
}
cur_value = val_const->value();
// A 2-state value can not have a constant with X/Z bits.
if (enum_type->base_type==IVL_VT_BOOL &&
! cur_value.is_defined()) {
cerr << use_enum->get_fileline()
<< ": error: Enumeration name " << cur->name
<< " cannot have an undefined value." << endl;
<< " can not have an undefined value." << endl;
des->errors += 1;
continue;
}
// If this is a literal constant and it has a defined
// width then the width must match the enumeration width.
if (PENumber *tmp = dynamic_cast<PENumber*>(cur->parm)) {
if (tmp->value().has_len() &&
(tmp->value().len() != enum_width)) {
cerr << use_enum->get_fileline()
<< ": error: Enumeration name " << cur->name
<< " has an incorrectly sized constant."
<< endl;
des->errors += 1;
}
}
// If we are padding/truncating a negative value for an
// unsigned enumeration that is an error or if the new
// value does not have a defined width.
if (((cur_value.len() != enum_width) ||
! cur_value.has_len()) &&
! enum_type->signed_flag && cur_value.is_negative()) {
cerr << use_enum->get_fileline()
<< ": error: Enumeration name " << cur->name
<< " has a negative value." << endl;
des->errors += 1;
}
// Narrower values need to be padded to the width of the
// enumeration and defined to have the specified width.
if (cur_value.len() < enum_width) {
cur_value = pad_to_width(cur_value, enum_width);
}
// Some wider values can be truncated.
if (cur_value.len() > enum_width) {
unsigned check_width = enum_width - 1;
// Check that the upper bits match the MSB
for (unsigned idx = enum_width;
idx < cur_value.len();
idx += 1) {
if (cur_value[idx] != cur_value[check_width]) {
// If this is an unsigned enumeration
// then zero padding is okay.
if (! enum_type->signed_flag &&
(idx == enum_width) &&
(cur_value[idx] == verinum::V0)) {
check_width += 1;
continue;
}
if (cur_value.is_defined()) {
cerr << use_enum->get_fileline()
<< ": error: Enumeration name "
<< cur->name
<< " has a value that is too "
<< ((cur_value > max_value) ?
"large" : "small")
<< " " << cur_value << "."
<< endl;
} else {
cerr << use_enum->get_fileline()
<< ": error: Enumeration name "
<< cur->name
<< " has trimmed bits that do "
<< "not match the enumeration "
<< "MSB: " << cur_value << "."
<< endl;
}
des->errors += 1;
break;
}
}
// If this is an unsigned value then make sure
// The upper bits are not 1.
if (! cur_value.has_sign() &&
(cur_value[enum_width] == verinum::V1)) {
cerr << use_enum->get_fileline()
<< ": error: Enumeration name "
<< cur->name
<< " has a value that is too large: "
<< cur_value << "." << endl;
des->errors += 1;
break;
}
cur_value = verinum(cur_value, enum_width);
}
// At this point the value has the correct size and needs
// to have the correct sign attribute set.
cur_value.has_len(true);
cur_value.has_sign(enum_type->signed_flag);
} else if (! cur_value.is_defined()) {
cerr << use_enum->get_fileline()
<< ": error: Enumeration name " << cur->name
<< " cannot have an undefined inferred value." << endl;
<< " has an undefined inferred value." << endl;
des->errors += 1;
continue;
}
// Cast any undefined bits to zero so the comparisons below
// return just true (1) or false (0).
verinum two_state_value = cur_value;
two_state_value.cast_to_int2();
// The enumeration value must fit into the enumeration bits.
if ((cur_value > max_value) ||
(cur_value.has_sign() && (cur_value < min_value))) {
if (!cur_value.is_defined()) {
if (cur_value.len() > (unsigned long)use_enum->packed_width()) {
cerr << use_enum->get_fileline()
<< ": error: Enumeration name " << cur->name
<< " value=" << cur_value
<< " is too wide for enumeration base type." << endl;
des->errors += 1;
}
} else if ((two_state_value > max_value) ||
(cur_value.has_sign() && (two_state_value < min_value))) {
cerr << use_enum->get_fileline()
<< ": error: Enumeration name " << cur->name
<< " cannot have a value equal to " << cur_value
<< "." << endl;
<< " has an inferred value that overflowed." << endl;
des->errors += 1;
}
@@ -223,23 +369,12 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
des->errors += 1;
}
// The values are explicitly sized to the width of the
// base type of the enumeration.
verinum tmp_val (0);
if (cur_value.len() < use_enum->base_width()) {
// Pad the current value if it is narrower than the final
// width of the enum.
tmp_val = pad_to_width (cur_value, use_enum->base_width());
tmp_val.has_len(true);
} else {
// Truncate an oversized value. We report out of bound
// values above. This may create duplicates.
tmp_val = verinum(cur_value, use_enum->base_width());
}
tmp_val.has_sign(enum_type->signed_flag);
rc_flag = use_enum->insert_name(name_idx, cur->name, cur_value);
if (scope)
rc_flag &= scope->add_enumeration_name(use_enum, cur->name);
else
rc_flag &= des->add_enumeration_name(use_enum, cur->name);
rc_flag = use_enum->insert_name(name_idx, cur->name, tmp_val);
rc_flag &= scope->add_enumeration_name(use_enum, cur->name);
if (! rc_flag) {
cerr << use_enum->get_fileline()
<< ": error: Duplicate enumeration name "
@@ -249,17 +384,238 @@ static void elaborate_scope_enumeration(Design*des, NetScope*scope,
// In case the next name has an implicit value,
// increment the current value by one.
if (cur_value.is_defined())
if (cur_value.is_defined()) {
cur_value = cur_value + one_value;
}
}
use_enum->insert_name_close();
}
static void elaborate_scope_enumerations(Design*des, NetScope*scope,
const list<enum_type_t*>&enum_types)
const set<enum_type_t*>&enum_types)
{
for (list<enum_type_t*>::const_iterator cur = enum_types.begin()
for (set<enum_type_t*>::const_iterator cur = enum_types.begin()
; cur != enum_types.end() ; ++ cur) {
elaborate_scope_enumeration(des, scope, *cur);
enum_type_t*curp = *cur;
elaborate_scope_enumeration(des, scope, curp);
}
}
void elaborate_rootscope_enumerations(Design*des)
{
for (set<enum_type_t*>::const_iterator cur = pform_enum_sets.begin()
; cur != pform_enum_sets.end() ; ++ cur) {
enum_type_t*curp = *cur;
elaborate_scope_enumeration(des, 0, curp);
}
}
/*
* If the pclass includes an implicit and explicit constructor, then
* merge the implicit constructor into the explicit constructor as
* statements in the beginning.
*
* This is not necessary for proper functionality, it is an
* optimization, so we can easily give up if it doesn't seem like it
* will obviously work.
*/
static void blend_class_constructors(PClass*pclass)
{
perm_string new1 = perm_string::literal("new");
perm_string new2 = perm_string::literal("new@");
PFunction*use_new;
PFunction*use_new2;
// Locate the explicit constructor.
map<perm_string,PFunction*>::iterator iter_new = pclass->funcs.find(new1);
if (iter_new == pclass->funcs.end())
use_new = 0;
else
use_new = iter_new->second;
// Locate the implicit constructor.
map<perm_string,PFunction*>::iterator iter_new2 = pclass->funcs.find(new2);
if (iter_new2 == pclass->funcs.end())
use_new2 = 0;
else
use_new2 = iter_new2->second;
// If there are no constructors, then we are done.
if (use_new==0 && use_new2==0)
return;
// While we're here, look for a super.new() call. If we find
// it, strip it out of the constructor and set it aside for
// when we actually call the chained constructor.
PChainConstructor*chain_new = use_new? use_new->extract_chain_constructor() : 0;
// If we do not have an explicit constructor chain, but there
// is a parent class, then create an implicit chain.
if (chain_new==0 && pclass->type->base_type!=0) {
chain_new = new PChainConstructor(pclass->type->base_args);
chain_new->set_line(*pclass);
}
// If there are both an implicit and explicit constructor,
// then blend the implicit constructor into the explicit
// constructor. This eases the task for the elaborator later.
if (use_new && use_new2) {
// These constructors must be methods of the same class.
ivl_assert(*use_new, use_new->method_of() == use_new2->method_of());
Statement*def_new = use_new->get_statement();
Statement*def_new2 = use_new2->get_statement();
// It is possible, i.e. recovering from a parse error,
// for the statement from the constructor to be
// missing. In that case, create an empty one.
if (def_new==0) {
def_new = new PBlock(PBlock::BL_SEQ);
use_new->set_statement(def_new);
}
if (def_new2) use_new->push_statement_front(def_new2);
// Now the implicit initializations are all built into
// the constructor. Delete the "new@" constructor.
pclass->funcs.erase(iter_new2);
delete use_new2;
use_new2 = 0;
}
if (chain_new) {
if (use_new2) {
use_new2->push_statement_front(chain_new);
} else {
use_new->push_statement_front(chain_new);
}
chain_new = 0;
}
}
static void elaborate_scope_class(Design*des, NetScope*scope, PClass*pclass)
{
class_type_t*use_type = pclass->type;
if (debug_scopes) {
cerr << pclass->get_fileline() <<": elaborate_scope_class: "
<< "Elaborate scope class " << pclass->pscope_name() << endl;
}
class_type_t*base_class = dynamic_cast<class_type_t*> (use_type->base_type);
if (use_type->base_type && !base_class) {
cerr << pclass->get_fileline() << ": error: "
<< "Base type of " << use_type->name
<< " is not a class." << endl;
des->errors += 1;
}
netclass_t*use_base_class = 0;
if (base_class) {
ivl_assert(*pclass, scope);
use_base_class = scope->find_class(base_class->name);
if (use_base_class == 0) {
cerr << pclass->get_fileline() << ": error: "
<< "Base class " << base_class->name
<< " not found." << endl;
des->errors += 1;
}
}
netclass_t*use_class = new netclass_t(use_type->name, use_base_class);
ivl_assert(*pclass, use_type->save_elaborated_type == 0);
use_type->save_elaborated_type = use_class;
// Class scopes have no parent scope, because references are
// not allowed to escape a class method.
NetScope*class_scope = new NetScope(0, hname_t(pclass->pscope_name()),
NetScope::CLASS);
class_scope->set_line(pclass);
class_scope->set_class_def(use_class);
use_class->set_class_scope(class_scope);
use_class->set_definition_scope(scope);
// Collect the properties, elaborate them, and add them to the
// elaborated class definition.
for (map<perm_string, class_type_t::prop_info_t>::iterator cur = use_type->properties.begin()
; cur != use_type->properties.end() ; ++ cur) {
ivl_type_s*tmp = cur->second.type->elaborate_type(des, scope);
ivl_assert(*pclass, tmp);
if (debug_scopes) {
cerr << pclass->get_fileline() << ": elaborate_scope_class: "
<< " Property " << cur->first
<< " type=" << *tmp << endl;
}
use_class->set_property(cur->first, cur->second.qual, tmp);
}
for (map<perm_string,PTask*>::iterator cur = pclass->tasks.begin()
; cur != pclass->tasks.end() ; ++cur) {
hname_t use_name (cur->first);
NetScope*method_scope = new NetScope(class_scope, use_name, NetScope::TASK);
// Task methods are always automatic...
method_scope->is_auto(true);
method_scope->set_line(cur->second);
if (debug_scopes) {
cerr << cur->second->get_fileline() << ": elaborate_scope_class: "
<< "Elaborate method (task) scope "
<< scope_path(method_scope) << endl;
}
cur->second->elaborate_scope(des, method_scope);
}
for (map<perm_string,PFunction*>::iterator cur = pclass->funcs.begin()
; cur != pclass->funcs.end() ; ++cur) {
hname_t use_name (cur->first);
NetScope*method_scope = new NetScope(class_scope, use_name, NetScope::FUNC);
// Function methods are always automatic...
method_scope->is_auto(true);
method_scope->set_line(cur->second);
if (debug_scopes) {
cerr << cur->second->get_fileline() << ": elaborate_scope_class: "
<< "Elaborate method (function) scope "
<< scope_path(method_scope) << endl;
}
cur->second->elaborate_scope(des, method_scope);
}
if (scope) {
scope->add_class(use_class);
} else {
des->add_class(use_class, pclass);
}
}
static void elaborate_scope_classes(Design*des, NetScope*scope,
const vector<PClass*>&classes)
{
for (size_t idx = 0 ; idx < classes.size() ; idx += 1) {
blend_class_constructors(classes[idx]);
elaborate_scope_class(des, scope, classes[idx]);
}
}
void elaborate_rootscope_classes(Design*des)
{
if (pform_classes.empty())
return;
for (map<perm_string,PClass*>::iterator cur = pform_classes.begin()
; cur != pform_classes.end() ; ++ cur) {
blend_class_constructors(cur->second);
elaborate_scope_class(des, 0, cur->second);
}
}
@@ -304,6 +660,25 @@ static void elaborate_scope_events_(Design*des, NetScope*scope,
}
}
static void elaborate_scope_task(Design*des, NetScope*scope, PTask*task)
{
hname_t use_name( task->pscope_name() );
NetScope*task_scope = new NetScope(scope, use_name, NetScope::TASK);
task_scope->is_auto(task->is_auto());
task_scope->set_line(task);
if (scope==0)
des->add_root_task(task_scope, task);
if (debug_scopes) {
cerr << task->get_fileline() << ": elaborate_scope_task: "
<< "Elaborate task scope " << scope_path(task_scope) << endl;
}
task->elaborate_scope(des, task_scope);
}
static void elaborate_scope_tasks(Design*des, NetScope*scope,
const map<perm_string,PTask*>&tasks)
{
@@ -345,19 +720,30 @@ static void elaborate_scope_tasks(Design*des, NetScope*scope,
des->errors += 1;
}
NetScope*task_scope = new NetScope(scope, use_name,
NetScope::TASK);
task_scope->is_auto((*cur).second->is_auto());
task_scope->set_line((*cur).second);
if (debug_scopes)
cerr << cur->second->get_fileline() << ": debug: "
<< "Elaborate task scope " << scope_path(task_scope) << endl;
(*cur).second->elaborate_scope(des, task_scope);
elaborate_scope_task(des, scope, cur->second);
}
}
static void elaborate_scope_func(Design*des, NetScope*scope, PFunction*task)
{
hname_t use_name( task->pscope_name() );
NetScope*task_scope = new NetScope(scope, use_name, NetScope::FUNC);
task_scope->is_auto(task->is_auto());
task_scope->set_line(task);
if (scope==0)
des->add_root_task(task_scope, task);
if (debug_scopes) {
cerr << task->get_fileline() << ": elaborate_scope_func: "
<< "Elaborate task scope " << scope_path(task_scope) << endl;
}
task->elaborate_scope(des, task_scope);
}
static void elaborate_scope_funcs(Design*des, NetScope*scope,
const map<perm_string,PFunction*>&funcs)
{
@@ -400,19 +786,33 @@ static void elaborate_scope_funcs(Design*des, NetScope*scope,
des->errors += 1;
}
NetScope*func_scope = new NetScope(scope, use_name,
NetScope::FUNC);
func_scope->is_auto((*cur).second->is_auto());
func_scope->set_line((*cur).second);
if (debug_scopes)
cerr << cur->second->get_fileline() << ": debug: "
<< "Elaborate function scope " << scope_path(func_scope) << endl;
(*cur).second->elaborate_scope(des, func_scope);
elaborate_scope_func(des, scope, cur->second);
}
}
void elaborate_rootscope_tasks(Design*des)
{
for (map<perm_string,PTaskFunc*>::iterator cur = pform_tasks.begin()
; cur != pform_tasks.end() ; ++ cur) {
if (PTask*task = dynamic_cast<PTask*> (cur->second)) {
elaborate_scope_task(des, 0, task);
continue;
}
if (PFunction*func = dynamic_cast<PFunction*>(cur->second)) {
elaborate_scope_func(des, 0, func);
continue;
}
cerr << cur->second->get_fileline() << ": internal error: "
<< "elabortae_rootscope_tasks does not understand "
<< "this object," << endl;
des->errors += 1;
}
}
class generate_schemes_work_item_t : public elaborator_work_item_t {
public:
generate_schemes_work_item_t(Design*des__, NetScope*scope, Module*mod)
@@ -445,12 +845,28 @@ class generate_schemes_work_item_t : public elaborator_work_item_t {
Module*mod_;
};
bool PPackage::elaborate_scope(Design*des, NetScope*scope)
{
if (debug_scopes) {
cerr << get_fileline() << ": PPackage::elaborate_scope: "
<< "Elaborate package " << scope_path(scope) << "." << endl;
}
collect_scope_parameters_(des, scope, parameters);
collect_scope_localparams_(des, scope, localparams);
elaborate_scope_enumerations(des, scope, enum_sets);
elaborate_scope_classes(des, scope, classes_lexical);
elaborate_scope_funcs(des, scope, funcs);
elaborate_scope_tasks(des, scope, tasks);
return true;
}
bool Module::elaborate_scope(Design*des, NetScope*scope,
const replace_t&replacements)
{
if (debug_scopes) {
cerr << get_fileline() << ": debug: Elaborate scope "
<< scope_path(scope) << "." << endl;
cerr << get_fileline() << ": Module::elaborate_scope: "
<< "Elaborate " << scope_path(scope) << "." << endl;
}
// Add the genvars to the scope.
@@ -468,6 +884,8 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
collect_scope_localparams_(des, scope, localparams);
collect_scope_specparams_(des, scope, specparams);
// Run parameter replacements that were collected from the
// containing scope and meant for me.
@@ -475,6 +893,9 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
elaborate_scope_enumerations(des, scope, enum_sets);
assert(classes.size() == classes_lexical.size());
elaborate_scope_classes(des, scope, classes_lexical);
// Run through the defparams for this module and save the result
// in a table for later final override.
@@ -495,7 +916,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
delete[]attr;
// Generate schemes need to have their scopes elaborated, but
// we cannot do that until defparams are run, so push it off
// we can not do that until defparams are run, so push it off
// into an elaborate work item.
if (debug_scopes)
cerr << get_fileline() << ": debug: "
@@ -518,6 +939,19 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
elaborate_scope_funcs(des, scope, funcs);
// Look for implicit modules and implicit gates for them.
for (map<perm_string,Module*>::iterator cur = nested_modules.begin()
; cur != nested_modules.end() ; ++cur) {
// Skip modules that must be explicitly instantiated.
if (cur->second->port_count() > 0)
continue;
PGModule*nested_gate = new PGModule(cur->second, cur->second->mod_name());
nested_gate->set_line(*cur->second);
gates_.push_back(nested_gate);
}
// Gates include modules, which might introduce new scopes, so
// scan all of them to create those scopes.
@@ -618,8 +1052,10 @@ bool PGenerate::generate_scope_loop_(Design*des, NetScope*container)
// Check the generate block name.
// A generate "loop" can not have the same name as another scope object.
const NetScope *child = container->child(hname_t(scope_name));
// A generate "loop" can not have the same name as another
// scope object. Find any scope with this name, not just an
// exact match scope.
const NetScope *child = container->child_byname(scope_name);
if (child) {
cerr << get_fileline() << ": error: generate \"loop\" and ";
child->print_type(cerr);
@@ -707,7 +1143,7 @@ bool PGenerate::generate_scope_loop_(Design*des, NetScope*container)
genvar_verinum);
// The file and line information should really come
// from the genvar statement, not the for loop.
scope->set_localparam(loop_index, gp, *this);
scope->set_parameter(loop_index, gp, *this);
if (debug_scopes)
cerr << get_fileline() << ": debug: "
<< "Create implicit localparam "
@@ -960,6 +1396,12 @@ bool PGenerate::generate_scope_case_(Design*des, NetScope*container)
return true;
}
if (debug_scopes) {
cerr << get_fileline() << ": PGenerate::generate_scope_case_: "
<< "Generate subscope " << use_name
<< " and elaborate." << endl;
}
NetScope*scope = new NetScope(container, use_name,
NetScope::GENBLOCK);
scope->set_line(get_file(), get_lineno());
@@ -1029,7 +1471,13 @@ void PGenerate::elaborate_subscope_direct_(Design*des, NetScope*scope)
typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generate_schemes.begin()
; cur != generate_schemes.end() ; ++ cur ) {
(*cur) -> generate_scope(des, scope);
PGenerate*curp = *cur;
if (debug_scopes) {
cerr << get_fileline() << ": elaborate_subscope_direct_: "
<< "Elaborate direct subscope " << curp->scope_name
<< " within scope " << scope_name << endl;
}
curp -> generate_scope(des, scope);
}
}
@@ -1041,6 +1489,21 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope)
scope->add_genvar((*cur).first, (*cur).second);
}
// Scan the localparams in this scope, and store the information
// needed to evaluate the parameter expressions. The expressions
// will be evaluated later, once all parameter overrides for this
// module have been done.
collect_scope_localparams_(des, scope, localparams);
// Run through the defparams for this scope and save the result
// in a table for later final override.
typedef list<PGenerate::named_expr_t>::const_iterator defparms_iter_t;
for (defparms_iter_t cur = defparms.begin()
; cur != defparms.end() ; ++ cur ) {
scope->defparams.push_back(make_pair(cur->first, cur->second));
}
// Scan the generated scope for nested generate schemes,
// and *generate* new scopes, which is slightly different
// from simple elaboration.
@@ -1051,12 +1514,6 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope)
(*cur) -> generate_scope(des, scope);
}
// Scan the localparams in this scope, and store the information
// needed to evaluate the parameter expressions. The expressions
// will be evaluated later, once all parameter overrides for this
// module have been done.
collect_scope_localparams_(des, scope, localparams);
// Scan through all the task and function declarations in this
// scope.
elaborate_scope_tasks(des, scope, tasks);
@@ -1081,7 +1538,7 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope)
if (debug_scopes)
cerr << get_fileline() << ": debug: Generated scope " << scope_path(scope)
<< " by generate block " << scope_name << endl;
<< " for generate block " << scope_name << endl;
// Save the scope that we created, for future use.
scope_list_.push_back(scope);
@@ -1201,7 +1658,7 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
continue;
}
cerr << get_fileline() << ": error: You cannot instantiate "
cerr << get_fileline() << ": error: You can not instantiate "
<< "module " << mod->mod_name() << " within itself." << endl;
cerr << get_fileline() << ": : The offending instance is "
<< get_name() << " within " << scope_path(scn) << "." << endl;
@@ -1294,8 +1751,12 @@ void PGModule::elaborate_scope_mod_instances_(Design*des, Module*mod, NetScope*s
<< "." << endl;
}
// Create the new scope as a MODULE with my name.
NetScope*my_scope = new NetScope(sc, use_name, NetScope::MODULE);
// Create the new scope as a MODULE with my name. Note
// that if this is a nested module, mark it thus so that
// scope searches will continue into the parent scope.
NetScope*my_scope = new NetScope(sc, use_name, NetScope::MODULE,
bound_type_? true : false,
mod->program_block);
my_scope->set_line(get_file(), mod->get_file(),
get_lineno(), mod->get_lineno());
my_scope->set_module_name(mod->mod_name());
@@ -1512,7 +1973,9 @@ void PBlock::elaborate_scope(Design*des, NetScope*scope) const
<< "Elaborate block scope " << use_name
<< " within " << scope_path(scope) << endl;
my_scope = new NetScope(scope, use_name, bl_type_==BL_PAR
// The scope type is begin-end or fork-join. The
// sub-types of fork-join are not interesting to the scope.
my_scope = new NetScope(scope, use_name, bl_type_!=BL_SEQ
? NetScope::FORK_JOIN
: NetScope::BEGIN_END);
my_scope->set_line(get_file(), get_lineno());
@@ -1574,6 +2037,17 @@ void PDelayStatement::elaborate_scope(Design*des, NetScope*scope) const
statement_ -> elaborate_scope(des, scope);
}
/*
* Statements that contain a further statement but do not
* intrinsically add a scope need to elaborate_scope the contained
* statement.
*/
void PDoWhile::elaborate_scope(Design*des, NetScope*scope) const
{
if (statement_)
statement_ -> elaborate_scope(des, scope);
}
/*
* Statements that contain a further statement but do not
* intrinsically add a scope need to elaborate_scope the contained
@@ -1585,6 +2059,18 @@ void PEventStatement::elaborate_scope(Design*des, NetScope*scope) const
statement_ -> elaborate_scope(des, scope);
}
/*
* The standard says that we create an implicit scope for foreach
* loops, but that is just to hold the index variables, and we'll
* handle them by creating unique names. So just jump into the
* contained statement for scope elaboration.
*/
void PForeach::elaborate_scope(Design*des, NetScope*scope) const
{
if (statement_)
statement_ -> elaborate_scope(des, scope);
}
/*
* Statements that contain a further statement but do not
* intrinsically add a scope need to elaborate_scope the contained
+549 -359
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
+246
View File
@@ -0,0 +1,246 @@
/*
* Copyright (c) 2012-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "pform_types.h"
# include "netlist.h"
# include "netclass.h"
# include "netdarray.h"
# include "netenum.h"
# include "netparray.h"
# include "netscalar.h"
# include "netstruct.h"
# include "netvector.h"
# include "netmisc.h"
# include <typeinfo>
# include "ivl_assert.h"
using namespace std;
/*
* Elaborations of types may vary depending on the scope that it is
* done in, so keep a per-scope cache of the results.
*/
ivl_type_s* data_type_t::elaborate_type(Design*des, NetScope*scope)
{
Definitions*use_definitions = scope;
if (use_definitions == 0)
use_definitions = des;
map<Definitions*,ivl_type_s*>::iterator pos = cache_type_elaborate_.lower_bound(use_definitions);
if (pos->first == use_definitions)
return pos->second;
ivl_type_s*tmp = elaborate_type_raw(des, scope);
cache_type_elaborate_.insert(pos, pair<NetScope*,ivl_type_s*>(scope, tmp));
return tmp;
}
ivl_type_s* data_type_t::elaborate_type_raw(Design*des, NetScope*) const
{
cerr << get_fileline() << ": internal error: "
<< "Elaborate method not implemented for " << typeid(*this).name()
<< "." << endl;
des->errors += 1;
return 0;
}
ivl_type_s* atom2_type_t::elaborate_type_raw(Design*des, NetScope*) const
{
switch (type_code) {
case 64:
if (signed_flag)
return &netvector_t::atom2s64;
else
return &netvector_t::atom2u64;
case 32:
if (signed_flag)
return &netvector_t::atom2s32;
else
return &netvector_t::atom2u32;
case 16:
if (signed_flag)
return &netvector_t::atom2s16;
else
return &netvector_t::atom2u16;
case 8:
if (signed_flag)
return &netvector_t::atom2s8;
else
return &netvector_t::atom2u8;
default:
cerr << get_fileline() << ": internal error: "
<< "atom2_type_t type_code=" << type_code << "." << endl;
des->errors += 1;
return 0;
}
}
ivl_type_s* class_type_t::elaborate_type_raw(Design*, NetScope*) const
{
ivl_assert(*this, save_elaborated_type);
return save_elaborated_type;
}
/*
* elaborate_type_raw for enumerations is actually mostly performed
* during scope elaboration so that the enumeration literals are
* available at the right time. At that time, the netenum_t* object is
* stashed in the scope so that I can retrieve it here.
*/
ivl_type_s* enum_type_t::elaborate_type_raw(Design*des, NetScope*scope) const
{
ivl_assert(*this, scope);
ivl_type_s*tmp = scope->enumeration_for_key(this);
if (tmp) return tmp;
tmp = des->enumeration_for_key(this);
return tmp;
}
ivl_type_s* vector_type_t::elaborate_type_raw(Design*des, NetScope*scope) const
{
vector<netrange_t> packed;
if (pdims.get()) {
for (list<pform_range_t>::const_iterator cur = pdims->begin()
; cur != pdims->end() ; ++ cur) {
NetExpr*me = elab_and_eval(des, scope, cur->first, 0, true);
NetExpr*le = elab_and_eval(des, scope, cur->second, 0, true);
/* If elaboration failed for either expression, we
should have already reported the error, so just
skip the following evaluation to recover. */
long mnum = 0, lnum = 0;
if ( me && ! eval_as_long(mnum, me) ) {
assert(0);
des->errors += 1;
}
if ( le && ! eval_as_long(lnum, le) ) {
assert(0);
des->errors += 1;
}
packed.push_back(netrange_t(mnum, lnum));
}
}
netvector_t*tmp = new netvector_t(packed, base_type);
tmp->set_signed(signed_flag);
tmp->set_isint(integer_flag);
return tmp;
}
ivl_type_s* real_type_t::elaborate_type_raw(Design*, NetScope*) const
{
switch (type_code) {
case REAL:
return &netreal_t::type_real;
case SHORTREAL:
return &netreal_t::type_shortreal;
}
return 0;
}
ivl_type_s* string_type_t::elaborate_type_raw(Design*, NetScope*) const
{
return &netstring_t::type_string;
}
ivl_type_s* parray_type_t::elaborate_type_raw(Design*des, NetScope*) const
{
cerr << get_fileline() << " : sorry: "
<< "Packed arrays are not currently supported in this context."
<< endl;
des->errors += 1;
return 0;
}
netstruct_t* struct_type_t::elaborate_type_raw(Design*des, NetScope*scope) const
{
netstruct_t*res = new netstruct_t;
res->packed(packed_flag);
if (union_flag)
res->union_flag(true);
for (list<struct_member_t*>::iterator cur = members->begin()
; cur != members->end() ; ++ cur) {
// Elaborate the type of the member.
struct_member_t*curp = *cur;
ivl_type_t mem_vec = curp->type->elaborate_type(des, scope);
if (mem_vec == 0)
continue;
// There may be several names that are the same type:
// <data_type> name1, name2, ...;
// Process all the member, and give them a type.
for (list<decl_assignment_t*>::iterator name = curp->names->begin()
; name != curp->names->end() ; ++ name) {
decl_assignment_t*namep = *name;
netstruct_t::member_t memb;
memb.name = namep->name;
memb.net_type = mem_vec;
res->append_member(des, memb);
}
}
return res;
}
ivl_type_s* uarray_type_t::elaborate_type_raw(Design*des, NetScope*scope) const
{
ivl_type_t btype = base_type->elaborate_type(des, scope);
assert(dims->size() >= 1);
list<pform_range_t>::const_iterator cur = dims->begin();
// Special case: if the dimension is nil:nil, this is a
// dynamic array. Note that we only know how to handle dynamic
// arrays with 1 dimension at a time.
if (cur->first==0 && cur->second==0) {
assert(dims->size()==1);
ivl_type_s*res = new netdarray_t(btype);
return res;
}
vector<netrange_t> dimensions;
bool bad_range = evaluate_ranges(des, scope, dimensions, *dims);
if (bad_range) {
cerr << get_fileline() << " : warning: "
<< "Bad dimensions for type here." << endl;
}
ivl_assert(*this, btype);
ivl_type_s*res = new netuarray_t(dimensions, btype);
return res;
}
+1666 -284
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008,2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2012 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -55,7 +55,7 @@ bool AProcess::elaborate(Design*des, NetScope*scope) const
// Evaluate the attributes for this process, if there
// are any. These attributes are to be attached to the
// NetProcTop object.
struct attrib_list_t*attrib_list = 0;
struct attrib_list_t*attrib_list;
unsigned attrib_list_n = 0;
attrib_list = evaluate_attributes(attributes, attrib_list_n, des, scope);
+138 -13
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2013 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -26,7 +26,9 @@
* target.
*/
# include "target.h"
# include "netclass.h"
# include "netlist.h"
# include "compiler.h"
# include <typeinfo>
# include <cassert>
# include <cstring>
@@ -165,6 +167,11 @@ bool NetSignExtend::emit_node(struct target_t*tgt) const
return tgt->sign_extend(this);
}
bool NetSubstitute::emit_node(struct target_t*tgt) const
{
return tgt->substitute(this);
}
bool NetUReduce::emit_node(struct target_t*tgt) const
{
return tgt->ureduce(this);
@@ -259,6 +266,17 @@ bool NetDisable::emit_proc(struct target_t*tgt) const
return tgt->proc_disable(this);
}
bool NetDoWhile::emit_proc(struct target_t*tgt) const
{
tgt->proc_do_while(this);
return true;
}
void NetDoWhile::emit_proc_recurse(struct target_t*tgt) const
{
proc_->emit_proc(tgt);
}
bool NetForce::emit_proc(struct target_t*tgt) const
{
return tgt->proc_force(this);
@@ -270,6 +288,11 @@ bool NetForever::emit_proc(struct target_t*tgt) const
return true;
}
bool NetForLoop::emit_proc(struct target_t*tgt) const
{
return tgt->proc_block(as_block_);
}
bool NetFree::emit_proc(struct target_t*tgt) const
{
tgt->proc_free(this);
@@ -316,6 +339,11 @@ bool NetWhile::emit_proc(struct target_t*tgt) const
return true;
}
void NetWhile::emit_proc_recurse(struct target_t*tgt) const
{
proc_->emit_proc(tgt);
}
void NetBlock::emit_recurse(struct target_t*tgt) const
{
if (last_ == 0)
@@ -378,16 +406,32 @@ void NetRepeat::emit_recurse(struct target_t*tgt) const
statement_->emit_proc(tgt);
}
void netclass_t::emit_scope(struct target_t*tgt) const
{
class_scope_->emit_scope(tgt);
}
void NetScope::emit_scope(struct target_t*tgt) const
{
if (debug_emit) {
cerr << "NetScope::emit_scope: "
<< "Emit scope " << scope_path(this) << endl;
}
tgt->scope(this);
for (NetEvent*cur = events_ ; cur ; cur = cur->snext_)
tgt->event(cur);
for (list<netenum_t*>::const_iterator cur = enum_sets_.begin()
for (map<perm_string,netclass_t*>::const_iterator cur = classes_.begin()
; cur != classes_.end() ; ++cur) {
cur->second->emit_scope(tgt);
tgt->class_type(this, cur->second);
}
for (map<const enum_type_t*,netenum_t*>::const_iterator cur = enum_sets_.begin()
; cur != enum_sets_.end() ; ++cur)
tgt->enumeration(this, *cur);
tgt->enumeration(this, cur->second);
for (map<hname_t,NetScope*>::const_iterator cur = children_.begin()
; cur != children_.end() ; ++ cur )
@@ -416,11 +460,20 @@ bool NetScope::emit_defs(struct target_t*tgt) const
{
bool flag = true;
if (debug_emit) {
cerr << "NetScope::emit_defs: "
<< "Emit definitions for " << scope_path(this) << endl;
}
switch (type_) {
case PACKAGE:
case MODULE:
for (map<hname_t,NetScope*>::const_iterator cur = children_.begin()
; cur != children_.end() ; ++ cur )
flag &= cur->second->emit_defs(tgt);
for (map<perm_string,netclass_t*>::const_iterator cur = classes_.begin()
; cur != classes_.end() ; ++ cur)
flag &= cur->second->emit_defs(tgt);
break;
case FUNC:
@@ -439,9 +492,9 @@ bool NetScope::emit_defs(struct target_t*tgt) const
return flag;
}
void NetWhile::emit_proc_recurse(struct target_t*tgt) const
bool netclass_t::emit_defs(struct target_t*tgt) const
{
proc_->emit_proc(tgt);
return class_scope_->emit_defs(tgt);
}
int Design::emit(struct target_t*tgt) const
@@ -451,11 +504,31 @@ int Design::emit(struct target_t*tgt) const
if (tgt->start_design(this) == false)
return -2;
// enumerate the scopes
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
scope != root_scopes_.end(); ++ scope )
(*scope)->emit_scope(tgt);
for (map<NetScope*,PTaskFunc*>::const_iterator scope = root_tasks_.begin()
; scope != root_tasks_.end() ; ++ scope) {
scope->first->emit_scope(tgt);
scope->first->emit_defs(tgt);
}
// enumerate package scopes
for (map<perm_string,NetScope*>::const_iterator scope = packages_.begin()
; scope != packages_.end() ; ++ scope) {
scope->second->emit_scope(tgt);
}
for (map<perm_string,netclass_t*>::const_iterator cur = classes_.begin()
; cur != classes_.end() ; ++cur) {
const NetScope*use_scope = cur->second->class_scope();
cur->second->emit_scope(tgt);
tgt->class_type(use_scope, cur->second);
cur->second->emit_defs(tgt);
}
// enumerate root scopes
for (list<NetScope*>::const_iterator scope = root_scopes_.begin()
; scope != root_scopes_.end(); ++ scope ) {
(*scope)->emit_scope(tgt);
}
// emit nodes
bool nodes_rc = true;
@@ -475,8 +548,11 @@ int Design::emit(struct target_t*tgt) const
// emit task and function definitions
bool tasks_rc = true;
for (list<NetScope*>::const_iterator scope = root_scopes_.begin();
scope != root_scopes_.end(); ++ scope )
for (map<perm_string,NetScope*>::const_iterator scope = packages_.begin()
; scope != packages_.end() ; ++ scope )
tasks_rc &= scope->second->emit_defs(tgt);
for (list<NetScope*>::const_iterator scope = root_scopes_.begin()
; scope != root_scopes_.end(); ++ scope )
tasks_rc &= (*scope)->emit_defs(tgt);
@@ -487,6 +563,15 @@ int Design::emit(struct target_t*tgt) const
for (const NetAnalogTop*idx = aprocs_ ; idx ; idx = idx->next_)
proc_rc &= idx->emit(tgt);
if (nodes_rc == false)
tgt->errors += 1;
if (tasks_rc == false)
tgt->errors += 1;
if (proc_rc == false)
tgt->errors += 1;
if (branches_rc == false)
tgt->errors += 1;
rc = tgt->end_design(this);
if (nodes_rc == false)
@@ -494,7 +579,7 @@ int Design::emit(struct target_t*tgt) const
if (tasks_rc == false)
return -2;
if (proc_rc == false)
return -3;
return -3;
if (branches_rc == false)
return -4;
@@ -506,6 +591,11 @@ void NetEAccess::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_access_func(this);
}
void NetEArrayPattern::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_array_pattern(this);
}
void NetEBinary::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_binary(this);
@@ -546,11 +636,31 @@ void NetEEvent::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_event(this);
}
void NetELast::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_last(this);
}
void NetENetenum::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_netenum(this);
}
void NetENew::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_new(this);
}
void NetENull::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_null(this);
}
void NetEProperty::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_property(this);
}
void NetEScope::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_scope(this);
@@ -566,6 +676,21 @@ void NetESFunc::expr_scan(struct expr_scan_t*tgt) const
tgt->expr_sfunc(this);
}
void NetEShallowCopy::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_scopy(this);
}
void NetEShallowCopy::expr_scan_oper1(struct expr_scan_t*tgt) const
{
arg1_->expr_scan(tgt);
}
void NetEShallowCopy::expr_scan_oper2(struct expr_scan_t*tgt) const
{
arg2_->expr_scan(tgt);
}
void NetEUFunc::expr_scan(struct expr_scan_t*tgt) const
{
tgt->expr_ufunc(this);
+11 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-1999 Stephen Williams (steve@icarus.com)
* Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -44,6 +44,14 @@ verinum* PEBinary::eval_const(Design*des, NetScope*scope) const
verinum*res;
switch (op_) {
case 'p': {
if (l->is_defined() && r->is_defined()) {
res = new verinum(pow(*l, *r));
} else {
res = new verinum(verinum::Vx, l->len());
}
break;
}
case '+': {
if (l->is_defined() && r->is_defined()) {
res = new verinum(*l + *r);
@@ -261,7 +269,7 @@ verinum* PEUnary::eval_const(Design*des, NetScope*scope) const
for (unsigned idx = 0 ; idx < val->len() ; idx += 1)
tmp.set(idx, val->get(idx));
*val = v_not(tmp) + verinum(verinum::V1, 1);
*val = -tmp;
val->has_sign(true);
return val;
}
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
+929 -575
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
+1 -23
View File
@@ -14,11 +14,8 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: hello_vpi.c,v 1.5 2007/01/17 05:35:48 steve Exp $"
#endif
/*
* This file contains an example VPI module to demonstrate the tools
@@ -60,22 +57,3 @@ void (*vlog_startup_routines[])() = {
my_hello_register,
0
};
/*
* $Log: hello_vpi.c,v $
* Revision 1.5 2007/01/17 05:35:48 steve
* Fix typo is hello_vpi.c example.
*
* Revision 1.4 2006/10/30 22:46:25 steve
* Updates for Cygwin portability (pr1585922)
*
* Revision 1.3 2002/08/12 01:35:01 steve
* conditional ident string using autoconfig.
*
* Revision 1.2 2002/08/11 23:47:04 steve
* Add missing Log and Ident strings.
*
* Revision 1.1 2002/04/18 03:25:16 steve
* More examples.
*
*/
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $Id: sqrt-virtex.v,v 1.5 2007/03/22 16:08:18 steve Exp $"
*/
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $Id: sqrt.vl,v 1.5 2007/03/22 16:08:18 steve Exp $"
*/
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
+1 -1
View File
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// This example describes a 16x1 RAM that can be synthesized into
+112 -80
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2013 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -24,6 +24,7 @@
# include <iostream>
# include "netlist.h"
# include "netvector.h"
# include "netmisc.h"
# include "ivl_assert.h"
@@ -118,11 +119,11 @@ NetNet* NetEBAdd::synthesize(Design*des, NetScope*scope, NetExpr*root)
}
perm_string path = lsig->scope()->local_symbol();
NetNet*osig = new NetNet(lsig->scope(), path, NetNet::IMPLICIT, width);
netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
osig_vec->set_signed(has_sign());
NetNet*osig = new NetNet(lsig->scope(), path, NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->local_flag(true);
osig->data_type(expr_type());
osig->set_signed(has_sign());
perm_string oname = osig->scope()->local_symbol();
NetAddSub *adder = new NetAddSub(lsig->scope(), oname, width);
@@ -173,11 +174,11 @@ NetNet* NetEBBits::synthesize(Design*des, NetScope*scope, NetExpr*root)
rsig = pad_to_width(des, rsig, width, *this);
assert(lsig->vector_width() == rsig->vector_width());
netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, width);
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->local_flag(true);
osig->data_type(expr_type());
perm_string oname = scope->local_symbol();
NetLogic*gate;
@@ -243,11 +244,11 @@ NetNet* NetEBComp::synthesize(Design*des, NetScope*scope, NetExpr*root)
rsig = pad_to_width(des, rsig, width, *this);
}
netvector_t*osig_vec = new netvector_t(IVL_VT_LOGIC);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, 1);
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->local_flag(true);
osig->data_type(IVL_VT_LOGIC);
// Test if the comparison is signed.
//
@@ -273,7 +274,7 @@ NetNet* NetEBComp::synthesize(Design*des, NetScope*scope, NetExpr*root)
if (op_ == 'E' || op_ == 'N') {
NetCaseCmp*gate = new NetCaseCmp(scope, scope->local_symbol(),
width, op_=='E'?true:false);
width, op_=='E'?NetCaseCmp::EEQ:NetCaseCmp::NEQ);
gate->set_line(*this);
connect(gate->pin(0), osig->pin(0));
connect(gate->pin(1), lsig->pin(0));
@@ -390,11 +391,11 @@ NetNet* NetEBPow::synthesize(Design*des, NetScope*scope, NetExpr*root)
connect(powr->pin_DataA(), lsig->pin(0));
connect(powr->pin_DataB(), rsig->pin(0));
netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
osig_vec->set_signed(has_sign());
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, width);
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->data_type(expr_type());
osig->set_signed(has_sign());
osig->local_flag(true);
connect(powr->pin_Result(), osig->pin(0));
@@ -427,11 +428,11 @@ NetNet* NetEBMult::synthesize(Design*des, NetScope*scope, NetExpr*root)
connect(mult->pin_DataA(), lsig->pin(0));
connect(mult->pin_DataB(), rsig->pin(0));
netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
osig_vec->set_signed(has_sign());
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, width);
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->data_type(expr_type());
osig->set_signed(has_sign());
osig->local_flag(true);
connect(mult->pin_Result(), osig->pin(0));
@@ -452,11 +453,11 @@ NetNet* NetEBDiv::synthesize(Design*des, NetScope*scope, NetExpr*root)
if (real_args) width = 1;
else width = expr_width();
netvector_t*osig_vec = new netvector_t(lsig->data_type(), width-1, 0);
osig_vec->set_signed(has_sign());
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, width);
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->data_type(lsig->data_type());
osig->set_signed(has_sign());
osig->local_flag(true);
switch (op()) {
@@ -530,10 +531,10 @@ NetNet* NetEBLogic::synthesize(Design*des, NetScope*scope, NetExpr*root)
return 0;
}
netvector_t*osig_tmp = new netvector_t(expr_type());
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, 1);
NetNet::IMPLICIT, osig_tmp);
osig->set_line(*this);
osig->data_type(expr_type());
osig->local_flag(true);
NetLogic*olog;
@@ -597,10 +598,10 @@ NetNet* NetEBShift::synthesize(Design*des, NetScope*scope, NetExpr*root)
if (shift == 0)
return lsig;
netvector_t*osig_vec = new netvector_t(expr_type(), expr_width()-1,0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, expr_width());
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->data_type(expr_type());
osig->local_flag(true);
// ushift is the amount of pad created by the shift.
@@ -614,14 +615,15 @@ NetNet* NetEBShift::synthesize(Design*des, NetScope*scope, NetExpr*root)
// to the amount left by the shift.
NetPartSelect*psel = new NetPartSelect(lsig, shift<0? ushift : 0,
part_width,
NetPartSelect::VP);
NetPartSelect::VP,
signed_flag && right_flag);
psel->set_line(*this);
des->add_node(psel);
netvector_t*psig_vec = new netvector_t(expr_type(), part_width-1, 0);
NetNet*psig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, part_width);
NetNet::IMPLICIT, psig_vec);
psig->set_line(*this);
psig->data_type(expr_type());
psig->local_flag(true);
connect(psig->pin(0), psel->pin(0));
@@ -646,10 +648,11 @@ NetNet* NetEBShift::synthesize(Design*des, NetScope*scope, NetExpr*root)
znum);
des->add_node(zcon);
netvector_t*zsig_vec = new netvector_t(osig->data_type(),
znum.len()-1, 0);
NetNet*zsig = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, znum.len());
NetNet::WIRE, zsig_vec);
zsig->set_line(*this);
zsig->data_type(osig->data_type());
zsig->local_flag(true);
connect(zcon->pin(0), zsig->pin(0));
@@ -676,10 +679,10 @@ NetNet* NetEBShift::synthesize(Design*des, NetScope*scope, NetExpr*root)
if (rsig == 0) return 0;
netvector_t*osig_vec = new netvector_t(expr_type(), expr_width()-1, 0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, expr_width());
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->data_type(expr_type());
osig->local_flag(true);
NetCLShift*dev = new NetCLShift(scope, scope->local_symbol(),
@@ -702,11 +705,11 @@ NetNet* NetEBShift::synthesize(Design*des, NetScope*scope, NetExpr*root)
NetNet* NetEConcat::synthesize(Design*des, NetScope*scope, NetExpr*root)
{
/* First, synthesize the operands. */
unsigned num_parms = parms_.count();
NetNet**tmp = new NetNet*[parms_.count()];
unsigned num_parms = parms_.size();
NetNet**tmp = new NetNet*[parms_.size()];
bool flag = true;
ivl_variable_type_t data_type = IVL_VT_NO_TYPE;
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) {
for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) {
if (parms_[idx]->expr_width() == 0) {
/* We need to synthesize a replication of zero. */
tmp[idx] = parms_[idx]->synthesize(des, scope, root);
@@ -739,10 +742,10 @@ NetNet* NetEConcat::synthesize(Design*des, NetScope*scope, NetExpr*root)
/* Make a NetNet object to carry the output vector. */
perm_string path = scope->local_symbol();
NetNet*osig = new NetNet(scope, path, NetNet::IMPLICIT, expr_width());
netvector_t*osig_vec = new netvector_t(data_type, expr_width()-1, 0);
NetNet*osig = new NetNet(scope, path, NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->local_flag(true);
osig->data_type(data_type);
NetConcat*concat = new NetConcat(scope, scope->local_symbol(),
osig->vector_width(),
@@ -754,8 +757,8 @@ NetNet* NetEConcat::synthesize(Design*des, NetScope*scope, NetExpr*root)
unsigned count_input_width = 0;
unsigned cur_pin = 1;
for (unsigned rpt = 0; rpt < repeat(); rpt += 1) {
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) {
unsigned concat_item = parms_.count()-idx-1;
for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) {
unsigned concat_item = parms_.size()-idx-1;
if (tmp[concat_item] == 0) continue;
connect(concat->pin(cur_pin), tmp[concat_item]->pin(0));
cur_pin += 1;
@@ -785,11 +788,11 @@ NetNet* NetEConst::synthesize(Design*des, NetScope*scope, NetExpr*)
return 0;
}
NetNet*osig = new NetNet(scope, path, NetNet::IMPLICIT, width);
netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
osig_vec->set_signed(has_sign());
NetNet*osig = new NetNet(scope, path, NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->local_flag(true);
osig->data_type(expr_type());
osig->set_signed(has_sign());
NetConst*con = new NetConst(scope, scope->local_symbol(), value());
con->set_line(*this);
@@ -806,11 +809,11 @@ NetNet* NetECReal::synthesize(Design*des, NetScope*scope, NetExpr*)
{
perm_string path = scope->local_symbol();
NetNet*osig = new NetNet(scope, path, NetNet::WIRE, 1);
netvector_t*osig_vec = new netvector_t(IVL_VT_REAL);
osig_vec->set_signed(has_sign());
NetNet*osig = new NetNet(scope, path, NetNet::WIRE, osig_vec);
osig->set_line(*this);
osig->local_flag(true);
osig->data_type(IVL_VT_REAL);
osig->set_signed(has_sign());
NetLiteral*con = new NetLiteral(scope, scope->local_symbol(), value_);
con->set_line(*this);
@@ -839,10 +842,10 @@ NetNet* NetEUBits::synthesize(Design*des, NetScope*scope, NetExpr*root)
}
unsigned width = isig->vector_width();
netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, width);
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->data_type(expr_type());
osig->local_flag(true);
perm_string oname = scope->local_symbol();
@@ -882,11 +885,12 @@ NetNet* NetEUnary::synthesize(Design*des, NetScope*scope, NetExpr*root)
if (expr_->has_sign() == false)
return sub;
netvector_t*sig_vec = new netvector_t(sub->data_type(),
sub->vector_width()-1, 0);
NetNet*sig = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, sub->vector_width());
NetNet::WIRE, sig_vec);
sig->set_line(*this);
sig->local_flag(true);
sig->data_type(sub->data_type());
NetAbs*tmp = new NetAbs(scope, scope->local_symbol(), sub->vector_width());
tmp->set_line(*this);
@@ -956,10 +960,10 @@ NetNet* NetEUReduce::synthesize(Design*des, NetScope*scope, NetExpr*root)
gate->set_line(*this);
des->add_node(gate);
netvector_t*osig_vec = new netvector_t(expr_type());
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, 1);
NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->data_type(expr_type());
osig->local_flag(true);
connect(gate->pin(0), osig->pin(0));
@@ -977,7 +981,10 @@ NetNet* NetECast::synthesize(Design*des, NetScope*scope, NetExpr*root)
switch (op()) {
case 'v':
isig = cast_to_int4(des, scope, isig, isig->vector_width());
isig = cast_to_int4(des, scope, isig, expr_width());
break;
case '2':
isig = cast_to_int2(des, scope, isig, expr_width());
break;
case 'r':
isig = cast_to_real(des, scope, isig);
@@ -1006,8 +1013,6 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root)
if (sub == 0) return 0;
NetNet*off = 0;
// Detect the special case that there is a base expression and
// it is constant. In this case we can generate fixed part selects.
if (NetEConst*base_const = dynamic_cast<NetEConst*>(base_)) {
@@ -1064,10 +1069,12 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root)
NetPartSelect::VP);
des->add_node(sel);
ivl_assert(*this, select_width > 0);
netvector_t*tmp_vec = new netvector_t(sub->data_type(),
select_width-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, select_width);
NetNet::WIRE, tmp_vec);
tmp->set_line(*this);
tmp->data_type(sub->data_type());
tmp->local_flag(true);
connect(sel->pin(0), tmp->pin(0));
@@ -1091,10 +1098,10 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root)
connect(cat->pin(concat_count), above->pin(0));
}
tmp_vec = new netvector_t(sub->data_type(), expr_width()-1, 0);
tmp = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, expr_width());
NetNet::WIRE, tmp_vec);
tmp->set_line(*this);
tmp->data_type(sub->data_type());
tmp->local_flag(true);
connect(cat->pin(0), tmp->pin(0));
}
@@ -1105,16 +1112,17 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root)
// actual part/bit select. Generate a NetPartSelect object to
// do the work, and replace "sub" with the selected output.
if (base_ != 0) {
off = base_->synthesize(des, scope, root);
NetNet*off = base_->synthesize(des, scope, root);
NetPartSelect*sel = new NetPartSelect(sub, off, expr_width(),
base_->has_sign());
sel->set_line(*this);
des->add_node(sel);
netvector_t*tmp_vec = new netvector_t(sub->data_type(),
expr_width()-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, expr_width());
tmp->data_type(sub->data_type());
NetNet::IMPLICIT, tmp_vec);
tmp->local_flag(true);
tmp->set_line(*this);
sub = tmp;
@@ -1135,10 +1143,11 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root)
// extension or 0 extension, depending on the has_sign() mode
// of the expression.
netvector_t*net_vec = new netvector_t(expr_type(), expr_width()-1, 0);
net_vec->set_signed(has_sign());
NetNet*net = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, expr_width());
NetNet::IMPLICIT, net_vec);
net->set_line(*this);
net->data_type(expr_type());
net->local_flag(true);
if (has_sign()) {
NetSignExtend*pad = new NetSignExtend(scope,
@@ -1149,7 +1158,6 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root)
connect(pad->pin(1), sub->pin(0));
connect(pad->pin(0), net->pin(0));
net->set_signed(true);
} else {
@@ -1166,10 +1174,10 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root)
con->set_line(*this);
des->add_node(con);
netvector_t*tmp_vec = new netvector_t(expr_type(), pad_width-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, pad_width);
NetNet::IMPLICIT, tmp_vec);
tmp->set_line(*this);
tmp->data_type(expr_type());
tmp->local_flag(true);
connect(tmp->pin(0), con->pin(0));
@@ -1221,9 +1229,9 @@ NetNet* NetETernary::synthesize(Design *des, NetScope*scope, NetExpr*root)
ivl_assert(*this, csig->vector_width() == 1);
unsigned width=expr_width();
NetNet*osig = new NetNet(csig->scope(), path, NetNet::IMPLICIT, width);
netvector_t*osig_vec = new netvector_t(expr_type(), width-1, 0);
NetNet*osig = new NetNet(csig->scope(), path, NetNet::IMPLICIT, osig_vec);
osig->set_line(*this);
osig->data_type(expr_type());
osig->local_flag(true);
/* Make sure the types match. */
@@ -1263,14 +1271,31 @@ NetNet* NetETernary::synthesize(Design *des, NetScope*scope, NetExpr*root)
*/
NetNet* NetESignal::synthesize(Design*des, NetScope*scope, NetExpr*root)
{
// If this is a synthesis with a specific value for the
// signal, then replace it (here) with a constant value.
if (net_->scope()==scope && net_->name()==scope->genvar_tmp) {
netvector_t*tmp_vec = new netvector_t(net_->data_type(),
net_->vector_width()-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, tmp_vec);
verinum tmp_val ((uint64_t)scope->genvar_tmp_val, net_->vector_width());
NetConst*tmp_const = new NetConst(scope, scope->local_symbol(), tmp_val);
tmp_const->set_line(*this);
des->add_node(tmp_const);
connect(tmp->pin(0), tmp_const->pin(0));
return tmp;
}
if (word_ == 0)
return net_;
netvector_t*tmp_vec = new netvector_t(net_->data_type(),
net_->vector_width()-1, 0);
NetNet*tmp = new NetNet(scope, scope->local_symbol(),
NetNet::IMPLICIT, net_->vector_width());
NetNet::IMPLICIT, tmp_vec);
tmp->set_line(*this);
tmp->local_flag(true);
tmp->data_type(net_->data_type());
// For NetExpr objects, the word index is already converted to
// a canonical (lsb==0) address. Just use the index directly.
@@ -1301,16 +1326,16 @@ static NetEvWait* make_func_trigger(Design*des, NetScope*scope, NetExpr*root)
NetEvWait*trigger = 0;
NexusSet*nset = root->nex_input(false);
if (nset && (nset->count() > 0)) {
if (nset && (nset->size() > 0)) {
NetEvent*ev = new NetEvent(scope->local_symbol());
ev->set_line(*root);
NetEvProbe*pr = new NetEvProbe(scope, scope->local_symbol(),
ev, NetEvProbe::ANYEDGE,
nset->count());
nset->size());
pr->set_line(*root);
for (unsigned idx = 0 ; idx < nset->count() ; idx += 1)
connect(nset[0][idx], pr->pin(idx));
for (unsigned idx = 0 ; idx < nset->size() ; idx += 1)
connect(nset->at(idx).lnk, pr->pin(idx));
des->add_node(pr);
@@ -1355,12 +1380,12 @@ NetNet* NetESFunc::synthesize(Design*des, NetScope*scope, NetExpr*root)
net->set_line(*this);
des->add_node(net);
netvector_t*osig_vec = new netvector_t(def->type, def->wid-1, 0);
osig_vec->set_signed(def->type==IVL_VT_REAL? true : false);
NetNet*osig = new NetNet(scope, scope->local_symbol(),
NetNet::WIRE, def->wid);
NetNet::WIRE, osig_vec);
osig->set_line(*this);
osig->local_flag(true);
osig->set_signed(def->type==IVL_VT_REAL? true : false);
osig->data_type(def->type);
connect(net->pin(0), osig->pin(0));
@@ -1386,11 +1411,11 @@ NetNet* NetESFunc::synthesize(Design*des, NetScope*scope, NetExpr*root)
NetNet* NetEUFunc::synthesize(Design*des, NetScope*scope, NetExpr*root)
{
svector<NetNet*> eparms (parms_.count());
vector<NetNet*> eparms (parms_.size());
/* Synthesize the arguments. */
bool errors = false;
for (unsigned idx = 0; idx < eparms.count(); idx += 1) {
for (unsigned idx = 0; idx < eparms.size(); idx += 1) {
if (dynamic_cast<NetEEvent*> (parms_[idx])) {
errors = true;
continue;
@@ -1423,16 +1448,23 @@ NetNet* NetEUFunc::synthesize(Design*des, NetScope*scope, NetExpr*root)
des->add_node(net);
/* Create an output signal and connect it to the function. */
netvector_t*osig_vec = new netvector_t(result_sig_->expr_type(),
result_sig_->vector_width()-1, 0);
NetNet*osig = new NetNet(scope_, scope_->local_symbol(), NetNet::WIRE,
result_sig_->vector_width());
osig_vec);
osig->set_line(*this);
osig->local_flag(true);
osig->data_type(result_sig_->expr_type());
connect(net->pin(0), osig->pin(0));
if (debug_synth2) {
cerr << get_fileline() << ": NetEUFunc::synthesize: "
<< "result_sig_->vector_width()=" << result_sig_->vector_width()
<< ", osig->vector_width()=" << osig->vector_width() << endl;
}
/* Connect the pins to the arguments. */
NetFuncDef*def = func_->func_def();
for (unsigned idx = 0; idx < eparms.count(); idx += 1) {
for (unsigned idx = 0; idx < eparms.size(); idx += 1) {
unsigned width = def->port(idx)->vector_width();
NetNet*tmp;
if (eparms[idx]->get_signed()) {
+39 -19
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2012 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,7 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "config.h"
@@ -24,75 +24,85 @@
# include "functor.h"
# include "netlist.h"
using namespace std;
functor_t::~functor_t()
{
}
void functor_t::event(class Design*, class NetEvent*)
void functor_t::event(Design*, NetEvent*)
{
}
void functor_t::signal(class Design*, class NetNet*)
void functor_t::signal(Design*, NetNet*)
{
}
void functor_t::process(class Design*, class NetProcTop*)
void functor_t::process(Design*, NetProcTop*)
{
}
void functor_t::lpm_abs(class Design*, class NetAbs*)
void functor_t::lpm_abs(Design*, NetAbs*)
{
}
void functor_t::lpm_add_sub(class Design*, class NetAddSub*)
void functor_t::lpm_add_sub(Design*, NetAddSub*)
{
}
void functor_t::lpm_compare(class Design*, class NetCompare*)
void functor_t::lpm_compare(Design*, NetCompare*)
{
}
void functor_t::lpm_const(class Design*, class NetConst*)
void functor_t::lpm_concat(Design*, NetConcat*)
{
}
void functor_t::lpm_divide(class Design*, class NetDivide*)
void functor_t::lpm_const(Design*, NetConst*)
{
}
void functor_t::lpm_literal(class Design*, class NetLiteral*)
void functor_t::lpm_divide(Design*, NetDivide*)
{
}
void functor_t::lpm_modulo(class Design*, class NetModulo*)
void functor_t::lpm_literal(Design*, NetLiteral*)
{
}
void functor_t::lpm_ff(class Design*, class NetFF*)
void functor_t::lpm_modulo(Design*, NetModulo*)
{
}
void functor_t::lpm_logic(class Design*, class NetLogic*)
void functor_t::lpm_ff(Design*, NetFF*)
{
}
void functor_t::lpm_mult(class Design*, class NetMult*)
void functor_t::lpm_logic(Design*, NetLogic*)
{
}
void functor_t::lpm_mux(class Design*, class NetMux*)
void functor_t::lpm_mult(Design*, NetMult*)
{
}
void functor_t::lpm_pow(class Design*, class NetPow*)
void functor_t::lpm_mux(Design*, NetMux*)
{
}
void functor_t::sign_extend(class Design*, class NetSignExtend*)
void functor_t::lpm_part_select(Design*, NetPartSelect*)
{
}
void functor_t::lpm_ureduce(class Design*, class NetUReduce*)
void functor_t::lpm_pow(Design*, NetPow*)
{
}
void functor_t::sign_extend(Design*, NetSignExtend*)
{
}
void functor_t::lpm_ureduce(Design*, NetUReduce*)
{
}
@@ -185,6 +195,11 @@ void NetCompare::functor_node(Design*des, functor_t*fun)
fun->lpm_compare(des, this);
}
void NetConcat::functor_node(Design*des, functor_t*fun)
{
fun->lpm_concat(des, this);
}
void NetConst::functor_node(Design*des, functor_t*fun)
{
fun->lpm_const(des, this);
@@ -225,6 +240,11 @@ void NetMux::functor_node(Design*des, functor_t*fun)
fun->lpm_mux(des, this);
}
void NetPartSelect::functor_node(Design*des, functor_t*fun)
{
fun->lpm_part_select(des, this);
}
void NetPow::functor_node(Design*des, functor_t*fun)
{
fun->lpm_pow(des, this);
+10 -5
View File
@@ -1,7 +1,7 @@
#ifndef __functor_H
#define __functor_H
#ifndef IVL_functor_H
#define IVL_functor_H
/*
* Copyright (c) 1999-2008 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
@@ -57,6 +57,9 @@ struct functor_t {
/* This method is called for each structural comparator. */
virtual void lpm_compare(class Design*des, class NetCompare*);
/* This method is called for each structural concatenation. */
virtual void lpm_concat(class Design*des, class NetConcat*);
/* This method is called for each structural constant. */
virtual void lpm_const(class Design*des, class NetConst*);
@@ -81,6 +84,8 @@ struct functor_t {
/* This method is called for each MUX. */
virtual void lpm_mux(class Design*des, class NetMux*);
virtual void lpm_part_select(class Design*des, class NetPartSelect*);
/* This method is called for each power. */
virtual void lpm_pow(class Design*des, class NetPow*);
@@ -100,4 +105,4 @@ struct proc_match_t {
virtual int block(class NetBlock*);
};
#endif
#endif /* IVL_functor_H */
+2 -2
View File
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU Library General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc.,
# 59 Temple Place - Suite 330
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Boston, MA 02111-1307, USA
#
@@ -28,7 +28,7 @@ SUFFIX=@SUFFIX@
# These are used for linking...
LD=$CC
LDFLAGS="@SHARED@ -L@LIBDIR@"
LDFLAGS="@IVCTARGETFLAGS@ @SHARED@ -L@LIBDIR@"
LDLIBS="-lveriuser$SUFFIX -lvpi$SUFFIX"
CCSRC=
+43 -12
View File
@@ -63,6 +63,7 @@ ivl_expr_file
ivl_expr_lineno
ivl_expr_name
ivl_expr_nature
ivl_expr_net_type
ivl_expr_opcode
ivl_expr_oper1
ivl_expr_oper2
@@ -70,6 +71,7 @@ ivl_expr_oper3
ivl_expr_parameter
ivl_expr_parm
ivl_expr_parms
ivl_expr_property_idx
ivl_expr_repeat
ivl_expr_scope
ivl_expr_sel_type
@@ -139,7 +141,9 @@ ivl_lpm_width
ivl_lval_idx
ivl_lval_mux
ivl_lval_nest
ivl_lval_part_off
ivl_lval_property_idx
ivl_lval_sel_type
ivl_lval_sig
ivl_lval_width
@@ -166,6 +170,12 @@ ivl_parameter_basename
ivl_parameter_expr
ivl_parameter_file
ivl_parameter_lineno
ivl_parameter_local
ivl_parameter_lsb
ivl_parameter_msb
ivl_parameter_scope
ivl_parameter_signed
ivl_parameter_width
ivl_path_condit
ivl_path_delay
@@ -175,10 +185,23 @@ ivl_path_source
ivl_path_source_negedge
ivl_path_source_posedge
ivl_process_analog
ivl_process_attr_cnt
ivl_process_attr_val
ivl_process_file
ivl_process_lineno
ivl_process_scope
ivl_process_stmt
ivl_process_type
ivl_scope_attr_cnt
ivl_scope_attr_val
ivl_scope_basename
ivl_scope_children
ivl_scope_child
ivl_scope_childs
ivl_scope_class
ivl_scope_classes
ivl_scope_def
ivl_scope_def_file
ivl_scope_def_lineno
@@ -194,6 +217,10 @@ ivl_scope_logs
ivl_scope_log
ivl_scope_lpms
ivl_scope_lpm
ivl_scope_mod_module_ports
ivl_scope_mod_module_port_name
ivl_scope_mod_module_port_type
ivl_scope_mod_module_port_width
ivl_scope_mod_port
ivl_scope_name
ivl_scope_param
@@ -228,8 +255,12 @@ ivl_signal_local
ivl_signal_lsb
ivl_signal_msb
ivl_signal_name
ivl_signal_net_type
ivl_signal_nex
ivl_signal_npath
ivl_signal_packed_dimensions
ivl_signal_packed_lsb
ivl_signal_packed_msb
ivl_signal_path
ivl_signal_port
ivl_signal_scope
@@ -237,18 +268,6 @@ ivl_signal_signed
ivl_signal_type
ivl_signal_width
ivl_path_delay
ivl_path_source
ivl_process_analog
ivl_process_attr_cnt
ivl_process_attr_val
ivl_process_file
ivl_process_lineno
ivl_process_scope
ivl_process_stmt
ivl_process_type
ivl_statement_type
ivl_stmt_block_count
@@ -272,6 +291,7 @@ ivl_stmt_lvals
ivl_stmt_lwidth
ivl_stmt_name
ivl_stmt_nevent
ivl_stmt_opcode
ivl_stmt_parm
ivl_stmt_parm_count
ivl_stmt_rval
@@ -292,6 +312,17 @@ ivl_switch_scope
ivl_switch_type
ivl_switch_width
ivl_type_base
ivl_type_element
ivl_type_name
ivl_type_packed_dimensions
ivl_type_packed_lsb
ivl_type_packed_msb
ivl_type_prop_name
ivl_type_prop_type
ivl_type_properties
ivl_type_signed
ivl_udp_init
ivl_udp_file
ivl_udp_lineno
+4 -4
View File
@@ -1,7 +1,7 @@
#ifndef __ivl_alloc_H
#define __ivl_alloc_H
#ifndef IVL_ivl_alloc_H
#define IVL_ivl_alloc_H
/*
* Copyright (C) 2010 Cary R. (cygcary@yahoo.com)
* Copyright (C) 2010-2014 Cary R. (cygcary@yahoo.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -83,4 +83,4 @@
__ivl_rtn; \
})
#endif
#endif /* IVL_ivl_alloc_H */
+5 -6
View File
@@ -1,5 +1,7 @@
#ifndef IVL_ivl_assert_H
#define IVL_ivl_assert_H
/*
* Copyright (c) 2007-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 2007-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -14,12 +16,9 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __ivl_assert_h
#define __ivl_assert_h
# include <cstdlib>
#define ivl_assert(tok, expression) \
@@ -32,4 +31,4 @@
} \
} while (0)
#endif
#endif /* IVL_ivl_assert_H */
+222 -60
View File
@@ -1,7 +1,7 @@
#ifndef __ivl_target_H
#define __ivl_target_H
#ifndef IVL_ivl_target_H
#define IVL_ivl_target_H
/*
* Copyright (c) 2000-2011 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -16,17 +16,25 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include <inttypes.h>
# include <stddef.h>
/* Re the _CLASS define: clang++ wants this to be class to match the
* definition, but clang (the C) compiler needs it to be a struct
* since class is not defined in C. They are effectively both pointers
* to an object so everything works out. */
#ifdef __cplusplus
#define _BEGIN_DECL extern "C" {
#define _END_DECL }
#define _CLASS class
#else
#define _BEGIN_DECL
#define _END_DECL
#define _CLASS struct
#endif
#ifndef __GNUC__
@@ -157,21 +165,8 @@ typedef struct ivl_array_s *ivl_array_t;
typedef struct ivl_branch_s *ivl_branch_t;
typedef struct ivl_delaypath_s*ivl_delaypath_t;
typedef struct ivl_design_s *ivl_design_t;
/* clang++ wants this to be class to match the definition, but clang
* (the C) compiler needs it to be a struct since class is not defined
* in C. They are effecively both pointers to an object so everything
* works out. */
#ifdef __cplusplus
typedef class ivl_discipline_s*ivl_discipline_t;
#else
typedef struct ivl_discipline_s*ivl_discipline_t;
#endif
/* See the comments above. */
#ifdef __cplusplus
typedef class netenum_t *ivl_enumtype_t;
#else
typedef struct netenum_t *ivl_enumtype_t;
#endif
typedef _CLASS ivl_discipline_s*ivl_discipline_t;
typedef const _CLASS netenum_t*ivl_enumtype_t;
typedef struct ivl_event_s *ivl_event_t;
typedef struct ivl_expr_s *ivl_expr_t;
typedef struct ivl_island_s *ivl_island_t;
@@ -180,12 +175,7 @@ typedef struct ivl_lval_s *ivl_lval_t;
typedef struct ivl_net_const_s*ivl_net_const_t;
typedef struct ivl_net_logic_s*ivl_net_logic_t;
typedef struct ivl_udp_s *ivl_udp_t;
/* See the comments above. */
#ifdef __cplusplus
typedef class ivl_nature_s *ivl_nature_t;
#else
typedef struct ivl_nature_s *ivl_nature_t;
#endif
typedef _CLASS ivl_nature_s *ivl_nature_t;
typedef struct ivl_net_probe_s*ivl_net_probe_t;
typedef struct ivl_nexus_s *ivl_nexus_t;
typedef struct ivl_nexus_ptr_s*ivl_nexus_ptr_t;
@@ -193,9 +183,11 @@ typedef struct ivl_parameter_s*ivl_parameter_t;
typedef struct ivl_process_s *ivl_process_t;
typedef struct ivl_scope_s *ivl_scope_t;
typedef struct ivl_signal_s *ivl_signal_t;
typedef struct ivl_port_info_s*ivl_port_info_t;
typedef struct ivl_switch_s *ivl_switch_t;
typedef struct ivl_memory_s *ivl_memory_t; //XXXX __attribute__((deprecated));
typedef struct ivl_statement_s*ivl_statement_t;
typedef const _CLASS ivl_type_s*ivl_type_t;
/*
* These are types that are defined as enumerations. These have
@@ -233,11 +225,16 @@ typedef enum ivl_expr_type_e {
IVL_EX_ENUMTYPE = 21,
IVL_EX_EVENT = 17,
IVL_EX_MEMORY = 4,
IVL_EX_NEW = 23,
IVL_EX_NULL = 22,
IVL_EX_NUMBER = 5,
IVL_EX_ARRAY_PATTERN = 26,
IVL_EX_PROPERTY = 24,
IVL_EX_REALNUM = 16,
IVL_EX_SCOPE = 6,
IVL_EX_SELECT = 7,
IVL_EX_SFUNC = 8,
IVL_EX_SHALLOWCOPY = 25,
IVL_EX_SIGNAL = 9,
IVL_EX_STRING = 10,
IVL_EX_TERNARY = 11,
@@ -301,7 +298,10 @@ typedef enum ivl_lpm_type_e {
IVL_LPM_CAST_INT2 = 35,
IVL_LPM_CAST_REAL = 33,
IVL_LPM_CONCAT = 16,
IVL_LPM_CONCATZ = 36, /* Transparent concat */
IVL_LPM_CMP_EEQ= 18, /* Case EQ (===) */
IVL_LPM_CMP_EQX= 37, /* Windcard EQ (==?) */
IVL_LPM_CMP_EQZ= 38, /* casez EQ */
IVL_LPM_CMP_EQ = 10,
IVL_LPM_CMP_GE = 1,
IVL_LPM_CMP_GT = 2,
@@ -328,6 +328,7 @@ typedef enum ivl_lpm_type_e {
IVL_LPM_SHIFTR = 7,
IVL_LPM_SIGN_EXT=27,
IVL_LPM_SUB = 8,
IVL_LPM_SUBSTITUTE=39,
/* IVL_LPM_RAM = 9, / obsolete */
IVL_LPM_UFUNC = 14
} ivl_lpm_type_t;
@@ -358,12 +359,14 @@ typedef enum ivl_scope_type_e {
IVL_SCT_TASK = 2,
IVL_SCT_BEGIN = 3,
IVL_SCT_FORK = 4,
IVL_SCT_GENERATE= 5
IVL_SCT_GENERATE= 5,
IVL_SCT_PACKAGE = 6,
IVL_SCT_CLASS = 7
} ivl_scope_type_t;
/* Signals (ivl_signal_t) that are ports into the scope that contains
them have a port type. Otherwise, they are port IVL_SIP_NONE. */
typedef enum ivl_signal_port_e {
typedef enum OUT {
IVL_SIP_NONE = 0,
IVL_SIP_INPUT = 1,
IVL_SIP_OUTPUT= 2,
@@ -403,9 +406,12 @@ typedef enum ivl_statement_type_e {
IVL_ST_DELAY = 11,
IVL_ST_DELAYX = 12,
IVL_ST_DISABLE = 13,
IVL_ST_DO_WHILE = 30,
IVL_ST_FORCE = 14,
IVL_ST_FOREVER = 15,
IVL_ST_FORK = 16,
IVL_ST_FORK_JOIN_ANY = 28,
IVL_ST_FORK_JOIN_NONE = 29,
IVL_ST_FREE = 26,
IVL_ST_RELEASE = 17,
IVL_ST_REPEAT = 18,
@@ -432,6 +438,9 @@ typedef enum ivl_variable_type_e {
IVL_VT_BOOL = 3,
IVL_VT_LOGIC = 4,
IVL_VT_STRING = 5,
IVL_VT_DARRAY = 6, /* Array (esp. dynamic array) */
IVL_VT_CLASS = 7, /* SystemVerilog class instances */
IVL_VT_QUEUE = 8, /* SystemVerilog queue instances */
IVL_VT_VECTOR = IVL_VT_LOGIC /* For compatibility */
} ivl_variable_type_t;
@@ -770,6 +779,11 @@ extern unsigned ivl_event_lineno(ivl_event_t net);
* Get the data type of the expression node. This uses the variable
* type enum to express the type of the expression node.
*
* ivl_expr_net_type
* This is used in some cases to carry more advanced type
* descriptions. Over the long run, all type information will be
* moved into the ivl_type_t type description method.
*
* ivl_expr_width
* This method returns the bit width of the expression at this
* node. It can be applied to any expression node, and returns the
@@ -802,6 +816,36 @@ extern unsigned ivl_event_lineno(ivl_event_t net);
*
* - IVL_EX_BINARY
*
* - IVL_EX_PROPERTY
* This expression represents the property select from a class
* type, for example "foo.property" where "foo" is a class handle and
* "property" is the name of one of the properties of the class. The
* ivl_expr_signal function returns the ivl_signal_t for "foo" and the
* data_type for the signal will be IVL_VT_CLASS.
*
* The ivl_signal_net_type(sig) for the "foo" signal will be a class
* type and from there you can get access to the type information.
*
* Elaboration reduces the properties of a class to a vector numbered
* from 0 to the number of properties. The ivl_expr_property_idx()
* function gets the index of the selected property into the property
* table. That number can be passed to ivl_type_prop_*() functions to
* get details about the property.
*
* If the property is an array, then the ivl_expr_oper1() function
* returns the canonical expression for accessing the element of the
* property.
*
* - IVL_EX_NEW
* This expression takes one or two operands. The first operand,
* returned by ivl_expr_oper1() is the number of elements to create
* for the dynamic array. The second operand, if present, is returned
* by the ivl_expr_oper2() function. If this returns a non-nil
* expression, it is the initial value to be written to the elements
* of the array. If the expression is an IVL_EX_ARRAY_PATTERN, then
* this is the very special case of a list of values to be written to
* array elements.
*
* - IVL_EX_SELECT
* This expression takes two operands, oper1 is the expression to
* select from, and oper2 is the selection base. The ivl_expr_width
@@ -810,6 +854,14 @@ extern unsigned ivl_event_lineno(ivl_event_t net);
* conversion from signal units to vector units, so the result of
* ivl_expr_oper1 should range from 0 to ivl_expr_width().
*
* This expression is also used to implement string substrings. If the
* sub-expression (oper1) is IVL_VT_STRING, then the base expression
* (oper2) is a character address, with 0 the first address of the
* string, 1 the second, and so on. This is OPPOSITE how a part select
* of a string cast to a vector works, to be aware. The size of the
* expression is an even multiple of 8, and is 8 times the number of
* characters to pick.
*
* - IVL_EX_SIGNAL
* This expression references a signal vector. The ivl_expr_signal
* function gets a handle for the signal that is referenced. The
@@ -839,6 +891,7 @@ extern unsigned ivl_event_lineno(ivl_event_t net);
*/
extern ivl_expr_type_t ivl_expr_type(ivl_expr_t net);
extern ivl_type_t ivl_expr_net_type(ivl_expr_t net);
extern ivl_variable_type_t ivl_expr_value(ivl_expr_t net);
extern const char*ivl_expr_file(ivl_expr_t net);
extern unsigned ivl_expr_lineno(ivl_expr_t net);
@@ -855,23 +908,23 @@ extern uint64_t ivl_expr_delay_val(ivl_expr_t net);
extern double ivl_expr_dvalue(ivl_expr_t net);
/* IVL_EX_ENUMTYPE */
extern ivl_enumtype_t ivl_expr_enumtype(ivl_expr_t net);
/* IVL_EX_SIGNAL, IVL_EX_SFUNC, IVL_EX_VARIABLE */
/* IVL_EX_PROPERTY IVL_EX_SIGNAL IVL_EX_SFUNC IVL_EX_VARIABLE */
extern const char* ivl_expr_name(ivl_expr_t net);
/* IVL_EX_BACCESS */
extern ivl_nature_t ivl_expr_nature(ivl_expr_t net);
/* IVL_EX_BINARY IVL_EX_UNARY */
extern char ivl_expr_opcode(ivl_expr_t net);
/* IVL_EX_BINARY IVL_EX_UNARY, IVL_EX_MEMORY IVL_EX_TERNARY */
/* IVL_EX_BINARY IVL_EX_UNARY, IVL_EX_MEMORY IVL_EX_NEW IVL_EX_TERNARY */
extern ivl_expr_t ivl_expr_oper1(ivl_expr_t net);
/* IVL_EX_BINARY IVL_EX_TERNARY */
/* IVL_EX_BINARY IVL_EX_NEW IVL_EX_TERNARY */
extern ivl_expr_t ivl_expr_oper2(ivl_expr_t net);
/* IVL_EX_TERNARY */
extern ivl_expr_t ivl_expr_oper3(ivl_expr_t net);
/* and expression */
extern ivl_parameter_t ivl_expr_parameter(ivl_expr_t net);
/* IVL_EX_CONCAT IVL_EX_UFUNC */
/* IVL_EX_ARRAY_PATTERN IVL_EX_CONCAT IVL_EX_UFUNC */
extern ivl_expr_t ivl_expr_parm(ivl_expr_t net, unsigned idx);
/* IVL_EX_CONCAT IVL_EX_SFUNC IVL_EX_UFUNC */
/* IVL_EX_ARRAY_PATTERN IVL_EX_CONCAT IVL_EX_SFUNC IVL_EX_UFUNC */
extern unsigned ivl_expr_parms(ivl_expr_t net);
/* IVL_EX_CONCAT */
extern unsigned ivl_expr_repeat(ivl_expr_t net);
@@ -879,9 +932,11 @@ extern unsigned ivl_expr_repeat(ivl_expr_t net);
extern ivl_select_type_t ivl_expr_sel_type(ivl_expr_t net);
/* IVL_EX_EVENT */
extern ivl_event_t ivl_expr_event(ivl_expr_t net);
/* IVL_EX_PROPERTY */
extern int ivl_expr_property_idx(ivl_expr_t net);
/* IVL_EX_SCOPE */
extern ivl_scope_t ivl_expr_scope(ivl_expr_t net);
/* IVL_EX_SIGNAL */
/* IVL_EX_PROPERTY IVL_EX_SIGNAL */
extern ivl_signal_t ivl_expr_signal(ivl_expr_t net);
/* any expression */
extern int ivl_expr_signed(ivl_expr_t net);
@@ -1218,7 +1273,7 @@ extern unsigned ivl_lpm_lineno(ivl_lpm_t net);
* width of the part. The ivl_lpm_q is the part end, and the
* ivl_lpm_data(0) is the non-part end.
*
* - Comparisons (IVL_LPM_CMP_GT/GE/EQ/NE/EEQ/NEE)
* - Comparisons (IVL_LPM_CMP_GT/GE/EQ/NE/EEQ/NEE/EQX/EQZ)
* These devices have two inputs, available by the ivl_lpm_data()
* function, and one output available by the ivl_lpm_q function. The
* output width is always 1, but the ivl_lpm_width() returns the width
@@ -1230,6 +1285,11 @@ extern unsigned ivl_lpm_lineno(ivl_lpm_t net);
* magnitude compare, the signedness does matter. In any case, the
* result of the compare is always unsigned.
*
* The EQX and EQZ nodes are windcard compares, where xz bits (EQX) or
* z bits (EQZ) in the data(1) operand are treated as windcards. no
* bits in the data(0) operand are wild. This matches the
* SystemVerilog convention for the ==? operator.
*
* - Mux Device (IVL_LPM_MUX)
* The MUX device has a q output, a select input, and a number of data
* inputs. The ivl_lpm_q output and the ivl_lpm_data inputs all have
@@ -1279,7 +1339,7 @@ extern unsigned ivl_lpm_lineno(ivl_lpm_t net);
* repeated to get the desired width. The ivl core assures that the
* input vector is exactly ivl_lpm_width() / ivl_lpm_size() bits.
*
* - Sign Exend (IVL_LPM_SIGN_EXT)
* - Sign Extend (IVL_LPM_SIGN_EXT)
* This node takes a single input and generates a single output. The
* input must be signed, and the output will be a vector sign extended
* to the desired width. The ivl_lpm_width() value is the output
@@ -1355,7 +1415,7 @@ extern ivl_nexus_t ivl_lpm_sync_set(ivl_lpm_t net);
extern ivl_expr_t ivl_lpm_sset_value(ivl_lpm_t net);
/* IVL_LPM_ARRAY */
extern ivl_signal_t ivl_lpm_array(ivl_lpm_t net);
/* IVL_LPM_PART */
/* IVL_LPM_PART IVL_LPM_SUBSTITUTE */
extern unsigned ivl_lpm_base(ivl_lpm_t net);
/* IVL_LPM_FF */
extern ivl_nexus_t ivl_lpm_clk(ivl_lpm_t net);
@@ -1365,12 +1425,14 @@ extern ivl_scope_t ivl_lpm_define(ivl_lpm_t net);
extern ivl_nexus_t ivl_lpm_enable(ivl_lpm_t net);
/* IVL_LPM_ADD IVL_LPM_CONCAT IVL_LPM_FF IVL_LPM_PART IVL_LPM_MULT
IVL_LPM_MUX IVL_LPM_POW IVL_LPM_SHIFTL IVL_LPM_SHIFTR IVL_LPM_SUB
IVL_LPM_UFUNC */
IVL_LPM_UFUNC IVL_LPM_SUBSTITUTE */
extern ivl_nexus_t ivl_lpm_data(ivl_lpm_t net, unsigned idx);
/* IVL_LPM_ADD IVL_LPM_MULT IVL_LPM_POW IVL_LPM_SUB */
/* IVL_LPM_ADD IVL_LPM_MULT IVL_LPM_POW IVL_LPM_SUB IVL_LPM_CMP_EQ
IVL_LPM_CMP_EEQ IVL_LPM_CMP_EQX IVL_LPM_CMP_EQZ IVL_LPM_CMP_NEE */
extern ivl_nexus_t ivl_lpm_datab(ivl_lpm_t net, unsigned idx);
/* IVL_LPM_ADD IVL_LPM_FF IVL_LPM_MULT IVL_LPM_PART IVL_LPM_POW
IVL_LPM_SUB IVL_LPM_UFUNC */
IVL_LPM_SUB IVL_LPM_UFUNC IVL_LPM_CMP_EEQ IVL_LPM_CMP_EQX
IVL_LPM_CMP_EQZ IVL_LPM_CMP_NEE IVL_LPM_SUBSTITUTE */
extern ivl_nexus_t ivl_lpm_q(ivl_lpm_t net);
extern ivl_drive_t ivl_lpm_drive0(ivl_lpm_t net);
extern ivl_drive_t ivl_lpm_drive1(ivl_lpm_t net);
@@ -1397,12 +1459,11 @@ extern const char*ivl_lpm_string(ivl_lpm_t net);
* for the local part selecting I might to in the lval object, as
* well as the target object width.
*
* ivl_lval_mux
* If the l-value includes a bit select expression, this method
* returns an ivl_expr_t that represents that
* expression. Otherwise, it returns 0.
* ivl_lval_mux (* obsolete *)
*
* (Should this be combined with ivl_lval_idx? -Ed)
* ivl_lval_nest
* If the l-value is an object more complex than a variable, then
* this returns the nested l-value (and ivl_lval_sig==0).
*
* ivl_lval_sig
* If the l-value is a variable, this method returns the signal
@@ -1419,6 +1480,11 @@ extern const char*ivl_lpm_string(ivl_lpm_t net);
* ivl_expr_t that represents the index expression. Otherwise, it
* returns 0.
*
* ivl_lval_property_idx
* If the l-value is a class object, this is the name of a property
* to select from the object. If this property is not present (<0)
* then the l-value represents the class object itself.
*
* SEMANTIC NOTES
* The ivl_lval_width is not necessarily the same as the width of the
* signal or memory word it represents. It is the width of the vector
@@ -1437,14 +1503,21 @@ extern const char*ivl_lpm_string(ivl_lpm_t net);
* then the ivl_lval_idx expression must *not* be present.
*
* For array words, the ivl_lval_width is the width of the word.
*
* - Arrayed properties
* If the l-value is a class property, then the ivl_lval_idx function
* will return an expression if the property is in fact arrayed. The
* expression is the canonical index for elements in the property.
*/
extern unsigned ivl_lval_width(ivl_lval_t net);
extern ivl_expr_t ivl_lval_mux(ivl_lval_t net); /* XXXX Obsolete? */
extern ivl_expr_t ivl_lval_mux(ivl_lval_t net) __attribute__((deprecated)); /* XXXX Obsolete? */
extern ivl_expr_t ivl_lval_idx(ivl_lval_t net);
extern ivl_expr_t ivl_lval_part_off(ivl_lval_t net);
extern ivl_select_type_t ivl_lval_sel_type(ivl_lval_t net);
extern int ivl_lval_property_idx(ivl_lval_t net);
extern ivl_signal_t ivl_lval_sig(ivl_lval_t net);
extern ivl_lval_t ivl_lval_nest(ivl_lval_t net);
/* NEXUS
@@ -1566,6 +1639,22 @@ extern ivl_signal_t ivl_nexus_ptr_sig(ivl_nexus_ptr_t net);
* Return the value of the parameter. This should be a simple
* constant expression, an IVL_EX_STRING or IVL_EX_NUMBER.
*
* ivl_parameter_msb
* ivl_parameter_lsb
* Returns the MSB and LSB for the parameter. For a parameter without
* a range the value is zero based and the width of the expression is
* used to determine the MSB.
*
* ivl_parameter_width
* return |MSB - LSB| + 1
*
* ivl_parameter_signed
* Returns if the parameter was declared to be signed.
*
* ivl_parameter_local
* Return whether parameter was local (localparam, implicit genvar etc)
* or not.
*
* ivl_parameter_file
* ivl_parameter_lineno
* Returns the file and line where this parameter is defined
@@ -1573,9 +1662,13 @@ extern ivl_signal_t ivl_nexus_ptr_sig(ivl_nexus_ptr_t net);
extern const char* ivl_parameter_basename(ivl_parameter_t net);
extern ivl_scope_t ivl_parameter_scope(ivl_parameter_t net);
extern ivl_expr_t ivl_parameter_expr(ivl_parameter_t net);
extern int ivl_parameter_msb(ivl_parameter_t net);
extern int ivl_parameter_lsb(ivl_parameter_t net);
extern unsigned ivl_parameter_width(ivl_parameter_t net);
extern int ivl_parameter_signed(ivl_parameter_t net);
extern int ivl_parameter_local(ivl_parameter_t net);
extern const char* ivl_parameter_file(ivl_parameter_t net);
extern unsigned ivl_parameter_lineno(ivl_parameter_t net);
extern unsigned ivl_parameter_lineno(ivl_parameter_t net);
/* SCOPE
@@ -1618,6 +1711,11 @@ extern unsigned ivl_parameter_lineno(ivl_parameter_t net);
* If the scope has no children, this method will return 0 and
* otherwise do nothing.
*
* ivl_scope_childs
* ivl_scope_child
* This is an alternative way of getting at the childs scopes of a
* given scope.
*
* ivl_scope_def
* Task definition scopes carry a task definition, in the form of
* a statement. This method accesses that definition. The
@@ -1719,6 +1817,10 @@ extern ivl_statement_t ivl_scope_def(ivl_scope_t net);
extern const char* ivl_scope_def_file(ivl_scope_t net);
extern unsigned ivl_scope_def_lineno(ivl_scope_t net);
extern size_t ivl_scope_childs(ivl_scope_t net);
extern ivl_scope_t ivl_scope_child(ivl_scope_t net, size_t idx);
extern unsigned ivl_scope_classes(ivl_scope_t net);
extern ivl_type_t ivl_scope_class(ivl_scope_t net, unsigned idx);
extern unsigned ivl_scope_enumerates(ivl_scope_t net);
extern ivl_enumtype_t ivl_scope_enumerate(ivl_scope_t net, unsigned idx);
extern unsigned ivl_scope_events(ivl_scope_t net);
@@ -1736,6 +1838,12 @@ extern const char* ivl_scope_basename(ivl_scope_t net);
extern unsigned ivl_scope_params(ivl_scope_t net);
extern ivl_parameter_t ivl_scope_param(ivl_scope_t net, unsigned idx);
extern ivl_scope_t ivl_scope_parent(ivl_scope_t net);
extern unsigned ivl_scope_mod_module_ports(ivl_scope_t net);
extern const char *ivl_scope_mod_module_port_name(ivl_scope_t net, unsigned idx );
extern ivl_signal_port_t ivl_scope_mod_module_port_type(ivl_scope_t net, unsigned idx );
extern unsigned ivl_scope_mod_module_port_width(ivl_scope_t net, unsigned idx );
extern unsigned ivl_scope_ports(ivl_scope_t net);
extern ivl_signal_t ivl_scope_port(ivl_scope_t net, unsigned idx);
extern ivl_nexus_t ivl_scope_mod_port(ivl_scope_t net, unsigned idx);
@@ -1785,13 +1893,23 @@ extern int ivl_scope_time_units(ivl_scope_t net);
* If the signal has been declared with a domain (Verilog-AMS) then
* this function will return a non-nil ivl_discipline_t.
*
* ivl_signal_msb
* ivl_signal_lsb
* ivl_signal_msb (deprecated)
* ivl_signal_lsb (deprecated)
* ivl_signal_packed_dimensions
* ivl_signal_packed_msb
* ivl_signal_packed_lsb
* ivl_signal_width
* These functions return the left and right indices, respectively,
* of the signal. If the signal is a scalar, both return 0. However,
* it doesn't mean that the signal is a scalar if both return 0, one
* can have a vector with 0 as both indices.
* These functions return the msb and lsb packed indices. The
* packed dimensions are declared differently from array
* dimensions, like so:
* reg [4:1][7:0] sig...
* which has two packed dimensions. The [4:1] dimension is the
* first, and so forth. If the signal is a scalar, it has 0
* dimension.
*
* The ivl_signal_msb/ivl_signal_lsb functions are deprecated
* versions that only work with variables that have less than two
* dimensions. They will return msb==lsb==0 for scalars.
*
* ivl_signal_port
* If the signal is a port to a module, this function returns the
@@ -1859,10 +1977,14 @@ extern unsigned ivl_signal_array_count(ivl_signal_t net);
extern unsigned ivl_signal_array_addr_swapped(ivl_signal_t net);
extern unsigned ivl_signal_dimensions(ivl_signal_t net);
extern ivl_discipline_t ivl_signal_discipline(ivl_signal_t net);
extern int ivl_signal_msb(ivl_signal_t net);
extern int ivl_signal_lsb(ivl_signal_t net);
extern unsigned ivl_signal_packed_dimensions(ivl_signal_t net);
extern int ivl_signal_packed_msb(ivl_signal_t net, unsigned dim);
extern int ivl_signal_packed_lsb(ivl_signal_t net, unsigned dim);
extern int ivl_signal_msb(ivl_signal_t net) __attribute__((deprecated));
extern int ivl_signal_lsb(ivl_signal_t net) __attribute__((deprecated));
extern unsigned ivl_signal_width(ivl_signal_t net);
extern ivl_signal_port_t ivl_signal_port(ivl_signal_t net);
extern int ivl_signal_module_port_index(ivl_signal_t net);
extern int ivl_signal_signed(ivl_signal_t net);
extern int ivl_signal_integer(ivl_signal_t net);
extern int ivl_signal_local(ivl_signal_t net);
@@ -1871,6 +1993,7 @@ extern unsigned ivl_signal_npath(ivl_signal_t net);
extern ivl_delaypath_t ivl_signal_path(ivl_signal_t net, unsigned idx);
extern ivl_signal_type_t ivl_signal_type(ivl_signal_t net);
extern ivl_variable_type_t ivl_signal_data_type(ivl_signal_t net);
extern ivl_type_t ivl_signal_net_type(ivl_signal_t net);
extern const char* ivl_signal_name(ivl_signal_t net);
extern const char* ivl_signal_basename(ivl_signal_t net);
extern const char* ivl_signal_attr(ivl_signal_t net, const char*key);
@@ -1958,7 +2081,7 @@ extern unsigned ivl_stmt_lineno(ivl_statement_t net);
* Statements that have event arguments (TRIGGER and WAIT) make
* those event objects available through these methods.
*
* ivl_stmt_lval
* ivl_stmt_lval
* ivl_stmt_lvals
* Return the number of l-values for an assignment statement, or
* the specific l-value. If there is more than 1 l-value, then the
@@ -1995,6 +2118,13 @@ extern unsigned ivl_stmt_lineno(ivl_statement_t net);
* the statement.) The ivl_stmt_delay_expr function returns the
* expression for the delay, or nil if there is no delay expression.
*
* The blocking assignment (IVL_ST_ASSIGN) may have an associated
* opcode, that can be extracted from ivl_stmt_opcode(). This opcode
* is the compressed operator used it statements like this:
* foo += <expr>
* The ivl_stmt_opcode() returns null (0) if this is not a compressed
* assignment statement.
*
* - IVL_ST_CASSIGN
* This reflects a procedural continuous assignment to an l-value. The
* l-value is the same as any other assignment (use ivl_stmt_lval).
@@ -2049,11 +2179,11 @@ extern unsigned ivl_stmt_lineno(ivl_statement_t net);
* triggers. The statement waits even if the sub-statement is nul.
*/
/* IVL_ST_BLOCK, IVL_ST_FORK */
/* IVL_ST_BLOCK, IVL_ST_FORK, IVL_ST_FORK_JOIN_ANY, IVL_ST_FORK_JOIN_NONE */
extern unsigned ivl_stmt_block_count(ivl_statement_t net);
/* IVL_ST_BLOCK, IVL_ST_FORK */
/* IVL_ST_BLOCK, IVL_ST_FORK, IVL_ST_FORK_JOIN_ANY, IVL_ST_FORK_JOIN_NONE */
extern ivl_scope_t ivl_stmt_block_scope(ivl_statement_t net);
/* IVL_ST_BLOCK, IVL_ST_FORK */
/* IVL_ST_BLOCK, IVL_ST_FORK, IVL_ST_FORK_JOIN_ANY, IVL_ST_FORK_JOIN_NONE */
extern ivl_statement_t ivl_stmt_block_stmt(ivl_statement_t net, unsigned i);
/* IVL_ST_UTASK IVL_ST_DISABLE */
extern ivl_scope_t ivl_stmt_call(ivl_statement_t net);
@@ -2088,6 +2218,8 @@ extern unsigned ivl_stmt_lvals(ivl_statement_t net);
extern unsigned ivl_stmt_lwidth(ivl_statement_t net);
/* IVL_ST_STASK */
extern const char* ivl_stmt_name(ivl_statement_t net);
/* IVL_ST_ASSIGN */
extern char ivl_stmt_opcode(ivl_statement_t net);
/* IVL_ST_STASK */
extern ivl_expr_t ivl_stmt_parm(ivl_statement_t net, unsigned idx);
/* IVL_ST_STASK */
@@ -2150,6 +2282,36 @@ extern ivl_attribute_t ivl_switch_attr_val(ivl_switch_t net, unsigned idx);
extern const char* ivl_switch_file(ivl_switch_t net);
extern unsigned ivl_switch_lineno(ivl_switch_t net);
/* TYPES
*
* ivl_type_base
* This returns the base type for the type. See the
* ivl_variable_type_t definition for the various base types.
*
* ivl_type_element
* Return the type of the element of an array. This is only valid
* for array types.
*
* ivl_type_signed
* Return TRUE if the type represents a signed packed vector or
* signed atomic type, and FALSE otherwise.
*
* SEMANTIC NOTES
*
* Class types have names and properties.
*/
extern ivl_variable_type_t ivl_type_base(ivl_type_t net);
extern ivl_type_t ivl_type_element(ivl_type_t net);
extern unsigned ivl_type_packed_dimensions(ivl_type_t net);
extern int ivl_type_packed_lsb(ivl_type_t net, unsigned dim);
extern int ivl_type_packed_msb(ivl_type_t net, unsigned dim);
extern int ivl_type_signed(ivl_type_t net);
extern const char* ivl_type_name(ivl_type_t net);
extern int ivl_type_properties(ivl_type_t net);
extern const char* ivl_type_prop_name(ivl_type_t net, int idx);
extern ivl_type_t ivl_type_prop_type(ivl_type_t net, int idx);
#if defined(__MINGW32__) || defined (__CYGWIN32__)
# define DLLEXPORT __declspec(dllexport)
#else
@@ -2180,4 +2342,4 @@ typedef const char* (*target_query_f) (const char*key);
_END_DECL
#endif
#endif /* IVL_ivl_target_H */

Some files were not shown because too many files have changed in this diff Show More