Altera_Forum
Honored Contributor
11 years agoROM lagging address by a full cycle?
I have a ROM implemented via megawizard and I noticed for some reason it seems to lag it's address by a full clock cycle, instead of loading the address present at the rising edge. The basic architecture is (using a switch as clock to allow for easy testing:
always @(posedge SW or negedge KEY) begin
if (~KEY) begin
addr <= 0;
else begin
addr <= addr + 1;
end
end
datamem data1(
.address(addr),
.clock(~SW),
.q(data_out));
assign LEDR = data_out;
assign LEDG = addr; I have the ROM initialized with a .MIF file, and I can tell based on the lights, that even if the address on positive level of the switch is 0, it takes two cycles initially for the values to start coming out initially. The throughput becomes one per cycle, but the same thing happens if I reset at for example address 5, I can tell the address goes to 0, but the immediate following cycle I get address 5, and then I get 0. To test further I even switched the ROM to a different switch for the clock, and after any change in the address it takes a full cycle of the ROM clock to show the change. Any thoughts? Is this an option I can configure, or will the ROM by its nature have a full cycle of latency? I had been under the impression that as long as the clock frequency was slow enough, the ROM could output the data of whatever address is present, immediately following the rising edge, kind of like a flip flop. Is this understanding incorrect? Thanks