Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SystemVerilog syntax code help

Status
Not open for further replies.

hcu

Advanced Member level 4
Full Member level 1
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.
 

ads-ee

Super Moderator
Staff member
Advanced Member level 7
Joined
Sep 10, 2013
Messages
7,938
Helped
1,822
Reputation
3,654
Reaction score
1,806
Trophy points
1,393
Location
USA
Activity points
60,160
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top