From 2b5c82d141a6ee46cc08f22cb1fc8fbf7d296a80 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 9 Apr 2012 16:00:08 -0700 Subject: [PATCH 1/2] SystemVerilog unbased literals cannot take a size. The SystemVerilog unbased literals (e.g. '0, '1, etc.) are expected to be used standalone and cannot take a size. This patch modifies the parsing code to give a good error message when this is done. --- lexor.lex | 7 +++++-- parse.y | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lexor.lex b/lexor.lex index 64d6f2e3c..0c4bc92d3 100644 --- a/lexor.lex +++ b/lexor.lex @@ -4,7 +4,7 @@ %{ /* - * Copyright (c) 1998-2011 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2012 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -377,8 +377,11 @@ TU [munpf] << "Using SystemVerilog 'N bit vector. Use at least " << "-g2005-sv to remove this warning." << endl; } + generation_t generation_save = generation_flag; + generation_flag = GN_VER2005_SV; yylval.number = make_unsized_binary(yytext); - return BASED_NUMBER; } + generation_flag = generation_save; + return UNBASED_NUMBER; } [0-9][0-9_]* { yylval.number = make_unsized_dec(yytext); diff --git a/parse.y b/parse.y index 6b97c6364..a777700df 100644 --- a/parse.y +++ b/parse.y @@ -386,7 +386,7 @@ static void current_function_set_statement(const YYLTYPE&loc, vector %token TYPE_IDENTIFIER %token DISCIPLINE_IDENTIFIER %token PATHPULSE_IDENTIFIER -%token BASED_NUMBER DEC_NUMBER +%token BASED_NUMBER DEC_NUMBER UNBASED_NUMBER %token REALTIME %token K_PLUS_EQ K_MINUS_EQ K_INCR K_DECR %token K_LE K_GE K_EG K_EQ K_NE K_CEQ K_CNE K_LP K_LS K_RS K_RSS K_SG @@ -1231,6 +1231,12 @@ number : BASED_NUMBER | DEC_NUMBER BASED_NUMBER { $$ = pform_verinum_with_size($1,$2, @2.text, @2.first_line); based_size = 0; } + | UNBASED_NUMBER + { $$ = $1; based_size = 0;} + | DEC_NUMBER UNBASED_NUMBER + { yyerror(@1, "error: Unbased SystemVerilog literal cannot have " + "a size."); + $$ = $1; based_size = 0;} ; open_range_list /* IEEE1800-2005 A.2.11 */ From bb1036b55c924a6070aab92289867edf2b24b7fb Mon Sep 17 00:00:00 2001 From: Larry Doolittle Date: Fri, 6 Apr 2012 16:38:38 -0700 Subject: [PATCH 2/2] Spelling refresh --- elab_lval.cc | 2 +- ivl_target.h | 2 +- lexor.lex | 2 +- netmisc.h | 2 +- parse.y | 2 +- pform.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/elab_lval.cc b/elab_lval.cc index b10656442..2cfb98016 100644 --- a/elab_lval.cc +++ b/elab_lval.cc @@ -200,7 +200,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des, // Special case: The l-value is an entire memory, or array // slice. This is, in fact, an error in l-values. Detect the - // situation by noting if the index count is less then the + // situation by noting if the index count is less than the // array dimensions (unpacked). if (reg->array_dimensions() > name_tail.index.size()) { cerr << get_fileline() << ": error: Cannot assign to array " diff --git a/ivl_target.h b/ivl_target.h index 32eb0e307..fddcf86f5 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -1800,7 +1800,7 @@ extern int ivl_scope_time_units(ivl_scope_t net); * dimension. * * The ivl_signal_msb/ivl_signal_lsb functions are deprecated - * versions that only work with variables that have less then two + * versions that only work with variables that have less than two * dimensions. They will return msb==lsb==0 for scalars. * * ivl_signal_port diff --git a/lexor.lex b/lexor.lex index 0c4bc92d3..01a891437 100644 --- a/lexor.lex +++ b/lexor.lex @@ -309,7 +309,7 @@ TU [munpf] } } - /* If this identifer names a previously declared type, then + /* If this identifier names a previously declared type, then return this as a TYPE_IDENTIFIER instead. */ if (rc == IDENTIFIER && gn_system_verilog()) { if (data_type_t*type = pform_test_type_identifier(yylval.text)) { diff --git a/netmisc.h b/netmisc.h index 5e96d3c8d..7f34131fa 100644 --- a/netmisc.h +++ b/netmisc.h @@ -130,7 +130,7 @@ extern NetExpr *normalize_variable_part_base(const list&indices, NetExpr*b unsigned long wid, bool is_up); /* * Calculate a canonicalizing expression for a slice select. The - * indices array is less then needed to fully address a bit, so the + * indices array is less than needed to fully address a bit, so the * result is a slice of the packed array. The return value is an * expression that gets to the base of the slice, and (lwid) becomes * the width of the slice, in bits. For example: diff --git a/parse.y b/parse.y index a777700df..792f36508 100644 --- a/parse.y +++ b/parse.y @@ -672,7 +672,7 @@ class_identifier ; /* The endname after a class declaration is a little tricky because - the class name is detected by the lexor as a TYPE_IDENTIFER if it + the class name is detected by the lexor as a TYPE_IDENTIFIER if it does indeed match a name. */ class_declaration_endname_opt : ':' TYPE_IDENTIFIER diff --git a/pform.h b/pform.h index 941f5f7d3..d3e51bf93 100644 --- a/pform.h +++ b/pform.h @@ -400,7 +400,7 @@ extern svector*pform_make_task_ports(const struct vlltype&loc, /* * The parser uses this function to convert a unary - * increment/decrement expression to the equivilent compressed + * increment/decrement expression to the equivalent compressed * assignment statement. */ extern PAssign* pform_compressed_assign_from_inc_dec(const struct vlltype&loc,