My knowledge on the subject is bare-bones. I created a .coe file and used Block Memory Generator to get an .mif file. I need to store the contents in the block memory and then use it. Following is my code:

module read_file;
reg [15:0] music [0:255];
$readmemh("blk_mem_gen_1.mif",  music);
integer i;
initial begin for(i=0; i<16; i=i+1)
$display("music[%d] = %h", i, music[i]);

As you can probably tell, I have no idea what I am doing. Please guide me through and point me to some resources if you happen to know some.

  • \$\begingroup\$ This is just to test if I can read data successfully. With $display I was hoping to get an output on Tcl console. My experience with Vivado is limited to 4-bit full adder using switches and LEDs. \$\endgroup\$ – Maxsash Oct 24 '19 at 3:38
  • 1
    \$\begingroup\$ so what happened when you compiled this ... were correct values read ? (I assume your coe file has contents which you added correctly) \$\endgroup\$ – Mitu Raj Oct 24 '19 at 4:17
  • \$\begingroup\$ @MituRaj No. There is no output in the console. Additionally from the Utilization report I can see that No Block RAM Tile is being utilized at all, which tells me I am doing something fundamentally wrong. \$\endgroup\$ – Maxsash Oct 24 '19 at 4:20
  • 1
    \$\begingroup\$ Give the full path of .mif file in the code ... \$\endgroup\$ – Mitu Raj Oct 24 '19 at 4:25
  • \$\begingroup\$ @MituRaj Thanks a lot! This seems to be working for now. Edit: I see output in the console now, though the Block RAM utilization is still zero. Any ideas? \$\endgroup\$ – Maxsash Oct 24 '19 at 4:41

Seems like your file path is causing problem. Specify full file path to .mif file

Anyway Vivado will synthesise only a distributed RAM for your array music. To use Block RAM, you have to generate one with initial values in a .coe file and instantiate it. But then, you can access the data only one at time in a clock cycle. You can't access multiple data in 'parallel'.

Useful link


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.