Skip to content

Instantly share code, notes, and snippets.

@osamaadam
Created July 10, 2019 14:27
Show Gist options
  • Save osamaadam/ff485d9f38965dd3c1bff8744bb07593 to your computer and use it in GitHub Desktop.
Save osamaadam/ff485d9f38965dd3c1bff8744bb07593 to your computer and use it in GitHub Desktop.
module sparseMemory();
typedef enum {false, true} boolean;
bit[31:0] highestIndex;
bit[31:0] lowestIndex;
boolean bigMemory[bit[31:0]];
initial begin
for(int i = 0; i < 25; i++) begin
bigMemory[$urandom] = true;
end
bigMemory.first(lowestIndex);
bigMemory.last(highestIndex);
$display("bigMemory has %0d inputs", bigMemory.size());
$display("The lowest index is %0d", lowestIndex);
$display("The highest index is %0d", highestIndex);
$display("Here are the addresses");
foreach(bigMemory[i])
$display(i);
end
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment