-
Notifications
You must be signed in to change notification settings - Fork 897
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4069 from daglem/simplify-array-slice-assignment
Simplify and correct array slice assignment
- Loading branch information
Showing
2 changed files
with
61 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module test ( | ||
offset_i, | ||
data_o, | ||
data_ref_o | ||
); | ||
input wire [ 2:0] offset_i; | ||
output reg [15:0] data_o; | ||
output reg [15:0] data_ref_o; | ||
|
||
always @(*) begin | ||
// defaults | ||
data_o = '0; | ||
data_ref_o = '0; | ||
|
||
// partial assigns | ||
data_ref_o[offset_i+:4] = 4'b1111; // unsigned | ||
data_o[offset_i+:4] = 1'sb1; // sign extension to 4'b1111 | ||
end | ||
|
||
endmodule |