The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
Jul 17th, 2024, 3:31pm
Pages: 1
Send Topic Print
RAM initialize!!! (Read 479 times)
alexworld83
New Member
*
Offline



Posts: 1

RAM initialize!!!
Oct 10th, 2011, 10:39am
 
Hello,

I described a RAM in verilog, and in the top level I instantiated 8 block of the same RAM. I have to initialize them by a different set of data... so I want to use the command "readmemb" at top level but I don't know the correct syntax or if this is possible

---------RAM code-----------

module ram_64B(clk, en, write_en, data_in, data_add, data_out);
     input clk, en, write_en;
     input [7:0] data_in;
     input [5:0] data_add;
     output [7:0] data_out;
     
     parameter RAM_WIDTH = 8;
  parameter RAM_ADDR_BITS = 6;
 
  //(* RAM_STYLE="{AUTO | BLOCK |  BLOCK_POWER1 | BLOCK_POWER2}" *)
  reg [RAM_WIDTH-1:0] ram [(2**RAM_ADDR_BITS)-1:0];
  reg [RAM_WIDTH-1:0] data_out;

  wire [RAM_ADDR_BITS-1:0] data_add;
  wire [RAM_WIDTH-1:0] data_in;

  always @(negedge clk)
     if (en)
           begin
        if (write_en) begin
           ram[data_add] <= data_in;
           data_out <= data_in;
        end
        else
           data_out <= ram[data_add];
     end
           
endmodule

---------Top level-------------------

ram_64B tm_filt1 (clk, en_ram, 1'b0, data_in_tm_filt1, data_add_tm, data_tm_filt1);
ram_64B tm_filt2 (clk, en_ram, 1'b0, data_in_tm_filt2, data_add_tm, data_tm_filt2);
ram_64B tm_filt3 (clk, en_ram, 1'b0, data_in_tm_filt3, data_add_tm, data_tm_filt3);
ram_64B tm_filt4 (clk, en_ram, 1'b0, data_in_tm_filt4, data_add_tm, data_tm_filt4);
ram_64B tm_filt5 (clk, en_ram, 1'b0, data_in_tm_filt5, data_add_tm, data_tm_filt5);
ram_64B tm_filt6 (clk, en_ram, 1'b0, data_in_tm_filt6, data_add_tm, data_tm_filt6);
ram_64B tm_filt7 (clk, en_ram, 1'b0, data_in_tm_filt7, data_add_tm, data_tm_filt7);
ram_64B tm_filt8 (clk, en_ram, 1'b0, data_in_tm_filt8, data_add_tm, data_tm_filt8);

-----------------------------------------------------------------

Thank you
Back to top
 
 
View Profile   IP Logged
ywguo
Community Fellow
*****
Offline



Posts: 943
Shanghai, PRC
Re: RAM initialize!!!
Reply #1 - Oct 14th, 2011, 6:57am
 
    [1] I don't know the reason why you have to initialize RAM block. Do you want to prevent from any X state in the simulation?
    [2] I don't see any readmemb in your code.
    [3] Assume you have verilog simulator, try to compile it and the simulator would tell you if there is any syntax error.
Back to top
 
 
View Profile   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.