This is a code for a 2 port data memory. When I compile it on quartus, number of memory bits are zero and is implemented as logic elements and doesn't infere a ram. How to solve that?
module dataMemoryTwoPorts( PAaddress , PBaddress , PAwriteData , PBwriteData , PAreadData , PBreadData,
PAwriteEn , PBwriteEn , PAreadEn , PBreadEn , clk);
// Inputs
// clock
input clk;
// Enables allow reading from memory from port A and port B
input PAreadEn , PBreadEn;
// Enables allow writing on memory through port A and port B
input PAwriteEn , PBwriteEn;
// Address of location to be accessed by port A and port B
input [31:0] PAaddress , PBaddress;
// Data to be written through port A and port B
input [31:0] PAwriteData , PBwriteData;
// Outputs
// Data to be read from port A and port B
output [31:0] PAreadData , PBreadData;
// Creating the memory vector
reg [7:0] dataMemory [0:8191];
//Initialize memory
initial begin
$readmemh("dataMemory.txt", dataMemory);
end
// Read operation, read only if the address is aligned and the read port is activated
assign PAreadData = ( PAreadEn ) ? { dataMemory[ PAaddress + 3 ] , dataMemory[ PAaddress + 2 ] , dataMemory[ PAaddress + 1] , dataMemory[PAaddress] } : 32'bx ;
assign PBreadData = ( PBreadEn ) ? { dataMemory[ PBaddress + 3 ] , dataMemory[ PBaddress + 2 ] , dataMemory[ PBaddress + 1] , dataMemory[PBaddress] } : 32'bx ;
// Write operation
always @ ( posedge clk ) begin
// for port A
if ( PAwriteEn ) begin
dataMemory [PAaddress ] <= PAwriteData[7 :0 ];
dataMemory [PAaddress+1] <= PAwriteData[15:8 ];
dataMemory [PAaddress+2] <= PAwriteData[23:16];
dataMemory [PAaddress+3] <= PAwriteData[31:24];
end
// for port B
if ( PBwriteEn ) begin
dataMemory [PBaddress ] <= PBwriteData[7 :0 ];
dataMemory [PBaddress+1] <= PBwriteData[15:8 ];
dataMemory [PBaddress+2] <= PBwriteData[23:16];
dataMemory [PBaddress+3] <= PBwriteData[31:24];
end
end
endmodule
i don't want to change the functionality of the data memory. read operation happen asynchronously write operations happens at posetive edge of the clock memory is byte addresable
