I have a Spartan-6 FPGA wired to the AEMIF memory interface on a TI DaVinci DM365 SoC that I control. The AEMIF is set up in Select Strobe mode. I'm trying to implement memory read/write on the FPGA over that interface, but it's not working. The hardware does work and this functionality has been working before written in VHDL (not written by me). I'm new to HDLs so maybe there is something obviously bogus here.
It's hard to tell what's actually going on as the clock is 60MHz and my scope/logic analyser struggles to go that fast.
Edit: I have since got this working. Setting drive_data in a combinatorial way meant that on read, the old memory value was driven out on the data bus, then later the sequential logic would pick up the new address and change the data during the cycle.
module main(
input EM_A_3,
input EM_A_7,
input EM_CLK,
inout [15:0] EM_D,
input EM_nCE1,
input EM_nOE,
input EM_nWE
);
wire [1:0] em_addr;
/* temporary storage for emif "registers" */
reg [15:0] mem [0:3];
reg [15:0] em_outdata;
supply0 rst; // reset always 0 for now
wire drive_data;
initial
begin: FOO
integer i;
for (i = 0; i < 4; i = i + 1) begin
mem[i] = 8'b0;
end
em_outdata = 8'b1;
end
// drive EM_D when CE1, OE are low, and WE is high
assign drive_data = !EM_nCE1 && !EM_nOE && EM_nWE;
assign EM_D = drive_data ? em_outdata : 8'bz;
assign em_addr = {EM_A_7, EM_A_3};
// clocked version (not working yet)
always @ (posedge EM_CLK)
begin
if (!EM_nCE1 && !EM_nWE) begin
mem[em_addr] <= EM_D;
end
if (!EM_nCE1 && !EM_nOE && EM_nWE) begin
em_outdata <= mem[em_addr];
end
end
endmodule