Commit Graph

387 Commits

Author SHA1 Message Date
Stephen Williams aa662e1ae1 System Verilog tasks can have multiple statements.
The begin/end block that wraps the statements can be implicit.
2011-11-06 10:07:43 -08:00
Stephen Williams fc44658dad Handle empty argument list to system function. (SystemVerilog) 2011-11-06 09:13:09 -08:00
Cary R 3b6e26aa90 An enumeration cannot have duplicate values.
Add code to check that an enumeration does not have duplicate values.
2011-10-01 09:32:37 -07:00
Stephen Williams 52019b0e55 Merge branch 'master' into work8 2011-09-18 19:48:50 -07:00
Stephen Williams 557e331ce1 Support SystemVerilog size cast. 2011-09-18 19:21:46 -07:00
Stephen Williams f0bf64271b SystemVerilog has more lax rules for function declarations.
Allow empty parameter lists
Allow lists of statements instead of simple statements.
2011-09-17 12:10:05 -07:00
Cary R b2ebc29c5a Fix some enum bugs.
This patch fixes a few more bugs in the enumeration code.

It add support for saving the file and line information to make
diagnostic messages better.

It updates some of the compiler warning messages to use the file
and line information.

It passes if the enumeration type is signed all the way to the
code generators.

It fixes the parser to correctly have the range after the signed
designation for the vector types.

It adds a warning that vvp does not currently support a negative
two state enumeration value.
2011-09-11 11:32:16 -07:00
Jared Casper 9b785031f5 Implement SystemVerilog final statements.
Add a new IVL_PR_FINAL process type.

Add a flag to NetScope in_final_ which is set when elaborating the
statement of a final procedure.

Add checks during statement elaboration for invalid statements in a
final procedure, similar to checks for statements in functions.

Do a final check to make sure no final blocks have delays.

In the vvp runtime, use "$final" as the flag for the thread created by
the final procedure.  During compilation, instead of adding such a
thread to the sched_list, add it to a new schedule_final_list that
mirrors the schedule_init_list, but is run at the end of simulation.
2011-08-11 14:31:38 -07:00
Prasad Joshi fa589badd8 Add support for increment and decrement operators
This patch adds support for increment/decrement operators as an
expression. The operations on real and vector slices have been
disabled for now.

These operators can be used as in independent statements. However, the
corresponding support is not added in parser.

Changes since V2:
- Additional error checking in elaboration to deny operation on vector
slices and real (suggested by Martin)

Changes since V1:
- Use 'i' and 'I' for increment (suggested by Cary)
- Evaluate sub-expression once (suggested by Cary and Stev)
- Add necessary checks during elaboration to ensure that the
	expression is valid (suggested Stev)
- Proper width handling with vectors (suggested by Martin)

Signed-off-by: Prasad Joshi <prasad@canopusconsultancy.com>
2011-08-11 14:25:19 -07:00
Cary R 836e61e878 Fix spacing issues in the code.
Remove space at the end of line and space before tab since they serve
no purpose.
2011-07-30 09:33:28 -07:00
Cary R fd30d6c921 Add more enumeration sequence name error checking.
This patch adds code to check for a negative or undefined value used in
an enumeration sequence name, it verifies that the count in an enumeration
sequence name is not zero and allows more decimal constant values in the
enumeration sequence name..
2011-07-20 21:03:19 -07:00
Stephen Williams 6ca44b48cc Add support for C-like assignments operators
SystemVerilog extended the assignments operator support to C-like
assignment operators and special bitwise assignment operators.

For example:
        a += 1;
        a -= 1;

The list of these operators can be found in SV LRM (1800-2009)
section 11.4.1.

NOTE: I fixed a few parts of this. In particular, the PEBShift
class is used for shift operators.

Acked-and-Tested-by: Oswaldo Cadenas <oswaldo.cadenas@gmail.com>
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-20 19:03:24 -07:00
Cary R b99846e0eb Make call to pow() unambiguous
pow(int, int) is ambiguous since it could use the double version from
the math library or the verinum version. This patch makes it obvious that
we want to use the double version.
2011-07-19 19:55:59 -07:00
Prasad Joshi 2cb9a2360c Add support for SystemVerilog style time literals
SystemVerilog has support for time literals. The time literal for
example #10ns, adds a delay of 10ns no matter the time unit currently
in effect. For more details please refer to
http://iverilog.wikia.com/wiki/Projects#SystemVerilog_Style_Time_Literals

Tested-by: Oswaldo Cadenas <oswaldo.cadenas@gmail.com>
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-14 18:43:55 -07:00
Prasad Joshi 537b8cba34 Assume module output primitive arguments as variables by default
A bit/logic output type in a module initially is defaulted to as a
variable. Depending on how they are used in the module, the type
changes accordingly.

For example

module test(output logic l);

        assign l = '0;

endmodule

The variable 'l' would be promoted to a Net data type, when the
'assign' statement is encountered.

Acked-by: Oswaldo Cadenas <oswaldo.cadenas@gmail.com>
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-14 18:29:19 -07:00
Prasad Joshi 743cb234c0 Initialization of atom types in module declaration
The module declaration should allow initialization of atom types (byte,
short int, int, and longint) data types.

For example:
$ cat clkgen.sv
module clkgen(output logic clk = 0, output byte p = '1);
initial begin
	#200;
	$display("p = %b", p);
	$finish;
end

initial forever #10 clk = ~clk;
endmodule

$ iverilog -g 2009 clkgen.sv

$ ./a.out
p = 11111111

$

Suggested-by: Oswaldo Cadenas <oswaldo.cadenas@gmail.com>
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-12 18:21:26 -07:00
Prasad Joshi f0ffac6038 Initialization of bit/logic in module declaration
The module declaration should allow initialization of the bit and
logic data types.

For example:
$ cat clkgen.sv
module clkgen(output logic clk = 0, output bit p = 1);
initial begin
	#200;
	$display("p = %b", p);
	$finish;
end

initial forever #10 clk = ~clk;
endmodule

$ iverilog -g 2009 clkgen.sv

$ ./a.out
p = 1

Suggested-by: Oswaldo Cadenas <oswaldo.cadenas@gmail.com>
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-12 18:14:53 -07:00
Prasad Joshi 7b7abb1d55 Support bit/logic return from functions.
Acked-by: Oswaldo Cadenas <oswaldo.cadenas@gmail.com>
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-12 18:03:12 -07:00
Prasad Joshi ceaa45e9e5 Allow 'bit' and 'logic' function arguments
SystemVerilog allows passing the 'bit' and 'logic' arguments to a
function. The patch adds support for parsing these function
definitions. The 'bit' data type is treated as boolean, whereas 'logic'
data type remains as logic.

Acked-by: Oswaldo Cadenas <oswaldo.cadenas@gmail.com>
Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-12 17:52:50 -07:00
Prasad Joshi 4242e94a17 Function definition without return type
The patch allows parsing of function definitions which do not have
explicit data type or range. The default return data type is assumed
to be reg unsigned and the default range is 0.

Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-05 19:28:40 -07:00
Prasad Joshi e497c1f1dc Explicit 'reg' return type in function definition
Verilog allows returning variables of 'reg' type. The icarus verilog
implicitly assumes the default returned type of the function as
'reg unsigned'. The patch allows to explicitly specify the 'reg' return
type.

Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-05 19:28:27 -07:00
Prasad Joshi 045a1b9808 Add support for variable of primitive data type 'logic'
Verilog allows user to define variables of primitive types. The patch
adds support for defining variables of type 'logic'. The data type
'logic' is the only primitive data type which supports defining ranges.

Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-04 10:25:50 -07:00
Prasad Joshi f25b957006 Add support for variable of primitive data type 'bit'
Verilog allows user to define variables of primitive types. The patch
adds support for defining variables of type 'bit'. The data type 'bit'
is the only primitive data type which supports defining ranges.

Signed-off-by: Prasad Joshi <prasadjoshi124@gmail.com>
2011-07-04 10:21:20 -07:00
Cary R 45ed389fc5 pform_module_define_port() already deletes the port attribute(s).
If there are attributes attached to a module port declaration them
pform_bind_attribute() which is called from pform_module_define_port()
will delete the attribute list. They do not need to be deleted locally.
2011-04-27 10:48:48 -07:00
Jared Casper 97d2389cb0 Allow SystemVerilog [size] dimension for unpacked arrays.
IEEE 1800-2005/9 says "each fixed-size dimension shall be represented by
an address range, such as [1:1024], or a single positive number to
specify the size of a fixed-size unpacked array, as in C. In other
words, [size] becomes the same as [0:size-1]."

This patch implements that translation in the parser.  It issues a
warning when doing so when the generation flag is less than 2005-sv.
2011-03-28 13:58:14 -07:00
Jared Casper 5ba1814e64 Wildcard named port connections.
Implements Section 23.3.2.4 of IEEE 1800-2009.
2011-03-23 11:29:00 -07:00
Larry Doolittle e9fda22ad9 Spelling fixes
Mostly then/than confusion.  All comments or README files,
except for one user-visible change in a tgt-vlog95 error message.
2011-03-14 16:28:36 -07:00
Cary R 468fd3d683 Allows multiple attribute instances.
This patch adds the ability to have multiple attribute instances
(e.g. (* foo = 1 *) (* bar = 2 *)).
2011-02-28 19:28:43 -08:00
Cary R 427aef8cc4 Add more file/line and scope information to the ivl interface, etc.
This patch adds/fixes the following:

  Adds file/line information to a UDP definition.

  Prints an error message if a UDP is passed signals wider than 1 bit.
  A UDP should supports a range, but the compiler currently does not.

  Add scope information for constants.

  Fix the Icarus extension UDP table entry element 'h' to use h.

  The ivl_udp_init() value is a char not unsigned.

  Add FILE_NAME() for a bunch more of the ivl interface objects.
2011-02-10 19:04:08 -08:00
Cary R 6ddf754082 Add support for giving both strengths to a pull device.
In the standard a pull device can be given both a 1 and 0 strength.
Only the appropriate one is actually used. This patch adds support
for giving both pull strength to a pull device.
2011-01-31 12:02:37 -08:00
Cary R eb81d2fe94 Fix some bugs in task integer/real arguments.
This patch fixes the following problem in the compiler:

  An integer task argument should be marked as an integer port.

  An implicit register can be converted to either a reg or an integer.

  An old style task port should default to <no type> unless reg or some
  other type is provided. ANSI style is always defined. For example:
    input ri;
    output ro;
    inout rio;
    real ri, ro, rio;
  should define all three task ports to be of type real.
2011-01-31 11:27:11 -08:00
Cary R d4a97b4a9c Add a generation for 1800-2005, etc.
It was a poor choice to only add -g2009 for 1800-2009 and ignore the
previous version of System Verilog 1800-2005. This patch adds a
generation for 1800-2005 and also adds `begin_keywords support for
1800-2005. The previous SystemVerilog keywords have been put under
the 1800-2005 generation and the new one from 1800-2009 have also
been added.
2011-01-12 16:36:17 -08:00
Cary R 1b0181351b Add a warning that ifnone with an edge-sensitive path is not supported.
Cadence allows an ifnone with an edge-sensitive path. Until we understand
exactly what this is and how to implement it this patch adds a warning
that an ifnone with an edge-sensitive path is not supported.
2011-01-12 16:07:11 -08:00
Stephen Williams 16e1570737 Merge branch 'master' into work2
Conflicts:
	elab_scope.cc
	net_nex_input.cc
	t-dll-api.cc
	vvp/parse.y
2010-11-28 08:38:40 -08:00
Stephen Williams 00c1176a5d Support enum base type vectors
Including bit/reg/logic types.
2010-11-12 19:28:43 -08:00
Stephen Williams 27dfdf99dd Enumeration element values can be expressions
Allow more complex enumeration expressions, which means putting
off the evaluation of the expression values until elaboration.
2010-11-12 18:47:06 -08:00
Stephen Williams 2f474358d9 Support enumeration element ranges.
This also fixes:
Set verinum.has_sign() correctly for enum values.
2010-11-09 21:05:47 -08:00
Cary R 7ddb556327 OpenBSD wants static before const
This is not really a problem, but to keep OpenBSD quiet we put static
before const (-W warning).
2010-11-03 13:04:23 -07:00
Cary R 225ca1e205 Change iterators to use prefix ++ since it is more efficient.
This patch changes all the iterator code to use a prefix ++ instead
of postfix since it is more efficient (no need for a temporary). It
is likely that the compiler could optimize this away, but lets make
it efficient from the start.
2010-11-02 10:43:16 -07:00
Stephen Williams cced1e771b Remove some uses of the svector template.
I'm adding more uses of the make_range_from_width function, so
it seems like time to get rid of its use of the svector template.
This thread led to a lot of other uses of svector that had to
also be removed.
2010-10-25 19:36:44 -07:00
Stephen Williams eb4ed82893 Finish up parser code for enum types
This gets the parser syntax actions done, up to the pform code.
It is ready for generating pform structures.
2010-10-24 11:21:17 -07:00
Stephen Williams 9037354c6b reg can take unsigned as well as signed.
SystemVerilog adds "unsigned" so that it can be explicit
as well as implicit.
2010-10-19 19:34:17 -07:00
Stephen Williams b80dbeee11 Give module port atom2 objects their proper widths.
These widths can be expressions as ranges, but must be present
as this is how we identify them as the various types of ints.
2010-10-19 19:07:44 -07:00
Stephen Williams 162e3aac3a Handle atom2 types in modules input/output ports. 2010-10-18 19:23:02 -07:00
Stephen Williams 568ee4436f Allow variables to implicitly convert to unresolved nets.
SystemVerilog allows variables to be either variables or unresolved
nets, depending on how they are used. If they are assigned by
procedural code, then they are variables. If they are assigned
by a continuous assignment, they are unresolved nets. Note that
they cannot be both, and when they are unresolved nets they can
only be assigned once.
2010-10-10 10:06:27 -07:00
Stephen Williams af6fd66648 Tasks functions with atom2 arguments.
Parse 2-value atoms as arguments to functions and tasks.
2010-10-10 10:06:27 -07:00
Stephen Williams e03ff763fb Parse support for SystemVerilog atom2 types. 2010-10-10 10:06:26 -07:00
Stephen Williams ec49f10e2d Revert bad merge from vhdl branch 2010-10-02 11:02:27 -07:00
Cary R df4722b92c The switch gates do not support a strength specification.
This patch splits the switch types out of the gates to allow
them to be defined to not take a strength specification.
2010-07-13 19:21:02 -07:00
Cary R 07ee2e7dff On error there is no need to pop the scope.
The error routines for task and function definitions were incorrectly
popping the scope. This should not be done since no scope was pushed.
Also assert that the current_task/function is 0 to catch that kind of
error like the other definition rules.
2010-06-18 15:48:00 -07:00