Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Inferring ram in fpga

Status
Not open for further replies.

nico24

Newbie
Joined
May 7, 2021
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
19
I am using an Altera Cyclone IV EP4CE6E22C8. I am trying to infer, I guess block ram, to use the FPGA memory resources, instead of the logic resources.

In order to get correct timing with the 6502 CPU module (arlet) I have used the following code:

Code:
module rom2716_a
(
    input [10:0] addr,
    output [7:0] q // reg
);

    reg [7:0] rom[2047:0];

    initial
    begin
        $readmemh("rom1a.txt", rom);
    end

    assign q = rom[addr];

endmodule

This will not use the memory resources when compiled, as I assume it is not 'recognized' as bram.

If I use the following code, as then it does use the memory resources of the FGPA, however, the timing is too late to be useful with the 6502 CPU module.

Code:
module rom2716_a2
(
    input [10:0] addr,
    input clk,
    output reg [7:0] q
);

    reg [7:0] rom[2047:0];

    initial
    begin
        $readmemh("rom1a.txt", rom);
    end

    always @ (posedge clk)
    begin
        q <= rom[addr];
    end

endmodule

Is there anything I can do to keep the timing of the first, but to get it using FPGA memory resources?
FYI I'm using the same clk timing for the CPU and the memory - maybe it's possible to use a higher frequency clk to get the timing earlier.

Thanks,

Nico
 

FPGA block RAM is synchronous RAM, in case of ROM mode, you have an address register that can't be bypassed.

1620459722608.png


Respectively the first clock-less design can't infer block RAM. I read that the arlet 6502 core expects synchronous memory (as any CPU softcore dedicated to FPGA). Thus I think, you only have designed your ROM interface inappropriately.
 
  • Like
Reactions: nico24

    nico24

    Points: 2
    Helpful Answer Positive Rating
Thanks - I should read the arlet 6502 documentation! It certainly works with asynchronous rom, but maybe not how it's supposed to be.
Thanks for the pointer!
 

I am using an Altera Cyclone IV EP4CE6E22C8. I am trying to infer, I guess block ram, to use the FPGA memory resources, instead of the logic resources.

In order to get correct timing with the 6502 CPU module (arlet) I have used the following code:

Code:
module rom2716_a
(
    input [10:0] addr,
    output [7:0] q // reg
);

    reg [7:0] rom[2047:0];

    initial
    begin
        $readmemh("rom1a.txt", rom);
    end

    assign q = rom[addr];

endmodule

This will not use the memory resources when compiled, as I assume it is not 'recognized' as bram.

If I use the following code, as then it does use the memory resources of the FGPA, however, the timing is too late to be useful with the 6502 CPU module.

Code:
module rom2716_a2
(
    input [10:0] addr,
    input clk,
    output reg [7:0] q
);

    reg [7:0] rom[2047:0];

    initial
    begin
        $readmemh("rom1a.txt", rom);
    end

    always @ (posedge clk)
    begin
        q <= rom[addr];
    end

endmodule

Is there anything I can do to keep the timing of the first, but to get it using FPGA memory resources?
FYI I'm using the same clk timing for the CPU and the memory - maybe it's possible to use a higher frequency clk to get the timing earlier.

Thanks,

Nico

Just check enable and all other pins...

always @ (posedge clk)
begin
if (en)
q <= rom[addr];
end


Try this it should work...Otherwise generate a code using IP generator....
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top