Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8975421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:52:38+00:00 2026-06-15T18:52:38+00:00

I am trying to port some SystemVerilog code to C++/SystemC, and am a bit

  • 0

I am trying to port some SystemVerilog code to C++/SystemC, and am a bit stuck on a couple lines where I see strange array indexing. Here is a simplified version of what I see.

typedef enum bit [2:0] {enu_red, enu_blue, enu_green} typ_enum; 

typedef struct packed {
    bit [3:0] field1;
    bit [3:0] field2;
} typ_struct;

...

var int arr_ints[typ_struct];
var int que_ints[$];

typ_struct obj_struct;
typ_enum   obj_enum;

int i = 3;

// assume all the declared variables hold valid values at this point
// also assume que_ints[i] is valid

if ((!arr_ints[obj_struct][1]) // these two lines are the problem
    && (que_ints[i][obj_struct])
)
begin
    // do something
end

Now after I port this code I get some compiler errors which I completely understand, because the original code doesn’t look exactly right to me. In the first line of the if statement, it looks like trying to index an integer type with a boolean value. In the second it looks like trying to index an integer type with an enumerated value. Yet this code apparently works. Can someone please explain what it is doing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:52:39+00:00Added an answer on June 15, 2026 at 6:52 pm

    This does bit slicing of the integer type. You will access the actual bits of the underlying int representation.

    If que_ints[5] is integer 0xdeadbeef, then:

    • que_ints[5][3] is 1
    • que_ints[5][7:4] is 0xe.

    In SystemC the range() function is the corollary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to port some code to 64-bit, but it seems that the thread
I'm trying to port some Java code, which requires arithmetic and logical bit shifts,
I am trying to port some Android 2.x code to Android 1.5, here is
I am trying to port some C Code but I am really stuck cause
I am trying to port some code form java do F# that generates a
I'm trying to port some Windows code to Linux, ideally through platform-independent libraries (eg
I'm trying to port some of my c++ code into c. I have the
I am trying to port some code using DevExpress XtraGrid to Wpf. What is
I am trying to port some C++ code from Windows to Solaris(Unix). There are
I'm trying to port some C++ code to C#, and one of the things

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.