0% found this document useful (0 votes)
143 views

Assignment 1

The document contains three code examples with questions: 1) Defines variables of different data types and asks for their values 2) Defines memory arrays and assigns values between them in a given order 3) Asks to declare a 2-state array, initialize it with specific values, and print a bit range of each using for and foreach loops
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
143 views

Assignment 1

The document contains three code examples with questions: 1) Defines variables of different data types and asks for their values 2) Defines memory arrays and assigns values between them in a given order 3) Asks to declare a 2-state array, initialize it with specific values, and print a bit range of each using for and foreach loops
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Given the following code sample:


byte my_byte;
integer my_integer = 32b0000_1111_xxxx_zzzz;
int my_int = my_integer;
bit [15:0] my_bit = 16h8000;
shortint my_short_int1= my_bit;
shortint my_short_int2 = my_short_int1-1;
a.What is the decimal range of values my_byte can take?
b.What is the value of:
my_integer?
my_int in hex?
my_bit in decimal?
my_short_int1 in decimal?
my_short_int2 in decimal?
2.
Given the following code sample:
bit [7:0] my_mem [3] = '{default:8'hA5};
logic [3:0] my_logicmem [4] = '{0,1,2,3};
logic [3:0] my_logic = 4hF;
Evaluate in order:
my_mem[2] = my_logicmem[4];
my_logic = my_logicmem[4];
my_logicmem[3] = my_mem[3];

my_mem[3] = my_logic;
my_logic = my_logicmem[1];
my_logic = my_mem[1];
my_logic = my_logicmem[my_logicmem[4]];
3. Write the SystemVerilog code to:
1)Declare a 2-state array, my_array, that holds four 12-bit values
2)initialize my_array so that:
1)my_array[0] = 12h012
2)my_array[1] = 12h345,
3)my_array[2] = 12h678,
4)my_array[3] = 12h9AB;

3) Traverse my_array and print out bits [5:4] of each 12-bit element
1)Using a for loop
2)Using a foreach loop

You might also like