Commit Graph

136 Commits

Author SHA1 Message Date
Christian Taedcke 6d5aabd4f0 Make a few constructors explicit.
This removes cppcheck warnings.
2015-10-22 12:33:33 +02: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
Nick Gasson 9a48166855 tgt-vhdl: Improve temporary signal name generation to avoid collisions
Fixes regression of simple_gen test.

Also extended ivl_lpm_size API call to support all LPM types. This
simplifies some of the VHDL LPM generation code a little.
2011-04-06 19:18:08 -07:00
Cary R 98f5ed2f85 Fix remaining space issues. 2011-03-14 16:26:31 -07:00
Nick Gasson 7b82bd26f5 tgt-vhdl: Fix shift2 test regression
Caused by translate_select emitting a logical instead of arithmetic
shift for signed arguments.
2011-03-08 19:08:59 -08:00
Nick Gasson a7fe5167e8 Generate VHDL report statements for $display
This changes the implementation of $display/$write to use VHDL
report statements rather the the std.textio functions. The code
produced is simpler and more like what a real VHDL designed would
write. However it no longer exactly matches the Verilog output as
most VHDL simulators prepend the text with simulation time, entity
name, severity level, etc. There is a corresponding change in
ivtest to support this.

Conflicts:

	tgt-vhdl/cast.cc
	tgt-vhdl/display.cc
	tgt-vhdl/vhdl_syntax.cc
	tgt-vhdl/vhdl_target.h
2010-10-05 20:02:04 +01:00
Nick Gasson 9faaf5f817 Add VHDL report statement
Not output yet, but will be used to replace std.textio
implementation of $display.

Conflicts:

	tgt-vhdl/vhdl_syntax.cc
2010-10-05 20:00:16 +01:00
Nick Gasson 2187f30207 Reduce number of 0 ns waits in generated VHDL
Previous we generated a "wait for 0 ns" statement after
every blocking assignment that wasn't the last statement
in the process. While this implements the Verilog semantics,
it generates excessive waits, and cannot usually be synthesised.
This patch only generates "wait for 0 ns" statements when it
cannot be avoid (e.g. when the target of a blocking assignment
is read in the same process).

An example:

  begin
    x = 5;
    if (x == 2)
      y = 7;
  end

Becomes:

  x <= 5;
  wait for 0 ns;    -- Required to implement assignment semantics
  if x = 2 then
    y <= 7;         -- No need for wait here, not read
    -- wait for 0 ns  (previously)
  end if;

Conflicts:

	tgt-vhdl/process.cc
	tgt-vhdl/stmt.cc
	tgt-vhdl/vhdl_target.h
2010-10-05 19:59:25 +01:00
Stephen Williams ec49f10e2d Revert bad merge from vhdl branch 2010-10-02 11:02:27 -07:00
Nick Gasson 43f904f793 Add uwire support to VHDL backend
Implemented as std_ulogic which behaves almost identically.
2010-09-30 12:22:39 +01:00
Nick Gasson 48ae8c1ce5 Generate VHDL report statements for $display
This changes the implementation of $display/$write to use VHDL
report statements rather the the std.textio functions. The code
produced is simpler and more like what a real VHDL designed would
write. However it no longer exactly matches the Verilog output as
most VHDL simulators prepend the text with simulation time, entity
name, severity level, etc. There is a corresponding change in
ivtest to support this.
2010-08-24 22:13:08 +01:00
Nick Gasson 0cec4495ca Add VHDL report statement
Not output yet, but will be used to replace std.textio
implementation of $display.
2010-08-18 23:50:13 +01:00
Nick Gasson f9da800cf5 Reduce number of 0 ns waits in generated VHDL
Previous we generated a "wait for 0 ns" statement after
every blocking assignment that wasn't the last statement
in the process. While this implements the Verilog semantics,
it generates excessive waits, and cannot usually be synthesised.
This patch only generates "wait for 0 ns" statements when it
cannot be avoid (e.g. when the target of a blocking assignment
is read in the same process).

An example:

  begin
    x = 5;
    if (x == 2)
      y = 7;
  end

Becomes:

  x <= 5;
  wait for 0 ns;    -- Required to implement assignment semantics
  if x = 2 then
    y <= 7;         -- No need for wait here, not read
    -- wait for 0 ns  (previously)
  end if;
2010-08-17 22:49:27 +01:00
Nick Gasson 406d3936af Add find_vars method to VHDL syntax objects
Finds set of read and written variables. For use in
post-processing the syntax tree for cleanup.
2010-08-17 22:49:27 +01:00
Nick Gasson 0d6b42885b Reduce superflous parens in generated VHDL
Purely cosmetic, replaces output like:

  if (x + foo(x + (2 * y))) then ...

With:

  if x + foo(x + (2 * y)) then ...
2010-08-17 22:49:27 +01:00
Cary R 86653ddff9 Remove some cppcheck warnings.
This patch modifies the code to remove some more cppcheck warnings.
2010-07-30 18:50:52 -07:00
Cary R c0a592bec2 Don't place a trailing ',' after the last enum item.
The SunPro compiler does not like having a ',' after the last
enum item.
2010-05-13 18:56:44 -07:00
Nick Gasson 9c568d8f47 VHDL: ensure with-select statement choices completely cover input space
Newer versions of GHDL seem to be stricter when checking this than
older versions. ModelSim still accepts an incomplete with-select,
however.

This patch makes the output 'U' if none of the conditions match.
2009-12-14 12:01:27 -08:00
Cary R 3f12a401eb Add some casts in tgt-vhdl to remove warnings.
The Cygwin compiler is a bit picky. This patch adds some casts
to remove compilation warnings. In the past I have had warnings
off because of problems with the STL, but we may as well get
rid of the warnings we can. It also does not recognize that an
assert(0) or assert(false) ends a routine so it complains about
no return at end of function or variables not being defined.
2009-12-11 21:46:49 -08:00
Nick Gasson 64e85304b5 VHDL translation for timescale
This patch generates delays with the correct VHDL units. Taking
into account the source module's timescale and precision.
2009-02-23 16:23:56 -08:00
Nick Gasson 5660e67b8b Support IVL_EX_DELAY in VHDL target
This patch adds a translation of 64-bit delay expressions to
vhdl_const_time objects.
2009-02-23 15:30:51 -08:00
Nick Gasson f89f3dcbaf More VHDL naming fixes
This handles the cases where:
    * Instance names contain leading/trailing underscores
    * Instance names contain consecutive underscores
    * Module names contain consecutive underscores
    * Module names contain leading/trailing underscores
	* Ports may be inconsistently renamed
2009-02-02 19:41:50 -08:00
Nick Gasson 3dadedf9b5 Fix VHDL bug where constant is assigned to input
This fixes a bug where the VHDL target would not
map ports in cases where the port was driven by
a constant.
2009-01-28 17:45:24 -08:00
Nick Gasson babc9c1352 Various signal naming fixes for VHDL target
This avoids generating invalid VHDL signal names in the
following cases:
	- The name begins or ends with an underscore
	- The name contains two consecutive underscores
	- The name is the same as a component declaration
	- The name differs from another only in case
2009-01-28 17:44:14 -08:00
Nick Gasson 308688f190 VHDL fix concatenation of std_logics
This fixes an assertion failure when taking a slice of
the result of concatenating several single-element vectors.
2009-01-25 07:59:06 -08:00
Nick Gasson 69e91e4065 Fix various problems with VHDL `buffer' port generation
This patch corrects several bugs with the generation of
VHDL `buffer' ports. The code generator should now
generate a buffer only if the port needs to be read inside
the architecture, otherwise it will stay `out'.

This also correct a bug where an output port is connected
directly to the output of an instantiated component. Generating
`buffer's would work here, but a more idiomatic VHDL approach is
to declare an intermediate signal which both outputs are connected
to. This is implemented in the patch (fixes the regression of
readout.v in the testsuite).
2009-01-25 07:49:54 -08:00
Nick Gasson e5ce88304e Fix mapping of VHDL expressions to function arguments
Noticed this as part of the test case for pr2516774b. Under some
circumstances the input arguments would be cast to the wrong type.
This patch ensures that all the arguments have the correct type.
2009-01-22 17:39:50 -08:00
Nick Gasson 3cc2018346 Emit VHDL hex constants for some unsigned bits strings
This patch changes the output of VHDL unsigned bit strings
which are 4, 8, 16, 32, or 64 bits to use VHDL hex string
constants.

So the following:
  "00000001"
Becomes
  X"01"

Which is much easier to read
2009-01-22 17:39:41 -08:00
Nick Gasson 78bc4b5d47 Fix assignment to VHDL function arguments
This patch is a fix for pr2516774.

The idea is to generate a local variable inside
a function whenever an argument is assigned to. The
variable has an initial value of the argument value
and is used in its place for the remainder of the
function. This patch also handles the case where the
argument is assigned to inside a while loop.
2009-01-19 19:50:48 -08:00
Nick Gasson ede6acca77 Store only a single VHDL entity for each Verilog module 2009-01-17 09:19:57 -08:00
Nick Gasson 6047eab005 Try to generate VHDL sensitivity lists whereever possible
This patch generates VHDL sensitivity lists for sequential
as well as combinatorial processes which do not contain
a wait statement. Otherwise it falls back on the original
wait-on/until behaviour.

This should make the generated VHDL more acceptable to
synthesisers.
2009-01-06 20:33:21 -08:00
Nick Gasson 19720a0f9d Prefer sensitivity list for VHDL combinatorial processes
This patch generates a sensitivity list for combinatorial
VHDL processes if they don't contain a wait statement, and
a wait-on statement if they do contain another wait statement.

This should help synthesisers correctly identifier
level-sensitive latches.
2009-01-06 20:33:08 -08:00
Nick Gasson 4f4191ecdd Add VHDL flag to specify maximum module depth
Specifying -pdepth=N only outputs entities that correspond
to Verilog modules found at depth < N in the hierarchy.

Setting -pdepth=0 (the default) outputs all entities.

This is for feature request 2391457
2008-12-16 09:05:33 -08:00
Nick Gasson 651d208451 Remove some uneccessary zero-time waits from VHDL outputs
This patch optimises away straight line sequences like:

wait for 0 ns;
wait for X ns;

to:

wait for X ns;

This tidies up the output a bit.

It also has the effect of removing all code from initial
processes where the assignments have been extracted as
VHDL signal intialisers. (c.f. pr2391337)
2008-12-07 16:53:47 -08:00
Nick Gasson d689c93879 Rework VHDL assignment statement generation
This changes the assignment statement generator so that
each VHDL declaration "knows" which type of assignment
statement can/should be used on (i.e. signals must be
assigned with <=). This will help us catch cases when
we try to use, for example, := with signals. This occurs
in pr2362211 where we try to assign to a signal within
a function (where only := can be used).
2008-12-07 16:49:57 -08:00
Larry Doolittle 4948875230 Allow building with gcc-4.4
With this small patch, building succeeds with Debian's current gcc-snapshot,
gcc (Debian 20081130-1) 4.4.0 20081130 (experimental) [trunk revision 142292]

That gcc also warns about the remaining #idents in
  vvp/concat.cc
  vvp/dff.h

The resulting build shows some regressions in the test suite, that
I am still investigating.  The patch does not break building, or show
test suite regressions, with gcc-4.3.
2008-12-05 20:48:25 -08:00
Nick Gasson a47b7352b4 Add casex/z support
A casex statement cannot be directly translated to a VHDL case
statement as VHDL does not treat the don't-care bit as special.
The solution here is to generate an if statement from the casex
which compares only the non-don't-care bit positions.
2008-10-14 20:16:10 +01:00
Nick Gasson a7cbb38248 Fix resizing of constant bit vectors
Emitting a VHDL expression like Resize("01", 32) is ambiguous
between interpreting "01" as a Signed or an Unsigned. There's
no point actually outputting this as we can sign-extend the
constant value in the code generator, which is what this
patch does.
2008-10-05 13:49:07 +01:00
Nick Gasson e5343ef73f Implement arithmetic right shift >>>
This is currently implemented using the numeric_std
shift_right function as the sra operator is not defined on
signed/unsigned types before VHDL-2006.
2008-09-13 15:23:42 +01:00
Nick Gasson 2516d63805 A basic translation of the Verilog power operator to VHDL
The exponentiation operator in VHDL is not defined for numeric_std
types. We can get around this by converting the operands to integers,
performing the operation, then converting the result back to the
original type. This will work OK in simulation but certainly will not
synthesise unless the operands are constant.

However, even this does not work quite correctly. The Integer type in
VHDL is signed and usually only 32 bits, therefore any result larger
than this will overflow and raise an exception. I can't see a way
around this at the moment.
2008-09-12 20:19:22 +01:00
Nick Gasson b5e65ac9ed Refactor and clean up cast.cc
This splits up the monolithic and confusing vhdl_expr::cast function into
several smaller to_XXX functions which each generate code to cast an 
expression to type XXX. This makes it much easier to understand and maintain.
2008-08-27 16:47:07 +01:00
Nick Gasson cb1d4fd278 Amend inaccurate comment 2008-08-18 16:15:05 +01:00
Nick Gasson e1deba51ab Handle BUFIF logic when vector inputs 2008-08-18 15:48:07 +01:00
Nick Gasson a577ee447b Generate process for sequential UDPs 2008-08-13 17:03:03 +01:00
Nick Gasson c404b761b7 Change `out' ports to `buffer' when the signal is read
Previously this was handled by creating an internal
signal that was connected to the output and could also
be read inside the entity. The correct solution is to
make the output `buffer' rather than `out'. However, this
does not work in the case when an output is connected to
an output of a child entity, and that values is read
in the parent. In this case *both* the outputs of the child
and the parent need to be made `buffer'.
2008-08-11 20:48:28 +01:00
Nick Gasson 9d7e4ac15f Allow delays in combinatorial UDPs
Add a `after' clause to the `with .. select' statement.
2008-08-11 20:36:09 +01:00
Nick Gasson 01bf741983 Implement combinatorial UDPs
Using a `with .. select' statement
2008-08-11 13:23:50 +01:00
Nick Gasson bf3734110e Add VHDL syntax element for `with .. select' statement
This will be used to implement combinatorial UDPs
2008-08-11 13:09:52 +01:00
Nick Gasson 8e0bf3ebff Add conversion from std_logic to (un)signed types
Implemented using the expression (0 => X, others => '0')
2008-08-10 11:22:23 +01:00
Nick Gasson e4d0a92d7c Division and modulus operators 2008-08-07 14:18:26 +01:00