enso:
I've not been following your SRAM interface issue closely, and the following suggestions may not be applicable. Further, I've not simulated the suggested code change.
Your SRAM interface module code is reproduced below. I am going to assume that [7:0]
xin is what you consider the output of the input buffer in the IOB, which should be defined as
inout [7:0] xdb. Similarly, I am going to assume that you have defined
[7:0] di as an
input to the module, and that you expect it to drive an output buffer in the IOB which can be tri-stated.
Code:
wire [7:0] xin = we ? 8'bZ : xdb[7:0] ; //on read, let data in
assign xdb[7:0] = we ? di[7:0] : 8'bZ; //on write, let data out
//
// Return read result next cycle
always @ (posedge sclk)
if(en & ~we) //on write, output 0 - for some reason it's FF
do[7:0] <= xin[7:0];
else
do[7:0] <= 8'h00;
I've come to determine that Xilinx's synthesizer assumes a logic 1 for any tri-state signals within the FPGA. There isn't a tri-state output available for the input buffer of the IOB on the Spartan 3/3E/3A families; it is simply connected to the FPGA fabric and/or the IOB FF. Thus, whenever
we is asserted and
xin is supposed to be tri-stated, a logic value of 1 is assumed by the synthesizer. This is most likely the reason that you are observing a 8'hFF for the SRAM module's
do signal as you appear to note in the comment you appear to have embedded in the your code.
I would suggest the following change to your code:
Code:
wire [7:0] xin = xdb; //on read, let data in
assign xdb[7:0] = we ? di : 8'bZ; //on write, let data out
//
// Return read result next cycle
assign clr_do = (we | ~en);
always @ (posedge sclk or posedge clr_do)
if(clr_do)
do[7:0] <= 0;
else
do[7:0] <= xin;
I expect that this code snippet will output a value of 0 from the
di port of your SRAM interface module for at least one cycle after
we is asserted or the SRAM is not selected. It will reflect the value on the external bidirectional pin
xdb whenever the SRAM
en is asserted on the rising edge of your system clock,
sclk.