From 97d2389cb09b8a5be8838c7ec2c4cc1321c25d13 Mon Sep 17 00:00:00 2001 From: Jared Casper Date: Sat, 20 Nov 2010 18:25:47 -0800 Subject: [PATCH] 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. --- parse.y | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/parse.y b/parse.y index a6bc54cf2..7bc27cee2 100644 --- a/parse.y +++ b/parse.y @@ -3463,6 +3463,19 @@ dimensions tmp->push_back(index); $$ = tmp; } + | '[' expression ']' + { if (generation_flag < GN_VER2005_SV) { + warn_count += 1; + cerr << @2 << ": warning: Use of SystemVerilog [size] dimension. " + << "Use at least -g2005-sv to remove this warning." << endl; + } + list *tmp = new list; + index_component_t index; + index.msb = new PENumber(new verinum((uint64_t)0, integer_width)); + index.lsb = new PEBinary('-', $2, new PENumber(new verinum((uint64_t)1, integer_width))); + tmp->push_back(index); + $$ = tmp; + } | dimensions '[' expression ':' expression ']' { list *tmp = $1; index_component_t index; @@ -3471,6 +3484,19 @@ dimensions tmp->push_back(index); $$ = tmp; } + | dimensions '[' expression ']' + { if (generation_flag < GN_VER2005_SV) { + warn_count += 1; + cerr << @2 << ": warning: Use of SystemVerilog [size] dimension. " + << "Use at least -g2005-sv to remove this warning." << endl; + } + list *tmp = $1; + index_component_t index; + index.msb = new PENumber(new verinum((uint64_t)0, integer_width)); + index.lsb = new PEBinary('-', $3, new PENumber(new verinum((uint64_t)1, integer_width))); + tmp->push_back(index); + $$ = tmp; + } /* This is used to express the return type of a function. */ function_range_or_type_opt