Advertisement
JayAurabind

Untitled

Jan 10th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VeriLog 18.00 KB | None | 0 0
  1. ///////////////////////////////////////////////////////////////////////
  2. ////                                                              ////
  3. ////  xilinx_internal_jtag.v                                      ////
  4. ////                                                              ////
  5. ////                                                              ////
  6. ////                                                              ////
  7. ////  Author(s):                                                  ////
  8. ////       Nathan Yawn ([email protected])                ////
  9. ////                                                              ////
  10. ////                                                              ////
  11. ////                                                              ////
  12. //////////////////////////////////////////////////////////////////////
  13. ////                                                              ////
  14. //// Copyright (C) 2008 Authors                                   ////
  15. ////                                                              ////
  16. //// This source file may be used and distributed without         ////
  17. //// restriction provided that this copyright statement is not    ////
  18. //// removed from the file and that any derivative work contains  ////
  19. //// the original copyright notice and the associated disclaimer. ////
  20. ////                                                              ////
  21. //// This source file is free software; you can redistribute it   ////
  22. //// and/or modify it under the terms of the GNU Lesser General   ////
  23. //// Public License as published by the Free Software Foundation; ////
  24. //// either version 2.1 of the License, or (at your option) any   ////
  25. //// later version.                                               ////
  26. ////                                                              ////
  27. //// This source is distributed in the hope that it will be       ////
  28. //// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
  29. //// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
  30. //// PURPOSE.  See the GNU Lesser General Public License for more ////
  31. //// details.                                                     ////
  32. ////                                                              ////
  33. //// You should have received a copy of the GNU Lesser General    ////
  34. //// Public License along with this source; if not, download it   ////
  35. //// from http://www.opencores.org/lgpl.shtml                     ////
  36. ////                                                              ////
  37. //////////////////////////////////////////////////////////////////////
  38. //                                                                  //
  39. // This file is a wrapper for the various Xilinx internal BSCAN     //
  40. // TAP devices.  It is designed to take the place of a separate TAP //
  41. // controller in Xilinx systems, to allow a user to access a CPU    //
  42. // debug module (such as that of the OR1200) through the FPGA's     //
  43. // dedicated JTAG / configuration port.                             //
  44. //                                                                  //
  45. //////////////////////////////////////////////////////////////////////
  46. //
  47. // CVS Revision History
  48. //
  49. // $Log: xilinx_internal_jtag.v,v $
  50. // Revision 1.4  2009-12-28 01:15:28  Nathan
  51. // Removed incorrect duplicate assignment of capture_dr_o in SPARTAN2 TAP, per bug report from Raul Fajardo.
  52. //
  53. // Revision 1.3  2009/06/16 02:54:23  Nathan
  54. // Changed some signal names for better consistency between different hardware modules.
  55. //
  56. // Revision 1.2  2009/05/17 20:54:16  Nathan
  57. // Changed email address to opencores.org
  58. //
  59. // Revision 1.1  2008/07/18 20:07:32  Nathan
  60. // Changed the directory structure to match existing projects.
  61. //
  62. // Revision 1.4  2008/07/11 08:26:10  Nathan
  63. // Ran through dos2unix
  64. //
  65. // Revision 1.3  2008/07/11 08:25:52  Nathan
  66. // Added logic to provide CAPTURE_DR signal when necessary, and to provide a TCK while UPDATE_DR is asserted.  Note that there is no TCK event between SHIFT_DR and UPDATE_DR, and no TCK event between UPDATE_DR and the next CAPTURE_DR; the Xilinx BSCAN devices do not provide it.  Tested successfully with the adv_dbg_if on Virtex-4.
  67. //
  68. // Revision 1.2  2008/06/09 19:34:14  Nathan
  69. // Syntax and functional fixes made after compiling each type of BSCAN module using Xilinx tools.
  70. //
  71. // Revision 1.1  2008/05/22 19:54:07  Nathan
  72. // Initial version
  73. //
  74.  
  75.  
  76. `include "xilinx_internal_jtag_options.v"
  77.  
  78. // Note that the SPARTAN BSCAN controllers have more than one channel.
  79. // This implementation always uses channel 1, this is not configurable.
  80. // If you want to use another channel, then it is probably because you
  81. // want to attach multiple devices to the BSCAN device, which means
  82. // you'll be making changes to this file anyway.
  83. // Virtex BSCAN devices are instantiated separately for each channel.
  84. // To select something other than the default (1), change the parameter
  85. // "virtex_jtag_chain".
  86.  
  87.  
  88. module xilinx_internal_jtag (
  89.     tck_o,
  90.     debug_tdo_i,
  91.     tdi_o,
  92.     test_logic_reset_o,
  93.     run_test_idle_o,
  94.     shift_dr_o,
  95.     capture_dr_o,
  96.     pause_dr_o,
  97.     update_dr_o,
  98.     debug_select_o
  99. );
  100.  
  101. // May be 1, 2, 3, or 4
  102. // Only used for Virtex 4/5 devices
  103. parameter virtex_jtag_chain = 1;
  104.  
  105. input debug_tdo_i;
  106. output tck_o;
  107. output tdi_o;
  108. output test_logic_reset_o;
  109. output run_test_idle_o;
  110. output shift_dr_o;
  111. output capture_dr_o;
  112. output pause_dr_o;
  113. output update_dr_o;
  114. output debug_select_o;
  115.  
  116. wire debug_tdo_i;
  117. wire tck_o;
  118. wire drck;
  119. wire tdi_o;
  120. wire test_logic_reset_o;
  121. wire run_test_idle_o;
  122. wire shift_dr_o;
  123. wire pause_dr_o;
  124. wire update_dr_o;
  125. wire debug_select_o;
  126.  
  127.  
  128.  
  129. `ifdef SPARTAN2
  130.  
  131. // Note that this version is missing three outputs.
  132. // It also does not have a real TCK...DRCK1 is only active when USER1 is selected
  133. // AND the TAP is in SHIFT_DR or CAPTURE_DR states...except there's no
  134. // capture_dr output.
  135.  
  136. reg capture_dr_o;
  137. wire update_bscan;
  138. reg update_out;
  139.  
  140. BSCAN_SPARTAN2 BSCAN_SPARTAN2_inst (
  141. .DRCK1(drck), // Data register output for USER1 functions
  142. .DRCK2(), // Data register output for USER2 functions
  143. .RESET(test_logic_reset_o), // Reset output from TAP controller
  144. .SEL1(debug_select_o), // USER1 active output
  145. .SEL2(), // USER2 active output
  146. .SHIFT(shift_dr_o), // SHIFT output from TAP controller
  147. .TDI(tdi_o), // TDI output from TAP controller
  148. .UPDATE(update_bscan), // UPDATE output from TAP controller
  149. .TDO1(debug_tdo_i), // Data input for USER1 function
  150. .TDO2( 1'b0 ) // Data input for USER2 function
  151. );
  152.  
  153. assign pause_dr_o = 1'b0;
  154. assign run_test_idle_o = 1'b0;
  155.  
  156. // We get one TCK during capture_dr state (low,high,SHIFT goes high on next DRCK high)
  157. // On that negative edge, set capture_dr, and it will get registered on the rising
  158. // edge.
  159. always @ (negedge tck_o)
  160. begin
  161.     if(debug_select_o && !shift_dr_o)
  162.         capture_dr_o <= 1'b1;
  163.     else
  164.         capture_dr_o <= 1'b0;
  165. end
  166.  
  167. // The & !update_bscan tern will provide a clock edge so update_dr_o can be registered
  168. // The &debug_select term will drop TCK when the module is un-selected (does not happen in the BSCAN block).
  169. // This allows a user to kludge clock ticks in the IDLE state, which is needed by the advanced debug module.
  170. assign tck_o = (drck & debug_select_o & !update_bscan);
  171.  
  172. // This will hold the update_dr output so it can be registered on the rising edge
  173. // of the clock created above.
  174. always @(posedge update_bscan or posedge capture_dr_o or negedge debug_select_o)
  175. begin
  176.     if(update_bscan) update_out <= 1'b1;
  177.     else if(capture_dr_o) update_out <= 1'b0;
  178.     else if(!debug_select_o) update_out <= 1'b0;
  179. end
  180.  
  181. assign update_dr_o = update_out;
  182.  
  183. `else
  184. `ifdef SPARTAN3
  185. // Note that this version is missing two outputs.
  186. // It also does not have a real TCK...DRCK1 is only active when USER1 is selected.
  187.  
  188. wire capture_dr_o;
  189. wire update_bscan;
  190. reg update_out;
  191.  
  192. BSCAN_SPARTAN3 BSCAN_SPARTAN3_inst (
  193. .CAPTURE(capture_dr_o), // CAPTURE output from TAP controller
  194. .DRCK1(drck), // Data register output for USER1 functions
  195. .DRCK2(), // Data register output for USER2 functions
  196. .RESET(test_logic_reset_o), // Reset output from TAP controller
  197. .SEL1(debug_select_o), // USER1 active output
  198. .SEL2(), // USER2 active output
  199. .SHIFT(shift_dr_o), // SHIFT output from TAP controller
  200. .TDI(tdi_o), // TDI output from TAP controller
  201. .UPDATE(update_bscan), // UPDATE output from TAP controller
  202. .TDO1(debug_tdo_i), // Data input for USER1 function
  203. .TDO2(1'b0) // Data input for USER2 function
  204. );
  205.  
  206. assign pause_dr_o = 1'b0;
  207. assign run_test_idle_o = 1'b0;
  208.  
  209. // The & !update_bscan tern will provide a clock edge so update_dr_o can be registered
  210. // The &debug_select term will drop TCK when the module is un-selected (does not happen in the BSCAN block).
  211. // This allows a user to kludge clock ticks in the IDLE state, which is needed by the advanced debug module.
  212. assign tck_o = (drck & debug_select_o & !update_bscan);
  213.  
  214. // This will hold the update_dr output so it can be registered on the rising edge
  215. // of the clock created above.
  216. always @(posedge update_bscan or posedge capture_dr_o or negedge debug_select_o)
  217. begin
  218.     if(update_bscan) update_out <= 1'b1;
  219.     else if(capture_dr_o) update_out <= 1'b0;
  220.     else if(!debug_select_o) update_out <= 1'b0;
  221. end
  222.  
  223. assign update_dr_o = update_out;
  224.  
  225. `else
  226. `ifdef SPARTAN3A
  227. // Note that this version is missing two outputs.
  228. // At least it has a real TCK.
  229.  
  230. wire capture_dr_o;
  231.  
  232. BSCAN_SPARTAN3A BSCAN_SPARTAN3A_inst (
  233. .CAPTURE(capture_dr_o), // CAPTURE output from TAP controller
  234. .DRCK1(), // Data register output for USER1 functions
  235. .DRCK2(), // Data register output for USER2 functions
  236. .RESET(test_logic_reset_o), // Reset output from TAP controller
  237. .SEL1(debug_select_o), // USER1 active output
  238. .SEL2(), // USER2 active output
  239. .SHIFT(shift_dr_o), // SHIFT output from TAP controller
  240. .TCK(tck_o), // TCK output from TAP controller
  241. .TDI(tdi_o), // TDI output from TAP controller
  242. .TMS(), // TMS output from TAP controller
  243. .UPDATE(update_dr_o), // UPDATE output from TAP controller
  244. .TDO1(debug_tdo_i), // Data input for USER1 function
  245. .TDO2( 1'b0) // Data input for USER2 function
  246. );
  247.  
  248. assign pause_dr_o = 1'b0;
  249. assign run_test_idle_o = 1'b0;
  250.    
  251.  
  252.  
  253. //-----------------------------------------------------------------------
  254. `else
  255.  `ifdef SPARTAN6
  256.  
  257.    wire capture_dr_o;
  258.    
  259. BSCAN_SPARTAN6 #(
  260. .JTAG_CHAIN(1) // Chain number.
  261. )
  262. BSCAN_SPARTAN6_inst (
  263. .CAPTURE(capture_dr_o), // 1-bit Scan Data Register Capture instruction.
  264. .DRCK(drck), // 1-bit Scan Clock instruction. DRCK is a gated version of TCTCK, it toggles during the CAPTUREDR and SHIFTDR states.
  265. .RESET(test_logic_reset_o), // 1-bit Scan register reset instruction.
  266. .RUNTEST(), // 1-bit Asserted when TAP controller is in Run Test Idle state. Make sure is the same  name as BSCAN primitive used in Spartan products.
  267. .SEL(debug_select_o), // 1-bit Scan mode Select instruction.
  268. .SHIFT(shift_dr_o), // 1-bit Scan Chain Shift instruction.
  269. .TCK(tck_o), // 1-bit Scan Clock. Fabric connection to TAP Clock pin.
  270. .TDI(tdi_o), // 1-bit Scan Chain Output. Mirror of TDI input pin to FPGA.
  271. .TMS(debug_tdo_i), // 1-bit Test Mode Select. Fabric connection to TAP.
  272. .UPDATE(update_bscan), // 1-bit Scan Register Update instruction.
  273. .TDO(debug_tdo_i) // 1-bit Scan Chain Input.
  274. );
  275. // End of BSCAN_SPARTAN6_inst instantiation
  276.  
  277.    assign pause_dr_o = 1'b0;
  278.    assign run_test_idle_o = 1'b0;
  279.  
  280.  
  281. //-------------------------------------------------------------------------  
  282.  
  283.    
  284. `else
  285. `ifdef VIRTEX
  286.  
  287. // Note that this version is missing three outputs.
  288. // It also does not have a real TCK...DRCK1 is only active when USER1 is selected.
  289.  
  290. reg capture_dr_o;
  291. wire update_bscan;
  292. reg update_out;
  293.  
  294. BSCAN_VIRTEX BSCAN_VIRTEX_inst (
  295. .DRCK1(drck), // Data register output for USER1 functions
  296. .DRCK2(), // Data register output for USER2 functions
  297. .RESET(test_logic_reset_o), // Reset output from TAP controller
  298. .SEL1(debug_select_o), // USER1 active output
  299. .SEL2(), // USER2 active output
  300. .SHIFT(shift_dr_o), // SHIFT output from TAP controller
  301. .TDI(tdi_o), // TDI output from TAP controller
  302. .UPDATE(update_bscan), // UPDATE output from TAP controller
  303. .TDO1(debug_tdo_i), // Data input for USER1 function
  304. .TDO2( 1'b0) // Data input for USER2 function
  305. );
  306.  
  307. assign pause_dr_o = 1'b0;
  308. assign run_test_idle_o = 1'b0;
  309.  
  310. // We get one TCK during capture_dr state (low,high,SHIFT goes high on next DRCK low)
  311. // On that negative edge, set capture_dr, and it will get registered on the rising
  312. // edge, then de-asserted on the same edge that SHIFT goes high.
  313. always @ (negedge tck_o)
  314. begin
  315.     if(debug_select_o && !shift_dr_o)
  316.         capture_dr_o <= 1'b1;
  317.     else
  318.         capture_dr_o <= 1'b0;
  319. end
  320.  
  321. // The & !update_bscan tern will provide a clock edge so update_dr_o can be registered
  322. // The &debug_select term will drop TCK when the module is un-selected (does not happen in the BSCAN block).
  323. // This allows a user to kludge clock ticks in the IDLE state, which is needed by the advanced debug module.
  324. assign tck_o = (drck & debug_select_o & !update_bscan);
  325.  
  326. // This will hold the update_dr output so it can be registered on the rising edge
  327. // of the clock created above.
  328. always @(posedge update_bscan or posedge capture_dr_o or negedge debug_select_o)
  329. begin
  330.     if(update_bscan) update_out <= 1'b1;
  331.     else if(capture_dr_o) update_out <= 1'b0;
  332.     else if(!debug_select_o) update_out <= 1'b0;
  333. end
  334.  
  335. assign update_dr_o = update_out;
  336.  
  337. `else
  338. `ifdef VIRTEX2
  339.  
  340. // Note that this version is missing two outputs.
  341. // It also does not have a real TCK...DRCK1 is only active when USER1 is selected.
  342.  
  343. wire capture_dr_o;
  344. wire update_bscan;
  345. reg update_out;
  346.  
  347. BSCAN_VIRTEX2 BSCAN_VIRTEX2_inst (
  348. .CAPTURE(capture_dr_o), // CAPTURE output from TAP controller
  349. .DRCK1(drck), // Data register output for USER1 functions
  350. .DRCK2(), // Data register output for USER2 functions
  351. .RESET(test_logic_reset_o), // Reset output from TAP controller
  352. .SEL1(debug_select_o), // USER1 active output
  353. .SEL2(), // USER2 active output
  354. .SHIFT(shift_dr_o), // SHIFT output from TAP controller
  355. .TDI(tdi_o), // TDI output from TAP controller
  356. .UPDATE(update_bscan), // UPDATE output from TAP controller
  357. .TDO1(debug_tdo_i), // Data input for USER1 function
  358. .TDO2( 1'b0 ) // Data input for USER2 function
  359. );
  360.  
  361. assign pause_dr_o = 1'b0;
  362. assign run_test_idle_o = 1'b0;
  363.  
  364. // The & !update_bscan tern will provide a clock edge so update_dr_o can be registered
  365. // The &debug_select term will drop TCK when the module is un-selected (does not happen in the BSCAN block).
  366. // This allows a user to kludge clock ticks in the IDLE state, which is needed by the advanced debug module.
  367. assign tck_o = (drck & debug_select_o & !update_bscan);
  368.  
  369. // This will hold the update_dr output so it can be registered on the rising edge
  370. // of the clock created above.
  371. always @(posedge update_bscan or posedge capture_dr_o or negedge debug_select_o)
  372. begin
  373.     if(update_bscan) update_out <= 1'b1;
  374.     else if(capture_dr_o) update_out <= 1'b0;
  375.     else if(!debug_select_o) update_out <= 1'b0;
  376. end
  377.  
  378. assign update_dr_o = update_out;
  379.  
  380. `else
  381. `ifdef VIRTEX4
  382. // Note that this version is missing two outputs.
  383. // It also does not have a real TCK...DRCK is only active when USERn is selected.
  384.  
  385. wire capture_dr_o;
  386. wire update_bscan;
  387. reg update_out;
  388.  
  389. BSCAN_VIRTEX4 #(
  390. .JTAG_CHAIN(virtex_jtag_chain)
  391. ) BSCAN_VIRTEX4_inst (
  392. .CAPTURE(capture_dr_o), // CAPTURE output from TAP controller
  393. .DRCK(drck), // Data register output for USER function
  394. .RESET(test_logic_reset_o), // Reset output from TAP controller
  395. .SEL(debug_select_o), // USER active output
  396. .SHIFT(shift_dr_o), // SHIFT output from TAP controller
  397. .TDI(tdi_o), // TDI output from TAP controller
  398. .UPDATE(update_bscan), // UPDATE output from TAP controller
  399. .TDO( debug_tdo_i ) // Data input for USER function
  400. );
  401.  
  402. assign pause_dr_o = 1'b0;
  403. assign run_test_idle_o = 1'b0;
  404.  
  405. // The & !update_bscan tern will provide a clock edge so update_dr_o can be registered
  406. // The &debug_select term will drop TCK when the module is un-selected (does not happen in the BSCAN block).
  407. // This allows a user to kludge clock ticks in the IDLE state, which is needed by the advanced debug module.
  408. assign tck_o = (drck & debug_select_o & !update_bscan);
  409.  
  410. // This will hold the update_dr output so it can be registered on the rising edge
  411. // of the clock created above.
  412. always @(posedge update_bscan or posedge capture_dr_o or negedge debug_select_o)
  413. begin
  414.     if(update_bscan) update_out <= 1'b1;
  415.     else if(capture_dr_o) update_out <= 1'b0;
  416.     else if(!debug_select_o) update_out <= 1'b0;
  417. end
  418.  
  419. assign update_dr_o = update_out;
  420.  
  421. `else
  422. `ifdef VIRTEX5
  423. // Note that this version is missing two outputs.
  424. // It also does not have a real TCK...DRCK is only active when USERn is selected.
  425.  
  426. wire capture_dr_o;
  427. wire update_bscan;
  428. reg update_out;
  429.  
  430. BSCAN_VIRTEX5 #(
  431. .JTAG_CHAIN(virtex_jtag_chain)
  432. ) BSCAN_VIRTEX5_inst (
  433. .CAPTURE(capture_dr_o), // CAPTURE output from TAP controller
  434. .DRCK(drck), // Data register output for USER function
  435. .RESET(test_logic_reset), // Reset output from TAP controller
  436. .SEL(debug_select_o), // USER active output
  437. .SHIFT(shift_dr_o), // SHIFT output from TAP controller
  438. .TDI(tdi_o), // TDI output from TAP controller
  439. .UPDATE(update_bscan), // UPDATE output from TAP controller
  440. .TDO(debug_tdo_i) // Data input for USER function
  441. );
  442.  
  443. assign pause_dr_o = 1'b0;
  444. assign run_test_idle_o = 1'b0;
  445.  
  446. // The & !update_bscan tern will provide a clock edge so update_dr_o can be registered
  447. // The &debug_select term will drop TCK when the module is un-selected (does not happen in the BSCAN block).
  448. // This allows a user to kludge clock ticks in the IDLE state, which is needed by the advanced debug module.
  449. assign tck_o = (drck & debug_select_o & !update_bscan);
  450.  
  451. // This will hold the update_dr output so it can be registered on the rising edge
  452. // of the clock created above.
  453. always @(posedge update_bscan or posedge capture_dr_o or negedge debug_select_o)
  454. begin
  455.     if(update_bscan) update_out <= 1'b1;
  456.     else if(capture_dr_o) update_out <= 1'b0;
  457.     else if(!debug_select_o) update_out <= 1'b0;
  458. end
  459.  
  460. assign update_dr_o = update_out;
  461.  
  462.  
  463. `endif
  464. `endif
  465. `endif
  466. `endif
  467. `endif
  468. `endif
  469. `endif //
  470. `endif //
  471.    
  472.  
  473. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement