2019-07-24 12:49:09 -05:00
|
|
|
/*
|
|
|
|
* yosys -- Yosys Open SYnthesis Suite
|
|
|
|
*
|
2021-06-07 17:39:36 -05:00
|
|
|
* Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com>
|
2019-07-24 12:49:09 -05:00
|
|
|
* 2019 Eddie Hung <eddie@fpgeh.com>
|
2021-06-07 17:39:36 -05:00
|
|
|
* 2019 David Shah <dave@ds0.me>
|
2019-07-24 12:49:09 -05:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* ---
|
|
|
|
*
|
|
|
|
* Tech-mapping rules for decomposing arbitrarily-sized $mul cells
|
|
|
|
* into an equivalent collection of smaller `DSP_NAME cells (with the
|
|
|
|
* same interface as $mul) no larger than `DSP_[AB]_MAXWIDTH, attached
|
|
|
|
* to $shl and $add cells.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-07-08 09:40:12 -05:00
|
|
|
`ifndef DSP_A_MAXWIDTH
|
2019-08-13 12:21:24 -05:00
|
|
|
$fatal(1, "Macro DSP_A_MAXWIDTH must be defined");
|
2019-07-08 09:40:12 -05:00
|
|
|
`endif
|
2019-07-16 17:55:13 -05:00
|
|
|
`ifndef DSP_B_MAXWIDTH
|
2019-08-13 12:21:24 -05:00
|
|
|
$fatal(1, "Macro DSP_B_MAXWIDTH must be defined");
|
|
|
|
`endif
|
|
|
|
`ifndef DSP_B_MAXWIDTH
|
|
|
|
$fatal(1, "Macro DSP_B_MAXWIDTH must be defined");
|
|
|
|
`endif
|
|
|
|
`ifndef DSP_A_MAXWIDTH_PARTIAL
|
|
|
|
`define DSP_A_MAXWIDTH_PARTIAL `DSP_A_MAXWIDTH
|
|
|
|
`endif
|
|
|
|
`ifndef DSP_B_MAXWIDTH_PARTIAL
|
|
|
|
`define DSP_B_MAXWIDTH_PARTIAL `DSP_B_MAXWIDTH
|
2019-07-16 17:55:13 -05:00
|
|
|
`endif
|
2019-07-08 09:40:12 -05:00
|
|
|
|
|
|
|
`ifndef DSP_NAME
|
2019-08-13 12:21:24 -05:00
|
|
|
$fatal(1, "Macro DSP_NAME must be defined");
|
2019-07-08 09:40:12 -05:00
|
|
|
`endif
|
|
|
|
|
|
|
|
`define MAX(a,b) (a > b ? a : b)
|
|
|
|
`define MIN(a,b) (a < b ? a : b)
|
|
|
|
|
2019-09-25 19:24:11 -05:00
|
|
|
(* techmap_celltype = "$mul $__mul" *)
|
2019-08-13 12:21:24 -05:00
|
|
|
module _80_mul (A, B, Y);
|
2019-07-08 09:40:12 -05:00
|
|
|
parameter A_SIGNED = 0;
|
|
|
|
parameter B_SIGNED = 0;
|
|
|
|
parameter A_WIDTH = 1;
|
|
|
|
parameter B_WIDTH = 1;
|
|
|
|
parameter Y_WIDTH = 1;
|
|
|
|
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-08 09:40:12 -05:00
|
|
|
input [A_WIDTH-1:0] A;
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-08 09:40:12 -05:00
|
|
|
input [B_WIDTH-1:0] B;
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-08 09:40:12 -05:00
|
|
|
output [Y_WIDTH-1:0] Y;
|
|
|
|
|
2019-09-25 19:25:44 -05:00
|
|
|
parameter _TECHMAP_CELLTYPE_ = "";
|
|
|
|
|
2019-07-08 09:40:12 -05:00
|
|
|
generate
|
2019-08-13 12:21:24 -05:00
|
|
|
if (0) begin end
|
|
|
|
`ifdef DSP_A_MINWIDTH
|
|
|
|
else if (A_WIDTH < `DSP_A_MINWIDTH)
|
|
|
|
wire _TECHMAP_FAIL_ = 1;
|
|
|
|
`endif
|
|
|
|
`ifdef DSP_B_MINWIDTH
|
|
|
|
else if (B_WIDTH < `DSP_B_MINWIDTH)
|
|
|
|
wire _TECHMAP_FAIL_ = 1;
|
|
|
|
`endif
|
|
|
|
`ifdef DSP_Y_MINWIDTH
|
|
|
|
else if (Y_WIDTH < `DSP_Y_MINWIDTH)
|
|
|
|
wire _TECHMAP_FAIL_ = 1;
|
|
|
|
`endif
|
2019-08-01 16:29:00 -05:00
|
|
|
`ifdef DSP_SIGNEDONLY
|
2019-09-25 19:26:47 -05:00
|
|
|
else if (_TECHMAP_CELLTYPE_ == "$mul" && !A_SIGNED && !B_SIGNED)
|
2019-08-01 16:29:00 -05:00
|
|
|
\$mul #(
|
|
|
|
.A_SIGNED(1),
|
|
|
|
.B_SIGNED(1),
|
|
|
|
.A_WIDTH(A_WIDTH + 1),
|
|
|
|
.B_WIDTH(B_WIDTH + 1),
|
2019-08-01 16:33:16 -05:00
|
|
|
.Y_WIDTH(Y_WIDTH)
|
2019-08-01 16:29:00 -05:00
|
|
|
) _TECHMAP_REPLACE_ (
|
|
|
|
.A({1'b0, A}),
|
|
|
|
.B({1'b0, B}),
|
2019-08-01 16:33:16 -05:00
|
|
|
.Y(Y)
|
2019-08-01 16:29:00 -05:00
|
|
|
);
|
|
|
|
`endif
|
2019-09-25 19:25:44 -05:00
|
|
|
else if (_TECHMAP_CELLTYPE_ == "$mul" && A_WIDTH < B_WIDTH)
|
2019-07-31 17:45:41 -05:00
|
|
|
\$mul #(
|
|
|
|
.A_SIGNED(B_SIGNED),
|
|
|
|
.B_SIGNED(A_SIGNED),
|
|
|
|
.A_WIDTH(B_WIDTH),
|
|
|
|
.B_WIDTH(A_WIDTH),
|
|
|
|
.Y_WIDTH(Y_WIDTH)
|
|
|
|
) _TECHMAP_REPLACE_ (
|
|
|
|
.A(B),
|
|
|
|
.B(A),
|
|
|
|
.Y(Y)
|
|
|
|
);
|
2019-08-13 12:21:24 -05:00
|
|
|
else begin
|
|
|
|
wire [1023:0] _TECHMAP_DO_ = "proc; clean";
|
2019-07-08 09:40:12 -05:00
|
|
|
|
2019-07-18 12:53:18 -05:00
|
|
|
`ifdef DSP_SIGNEDONLY
|
2019-08-13 12:21:24 -05:00
|
|
|
localparam sign_headroom = 1;
|
2019-07-18 12:53:18 -05:00
|
|
|
`else
|
2019-08-13 12:21:24 -05:00
|
|
|
localparam sign_headroom = 0;
|
2019-07-18 12:53:18 -05:00
|
|
|
`endif
|
|
|
|
|
2019-08-13 12:21:24 -05:00
|
|
|
genvar i;
|
|
|
|
if (A_WIDTH > `DSP_A_MAXWIDTH) begin
|
|
|
|
localparam n = (A_WIDTH-`DSP_A_MAXWIDTH+`DSP_A_MAXWIDTH_PARTIAL-sign_headroom-1) / (`DSP_A_MAXWIDTH_PARTIAL-sign_headroom);
|
|
|
|
localparam partial_Y_WIDTH = `MIN(Y_WIDTH, B_WIDTH+`DSP_A_MAXWIDTH_PARTIAL);
|
|
|
|
localparam last_A_WIDTH = A_WIDTH-n*(`DSP_A_MAXWIDTH_PARTIAL-sign_headroom);
|
|
|
|
localparam last_Y_WIDTH = B_WIDTH+last_A_WIDTH;
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
if (A_SIGNED && B_SIGNED) begin : blk
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-08-13 12:21:24 -05:00
|
|
|
wire signed [partial_Y_WIDTH-1:0] partial [n-1:0];
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-22 15:01:26 -05:00
|
|
|
wire signed [last_Y_WIDTH-1:0] last_partial;
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-08-13 12:21:24 -05:00
|
|
|
wire signed [Y_WIDTH-1:0] partial_sum [n:0];
|
2019-07-18 15:11:26 -05:00
|
|
|
end
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
else begin : blk
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-18 15:11:26 -05:00
|
|
|
wire [partial_Y_WIDTH-1:0] partial [n-1:0];
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-22 15:01:26 -05:00
|
|
|
wire [last_Y_WIDTH-1:0] last_partial;
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-08-13 12:21:24 -05:00
|
|
|
wire [Y_WIDTH-1:0] partial_sum [n:0];
|
2019-07-18 15:11:26 -05:00
|
|
|
end
|
2019-07-08 09:40:12 -05:00
|
|
|
|
2019-09-26 00:58:55 -05:00
|
|
|
for (i = 0; i < n; i=i+1) begin:sliceA
|
2019-09-25 19:24:11 -05:00
|
|
|
\$__mul #(
|
2019-07-19 11:16:13 -05:00
|
|
|
.A_SIGNED(sign_headroom),
|
2019-09-25 19:24:11 -05:00
|
|
|
.B_SIGNED(B_SIGNED),
|
2019-08-13 12:21:24 -05:00
|
|
|
.A_WIDTH(`DSP_A_MAXWIDTH_PARTIAL),
|
2019-07-08 09:40:12 -05:00
|
|
|
.B_WIDTH(B_WIDTH),
|
2019-07-18 11:20:48 -05:00
|
|
|
.Y_WIDTH(partial_Y_WIDTH)
|
2019-09-26 00:58:55 -05:00
|
|
|
) mul (
|
2019-08-13 12:21:24 -05:00
|
|
|
.A({{sign_headroom{1'b0}}, A[i*(`DSP_A_MAXWIDTH_PARTIAL-sign_headroom) +: `DSP_A_MAXWIDTH_PARTIAL-sign_headroom]}),
|
2019-07-08 09:40:12 -05:00
|
|
|
.B(B),
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
.Y(blk.partial[i])
|
2019-07-08 09:40:12 -05:00
|
|
|
);
|
2019-07-26 17:30:51 -05:00
|
|
|
// TODO: Currently a 'cascade' approach to summing the partial
|
|
|
|
// products is taken here, but a more efficient 'binary
|
|
|
|
// reduction' approach also exists...
|
2019-08-13 12:21:24 -05:00
|
|
|
if (i == 0)
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
assign blk.partial_sum[i] = blk.partial[i];
|
2019-09-26 11:57:11 -05:00
|
|
|
else
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
assign blk.partial_sum[i] = (blk.partial[i] << (* mul2dsp *) i*(`DSP_A_MAXWIDTH_PARTIAL-sign_headroom)) + (* mul2dsp *) blk.partial_sum[i-1];
|
2019-07-08 09:40:12 -05:00
|
|
|
end
|
|
|
|
|
2019-09-25 19:24:11 -05:00
|
|
|
\$__mul #(
|
2019-07-08 09:40:12 -05:00
|
|
|
.A_SIGNED(A_SIGNED),
|
|
|
|
.B_SIGNED(B_SIGNED),
|
2019-08-01 12:01:43 -05:00
|
|
|
.A_WIDTH(last_A_WIDTH),
|
2019-07-08 09:40:12 -05:00
|
|
|
.B_WIDTH(B_WIDTH),
|
2019-07-22 15:01:26 -05:00
|
|
|
.Y_WIDTH(last_Y_WIDTH)
|
2019-09-26 00:58:55 -05:00
|
|
|
) sliceA.last (
|
2019-08-01 12:01:43 -05:00
|
|
|
.A(A[A_WIDTH-1 -: last_A_WIDTH]),
|
2019-07-08 09:40:12 -05:00
|
|
|
.B(B),
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
.Y(blk.last_partial)
|
2019-07-08 09:40:12 -05:00
|
|
|
);
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
assign blk.partial_sum[n] = (blk.last_partial << (* mul2dsp *) n*(`DSP_A_MAXWIDTH_PARTIAL-sign_headroom)) + (* mul2dsp *) blk.partial_sum[n-1];
|
|
|
|
assign Y = blk.partial_sum[n];
|
2019-07-08 09:40:12 -05:00
|
|
|
end
|
|
|
|
else if (B_WIDTH > `DSP_B_MAXWIDTH) begin
|
2019-08-13 12:21:24 -05:00
|
|
|
localparam n = (B_WIDTH-`DSP_B_MAXWIDTH+`DSP_B_MAXWIDTH_PARTIAL-sign_headroom-1) / (`DSP_B_MAXWIDTH_PARTIAL-sign_headroom);
|
|
|
|
localparam partial_Y_WIDTH = `MIN(Y_WIDTH, A_WIDTH+`DSP_B_MAXWIDTH_PARTIAL);
|
|
|
|
localparam last_B_WIDTH = B_WIDTH-n*(`DSP_B_MAXWIDTH_PARTIAL-sign_headroom);
|
|
|
|
localparam last_Y_WIDTH = A_WIDTH+last_B_WIDTH;
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
if (A_SIGNED && B_SIGNED) begin : blk
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-08-13 12:21:24 -05:00
|
|
|
wire signed [partial_Y_WIDTH-1:0] partial [n-1:0];
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-22 15:01:26 -05:00
|
|
|
wire signed [last_Y_WIDTH-1:0] last_partial;
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-08-13 12:21:24 -05:00
|
|
|
wire signed [Y_WIDTH-1:0] partial_sum [n:0];
|
2019-07-18 15:11:26 -05:00
|
|
|
end
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
else begin : blk
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-18 15:11:26 -05:00
|
|
|
wire [partial_Y_WIDTH-1:0] partial [n-1:0];
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-22 15:01:26 -05:00
|
|
|
wire [last_Y_WIDTH-1:0] last_partial;
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-08-13 12:21:24 -05:00
|
|
|
wire [Y_WIDTH-1:0] partial_sum [n:0];
|
2019-07-18 15:11:26 -05:00
|
|
|
end
|
2019-07-08 09:40:12 -05:00
|
|
|
|
2019-09-26 00:58:55 -05:00
|
|
|
for (i = 0; i < n; i=i+1) begin:sliceB
|
2019-09-25 19:24:11 -05:00
|
|
|
\$__mul #(
|
|
|
|
.A_SIGNED(A_SIGNED),
|
2019-07-19 11:16:13 -05:00
|
|
|
.B_SIGNED(sign_headroom),
|
2019-07-08 09:40:12 -05:00
|
|
|
.A_WIDTH(A_WIDTH),
|
2019-08-13 12:21:24 -05:00
|
|
|
.B_WIDTH(`DSP_B_MAXWIDTH_PARTIAL),
|
2019-07-18 11:20:48 -05:00
|
|
|
.Y_WIDTH(partial_Y_WIDTH)
|
2019-07-08 09:40:12 -05:00
|
|
|
) mul (
|
|
|
|
.A(A),
|
2019-08-13 12:21:24 -05:00
|
|
|
.B({{sign_headroom{1'b0}}, B[i*(`DSP_B_MAXWIDTH_PARTIAL-sign_headroom) +: `DSP_B_MAXWIDTH_PARTIAL-sign_headroom]}),
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
.Y(blk.partial[i])
|
2019-07-08 09:40:12 -05:00
|
|
|
);
|
2019-08-13 12:21:24 -05:00
|
|
|
// TODO: Currently a 'cascade' approach to summing the partial
|
2019-07-31 17:45:41 -05:00
|
|
|
// products is taken here, but a more efficient 'binary
|
|
|
|
// reduction' approach also exists...
|
2019-08-13 12:21:24 -05:00
|
|
|
if (i == 0)
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
assign blk.partial_sum[i] = blk.partial[i];
|
2019-09-26 11:57:11 -05:00
|
|
|
else
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
assign blk.partial_sum[i] = (blk.partial[i] << (* mul2dsp *) i*(`DSP_B_MAXWIDTH_PARTIAL-sign_headroom)) + (* mul2dsp *) blk.partial_sum[i-1];
|
2019-07-08 09:40:12 -05:00
|
|
|
end
|
|
|
|
|
2019-09-25 19:24:11 -05:00
|
|
|
\$__mul #(
|
2019-08-01 12:01:43 -05:00
|
|
|
.A_SIGNED(A_SIGNED),
|
|
|
|
.B_SIGNED(B_SIGNED),
|
|
|
|
.A_WIDTH(A_WIDTH),
|
|
|
|
.B_WIDTH(last_B_WIDTH),
|
|
|
|
.Y_WIDTH(last_Y_WIDTH)
|
2019-09-26 00:58:55 -05:00
|
|
|
) mul_sliceB_last (
|
2019-08-01 12:01:43 -05:00
|
|
|
.A(A),
|
|
|
|
.B(B[B_WIDTH-1 -: last_B_WIDTH]),
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
.Y(blk.last_partial)
|
2019-08-01 12:01:43 -05:00
|
|
|
);
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
assign blk.partial_sum[n] = (blk.last_partial << (* mul2dsp *) n*(`DSP_B_MAXWIDTH_PARTIAL-sign_headroom)) + (* mul2dsp *) blk.partial_sum[n-1];
|
|
|
|
assign Y = blk.partial_sum[n];
|
2019-07-08 09:40:12 -05:00
|
|
|
end
|
2019-08-13 12:21:24 -05:00
|
|
|
else begin
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
if (A_SIGNED) begin : blkA
|
2019-08-01 14:17:14 -05:00
|
|
|
wire signed [`DSP_A_MAXWIDTH-1:0] Aext = $signed(A);
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
end
|
|
|
|
else begin : blkA
|
2019-08-01 14:17:14 -05:00
|
|
|
wire [`DSP_A_MAXWIDTH-1:0] Aext = A;
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
end
|
|
|
|
if (B_SIGNED) begin : blkB
|
2019-08-01 14:17:14 -05:00
|
|
|
wire signed [`DSP_B_MAXWIDTH-1:0] Bext = $signed(B);
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
end
|
|
|
|
else begin : blkB
|
2019-08-01 14:17:14 -05:00
|
|
|
wire [`DSP_B_MAXWIDTH-1:0] Bext = B;
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
end
|
2019-08-01 14:17:14 -05:00
|
|
|
|
2019-07-18 17:37:35 -05:00
|
|
|
`DSP_NAME #(
|
|
|
|
.A_SIGNED(A_SIGNED),
|
|
|
|
.B_SIGNED(B_SIGNED),
|
2019-08-01 14:17:14 -05:00
|
|
|
.A_WIDTH(`DSP_A_MAXWIDTH),
|
|
|
|
.B_WIDTH(`DSP_B_MAXWIDTH),
|
|
|
|
.Y_WIDTH(`MIN(Y_WIDTH,`DSP_A_MAXWIDTH+`DSP_B_MAXWIDTH)),
|
2019-07-18 17:37:35 -05:00
|
|
|
) _TECHMAP_REPLACE_ (
|
verilog: significant block scoping improvements
This change set contains a number of bug fixes and improvements related to
scoping and resolution in generate and procedural blocks. While many of the
frontend changes are interdependent, it may be possible bring the techmap
changes in under a separate PR.
Declarations within unnamed generate blocks previously encountered issues
because the data declarations were left un-prefixed, breaking proper scoping.
The LRM outlines behavior for generating names for unnamed generate blocks. The
original goal was to add this implicit labelling, but doing so exposed a number
of issues downstream. Additional testing highlighted other closely related scope
resolution issues, which have been fixed. This change also adds support for
block item declarations within unnamed blocks in SystemVerilog mode.
1. Unlabled generate blocks are now implicitly named according to the LRM in
`label_genblks`, which is invoked at the beginning of module elaboration
2. The Verilog parser no longer wraps explicitly named generate blocks in a
synthetic unnamed generate block to avoid creating extra hierarchy levels
where they should not exist
3. The techmap phase now allows special control identifiers to be used outside
of the topmost scope, which is necessary because such wires and cells often
appear in unlabeled generate blocks, which now prefix the declarations within
4. Some techlibs required modifications because they relied on the previous
invalid scope resolution behavior
5. `expand_genblock` has been simplified, now only expanding the outermost
scope, completely deferring the inspection and elaboration of nested scopes;
names are now resolved by looking in the innermost scope and stepping outward
6. Loop variables now always become localparams during unrolling, allowing them
to be resolved and shadowed like any other identifier
7. Identifiers in synthetic function call scopes are now prefixed and resolved
in largely the same manner as other blocks
before: `$func$\func_01$tests/simple/scopes.blk.v:60$5$\blk\x`
after: `\func_01$func$tests/simple/scopes.v:60$5.blk.x`
8. Support identifiers referencing a local generate scope nested more
than 1 level deep, i.e. `B.C.x` while within generate scope `A`, or using a
prefix of a current or parent scope, i.e. `B.C.D.x` while in `A.B`, `A.B.C`,
or `A.B.C.D`
9. Variables can now be declared within unnamed blocks in SystemVerilog mode
Addresses the following issues: 656, 2423, 2493
2021-01-27 12:30:22 -06:00
|
|
|
.A(blkA.Aext),
|
|
|
|
.B(blkB.Bext),
|
2019-07-18 12:53:18 -05:00
|
|
|
.Y(Y)
|
2019-07-08 09:40:12 -05:00
|
|
|
);
|
|
|
|
end
|
2019-08-13 12:21:24 -05:00
|
|
|
end
|
2019-07-08 09:40:12 -05:00
|
|
|
endgenerate
|
|
|
|
endmodule
|
|
|
|
|
2019-09-25 19:24:11 -05:00
|
|
|
(* techmap_celltype = "$mul $__mul" *)
|
2019-08-13 12:21:24 -05:00
|
|
|
module _90_soft_mul (A, B, Y);
|
2019-07-19 13:39:24 -05:00
|
|
|
parameter A_SIGNED = 0;
|
|
|
|
parameter B_SIGNED = 0;
|
|
|
|
parameter A_WIDTH = 1;
|
|
|
|
parameter B_WIDTH = 1;
|
|
|
|
parameter Y_WIDTH = 1;
|
2019-07-08 09:40:12 -05:00
|
|
|
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-19 13:39:24 -05:00
|
|
|
input [A_WIDTH-1:0] A;
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-19 13:39:24 -05:00
|
|
|
input [B_WIDTH-1:0] B;
|
2020-05-18 11:15:03 -05:00
|
|
|
(* force_downto *)
|
2019-07-19 13:39:24 -05:00
|
|
|
output [Y_WIDTH-1:0] Y;
|
|
|
|
|
2019-07-19 22:20:33 -05:00
|
|
|
// Indirection necessary since mapping
|
|
|
|
// back to $mul will cause recursion
|
2019-07-19 13:39:24 -05:00
|
|
|
generate
|
2019-08-13 12:21:24 -05:00
|
|
|
if (A_SIGNED && !B_SIGNED)
|
|
|
|
\$__soft_mul #(
|
|
|
|
.A_SIGNED(A_SIGNED),
|
|
|
|
.B_SIGNED(1),
|
|
|
|
.A_WIDTH(A_WIDTH),
|
|
|
|
.B_WIDTH(B_WIDTH+1),
|
|
|
|
.Y_WIDTH(Y_WIDTH)
|
|
|
|
) _TECHMAP_REPLACE_ (
|
|
|
|
.A(A),
|
|
|
|
.B({1'b0,B}),
|
|
|
|
.Y(Y)
|
|
|
|
);
|
|
|
|
else if (!A_SIGNED && B_SIGNED)
|
|
|
|
\$__soft_mul #(
|
|
|
|
.A_SIGNED(1),
|
|
|
|
.B_SIGNED(B_SIGNED),
|
|
|
|
.A_WIDTH(A_WIDTH+1),
|
|
|
|
.B_WIDTH(B_WIDTH),
|
|
|
|
.Y_WIDTH(Y_WIDTH)
|
|
|
|
) _TECHMAP_REPLACE_ (
|
|
|
|
.A({1'b0,A}),
|
|
|
|
.B(B),
|
|
|
|
.Y(Y)
|
|
|
|
);
|
|
|
|
else
|
|
|
|
\$__soft_mul #(
|
|
|
|
.A_SIGNED(A_SIGNED),
|
|
|
|
.B_SIGNED(B_SIGNED),
|
|
|
|
.A_WIDTH(A_WIDTH),
|
|
|
|
.B_WIDTH(B_WIDTH),
|
|
|
|
.Y_WIDTH(Y_WIDTH)
|
|
|
|
) _TECHMAP_REPLACE_ (
|
|
|
|
.A(A),
|
|
|
|
.B(B),
|
|
|
|
.Y(Y)
|
|
|
|
);
|
2019-07-19 13:39:24 -05:00
|
|
|
endgenerate
|
|
|
|
endmodule
|