cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
shyvana
Visitor
Visitor
9,344 Views
Registered: ‎01-23-2015

Inferring Block Ram with Byte Wide Write Enable?

Jump to solution

Hi, currently I am working on a MAC to AXI Lite interface and one part of the AXI Lite interface requires writes to include a byte wide enable on a 32 bit data bus. I was easily able to infer some block ram with a 32 bit data_in  port. I can't seem to find a way to include a write enable. Thanks. 

 

This is the general template I have been using to infer dual port brams so far. If there is a better way I would love to know.

 

module bram_tdp #(
    parameter DATA = 72,
    parameter ADDR = 10
) (
    // Port A
    input   wire                a_clk,
    input   wire                a_wr,
    input   wire    [ADDR-1:0]  a_addr,
    input   wire    [DATA-1:0]  a_din,
    output  reg    [DATA-1:0]  a_dout,
     
    // Port B
    input   wire                b_clk,
    input   wire                b_wr,
    input   wire    [ADDR-1:0]  b_addr,
    input   wire    [DATA-1:0]  b_din,
    output  reg    [DATA-1:0]  b_dout
);
 
// Shared memory
reg [DATA-1:0] mem [(2**ADDR)-1:0];
 
// Port A
always @(posedge a_clk) begin
    a_dout      <= mem[a_addr];
    if(a_wr) begin
        a_dout      <= a_din;
        mem[a_addr] <= a_din;
    end
end
 
// Port B
always @(posedge b_clk) begin
    b_dout      <= mem[b_addr];
    if(b_wr) begin
        b_dout      <= b_din;
        mem[b_addr] <= b_din;
    end
end
 
endmodule

 

0 Kudos
1 Solution

Accepted Solutions
arpansur
Moderator
Moderator
17,326 Views
Registered: ‎07-01-2015

Hi @shyvana,

 

Please try with language template.

 

Thanks,
Arpan

Thanks,
Arpan
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------

View solution in original post

1.JPG
5 Replies
arpansur
Moderator
Moderator
9,337 Views
Registered: ‎07-01-2015

Hi @shyvana,

 

Which device you are targeting? Is it from language templates?

Please go through page163 of following link to get more information on coding styles of RAM
http://www.xilinx.com/itp/xilinx10/books/docs/xst/xst.pdf

 

Thanks,
Arpan

Thanks,
Arpan
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
shyvana
Visitor
Visitor
9,335 Views
Registered: ‎01-23-2015

Sorry for not mentioning 7 series, non US or US+. 

No this was a template I found on stack exchange a long time ago.

 

Are there other templates?

0 Kudos
arpansur
Moderator
Moderator
17,327 Views
Registered: ‎07-01-2015

Hi @shyvana,

 

Please try with language template.

 

Thanks,
Arpan

Thanks,
Arpan
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------

View solution in original post

1.JPG
shyvana
Visitor
Visitor
9,321 Views
Registered: ‎01-23-2015
Thank you very much! I never knew about this... well I probably just skimmed over it. I recently started using Vivado. Much appreciated.
0 Kudos
arpansur
Moderator
Moderator
9,319 Views
Registered: ‎07-01-2015

Hi @shyvana.

 

You are welcome :).

 

Thanks,
Arpan

Thanks,
Arpan
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos