f



Port declaration for a memory array

Hi,
I am want to declare a port for memory array which is constructed
using flip-flops.
For example:

module test_mode( clk, address, input_bus, mem_out)

input enable;
input [3:0] address;
input [7:0] input_bus;
output [7:0] mem_out [0:15];

reg [7:0] mem_out [0:15];

always @ (posedge clk )
begin
mem_out[address] <= input_bus;
end

endmodule


Please suggest the proper syntax for the synthesizable code.

Regards,
Atul
0
atul.ee (21)
2/3/2010 9:20:42 AM
comp.lang.verilog 3837 articles. 2 followers. Post Follow

3 Replies
4233 Views

Similar Articles

[PageSpeed] 29

On Feb 3, 4:20=A0am, "Atul.ee" <atul...@gmail.com> wrote:
> Hi,
> I am want to declare a port for memory array which is constructed
> using flip-flops.
> For example:
>
> module test_mode( clk, address, input_bus, mem_out)
>
> input enable;
> input [3:0] address;
> input [7:0] input_bus;
> output [7:0] mem_out [0:15];
>
> reg [7:0] mem_out [0:15];
>
> always @ (posedge clk )
> begin
> mem_out[address] <=3D input_bus;
> end
>
> endmodule
>
> Please suggest the proper syntax for the synthesizable code.
>
> Regards,
> Atul

For Verilog and Verilog2001, there is no syntax.  There is no support
for arrays as I/O.

Can anyone comment on SystemVerilog?  And is SystemVerilog an option
for you?
0
John_H
2/3/2010 3:06:06 PM
On Wed, 3 Feb 2010 07:06:06 -0800 (PST), John_H wrote:

>For Verilog and Verilog2001, there is no syntax.  There is no support
>for arrays as I/O.
>
>Can anyone comment on SystemVerilog?  And is SystemVerilog an option
>for you?

See my post in today's earlier thread 
"concatenation with a for loop".
-- 
Jonathan Bromley
0
Jonathan
2/3/2010 4:43:37 PM
On Wed, 3 Feb 2010 01:20:42 -0800 (PST), "Atul.ee" <atul.ee@gmail.com>
wrote:

>Hi,
>I am want to declare a port for memory array which is constructed
>using flip-flops.
>For example:
>
>module test_mode( clk, address, input_bus, mem_out)
>
>input enable;
>input [3:0] address;
>input [7:0] input_bus;
>output [7:0] mem_out [0:15];
>
>reg [7:0] mem_out [0:15];
>
>always @ (posedge clk )
>begin
>mem_out[address] <= input_bus;
>end
>
>endmodule
>
>
>Please suggest the proper syntax for the synthesizable code.
>
>Regards,
>Atul

From your code, it's not clear whether you want an "addressable"
entity (suggested by your input address and array operation in the
always block) or access to all the memory simultaneously (suggested by
your mem_out declaration). Perhaps you mean the following:

module test_mode( clk, enable, address, input_bus, mem_out)
input enable;
input [3:0] address;
input [7:0] input_bus;
output [7:0] mem_out;

reg [7:0] memory [0:15];

assign mem_out = memory[address];

always @ (posedge clk )
begin
	if (enable) memory[address] <= input_bus;
end

endmodule

If you really want full access to all the memory you'll need to define
a 128 bit output into which you need to slice externally.

ie 
output [127:0] mem_out;
assign mem_out = {memory[15], memory[14], ...};
-- 
Muzaffer Kal

DSPIA INC.
ASIC/FPGA Design Services

http://www.dspia.com
0
Muzaffer
2/3/2010 11:55:01 PM
Reply: