Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
9 years ago

Checking the RAM and Inserting Image into in a RAM

I have designed a RAM. The RAM has following codes.

module ram_8bit (we,re, clk, add, datin, datout);

input [6:0] add;

input we, re, clk;

input [7:0] datin;

output[7:0] datout;

reg [7:0] datout;

reg [7:0] mem [127:0];

always @(posedge clk) begin

if (we) mem[add] <= datin; //data write

else if (re) datout = mem[add]; //data read

else datout=datout;

end

endmodule

The code a have written here shows a ram but the input and output simulation file remains same. I have attached the files here. Please see the files. Any one please help me regarding this code. Where is the wrong i made? or My input is wrong. Please help. I want to insert an image in this RAM. I mean the images pixel value not the image. Can any one help me? I am in big trouble.

Thanks in advance.

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Do you mean you need to initialize the RAM? Or you'd like to perform a simulation that writes the image into the RAM? If you want to initialize, normally the values are stored in a file and either the $readmemh or $readmemb functions are used.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Dear SusannahM,

    Thanks for your reply.

    Yes, I want to perform a simulation that writes the image into the RAM. If would please see the input and output image of that program, and suggest me regarding the change the output.

    Thanks again.