Add Proposal | Add Analysis | Edit Class, Environment, or Release |
Number | 450
|
Category | enhancement
|
Synopsis | Compressed Assignment Satements
|
State | open
|
Class | enhancement
|
Arrival-Date | Aug 26 2003
|
Originator | Stephen Williams <steve@icarus.com>
|
Release | 2001b
|
Environment |
|
Description |
It is common in behavioral Verilog code to write read-modify-write statements that read a variable, use it as an operand to a binary operator, then write the result back. I propose adding to Verilog the compressed assignment statements by extending the assignment statement BNF: Change A.6.2 Procedural blocks and assignments to add: compressed_assignment ::= variable_lvalue assign_type [delay_or_event_control] expression assign_type ::= += | -= | *= | /= | <<= | <<<= | >>= | >>>= | &= | |= | ^= | ~&= | ~|= | ~^= (The assign_type values are tokens, with no white space inside.) Change A.6.4 to include: statement := ... | { attribute_instance } compressed_assignment ; ... In all cases, the compressed assignment is a shorthand for the long form "lvalue = [delay_or_event_control] lvalue AOP expression". The rules for signedness of operands of the compressed assignment are the same as for the long form of the statement. The assignment behaves as a blocking assignment. If there is a delay_or_event_control, then the value is calculated as in the long form, to wit the value to be assigned is calculated first before the delay, and then, after the delay, the assignment completes and the statement completes. Examples: i += 1; x |= #(5) 'hff; hot <<= @(posedge clk) 1; NOTE: There should also be a non-blocking form, but I need to dream up a pretty syntax for it. "<+=" won't work because due to the existing "<<=" token. -- Steve Williams "The woods are lovely, dark and deep. steve at icarus.com But I have promises to keep, http://www.icarus.com and lines to code before I sleep, http://www.picturel.com And lines to code before I sleep." |
Fix |
|
Audit-Trail |
From: Shalom Bresticker <Shalom.Bresticker@motorola.com> To: Stephen Williams <steve@icarus.com> Cc: etf-bugs@boyd.com Subject: Re: enhancement/450: : Compressed Assignment Satements Date: Wed, 27 Aug 2003 14:56:28 +0300 I know C has that type of syntax, but I have always considered it to be one of the less readable features of the language. Here you are adding in the delay_or_event_control, which makes it even less readable. If you write "i += 1", then to read it, you should imagine the "i +" to be duplicated on the other side of the "=". I still don't like it, but at least the two sides are adjacent to each other. If you write "hot <<= @(posedge clk) 1", then the "hot <<" becomes duplicated far away, on the right hand edge of the statement. You have put a great distance between the operator << and its right-hand operand ("1"). > Examples: > i += 1; > x |= #(5) 'hff; > hot <<= @(posedge clk) 1; Shalom -- Shalom Bresticker Shalom.Bresticker@motorola.com Design & Reuse Methodology Tel: +972 9 9522268 Motorola Semiconductor Israel, Ltd. Fax: +972 9 9522890 POB 2208, Herzlia 46120, ISRAEL Cell: +972 50 441478 |
Unformatted |
|
Hosted by Boyd Technology