Help in Memory array in Verilog ..

P

pgh

Guest
Hi:
I need a help in 2-D arrays(memories)in verilog
I have module that needs input from a testbench which is a memory

module prob(a, b,c)
output a;
input b,c;
reg [15:0] k [0:15];
reg [0:15] j;
integer count;

j=k[count];

endmodule

Test Bench

Here is the example:

module test_mod ();

reg [15:0] mem [0:15]

test M1 (a,b,c)

initial begin
readmemh("init.dat",mem);
end


Problem: I want to pass the values of mem in testbench to k in module. How
can i do that? Can i declare memory as a port and pass teh values?

I would really appreciate any kind of help
thankyou
Sari.
 
Change your 2-D memory into one very large 1-D vector, pass that to the
module, then break that vector back into the 2-D memory chunks, all
combinatorial.

Verilog doesn't do 2-D ports.

"pgh" <sari_234@yahoo.com> wrote in message
news:4b686dec0a25e7e176924209d1e5c28f@localhost.talkaboutprogramming.com...
Hi:
I need a help in 2-D arrays(memories)in verilog
I have module that needs input from a testbench which is a memory

module prob(a, b,c)
output a;
input b,c;
reg [15:0] k [0:15];
reg [0:15] j;
integer count;

j=k[count];

endmodule

Test Bench

Here is the example:

module test_mod ();

reg [15:0] mem [0:15]

test M1 (a,b,c)

initial begin
readmemh("init.dat",mem);
end


Problem: I want to pass the values of mem in testbench to k in module. How
can i do that? Can i declare memory as a port and pass teh values?

I would really appreciate any kind of help
thankyou
Sari.
 
"pgh" <sari_234@yahoo.com> wrote in message news:<4b686dec0a25e7e176924209d1e5c28f@localhost.talkaboutprogramming.com>...
module test_mod ();

reg [15:0] mem [0:15]

test M1 (a,b,c)

initial begin
readmemh("init.dat",mem);
end


Problem: I want to pass the values of mem in testbench to k in module. How
can i do that? Can i declare memory as a port and pass teh values?
No, you can't have a port that is a memory.

You can write a loop that walks through mem and copies the values into k
using a hierarchical reference (i.e. M1.k). But if you are doing that,
you might as well do the $readmemh directly into M1.k and forget about
reading it into mem in the first place.
 

Welcome to EDABoard.com

Sponsor

Back
Top