Jul 28, 2021 #1 H hcu Advanced Member level 4 Joined Feb 28, 2017 Messages 101 Helped 0 Reputation 0 Reaction score 0 Trophy points 16 Activity points 874 Hi, I have a doubt about the SystemVerilog code snippet. Code: sub_top #( ) inst_sub_top ( .count((VALUE[FACTOR-1:0] - {{(FACTOR-1){1'b0}},1'b1})), .dummy() ); where VALUE is a parameter defined as 4, while FACTOR is a local param which is a 2. How to understand this line ((VALUE[FACTOR-1:0] - {{(FACTOR-1){1'b0}},1'b1})) . Note: No syntax errors.
Hi, I have a doubt about the SystemVerilog code snippet. Code: sub_top #( ) inst_sub_top ( .count((VALUE[FACTOR-1:0] - {{(FACTOR-1){1'b0}},1'b1})), .dummy() ); where VALUE is a parameter defined as 4, while FACTOR is a local param which is a 2. How to understand this line ((VALUE[FACTOR-1:0] - {{(FACTOR-1){1'b0}},1'b1})) . Note: No syntax errors.
Jul 28, 2021 #2 ads-ee Super Moderator Staff member Joined Sep 10, 2013 Messages 7,944 Helped 1,822 Reputation 3,654 Reaction score 1,808 Trophy points 1,393 Location USA Activity points 60,208 Not sure how this is supposed to work with the given VALUE = 4 and FACTOR = 2 as the result ends up being -1. ((VALUE[FACTOR-1:0] - {{(FACTOR-1){1'b0}},1'b1})) VALUE[2-1:0] = VALUE[1:0] FACTOR-1 = 2-1 = 1 { {1{1'b0}}, 1'b1}, where {x,y} is concatenation of x and y The 1 in {1{x}} is the repeat value. e.g. {3{1'b0}} = 3'b000 in this case it is 1'b0 so the line means. .count (VALUE[1:0] - 2'b01), Upvote 0 Downvote
Not sure how this is supposed to work with the given VALUE = 4 and FACTOR = 2 as the result ends up being -1. ((VALUE[FACTOR-1:0] - {{(FACTOR-1){1'b0}},1'b1})) VALUE[2-1:0] = VALUE[1:0] FACTOR-1 = 2-1 = 1 { {1{1'b0}}, 1'b1}, where {x,y} is concatenation of x and y The 1 in {1{x}} is the repeat value. e.g. {3{1'b0}} = 3'b000 in this case it is 1'b0 so the line means. .count (VALUE[1:0] - 2'b01),