SystemVerilog syntax code help

Status
Not open for further replies.

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.
 

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),
 

    hcu

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…