Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support inserting package symbols underneath module symbols #474

Closed
veripoolbot opened this issue Apr 2, 2012 · 7 comments
Closed

Support inserting package symbols underneath module symbols #474

veripoolbot opened this issue Apr 2, 2012 · 7 comments
Assignees
Labels
resolution: fixed Closed; fixed type: feature-IEEE Request to add new feature, described in IEEE 1800

Comments

@veripoolbot
Copy link
Contributor


Author Name: Alex Solomatnikov
Original Redmine Issue: 474 from https://www.veripool.org
Original Date: 2012-04-02
Original Assignee: Wilson Snyder (@wsnyder)


Source code line:

package functions;
         localparam MEM_INIT_STRING_LENGTH = 512;
         localparam MAX_STRING_LENGTH = 20;
...
endpackage

module a
...
// synthesis translate off
import functions::*;
// synthesis translate on
...
localparam MAX_STRING_LENGTH             = 20;

Backtrace:

 {d4} w0  functions  L3 [LIB]
     1:2: VAR 0xadbd80  {d5} w0  MEM_INIT_STRING_LENGTH LPARAM
     1:2:1: BASICDTYPE 0xad9c60  {d5} w1  logic kwd=logic [IMPLICIT]
     1:2:3: CONST 0xadd5d0  {d5} swu32/10  ?32?sh200
     1:2: VAR 0xadd720  {d6} w0  MAX_STRING_LENGTH LPARAM
     1:2:1: BASICDTYPE 0xadde70  {d6} w1  logic kwd=logic [IMPLICIT]
     1:2:3: CONST 0xad9df0  {d6} swu32/5  ?32?sh14
...
     1: MODULE 0xcc7930  {d1251} w0  a  L3
...
     1:2: PACKAGEIMPORT 0xcf4210  {d1480} w0  * -> PACKAGE 0xadd9e0  {d4} w0  functions  L3 [LIB]
...
     1:2: VAR 0xcf7f90  {d1514} w0  MAX_STRING_LENGTH LPARAM

```


@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2012-04-02T23:43:21Z


It really should say "unsupported". Currently imports are handled by pulling the symbols into the local module, which isn't proper, but works in most cases. This could be specialized to avoid importing symbols of the same name, but that's still incorrect as the localparam could have a different value inside the package. Therefore package imports need to added as a special scope, or special import cross references, name by name.

Note this is broken in Verilog-Perl too; though someone is unlikely to notice unless the conflicting symbol is in one place a data type, and a var in the other.

Added t_package_ddecl test to work on later.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Alex Solomatnikov
Original Date: 2012-04-03T01:14:57Z


It looks like there is a related problem: localparam defined inside package cannot be used in function defined inside the same package:

package functions;
         localparam MAX_STRING_LENGTH = 20;

         function [8*3:1] get_time_unit;
                 input [8*MAX_STRING_LENGTH:1] time_string;

                 integer index;
                 reg [8*3:1] time_unit;

                 begin
                         index = 0;
                         time_unit = "";

                         for (index = 1; index <= MAX_STRING_LENGTH; index = index + 1)
...
                         get_time_unit = time_unit;
                 end
         endfunction
...
         function integer is_period;
                 input [8*MAX_STRING_LENGTH:1] time_string;
...
endpackage

module generic_a
#(
...
         parameter output_clock_frequency = "0 ps",
...
) (
         input wire          refclk,
         input wire          rst,
...
);
         import functions::*;
localparam output_clock_as_period = is_period(output_clock_frequency);
...


I get 2 errors:

%Error: ...: Expecting expression to be constant, but can't determine constant for FUNCREF 'is_period'
%Error: ...: ... Location of non-constant VARREF 'MAX_STRING_LENGTH': Language violation: reference to non-function-local variable

The first is on localparam output_clock_as_period = is_period(

The second is on for (index = 1; index <= MAX_STRING_LENGTH; index = index + 1)

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Alex Solomatnikov
Original Date: 2012-05-04T00:23:38Z


Another example:

package verbosity_pkg;
    
    typedef enum int {VERBOSITY_NONE, 
		     VERBOSITY_FAILURE, 
		     VERBOSITY_ERROR, 
		     VERBOSITY_WARNING, 
		     VERBOSITY_INFO,
		     VERBOSITY_DEBUG} Verbosity_t;

    Verbosity_t  verbosity = VERBOSITY_INFO;
    string 	message = "";
...
endpackage


module a_clock_source (clk);
    output clk;

    parameter CLOCK_RATE = 10;  // clock rate in MHz

// synthesis translate_off
    import verbosity_pkg::*;

    localparam HALF_CLOCK_PERIOD   = 1000.000000/CLOCK_RATE/2; // half clock period in ns
    
    logic clk = 1'b0;

    string message   = "*uninitialized*";
...

verilator error:

%Error: Internal Error: ...: ../V3SymTable.h:60: Inserting two symbols with same name: message

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2012-07-31T22:57:34Z


In 3.840.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Alex Solomatnikov
Original Date: 2012-07-31T23:04:37Z


Was this issue really fixed?

Changes file says about different issue:

Fix parameters not supported in constant functions, #�. [Alex Solomatnikov]

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2012-07-31T23:24:02Z


You are right, the bug fixed was part of your test case but not the main point, which remains unresolved.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2013-01-15T04:40:42Z


This was fixed in 3.844 as part of #�.

@veripoolbot veripoolbot added resolution: fixed Closed; fixed type: feature-IEEE Request to add new feature, described in IEEE 1800 labels Dec 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution: fixed Closed; fixed type: feature-IEEE Request to add new feature, described in IEEE 1800
Projects
None yet
Development

No branches or pull requests

2 participants