Issue #474
Support inserting package symbols underneath module symbols
| Status: | Closed | Start date: | 04/02/2012 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | Wilson Snyder | % Done: | 0% |
|
| Category: | Unsupported | |||
| Target version: | - |
Description
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:
Tree file:
<pre>
1: PACKAGE 0xadd9e0 <e526245> {d4} w0 functions L3 [LIB]
1:2: VAR 0xadbd80 <e4> {d5} w0 MEM_INIT_STRING_LENGTH LPARAM
1:2:1: BASICDTYPE 0xad9c60 <e5> {d5} w1 logic kwd=logic [IMPLICIT]
1:2:3: CONST 0xadd5d0 <e7> {d5} swu32/10 ?32?sh200
1:2: VAR 0xadd720 <e13> {d6} w0 MAX_STRING_LENGTH LPARAM
1:2:1: BASICDTYPE 0xadde70 <e10> {d6} w1 logic kwd=logic [IMPLICIT]
1:2:3: CONST 0xad9df0 <e12> {d6} swu32/5 ?32?sh14
...
1: MODULE 0xcc7930 <e526246> {d1251} w0 a L3
...
1:2: PACKAGEIMPORT 0xcf4210 <e16910> {d1480} w0 * -> PACKAGE 0xadd9e0 <e526245> {d4} w0 functions L3 [LIB]
...
1:2: VAR 0xcf7f90 <e11731> {d1514} w0 MAX_STRING_LENGTH LPARAM
</pre>
History
Updated by Wilson Snyder about 1 year ago
- Subject changed from %Error: Internal Error: ...: ../V3SymTable.h:60: Inserting two symbols with same name: MAX_STRING_LENGTH to Support inserting package symbols underneath module symbols
- Category set to Unsupported
- Status changed from New to Feature
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.
Updated by Alex Solomatnikov about 1 year ago
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)
Updated by Alex Solomatnikov about 1 year ago
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
Updated by Alex Solomatnikov 10 months ago
Was this issue really fixed?
Changes file says about different issue:
Fix parameters not supported in constant functions, bug474. [Alex Solomatnikov]
Updated by Wilson Snyder 10 months ago
- Status changed from Closed to Feature
You are right, the bug fixed was part of your test case but not the main point, which remains unresolved.
Updated by Wilson Snyder 4 months ago
- Status changed from Feature to Closed
- Assignee set to Wilson Snyder
This was fixed in 3.844 as part of bug591.
Also available in: Atom
![[logo]](/img/veripool_small.png)