1

I'm trying to assignment logic l_data[31:0]; to byte data[];.

data = l_data; is not legal SystemVerilog assignment. How can it be done?

1
  • data is 8 bits l_data is 32 bits wide. Which bits of l_data do you want to assign to data? Commented Jan 1, 2014 at 20:26

1 Answer 1

5

Use a bit-stream cast (section 6.24.3 of the IEEE Std 1800-2012 LRM). You will need to create a typedef for the cast, but it is a good idea to use typedefs for all your variable declarations anyways.

typedef byte unsigned dynamic_byte_array_t[];
typedef logic fixed_logic_array_t[31:0];

dynamic_byte_array_t data;
fixed_logic_array_t l_data;

data = dynamic_byte_array_t'(l_data);

A couple of notes:

  1. Be careful using byte, it is signed by default.
  2. I add a _t suffix to all my type basic names,
  3. I suggest using more meaningful type names than what I have used here.
  4. The bit-stream cast has one specific order to move bits-left-to-right. Use the streaming operator if you need more complex bit ordering (Section 11.4.14)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.