Forum Discussion
Altera_Forum
Honored Contributor
8 years agoVerilog coding issue
:confused::confused:Hello everyone can some buddy guide me how initialize your own data set in verilog with complete sample example. I have written a code but getting error module mean(A1,A...
Altera_Forum
Honored Contributor
8 years agoCouple of different ways to do it, either all in verilog or with using a text file to init the memory contents.
So you can do this in verilog to initialize the block memory device memdat from the contents of a file:
reg memdat;
initial $readmemb("meminit.txt", memdat, 0, 4095);
where the file meminit.txt contains 4096 lines of data (in this case 12bit binary strings since I used $readmemb):
000000000000
011000110001
111111000001
...
111111111111
or instead of that initial block that uses an external text file, you could use plain old verilog assignment statements:
initial
begin
memdat = 12'hFFF;
memdat = 12'b0000_1111_0000;
...
memdat = 12'd1234;
end
or a more complex set of verilog code:
initial
begin : init_block
integer i;
for (i = 0; i < 4096; i = i+1) memdat = 12'h000;
memdat = 12'd1234;
... etc
end