UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Visitor melinda3
Visitor
13,511 Views
Registered: ‎11-11-2009

Verilog - Single Port Block RAM with registered output

Hi,

 

I need single port block RAM with registered output. I use Verilog HDL...(Virtex-5). I change XST Template Verilog code for single port BRAM:

//// Single-Port RAM with Synchronous Read (Read Through)//module v_rams_07 (clk, we, a, di, do);input clk;input we;input [5:0] a;input [15:0] di;output [15:0] do;reg [15:0] ram [63:0];reg [5:0] read_a;always @(posedge clk) begin if (we) ram[a] <= di; read_a <= a;endassign do = ram[read_a];endmodule

 to:

 

module v_rams_07 (clk, we, a, di, do);input clk;input we;input [5:0] a;input [15:0] di;output reg [15:0] do;reg [15:0] ram [63:0];reg [5:0] read_a;always @(posedge clk) begin if (we) ram[a] <= di; read_a <= a; do <= ram[read_a];endendmodule

 

 ,but with this modification, XST inffers dual port block BRAM instead single port BRAM.

 

 

 

How to inffer single port BRAM with registered output? Am I doing something wrong?

 

(PS: I saw in CoreGen we can add this options - registered output, but I need/wanna to inffer that BRAM design) 

 

Best Regards 

 

0 Kudos
5 Replies
Xilinx Employee
Xilinx Employee
13,496 Views
Registered: ‎11-28-2007

Re: Verilog - Single Port Block RAM with registered output

Try registering the output of the ram instead of the registering the address input.

 

 

Cheers,

Jim

 

Cheers,
Jim
0 Kudos
Visitor melinda3
Visitor
13,487 Views
Registered: ‎11-11-2009

Re: Verilog - Single Port Block RAM with registered output

Hi,

 

Do you mean just to delete line : read_a <= a; and write do <= ram[a];  ?

 

Best Regards

0 Kudos
Visitor melinda3
Visitor
13,482 Views
Registered: ‎11-11-2009

Re: Verilog - Single Port Block RAM with registered output

Hi again,

 

(*) Just to add remark to my previous question ...I read that for Virtex-5 Block RAM - "All inputs, data, address, clock enables, and write enables are registered".

 

1)Can someone explain me on XST template example I wrote in my first post, why then in this example "Single-Port RAM With Synchronous Read (Read Through)"  we have read address  registered - inplicitly, if all inputs are automatically registered? Please clear this ....

 

2)Does (*) mean that "Single-Port RAM With Synchronous Read (Read Through)" have all inputs registered also we didn't write inplicitly that all inputs are also regs or ....?

 

 

 Thanks and best regards

0 Kudos
Xilinx Employee
Xilinx Employee
13,472 Views
Registered: ‎11-28-2007

Re: Verilog - Single Port Block RAM with registered output

Yes. and also add one more register after do before sending it to the output (see below where I added an intermediate register do0). Please also note that xst infers distributed RAM or BRAM based on the size. For small RAMs, you may need to use ram_style constraint to fore the use of BRAM.

 

module v_rams_07 (clk, we, a, di, do);

input clk;
input we;
input [6:0] a;
input [15:0] di;
output reg [15:0] do;

reg [15:0] ram [0:127];
reg [15:0] do0;

reg [5:0] read_a;

always @(posedge clk) begin 
if (we)    ram[a] <= di; 

do0 <= ram[a];

do <= do0;
end

endmodule

 


melinda3 wrote:

Hi,

 

Do you mean just to delete line : read_a <= a; and write do <= ram[a];  ?

 

Best Regards


 

 

Cheers,
Jim
0 Kudos
Xilinx Employee
Xilinx Employee
13,471 Views
Registered: ‎11-28-2007

Re: Verilog - Single Port Block RAM with registered output

1) It's just a coding style. You either register the address input or register the ram output to reflect the one cycle latency of the RAM. When it comes to inference it's all about the coding style. Stick to templates that work, you will be fine.
Cheers,
Jim
 

melinda3 wrote:

Hi again,

 

(*) Just to add remark to my previous question ...I read that for Virtex-5 Block RAM - "All inputs, data, address, clock enables, and write enables are registered".

 

1)Can someone explain me on XST template example I wrote in my first post, why then in this example "Single-Port RAM With Synchronous Read (Read Through)"  we have read address  registered - inplicitly, if all inputs are automatically registered? Please clear this ....

 

2)Does (*) mean that "Single-Port RAM With Synchronous Read (Read Through)" have all inputs registered also we didn't write inplicitly that all inputs are also regs or ....?

 

 

 Thanks and best regards


 

Cheers,
Jim
0 Kudos