dirty.sv 844 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // dirty.sv
  3. //
  4. // SDRAM dirty bit
  5. //
  6. // Tracks dirty SDRAM pages on a 4K granularity. Currently accessed
  7. // from the CPU one bit at a time, but could be improved.
  8. // W1C semantics from the CPU.
  9. //
  10. module dirty
  11. #(parameter pagebits = 13,
  12. parameter pages = 1 << pagebits
  13. )
  14. (
  15. input rst_n,
  16. input clk,
  17. input [pagebits-1:0] dirty_pg,
  18. input dirty_stb,
  19. input [31:2] cpu_addr,
  20. input [ 3:0] cpu_wstrb,
  21. input [31:0] cpu_wdata,
  22. output [31:0] cpu_rdata
  23. );
  24. assign cpu_rdata[31:1] = 'b0;
  25. dirtyram ram (
  26. .clock (clk),
  27. .address_a (cpu_addr[pagebits+1:2]),
  28. .data_a (1'b0),
  29. .wren_a (cpu_wstrb[0] & cpu_wdata[0]),
  30. .q_a (cpu_rdata[0]),
  31. .rden_a (1'b1),
  32. .address_b (dirty_pg),
  33. .data_b (1'b1),
  34. .wren_b (dirty_stb),
  35. .q_b ( ),
  36. .rden_b (1'b0)
  37. );
  38. endmodule