For Loop

Syntax:
for (reg_initialisation ; conditional ; reg_update) statement

The for loop is the same as the for loop in C. It has three parts: the first part is executed once, before the loop is entered; the second part is the test which (when true causes the loop to re-iterate); and the third part is executed at the end of each iteration.

        integer list [31:0];
        integer index;

        initial begin
           for(index = 0; index < 32; index = index + 1)
              list[index] = index + index;
           end

EXERCISE Initialise the following memory so that each location contains its own address plus 24 ie. memory16_256[0] contains 0000000000011000, (24 in decimal).
        reg [15:0] memory16_256 [255:0];

Answers


previous next contents