Commit Graph

6240 Commits

Author SHA1 Message Date
Stephen Williams 78788d17fe Translate VHDL string literals to bit vectors 2011-08-20 11:11:47 -07:00
Stephen Williams 13c17a2485 Fix broken creation of ExpString. 2011-08-17 20:53:49 -07:00
Stephen Williams f5220c54f1 Handle variables in process statements
Parse variables declared in the declaration section of process
statements, and support variable assignment statements.
2011-08-17 20:19:15 -07:00
Jared Casper 51b1d57f19 Update increment and decrement design dump and comments. 2011-08-14 15:13:13 -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
Prasad Joshi 6a40d9edaa Change the net expression cast from 'i' to 'v'
Icarus uses 'i' in the net expressions for a cast to integer. Replacing
it with 'v' would free the character 'i' that can be used for increment
operators. This changes cast operators to become 'v', '2', and 'r'.

Signed-off-by: Prasad Joshi <prasad@canopusconsultancy.com>
Suggested-by: Cary R. <cygcary@yahoo.com>
2011-08-07 11:40:34 -07:00
Martin Whitaker 5fc1a9c9e0 Fix for pr3368642.v.
The vvp target code generator may not elide a BUFZ if the output of
the BUFZ is connected to a net that is the subject of a procedural
force statement.
2011-08-07 11:15:16 -07:00
Stephen Williams 3e3b83da30 Add some detail on how libraries work. 2011-08-05 12:11:54 -07:00
Stephen Williams 13ecb67717 Add support for vhdl named libraries.
Put libraries in a directory of libraries, support a search path
of library directories, and read those libraries as needed.
2011-07-30 18:18:03 -07:00
Stephen Williams f2629d53a2 Add VHDL support for named libraries
Named libraries are similar to the work library, but they are not
written to implicitly, or imported implicitly. They are only brought
in by a "library" clause, the the packages within the library are
brought in by a "use" clause.
2011-07-30 15:04:07 -07:00
Cary R 72769146ee Remove all the user code compilation warnings
Remove all the compilation warnings that are from user changeable code.
There are still some warnings related to the flex generated lexor code.
2011-07-30 09:37:14 -07:00
Cary R de356b03c8 Fix most of the cppcheck warnings in the vhdlpp directory.
Mostly using size() vs empty() in the STL and a missing initialization.
2011-07-30 09:35:12 -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
Pawel Szostek 547ea61be8 Delete dynamically allocated objects in vhdlpp 2011-07-28 15:03:28 -07:00
Cary R dcfe1f0c2c Properly define the $ivlh_attribute_event() function.
Technically the sized function is not currently needed by Icarus since
the SFT file handles this type of information, but lets define this so
that things work correctly if we ever switch to using the standard VPI
interface. Also mark this as a system defined function.
2011-07-27 18:33:15 -07:00
Stephen Williams fcecfc065c Handle bit types in package library stream. 2011-07-24 16:16:01 -07:00
Stephen Williams 521005caf6 Add +vhdl-work+ control to the config file.
Presumably, the user will want the ability to explicitly set the
working library location, so create a +vhdl-work+ plusarg setting
for exactly that purpose.
2011-07-24 15:24:32 -07:00
Stephen Williams 19099c944f Automatically include vhdl_sys vpi module. 2011-07-24 12:04:23 -07:00
Stephen Williams 9ee938f0b4 Replace package in work library when I get a new one. 2011-07-24 11:06:59 -07:00
Stephen Williams 116d9f5f54 Merge branch 'master' into work7 2011-07-24 11:06:22 -07:00
Pawel Szostek 981425fcce Add semantics check in component instantiation
There have been applied rules for port and signal
association in component instatiation statements
described in the VHDL standard.
2011-07-24 10:14:41 -07:00
Pawel Szostek e19089e838 Use multimap in VHDL Component Instantiations
Port map aspects were held in std::maps. Because
of that, in case of multiple assignments to the same
port, some assignments were lost and in effect vhdlpp
produced correct verilog code from a buggy VHDL.

Std::map was replaced by std::multimap. Thanks to it
we can gather this multiple assignments and detect them
in the elaboration phase.
2011-07-24 10:08:14 -07:00
Pawel Szostek 50f7e1b69e Add parser cleanup to vhdlpp
This commit adds removal of global objects in
the execution of vhdlpp. This includes deleting
design entities and the global parse scope.
2011-07-24 10:03:03 -07:00
Pawel Szostek eb98ed9ce2 Add additional deletion in VHDL classes' destructors
Delete dynamically allocated objects in ScopeBase,
Architecture, ComponentInstatiation, Entity and Package.
2011-07-24 09:58:57 -07:00
Pawel Szostek a8fae6bbf7 Use stl algorithms and templates in ScopeBase destructor
This patch applies a more sophisticated method for
cleaning containers in VHDL ScopeBase class.
2011-07-24 09:57:20 -07:00
Pawel Szostek a5ca9ea8be Use separate containers for current and previous scopes
This patch introduces in ScopeBase separate containers
for declarations coming from the current scope and from
the previous scopes.
Until now, in one scope, all objects were kept in an stl map.
When a scope was created inside other scopes, a shallow
copy of the map was made. This solution was nice for
name shadowing (in new scopes, when a name was
encountered, the old objects were overridden by a new
one), but didn't allow for distinguishing where the objects
were allocated. As a result, it is impossible to know who
the owner is and who should delete them.

In this commit ScopeBase gets two containers: for old
and new objects. If a ScopeBase is made from another
ScopeBase object, all objects from the copied object
go to an old_XXX container, where XXX depends on the
type of the copied objects. When a ScopeBase object
is deleted, the objects from new_XXX are deleted and
the ones from old_XXX are not touched.

This patch adds some complexity to the internals
of ScopeBase, but leaves its interface unchanged.
2011-07-24 09:53:06 -07:00
Pawel Szostek 3764216a88 Use stl stack for for carrying scopes
This is rather a cosmetic change. The patch changes
the container used for stack of scopes from std::list
to std::stack. It suits this particular application
a bit better.
2011-07-24 09:50:31 -07:00
Pawel Szostek 21008f2ba9 Add missing or fix existing deletes in VHDL parser
Thanks to valgrind analysis it turned out that
there were objects in the parser that were not being
deleted in a proper way. This patch fixes them all.
2011-07-24 09:47:41 -07:00
Pawel Szostek 46684bb28e Use dynamic allocation for VHDL global built-in types
Instead of using automatic variables for global
types, I allocate them dynamically. Thanks to it,
all type objects can be treated in the same way,
as all of them are pointers allocated with `new'.
Now we will be able to remove all scopes in the same
manner, no matter if it is a global or local scope,
by deleting all carried pointers.
2011-07-24 09:45:25 -07:00
Stephen Williams 148600814d Handle std_logic_vector library output stream
When writing arrays to the work library, handle the special
case that it is an array of std_logic and write a std_logic_vector
declaration instead. This makes for a more compact description.
2011-07-23 10:44:36 -07:00
Stephen Williams df8efed22b Parse work library for imported packages
When a "use" clause tries to pull a package from the work library,
put together a file name and try to find that package in the
work library directory. If found, parse the package file and
try again to find the package.
2011-07-23 10:07:20 -07:00
Stephen Williams 3ef1d01ad1 Rework parse/lex API to be reentrant
Bison and Flex generate different interfaces for reentrant
parsers, so handle that different API. We need this change
because library support is going to reuse the parser to
read in library packages.
2011-07-22 20:49:57 -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
Cary R 7d7d01aee2 Remove compile warning.
isprint() is defined to take an int and if it is defined as a macro then
you can get a warning that a char is being used as an array index. This
patch fixes this warning in tgt-vlog95/msic.c
2011-07-20 19:06:05 -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
Stephen Williams 4989555646 Fix unary convert of real to bool
Sometimes real values are converted to BOOL values, and the
NetECast needs to handle it properly.
2011-07-20 18:45:13 -07:00
Stephen Williams e2932cb6b5 Add ExpName::elaborate_rval member function
This function is for the time being used in the
component instatiation. It is checked, whether
an expression is a correct r-value.
To be a correct r-value, it must be either
port name or signal name.
2011-07-19 21:29:05 -07:00
Cary R 5821139e0f vlog95: Add debug code for emitting a nexus.
This patch adds debug code that can be used to investigate how a nexus
is built.
2011-07-19 20:09:57 -07:00
Cary R a241bf4f74 Fix mixed size verinum negative comparisons.
For mixed sized negative operands the verinum comparisons were sometimes
returning the wrong value.
2011-07-19 20:04:00 -07:00
Cary R fd4f07906d Check that enum initializations are in range.
This patch adds checks to verify that all enum initializations (explicit
or implicit) are in range.
2011-07-19 19:57:49 -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
Stephen Williams 38854822da Write package headers to a library file
Build up a work library by writing a VHDL representation of the
package header into a source file. This representation needs to
be accurate enough that later invocations of vhdlpp can read them
with the VHDL parser.
2011-07-19 19:19:27 -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
Pawel Szostek 60deb775ca Add support for VHDL's loop statements 2011-07-12 19:20:04 -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