??? 10/15/07 02:45 Read: times |
#145753 - Simulator question Responding to: ???'s previous message |
Following is a tiny bit of Verilog that has me Vericonfused.
`timescale 1us / 1ns module Client ( input clock, input [7:0] dataIn, input inputStrobe, output [7:0] dataOut ); reg [7:0] dataStore; assign dataOut = dataStore + 1; always @(posedge clock) // On rising clock edge if (inputStrobe) // If there is new data ... dataStore <= dataIn; // store it locally endmodule /* ///////////////////////////////////////////////////////////////////////// */ `timescale 1us / 1ns module Server; reg sysClock; reg [7:0] data; reg strobe; wire [7:0] inPlusOne; Client aClient (sysClock, data, strobe, inPlusOne); always begin // Clock generator #1 sysClock <= 0; #1 sysClock <= 1; end initial begin // Simple testbench to feed a couple sysClock <= 1; // of bytes to the client data <= 0; strobe <= 0; #6 data <= 1; strobe <= 1; #2 strobe <= 0; #6 data <= 2; strobe <= 1; #2 strobe <= 0; #10 $finish; end endmoduleThe Client module uses a technique recommended by Andy to receive and store a data byte from a server module whenever a "new data avaialable" strobe is asserted. The strobe is assumed to be synchronized with the clock. The Server module creates one instance of the Client module and then feeds it a couple of bytes as described above. Here's what the Xilinx simulator did with this: The server's signals are above the grey bar; the client's are below. The thing that's driving me nuts is at time 6, when the server asserts the strobe. For some reason, the simulator shows the client acting on the strobe on the same clock edge as it was asserted. Is that correct? In real hardware, wouldn't the client change dataStore and dataOut on the next rising clock edge, at time 8? It seems like I must be missing something about how the simulator works, but I don't know if I need to be thinking differently, or coding differently, or ??? Any hints would be more than appreciated. -- Russ PS: For what it's worth, the Xilinx simulator and ModelSim both work the same for the simple example above. However, I first ran into this problem with a somewhat more complicated program, and in that case the two simulators gave different results. |