top.v 815 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. `include "../verilog/fifo_async.v"
  2. module top (
  3. input reset,
  4. input rd_clk,
  5. input wr_clk,
  6. input wr_en,
  7. input [15 : 0] wr_data,
  8. output full,
  9. output [4 : 0] led
  10. );
  11. reg [2 : 0] sync_reset_n;
  12. wire fifo_full;
  13. wire fifo_empty;
  14. wire [15 : 0] rd_data;
  15. assign full = fifo_full;
  16. assign led[4] = fifo_full;
  17. assign led[3 : 0] = {^rd_data[15 : 12], ^rd_data[11 : 8], ^rd_data[7 : 4], ^rd_data[3 : 0]};
  18. fifo_async #(
  19. .DATA_WIDTH (16),
  20. .ADDR_WIDTH (4)
  21. ) fifo_async (
  22. .reset_n (sync_reset_n[2]),
  23. .wr_clk(wr_clk),
  24. .wr_en(!fifo_full & wr_en),
  25. .full(fifo_full),
  26. .wr_data(wr_data),
  27. .rd_clk(rd_clk),
  28. .rd_en(!fifo_empty),
  29. .empty(fifo_empty),
  30. .rd_data(rd_data)
  31. );
  32. always @(posedge wr_clk) begin
  33. sync_reset_n[2] <= sync_reset_n[1];
  34. sync_reset_n[1] <= sync_reset_n[0];
  35. sync_reset_n[0] <= !reset;
  36. end
  37. endmodule