1. /* Machine-generated using Migen */
  2. module top(
  3. input sys_clk,
  4. input sys_rst
  5. );
  6.  
  7. reg [31:0] wishbone_dat_o;
  8. wire [31:0] wishbone_lm32d_dat_o;
  9. wire wishbone_lm32d_stb_o;
  10. reg [3:0] wishbone_sel_o;
  11. wire [3:0] wishbone_lm32d_sel_o;
  12. reg [1:0] wishbone_bte_o;
  13. wire [2:0] wishbone_lm32d_cti_o;
  14. reg roundrobin_grant;
  15. reg lm32_I_RTY_I;
  16. reg [31:0] wishbone_lm32d_dat_i;
  17. reg wishbone_lm32d_ack_i;
  18. wire wishbone_lm32i_cyc_o;
  19. reg wishbone_lm32i_ack_i;
  20. wire [2:0] wishbone_lm32i_cti_o;
  21. reg [31:0] wishbone_adr_o;
  22. reg wishbone_cyc_o;
  23. reg wishbone_lm32i_err_i;
  24. reg [31:0] wishbone_dat_i;
  25. reg wishbone_we_o;
  26. reg wishbone_stb_o;
  27. reg wishbone_ack_i;
  28. wire wishbone_lm32d_cyc_o;
  29. reg [2:0] wishbone_cti_o;
  30. wire wishbone_lm32d_we_o;
  31. reg wishbone_err_i;
  32. wire [1:0] wishbone_lm32d_bte_o;
  33. reg [1:0] roundrobin_request;
  34. wire [31:0] wishbone_lm32i_adr_o;
  35. reg [31:0] wishbone_lm32i_dat_i;
  36. wire [31:0] wishbone_lm32i_dat_o;
  37. wire [3:0] wishbone_lm32i_sel_o;
  38. reg wishbone_lm32d_err_i;
  39. wire wishbone_lm32i_stb_o;
  40. wire wishbone_lm32i_we_o;
  41. wire [31:0] wishbone_lm32d_adr_o;
  42. reg lm32_D_RTY_I;
  43. wire [1:0] wishbone_lm32i_bte_o;
  44.  
  45. always @(*) begin
  46. lm32_I_RTY_I = 1'd0;
  47. lm32_D_RTY_I = 1'd0;
  48. case (roundrobin_grant)
  49. 1'd0: begin
  50. wishbone_adr_o = wishbone_lm32i_adr_o;
  51. end
  52. default: begin
  53. wishbone_adr_o = wishbone_lm32d_adr_o;
  54. end
  55. endcase
  56. case (roundrobin_grant)
  57. 1'd0: begin
  58. wishbone_dat_o = wishbone_lm32i_dat_o;
  59. end
  60. default: begin
  61. wishbone_dat_o = wishbone_lm32d_dat_o;
  62. end
  63. endcase
  64. case (roundrobin_grant)
  65. 1'd0: begin
  66. wishbone_sel_o = wishbone_lm32i_sel_o;
  67. end
  68. default: begin
  69. wishbone_sel_o = wishbone_lm32d_sel_o;
  70. end
  71. endcase
  72. case (roundrobin_grant)
  73. 1'd0: begin
  74. wishbone_cyc_o = wishbone_lm32i_cyc_o;
  75. end
  76. default: begin
  77. wishbone_cyc_o = wishbone_lm32d_cyc_o;
  78. end
  79. endcase
  80. case (roundrobin_grant)
  81. 1'd0: begin
  82. wishbone_stb_o = wishbone_lm32i_stb_o;
  83. end
  84. default: begin
  85. wishbone_stb_o = wishbone_lm32d_stb_o;
  86. end
  87. endcase
  88. case (roundrobin_grant)
  89. 1'd0: begin
  90. wishbone_we_o = wishbone_lm32i_we_o;
  91. end
  92. default: begin
  93. wishbone_we_o = wishbone_lm32d_we_o;
  94. end
  95. endcase
  96. case (roundrobin_grant)
  97. 1'd0: begin
  98. wishbone_cti_o = wishbone_lm32i_cti_o;
  99. end
  100. default: begin
  101. wishbone_cti_o = wishbone_lm32d_cti_o;
  102. end
  103. endcase
  104. case (roundrobin_grant)
  105. 1'd0: begin
  106. wishbone_bte_o = wishbone_lm32i_bte_o;
  107. end
  108. default: begin
  109. wishbone_bte_o = wishbone_lm32d_bte_o;
  110. end
  111. endcase
  112. wishbone_lm32i_dat_i = wishbone_dat_i;
  113. wishbone_lm32d_dat_i = wishbone_dat_i;
  114. wishbone_lm32i_ack_i = wishbone_ack_i;
  115. wishbone_lm32d_ack_i = wishbone_ack_i;
  116. wishbone_lm32i_err_i = wishbone_err_i;
  117. wishbone_lm32d_err_i = wishbone_err_i;
  118. roundrobin_request = {wishbone_lm32d_cyc_o, wishbone_lm32i_cyc_o};
  119. end
  120.  
  121. always @(posedge sys_clk) begin
  122. if (sys_rst) begin
  123. roundrobin_grant <= 1'd0;
  124. end else begin
  125. case (roundrobin_grant)
  126. 1'd0: begin
  127. if ((~roundrobin_request[0])) begin
  128. if (roundrobin_request[1]) begin
  129. roundrobin_grant <= 1'd1;
  130. end
  131. end
  132. end
  133. 1'd1: begin
  134. if ((~roundrobin_request[1])) begin
  135. if (roundrobin_request[0]) begin
  136. roundrobin_grant <= 1'd0;
  137. end
  138. end
  139. end
  140. endcase
  141. end
  142. end
  143.  
  144. lm32_top lm32(
  145. .I_ERR_I(wishbone_lm32i_err_i),
  146. .ext_break(lm32_ext_break),
  147. .D_RTY_I(lm32_D_RTY_I),
  148. .D_ACK_I(wishbone_lm32d_ack_i),
  149. .I_ACK_I(wishbone_lm32i_ack_i),
  150. .I_DAT_I(wishbone_lm32i_dat_i),
  151. .D_ERR_I(wishbone_lm32d_err_i),
  152. .interrupt(lm32_interrupt),
  153. .D_DAT_I(wishbone_lm32d_dat_i),
  154. .I_RTY_I(lm32_I_RTY_I),
  155. .I_WE_O(wishbone_lm32i_we_o),
  156. .I_ADR_O(wishbone_lm32i_adr_o),
  157. .I_CTI_O(wishbone_lm32i_cti_o),
  158. .I_BTE_O(wishbone_lm32i_bte_o),
  159. .D_WE_O(wishbone_lm32d_we_o),
  160. .D_STB_O(wishbone_lm32d_stb_o),
  161. .D_BTE_O(wishbone_lm32d_bte_o),
  162. .I_CYC_O(wishbone_lm32i_cyc_o),
  163. .D_CYC_O(wishbone_lm32d_cyc_o),
  164. .D_SEL_O(wishbone_lm32d_sel_o),
  165. .I_SEL_O(wishbone_lm32i_sel_o),
  166. .I_LOCK_O(lm32_I_LOCK_O),
  167. .I_STB_O(wishbone_lm32i_stb_o),
  168. .I_DAT_O(wishbone_lm32i_dat_o),
  169. .D_CTI_O(wishbone_lm32d_cti_o),
  170. .D_DAT_O(wishbone_lm32d_dat_o),
  171. .D_LOCK_O(lm32_D_LOCK_O),
  172. .D_ADR_O(wishbone_lm32d_adr_o),
  173. .clk_i(sys_clk),
  174. .rst_i(sys_rst)
  175. );
  176.  
  177. endmodule
  178.  
  179.