2
0

abcbus.sv 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. module abcbus (
  2. input rst_n,
  3. input sys_clk,
  4. input sdram_clk, // Assumed to be a multiple of sys_clk
  5. input stb_1mhz, // 1-2 MHz sys_clk strobe
  6. // CPU interface
  7. input abc_valid, // Control/status registers
  8. input map_valid, // Memory map
  9. input [31:0] cpu_addr,
  10. input [31:0] cpu_wdata,
  11. input [3:0] cpu_wstrb,
  12. output [31:0] cpu_rdata, // For the ABC-bus control
  13. output [31:0] cpu_rdata_map, // For the map RAM
  14. output reg irq,
  15. // ABC bus
  16. input abc_clk,
  17. input [15:0] abc_a,
  18. inout [7:0] abc_d,
  19. output reg abc_d_oe,
  20. input abc_rst_n,
  21. input abc_cs_n,
  22. input [4:0] abc_out_n,
  23. input [1:0] abc_inp_n,
  24. input abc_xmemfl_n,
  25. input abc_xmemw800_n, // Memory write strobe (ABC800)
  26. input abc_xmemw80_n, // Memory write strobe (ABC80)
  27. input abc_xinpstb_n, // I/O read strobe (ABC800)
  28. input abc_xoutpstb_n, // I/O write strobe (ABC80)
  29. // The following are inverted versus the bus IF
  30. // the corresponding MOSFETs are installed
  31. output abc_rdy_x, // RDY = WAIT#
  32. output abc_resin_x, // System reset request
  33. output abc_int80_x, // System INT request (ABC80)
  34. output abc_int800_x, // System INT request (ABC800)
  35. output abc_nmi_x, // System NMI request (ABC800)
  36. output abc_xm_x, // System memory override (ABC800)
  37. // Host/device control
  38. output abc_master, // 1 = host, 0 = device
  39. output reg abc_a_oe,
  40. // Bus isolation
  41. output abc_d_ce_n,
  42. // ABC-bus extension header
  43. // (Note: cannot use an array here because HC and HH are
  44. // input only.)
  45. inout exth_ha,
  46. inout exth_hb,
  47. input exth_hc,
  48. inout exth_hd,
  49. inout exth_he,
  50. inout exth_hf,
  51. inout exth_hg,
  52. input exth_hh,
  53. // SDRAM interface
  54. output [24:0] sdram_addr,
  55. input [7:0] sdram_rd,
  56. output reg sdram_rrq,
  57. input sdram_rack,
  58. input sdram_rready,
  59. output [7:0] sdram_wd,
  60. output reg sdram_wrq,
  61. input sdram_wack
  62. );
  63. // Set if MOSFETs Q1-Q6 are installed rather than the corresponding
  64. // resistors. BOTH CANNOT BE INSTALLED AT THE SAME TIME.
  65. parameter [6:1] mosfet_installed = 6'b111_111;
  66. parameter [0:0] exth_reversed = 1'b0;
  67. // Synchronizer for ABC-bus input signals; also changes
  68. // the sense to positive logic where applicable
  69. wire abc_clk_s;
  70. wire [15:0] abc_a_s;
  71. wire [7:0] abc_di;
  72. wire abc_rst_s;
  73. wire abc_cs_s;
  74. wire [4:0] abc_out_s;
  75. wire [1:0] abc_inp_s;
  76. wire abc_xmemfl_s;
  77. wire abc_xmemw800_s;
  78. wire abc_xmemw80_s;
  79. wire abc_xinpstb_s;
  80. wire abc_xoutpstb_s;
  81. synchronizer #( .width(39) ) abc_synchro
  82. (
  83. .rst_n ( rst_n ),
  84. .clk ( sys_clk ),
  85. .d ( { abc_clk, abc_a, abc_d, ~abc_rst_n, ~abc_cs_n,
  86. ~abc_out_n, ~abc_inp_n, ~abc_xmemfl_n, ~abc_xmemw800_n,
  87. ~abc_xmemw80_n, ~abc_xinpstb_n, ~abc_xoutpstb_n } ),
  88. .q ( { abc_clk_s, abc_a_s, abc_di, abc_rst_s, abc_cs_s,
  89. abc_out_s, abc_inp_s, abc_xmemfl_s, abc_xmemw800_s,
  90. abc_xmemw80_s, abc_xinpstb_s, abc_xoutpstb_s } )
  91. );
  92. assign abc_master = 1'b0; // Only device mode supported
  93. assign abc_d_ce_n = 1'b0; // Do not isolate busses
  94. reg abc_clk_active;
  95. // On ABC800, only one of XINPSTB# or XOUTPSTB# will be active;
  96. // on ABC80 they will either be 00 or ZZ; in the latter case pulled
  97. // low by external resistors.
  98. wire abc80 = abc_xinpstb_s & abc_xoutpstb_s;
  99. wire abc800 = ~abc80;
  100. // Memory and I/O read/write strobes for ABC-bus
  101. reg abc_xmemrd;
  102. reg abc_xmemwr;
  103. reg [1:0] abc_inp;
  104. reg [4:0] abc_out;
  105. reg abc_rst;
  106. reg abc_cs;
  107. reg [3:1] abc_stb; // Delayed strobes
  108. always @(posedge sdram_clk)
  109. begin
  110. abc_xmemrd <= abc_clk_active & abc_xmemfl_s;
  111. abc_xmemwr <= abc_clk_active &
  112. (abc800 ? abc_xmemw800_s : abc_xmemw80_s);
  113. abc_inp <= abc_inp_s & {2{abc_clk_active}};
  114. abc_out <= abc_out_s & {5{abc_clk_active}};
  115. abc_rst <= abc_rst_s & abc_clk_active;
  116. abc_cs <= abc_cs_s & abc_clk_active;
  117. abc_stb <= { abc_stb, |{abc_inp, abc_out, abc_rst,
  118. abc_cs, abc_xmemrd, abc_xmemwr} };
  119. end
  120. reg [7:0] abc_do;
  121. assign abc_d = abc_d_oe ? abc_do : 8'hzz;
  122. reg [8:0] ioselx;
  123. wire iosel_en = ioselx[8];
  124. wire iosel = ioselx[5:0];
  125. // ABC-bus I/O select
  126. always @(negedge rst_n or posedge sdram_clk)
  127. if (~rst_n)
  128. ioselx <= 9'b0;
  129. else if (abc_rst)
  130. ioselx <= 9'b0;
  131. else if (abc_cs)
  132. ioselx <= { 1'b1, abc_di };
  133. // Open drain signals with optional MOSFETs
  134. reg abc_wait = 1'b0;
  135. reg abc_int = 1'b0;
  136. reg abc_nmi = 1'b0;
  137. reg abc_resin = 1'b0;
  138. reg abc_xm = 1'b0;
  139. function reg opt_mosfet(input signal, input mosfet);
  140. if (mosfet)
  141. opt_mosfet = signal;
  142. else
  143. opt_mosfet = signal ? 1'b0 : 1'bz;
  144. endfunction // opt_mosfet
  145. assign abc_int80_x = opt_mosfet(abc_int & abc80, mosfet_installed[1]);
  146. assign abc_rdy_x = opt_mosfet(abc_wait, mosfet_installed[2]);
  147. assign abc_nmi_x = opt_mosfet(abc_nmi, mosfet_installed[3]);
  148. assign abc_resin_x = opt_mosfet(abc_resin, mosfet_installed[4]);
  149. assign abc_int800_x = opt_mosfet(abc_int & abc800, mosfet_installed[5]);
  150. assign abc_xm_x = opt_mosfet(abc_xm, mosfet_installed[6]);
  151. // Detect ABC-bus clock: need a minimum frequency of 84/64 MHz
  152. // to be considered live.
  153. reg [2:0] abc_clk_ctr;
  154. reg [1:0] abc_clk_q;
  155. always @(negedge rst_n or posedge sys_clk)
  156. if (~rst_n)
  157. begin
  158. abc_clk_q <= 2'b0;
  159. abc_clk_ctr <= 3'b0;
  160. abc_clk_active <= 1'b0;
  161. end
  162. else
  163. begin
  164. abc_clk_q <= { abc_clk_q[0], abc_clk_s };
  165. case ( { abc_clk_q == 2'b10, stb_1mhz } )
  166. 5'b10: begin
  167. if (abc_clk_ctr == 3'b111)
  168. abc_clk_active <= 1'b1;
  169. else
  170. abc_clk_ctr <= abc_clk_ctr + 1'b1;
  171. end
  172. 5'b01: begin
  173. if (abc_clk_ctr == 3'b000)
  174. abc_clk_active <= 1'b0;
  175. else
  176. abc_clk_ctr <= abc_clk_ctr - 1'b1;
  177. end
  178. default: begin
  179. // nothing
  180. end
  181. endcase // case ( {(abc_clk_q == 2'10), sys_clk_stb[6]} )
  182. end // else: !if(~rst_n)
  183. // ABC-bus extension header (exth_c and exth_h are input only)
  184. // The naming of pins is kind of nonsensical:
  185. //
  186. // +3V3 - 1 2 - +3V3
  187. // HA - 3 4 - HE
  188. // HB - 5 6 - HG
  189. // HC - 7 8 - HH
  190. // HD - 9 10 - HF
  191. // GND - 11 12 - GND
  192. //
  193. // This layout allows the header to be connected on either side
  194. // of the board. This logic assigns the following names to the pins;
  195. // if the ext_reversed is set to 1 then the left and right sides
  196. // are flipped.
  197. //
  198. // +3V3 - 1 2 - +3V3
  199. // exth[0] - 3 4 - exth[1]
  200. // exth[2] - 5 6 - exth[3]
  201. // exth[6] - 7 8 - exth[7]
  202. // exth[4] - 9 10 - exth[5]
  203. // GND - 11 12 - GND
  204. wire [7:0] exth_d; // Input data
  205. wire [5:0] exth_q; // Output data
  206. wire [5:0] exth_oe; // Output enable
  207. assign exth_d[0] = exth_reversed ? exth_he : exth_ha;
  208. assign exth_d[1] = exth_reversed ? exth_ha : exth_he;
  209. assign exth_d[2] = exth_reversed ? exth_hg : exth_hb;
  210. assign exth_d[3] = exth_reversed ? exth_hb : exth_hg;
  211. assign exth_d[4] = exth_reversed ? exth_hf : exth_hd;
  212. assign exth_d[5] = exth_reversed ? exth_hd : exth_hf;
  213. assign exth_d[6] = exth_reversed ? exth_hh : exth_hc;
  214. assign exth_d[7] = exth_reversed ? exth_hc : exth_hh;
  215. wire [2:0] erx = { 2'b00, exth_reversed };
  216. assign exth_ha = exth_oe[3'd0 ^ erx] ? exth_q[3'd0 ^ erx] : 1'bz;
  217. assign exth_he = exth_oe[3'd1 ^ erx] ? exth_q[3'd1 ^ erx] : 1'bz;
  218. assign exth_hb = exth_oe[3'd2 ^ erx] ? exth_q[3'd2 ^ erx] : 1'bz;
  219. assign exth_hg = exth_oe[3'd3 ^ erx] ? exth_q[3'd3 ^ erx] : 1'bz;
  220. assign exth_hd = exth_oe[3'd4 ^ erx] ? exth_q[3'd4 ^ erx] : 1'bz;
  221. assign exth_hf = exth_oe[3'd5 ^ erx] ? exth_q[3'd5 ^ erx] : 1'bz;
  222. assign exth_q = 6'b0;
  223. assign exth_oe = 6'b0;
  224. // ABC SDRAM interface
  225. //
  226. // Memory map for ABC-bus memory references.
  227. // 512 byte granularity for memory (registers 0-127),
  228. // one input and one output queue per select code for I/O (128-255).
  229. //
  230. // bit [24:0] = SDRAM address.
  231. // bit [25] = write enable ( bit 30 from CPU )
  232. // bit [26] = read enable ( bit 31 from CPU )
  233. // bit [35:27] = DMA count for I/O ( separate register 384-511 from CPU )
  234. //
  235. // Accesses from the internal CPU supports 32-bit accesses only!
  236. //
  237. // If the DMA counter is exhausted, or I/O operations other than port 0,
  238. // I/O is instead directed to a memory area pointed to by the iomem_base
  239. // register as:
  240. // bit [24:4] = iomem_base
  241. // bit [3] = read
  242. // bit [2:0] = port
  243. //
  244. // However, the rd and wr enable bits in the I/O map still apply.
  245. //
  246. wire [7:0] abc_map_addr =
  247. abc_out_s[0] ? { 1'b1, iosel, 1'b0 } :
  248. abc_inp_s[0] ? { 1'b1, iosel, 1'b1 } :
  249. { 1'b0, abc_a_s[15:9] };
  250. wire [35:0] rdata_abcmemmap;
  251. wire [35:0] abc_memmap_rd;
  252. //
  253. // For I/O, don't allow the read/write enables to conflict with
  254. // the direction of the I/O.
  255. //
  256. wire [1:0] abcmap_masked_rdwr = cpu_wdata[31:30] &
  257. { ~cpu_addr[9] | ~cpu_addr[2],
  258. ~cpu_addr[9] | cpu_addr[2] };
  259. wire [8:0] next_dma_count = abc_dma_count - 1'b1;
  260. wire next_dma_empty = ~&next_dma_count;
  261. abcmapram abcmapram (
  262. .aclr ( ~rst_n ),
  263. .clock ( sdram_clk ),
  264. .address_a ( abc_map_addr ),
  265. .data_a ( { next_dma_count,
  266. abc_rden, abc_wren,
  267. abc_memaddr + 1'b1 } ),
  268. .wren_a ( abc_dma_update ),
  269. .byteena_a ( 4'b1111 ),
  270. .q_a ( abc_memmap_rd ),
  271. .address_b ( cpu_addr[9:2] ),
  272. .data_b ( { cpu_wdata[8:0],
  273. abcmap_masked_rdwr,
  274. cpu_wdata[24:0] } ),
  275. .wren_b ( map_valid & ~cpu_addr[11] & cpu_wstrb[0] ),
  276. .byteena_b ( { cpu_addr[10],
  277. {3{~cpu_addr[10]}} } ),
  278. .q_b ( rdata_abcmemmap )
  279. );
  280. // Note: added one extra cycle of pipelining here for timing
  281. reg [24:0] abc_memaddr;
  282. reg [8:0] abc_dma_count;
  283. reg abc_dma_nzero;
  284. reg abc_rden;
  285. reg abc_wren;
  286. always @(negedge rst_n or posedge sdram_clk)
  287. if (~rst_n)
  288. begin
  289. abc_dma_count <= 9'b0;
  290. abc_dma_nzero <= 1'b0;
  291. abc_rden <= 1'b0;
  292. abc_wren <= 1'b0;
  293. abc_memaddr <= 26'b0;
  294. end
  295. else
  296. begin
  297. { abc_dma_count, abc_rden, abc_wren, abc_memaddr } <= abc_memmap_rd;
  298. abc_dma_nzero <= |abc_memmap_rd[35:27]; // -> |abc_dma_count
  299. end
  300. //
  301. // RAM for the status register (INP 1). This is in a separate SRAM
  302. // so that it can be adjusted for certain DMA events.
  303. // bit [7:0] - status register value
  304. // bit [8] - clear bit 0 on read DMA empty
  305. // bit [9] - clear bit 0 on write DMA empty
  306. // bit [10] - clear bit 1 on write DMA empty
  307. // bit [11] - clear bit 7 on any DMA event
  308. //
  309. wire [15:0] status_out;
  310. wire [15:0] rdata_status;
  311. statusram statusram (
  312. .aclr ( ~rst_n ),
  313. .clock ( sdram_clk ),
  314. .address_a ( iosel ),
  315. .data_a ( status_out &
  316. ~{ 4'hf0, status_out[11], 5'b00000,
  317. status_out[10] & abc_out_s[0]
  318. & next_dma_empty,
  319. ((status_out[9] & abc_out_s[0]) |
  320. (status_out[8] & abc_inp_s[0]))
  321. & next_dma_empty } ),
  322. .wren_a ( abc_dma_update ),
  323. .q_a ( status_out ),
  324. .address_b ( cpu_addr[7:2] ),
  325. .data_b ( cpu_wdata[11:0] ),
  326. .q_b ( rdata_status ),
  327. .wren_b ( map_valid & cpu_addr[11] & cpu_wstrb[0] )
  328. );
  329. assign cpu_rdata_map = cpu_addr[11] ?
  330. { 16'b0, rdata_status } :
  331. cpu_addr[10] ?
  332. { 23'b0, rdata_abcmemmap[35:27] } :
  333. { rdata_abcmemmap[26:25], 5'b0,
  334. rdata_abcmemmap[24:0] };
  335. reg [24:4] abc_iobase;
  336. reg abc_memrd_en;
  337. reg abc_memwr_en;
  338. reg abc_dma_en;
  339. reg abc_iowr_en;
  340. reg abc_iord_en;
  341. reg abc_do_memrd;
  342. reg abc_do_memwr;
  343. reg abc_racked;
  344. reg abc_wacked;
  345. wire abc_rack;
  346. wire abc_wack;
  347. wire abc_rready;
  348. always @(posedge sdram_clk or negedge rst_n)
  349. if (~rst_n)
  350. begin
  351. abc_memrd_en <= 1'b0;
  352. abc_memwr_en <= 1'b0;
  353. abc_dma_en <= 1'b0;
  354. abc_iord_en <= 1'b0;
  355. abc_iowr_en <= 1'b0;
  356. abc_do_memrd <= 1'b0;
  357. abc_do_memwr <= 1'b0;
  358. sdram_rrq <= 1'b0;
  359. sdram_wrq <= 1'b0;
  360. abc_racked <= 1'b0;
  361. abc_wacked <= 1'b0;
  362. abc_dma_update <= 1'b0;
  363. end
  364. else
  365. begin
  366. // Careful with the registering here: need to make sure
  367. // abcmapram is caught up for I/O; for memory the address
  368. // will have been stable for some time
  369. abc_memwr_en <= abc_xmemwr;
  370. abc_memrd_en <= abc_xmemrd;
  371. abc_dma_en <= iosel_en & (abc_out[0] | abc_inp[0]) & abc_stb[3] &
  372. abc_dma_nzero;
  373. abc_iowr_en <= iosel_en & |abc_out & abc_stb[3];
  374. abc_iord_en <= iosel_en & |abc_inp & abc_stb[3];
  375. abc_do_memrd <= abc_rden & (abc_memrd_en |
  376. (abc_iord_en & abc_inp[0]));
  377. abc_do_memwr <= abc_wren & (abc_memwr_en | abc_iowr_en);
  378. abc_racked <= abc_do_memrd & (sdram_rack | abc_racked);
  379. abc_wacked <= abc_do_memwr & (sdram_wack | abc_wacked);
  380. sdram_rrq <= abc_do_memrd & ~abc_racked;
  381. sdram_wrq <= abc_do_memwr & ~abc_wacked;
  382. // This will be true for one cycle only, which is what we want
  383. abc_dma_update <= abc_dma_en &
  384. ((sdram_rrq & abc_racked) |
  385. (sdram_wrq & abc_wacked));
  386. end // else: !if(~rst_n)
  387. assign sdram_addr =
  388. (abc_dma_en & |abc_dma_count) ? abc_memaddr :
  389. (abc_iord_en|abc_iowr_en) ? { abc_iobase, |abc_inp_s, abc_a_s[2:0] } :
  390. { abc_memaddr[24:9], abc_a_s[8:0] };
  391. assign sdram_wd = abc_di;
  392. // I/O status bits: sets the irq_status bits (sticky, write-1-clear)
  393. // The RST# (INP 7) and CS# (OUT 1) signals are always valid
  394. // regardless of the current select code; OUT 0/INP 0 only
  395. // set the bit once the DMA counter reaches or already is zero.
  396. wire [7:0] abc_inpflag = { abc_rst, 5'b00000,
  397. abc_iord_en & abc_rden & abc_inp[1],
  398. abc_iord_en & abc_rden & ~abc_dma_nzero & abc_inp[0] };
  399. wire [7:0] abc_outflag = { 2'b00,
  400. {4{abc_iowr_en & abc_wren}} & abc_out[4:1],
  401. abc_cs,
  402. abc_iowr_en & abc_wren & ~abc_dma_nzero & abc_out[0] };
  403. // DMA status register: set on *any* DMA access.
  404. // bit 0 = out DMA; bit 1 = in DMA.
  405. wire [1:0] abc_dmaflag = { abc_iord_en & abc_rden & abc_dma_en,
  406. abc_iowr_en & abc_wren & abc_dma_en };
  407. //
  408. // ABC-bus data bus handling
  409. //
  410. always @(posedge sdram_clk or negedge rst_n)
  411. if (~rst_n)
  412. begin
  413. abc_do <= 8'hxx;
  414. abc_d_oe <= 1'b0;
  415. end
  416. else if (abc_inp[1] & abc_iord_en & abc_rden)
  417. begin
  418. abc_do <= status_out;
  419. abc_d_oe <= 1'b1;
  420. end
  421. else if (abc_racked & sdram_rready)
  422. begin
  423. abc_do <= sdram_rd;
  424. abc_d_oe <= 1'b1;
  425. end
  426. else
  427. begin
  428. abc_do <= 8'hxx;
  429. abc_d_oe <= 1'b0;
  430. end
  431. //
  432. // ABC-bus control/status registers
  433. // All these registers are 32-bit access only except the I/O status
  434. // register (which is write-1-clear.)
  435. //
  436. reg clear_irq;
  437. reg [31:0] irq_mask;
  438. always @(posedge sys_clk or negedge rst_n)
  439. if (~rst_n)
  440. begin
  441. abc_iobase <= 20'bx;
  442. irq_mask <= 32'b0;
  443. clear_irq <= 1'b0;
  444. // abc_resin, nmi, int and wait are deliberately not affected
  445. // by an internal CPU reset. They are, however, initialized
  446. // to 0 on a CPU init (see above.)
  447. end
  448. else
  449. begin
  450. clear_irq <= 1'b0;
  451. if (abc_valid & cpu_wstrb[0])
  452. begin
  453. casez (cpu_addr[5:2])
  454. 5'b??010:
  455. abc_iobase <= cpu_wdata[24:4];
  456. 5'b??011:
  457. { abc_resin, abc_nmi, abc_int, abc_wait } <= cpu_wdata[3:0];
  458. 5'b??100:
  459. irq_mask <= cpu_wdata;
  460. 5'b??101:
  461. clear_irq <= 1'b1;
  462. default:
  463. /* do nothing */ ;
  464. endcase // casez (cpu_addr[5:2])
  465. end // if (abc_valid & cpu_wstrb[0])
  466. end
  467. reg [2:0] abc_status[0:1];
  468. always @(posedge sys_clk)
  469. begin
  470. abc_status[0] <= { 5'b0, abc800, abc_rst_s, abc_clk_active };
  471. abc_status[1] <= abc_status[0];
  472. end
  473. wire [31:0] irq_status_in = { 5'b0, abc_status[1] ^ abc_status[0],
  474. 6'b0, abc_dmaflag,
  475. abc_inpflag,
  476. abc_outflag };
  477. reg [31:0] irq_status;
  478. wire [31:0] irq_status_mask = 32'h07_03_83_3f; // Valid status bits
  479. always @(negedge rst_n or posedge sys_clk)
  480. if (~rst_n)
  481. irq_status <= 32'b0;
  482. else
  483. irq_status <= ( irq_status_in & irq_status_mask ) |
  484. (irq_status & ~({32{clear_irq}} & cpu_wdata));
  485. // Level triggered IRQ
  486. always @(negedge rst_n or posedge sys_clk)
  487. if (~rst_n)
  488. irq <= 1'b0;
  489. else
  490. irq <= |(irq_status & irq_mask);
  491. // Read MUX
  492. always_comb
  493. casez (cpu_addr[5:2])
  494. 5'b00000: cpu_rdata = { 24'b0, abc_status[0] };
  495. 5'b00001: cpu_rdata = { 23'b0, ~iosel_en, ioselx[7:0] };
  496. 5'b00010: cpu_rdata = abc_iobase;
  497. 5'b00011: cpu_rdata = { 28'b0, abc_resin, abc_nmi, abc_int, abc_wait };
  498. 5'b00100: cpu_rdata = irq_mask & irq_status_mask;
  499. 5'b00101: cpu_rdata = irq_status;
  500. default: cpu_rdata = 32'bx;
  501. endcase // casez (cpu_addr[5:2])
  502. endmodule // abcbus