nios2_uc_nios2_cpu_debug_slave_tck.v 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. //Legal Notice: (C)2020 Altera Corporation. All rights reserved. Your
  2. //use of Altera Corporation's design tools, logic functions and other
  3. //software and tools, and its AMPP partner logic functions, and any
  4. //output files any of the foregoing (including device programming or
  5. //simulation files), and any associated documentation or information are
  6. //expressly subject to the terms and conditions of the Altera Program
  7. //License Subscription Agreement or other applicable license agreement,
  8. //including, without limitation, that your use is for the sole purpose
  9. //of programming logic devices manufactured by Altera and sold by Altera
  10. //or its authorized distributors. Please refer to the applicable
  11. //agreement for further details.
  12. // synthesis translate_off
  13. `timescale 1ns / 1ps
  14. // synthesis translate_on
  15. // turn off superfluous verilog processor warnings
  16. // altera message_level Level1
  17. // altera message_off 10034 10035 10036 10037 10230 10240 10030
  18. module nios2_uc_nios2_cpu_debug_slave_tck (
  19. // inputs:
  20. MonDReg,
  21. break_readreg,
  22. dbrk_hit0_latch,
  23. dbrk_hit1_latch,
  24. dbrk_hit2_latch,
  25. dbrk_hit3_latch,
  26. debugack,
  27. ir_in,
  28. jtag_state_rti,
  29. monitor_error,
  30. monitor_ready,
  31. reset_n,
  32. resetlatch,
  33. tck,
  34. tdi,
  35. tracemem_on,
  36. tracemem_trcdata,
  37. tracemem_tw,
  38. trc_im_addr,
  39. trc_on,
  40. trc_wrap,
  41. trigbrktype,
  42. trigger_state_1,
  43. vs_cdr,
  44. vs_sdr,
  45. vs_uir,
  46. // outputs:
  47. ir_out,
  48. jrst_n,
  49. sr,
  50. st_ready_test_idle,
  51. tdo
  52. )
  53. ;
  54. output [ 1: 0] ir_out;
  55. output jrst_n;
  56. output [ 37: 0] sr;
  57. output st_ready_test_idle;
  58. output tdo;
  59. input [ 31: 0] MonDReg;
  60. input [ 31: 0] break_readreg;
  61. input dbrk_hit0_latch;
  62. input dbrk_hit1_latch;
  63. input dbrk_hit2_latch;
  64. input dbrk_hit3_latch;
  65. input debugack;
  66. input [ 1: 0] ir_in;
  67. input jtag_state_rti;
  68. input monitor_error;
  69. input monitor_ready;
  70. input reset_n;
  71. input resetlatch;
  72. input tck;
  73. input tdi;
  74. input tracemem_on;
  75. input [ 35: 0] tracemem_trcdata;
  76. input tracemem_tw;
  77. input [ 6: 0] trc_im_addr;
  78. input trc_on;
  79. input trc_wrap;
  80. input trigbrktype;
  81. input trigger_state_1;
  82. input vs_cdr;
  83. input vs_sdr;
  84. input vs_uir;
  85. reg [ 2: 0] DRsize /* synthesis ALTERA_ATTRIBUTE = "SUPPRESS_DA_RULE_INTERNAL=\"D101,D103,R101\"" */;
  86. wire debugack_sync;
  87. reg [ 1: 0] ir_out;
  88. wire jrst_n;
  89. wire monitor_ready_sync;
  90. reg [ 37: 0] sr /* synthesis ALTERA_ATTRIBUTE = "SUPPRESS_DA_RULE_INTERNAL=\"D101,D103,R101\"" */;
  91. wire st_ready_test_idle;
  92. wire tdo;
  93. wire unxcomplemented_resetxx1;
  94. wire unxcomplemented_resetxx2;
  95. always @(posedge tck)
  96. begin
  97. if (vs_cdr)
  98. case (ir_in)
  99. 2'b00: begin
  100. sr[35] <= debugack_sync;
  101. sr[34] <= monitor_error;
  102. sr[33] <= resetlatch;
  103. sr[32 : 1] <= MonDReg;
  104. sr[0] <= monitor_ready_sync;
  105. end // 2'b00
  106. 2'b01: begin
  107. sr[35 : 0] <= tracemem_trcdata;
  108. sr[37] <= tracemem_tw;
  109. sr[36] <= tracemem_on;
  110. end // 2'b01
  111. 2'b10: begin
  112. sr[37] <= trigger_state_1;
  113. sr[36] <= dbrk_hit3_latch;
  114. sr[35] <= dbrk_hit2_latch;
  115. sr[34] <= dbrk_hit1_latch;
  116. sr[33] <= dbrk_hit0_latch;
  117. sr[32 : 1] <= break_readreg;
  118. sr[0] <= trigbrktype;
  119. end // 2'b10
  120. 2'b11: begin
  121. sr[15 : 2] <= trc_im_addr;
  122. sr[1] <= trc_wrap;
  123. sr[0] <= trc_on;
  124. end // 2'b11
  125. endcase // ir_in
  126. if (vs_sdr)
  127. case (DRsize)
  128. 3'b000: begin
  129. sr <= {tdi, sr[37 : 2], tdi};
  130. end // 3'b000
  131. 3'b001: begin
  132. sr <= {tdi, sr[37 : 9], tdi, sr[7 : 1]};
  133. end // 3'b001
  134. 3'b010: begin
  135. sr <= {tdi, sr[37 : 17], tdi, sr[15 : 1]};
  136. end // 3'b010
  137. 3'b011: begin
  138. sr <= {tdi, sr[37 : 33], tdi, sr[31 : 1]};
  139. end // 3'b011
  140. 3'b100: begin
  141. sr <= {tdi, sr[37], tdi, sr[35 : 1]};
  142. end // 3'b100
  143. 3'b101: begin
  144. sr <= {tdi, sr[37 : 1]};
  145. end // 3'b101
  146. default: begin
  147. sr <= {tdi, sr[37 : 2], tdi};
  148. end // default
  149. endcase // DRsize
  150. if (vs_uir)
  151. case (ir_in)
  152. 2'b00: begin
  153. DRsize <= 3'b100;
  154. end // 2'b00
  155. 2'b01: begin
  156. DRsize <= 3'b101;
  157. end // 2'b01
  158. 2'b10: begin
  159. DRsize <= 3'b101;
  160. end // 2'b10
  161. 2'b11: begin
  162. DRsize <= 3'b010;
  163. end // 2'b11
  164. endcase // ir_in
  165. end
  166. assign tdo = sr[0];
  167. assign st_ready_test_idle = jtag_state_rti;
  168. assign unxcomplemented_resetxx1 = jrst_n;
  169. altera_std_synchronizer the_altera_std_synchronizer1
  170. (
  171. .clk (tck),
  172. .din (debugack),
  173. .dout (debugack_sync),
  174. .reset_n (unxcomplemented_resetxx1)
  175. );
  176. defparam the_altera_std_synchronizer1.depth = 2;
  177. assign unxcomplemented_resetxx2 = jrst_n;
  178. altera_std_synchronizer the_altera_std_synchronizer2
  179. (
  180. .clk (tck),
  181. .din (monitor_ready),
  182. .dout (monitor_ready_sync),
  183. .reset_n (unxcomplemented_resetxx2)
  184. );
  185. defparam the_altera_std_synchronizer2.depth = 2;
  186. always @(posedge tck or negedge jrst_n)
  187. begin
  188. if (jrst_n == 0)
  189. ir_out <= 2'b0;
  190. else
  191. ir_out <= {debugack_sync, monitor_ready_sync};
  192. end
  193. //synthesis translate_off
  194. //////////////// SIMULATION-ONLY CONTENTS
  195. assign jrst_n = reset_n;
  196. //////////////// END SIMULATION-ONLY CONTENTS
  197. //synthesis translate_on
  198. //synthesis read_comments_as_HDL on
  199. // assign jrst_n = 1;
  200. //synthesis read_comments_as_HDL off
  201. endmodule