Thanks, thats a great resource!
I think I do understand the concept of writing to a FIFO, but I get stuck on how I would perform certain actions on the same clock cycle that the FIFO is synced to.
wire[54:0] write_fifo_data;
assign write_fifo_data[0:31] = {8'hFF, red, green, blue};
wire [0:22] sdram_address = 0;
assign write_fifo_data[32:54] = sdram_address;
wire rst_n = ~rst;
wire full;
wire empty;
wire write_enable;
wire read_enable;
fifo #(.BUS_WIDTH(55)) wr_fifo(
.rst_n(rst_n),
.wr_clk(pixel_dclk),
.rd_clk(clock_100mhz),
.wr_data(write_fifo_data),
.rd_data(read_fifo_data),
.wr(write_enable),
.rd(read_enable),
.full(write_enable),
.rst_n(rst_n),
.empty(empty)
);
always@(posedge pixel_dclk) begin
write_enable = 1;
sdram_address <= sdram_address + 1;
end
The wr_clk of the FIFO is the pixel_dclk, this will make sure everytime the pixel_dclk is pulsed write_fifo_data is written to the FIFO, if write_enabled is high.
But on the same clock edge I need to increment the sdram_address which is part of the write_fifo_data.
This is done in the always@(posedge pixel_dclk), and here is where I'm confused how can I make sure this is done reliably always after or always before, the actual data gets written to the FIFO.
I hope this makes sense