refactor: move to dpi module for memory access

This commit is contained in:
xinyangli 2024-04-03 22:39:33 +08:00
parent a478ef7639
commit 97cf418c86
Signed by: xin
SSH key fingerprint: SHA256:qZ/tzd8lYRtUFSrfBDBMcUqV4GHKxqeqRA3huItgvbk
15 changed files with 443 additions and 207 deletions

View file

@ -0,0 +1,24 @@
import "DPI-C" function int pmem_read(input int addr);
import "DPI-C" function void pmem_write(input int waddr, input int wdata, input byte wmask);
module RamDpi (
input writeEnable,
input valid,
input [31:0] writeAddr,
input [31:0] writeData,
input [3:0] writeMask,
input reg [31:0] readAddr,
output reg [31:0] readData
);
always @(*) begin
if (valid) begin // 有读写请求时
readData = pmem_read(readAddr);
if (writeEnable) begin // 有写请求时
pmem_write(writeAddr, writeData, { 4'h0, writeMask });
end
end
else begin
readData = 0;
end
end
endmodule