iodevs.vh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. reg [31:0] nxdev_rdata;
  2. reg [31:0] iodev_rdata;
  3. wire [3:0] xdev_valid = iodev_mem_valid << cpu_mem_addr[29:28];
  4. wire [15:0] iodev_valid = xdev_valid[3] << cpu_mem_addr[10:7];
  5. wire [31:0] iodev_rdata_sys;
  6. wire [ 0:0] iodev_valid_sys = iodev_valid[0:0];
  7. tri1 [ 0:0] iodev_wait_n_sys;
  8. wire [31:0] iodev_rdata_sysclock;
  9. wire [ 0:0] iodev_irq_sysclock;
  10. wire [ 0:0] iodev_valid_sysclock = iodev_valid[1:1];
  11. tri1 [ 0:0] iodev_wait_n_sysclock;
  12. wire [31:0] iodev_rdata_console;
  13. wire [ 0:0] iodev_irq_console;
  14. wire [ 0:0] iodev_valid_console = iodev_valid[2:2];
  15. tri1 [ 0:0] iodev_wait_n_console;
  16. wire [31:0] iodev_rdata_sdcard;
  17. wire [ 0:0] iodev_irq_sdcard;
  18. wire [ 0:0] iodev_valid_sdcard = iodev_valid[3:3];
  19. tri1 [ 0:0] iodev_wait_n_sdcard;
  20. wire [31:0] iodev_rdata_i2c;
  21. wire [ 0:0] iodev_irq_i2c;
  22. wire [ 0:0] iodev_valid_i2c = iodev_valid[4:4];
  23. tri1 [ 0:0] iodev_wait_n_i2c;
  24. wire [31:0] iodev_rdata_esp;
  25. wire [ 0:0] iodev_irq_esp;
  26. wire [ 0:0] iodev_valid_esp = iodev_valid[5:5];
  27. tri1 [ 0:0] iodev_wait_n_esp;
  28. wire [31:0] iodev_rdata_abc;
  29. wire [ 0:0] iodev_irq_abc;
  30. wire [ 0:0] iodev_valid_abc = iodev_valid[6:6];
  31. tri1 [ 0:0] iodev_wait_n_abc;
  32. wire [31:0] iodev_rdata_abcmemmap;
  33. wire [ 0:0] iodev_valid_abcmemmap = xdev_valid[0:0];
  34. tri1 [ 0:0] iodev_wait_n_abcmemmap;
  35. // I/O input MUX
  36. always_comb
  37. case (cpu_mem_addr[29:28])
  38. 2'd0: iodev_rdata = iodev_rdata_abcmemmap;
  39. 2'd3:
  40. case (cpu_mem_addr[10:7])
  41. 4'd0: iodev_rdata = iodev_rdata_sys;
  42. 4'd1: iodev_rdata = iodev_rdata_sysclock;
  43. 4'd2: iodev_rdata = iodev_rdata_console;
  44. 4'd3: iodev_rdata = iodev_rdata_sdcard;
  45. 4'd4: iodev_rdata = iodev_rdata_i2c;
  46. 4'd5: iodev_rdata = iodev_rdata_esp;
  47. 4'd6: iodev_rdata = iodev_rdata_abc;
  48. default: iodev_rdata = 32'hffffffff;
  49. endcase
  50. default: iodev_rdata = 32'hffffffff;
  51. endcase
  52. tri0 [31:0] sys_irq;
  53. assign sys_irq[ 3] = iodev_irq_sysclock[0];
  54. assign sys_irq[ 4] = iodev_irq_console[0];
  55. assign sys_irq[ 5] = iodev_irq_sdcard[0];
  56. assign sys_irq[ 6] = iodev_irq_i2c[0];
  57. assign sys_irq[ 7] = iodev_irq_esp[0];
  58. assign sys_irq[ 8] = iodev_irq_abc[0];
  59. localparam [31:0] irq_edge_mask = 32'h00000148;
  60. localparam [31:0] irq_masked = ~32'h000001ff;
  61. wire iodev_wait_n = (&iodev_wait_n_sys) &
  62. (&iodev_wait_n_sysclock) &
  63. (&iodev_wait_n_console) &
  64. (&iodev_wait_n_sdcard) &
  65. (&iodev_wait_n_i2c) &
  66. (&iodev_wait_n_esp) &
  67. (&iodev_wait_n_abc) &
  68. (&iodev_wait_n_abcmemmap);