返回首页
当前位置: FPGA主页 > 精彩文章 >

如何使用ModelSim-Altera对NiosII仿真?(3)

时间:2010-01-27 11:37来源:网络 作者:芯合 点击:
ModelSim-Altera部分 第一步:编译Verilog Quartus II已经产生好ModelSim的macro,你只要打s就可重新编译,這是最危险的时刻,若会失败都是出在这个时候。若成功编
 
ModelSim-Altera部分
第一步:编译Verilog

      Quartus II已经产生好ModelSim的macro,你只要打s就可重新编译,這是最危险的时刻,若会失败都是出在这个时候。若成功编译,会有以下的結果:
  1. # Reading C:/altera/72/modelsim_ae/tcl/vsim/pref.tcl   
  2. # Reading D:/0Clare/DE2/DE2_NIOS_ModelSim2/nios_ii_sim/modelsim.tcl   
  3. # c:/altera/72/quartus//sopc_builder  
  4. # c:/altera/72/quartus//bin/perl  
  5. # Sopc_Builder Directory: c:/altera/72/quartus//sopc_builder   
  6. # @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   
  7. # @@   
  8. # @@ setup_sim.do   
  9. # @@   
  10. # @@ Defined aliases:   
  11. # @@   
  12. # @@ s -- Load all design (HDL) files.   
  13. # @@ re-vlog/re-vcom and re-vsim the design.   
  14. # @@   
  15. # @@ c -- Re-compile memory contents.   
  16. # @@ Builds C- and assembly-language programs   
  17. # @@ (and associated simulation data-files   
  18. # @@ such as UART simulation strings) for   
  19. # @@ refreshing memory contents.   
  20. # @@ Does NOT re-generate hardware (HDL) files   
  21. # @@ ONLY WORKS WITH LEGACY SDK (Not the Nios IDE)   
  22. # @@   
  23. # @@ w -- Sets-up waveforms for this design   
  24. # @@ Each SOPC-Builder component may have   
  25. # @@ signals 'marked' for display during   
  26. # @@ simulation. This command opens a wave-   
  27. # @@ window containing all such signals.   
  28. # @@   
  29. # @@ l -- Sets-up list waveforms for this design   
  30. # @@ Each SOPC-Builder component may have   
  31. # @@ signals 'marked' for listing during   
  32. # @@ simulation. This command opens a list-   
  33. # @@ window containing all such signals.   
  34. # @@   
  35. # @@ jtag_uart_drive -- display interactive input window for jtag_uart   
  36. # @@   
  37. # @@ h -- print this message   
  38. # @@   
  39. # @@   
  40. #  OpenFile "nios_ii_sim.mpf"   
  41. # Loading project nios_ii_sim  
  42. s  
  43. # Model Technology ModelSim ALTERA vlog 6.1g Compiler 2006.08 Aug 12 2006  
  44. # -- Compiling module button_pio_s1_arbitrator  
  45. # -- Compiling module cpu_jtag_debug_module_arbitrator  
  46. # -- Compiling module cpu_data_master_arbitrator  
  47. # -- Compiling module cpu_instruction_master_arbitrator  
  48. # -- Compiling module jtag_uart_avalon_jtag_slave_arbitrator  
  49. # -- Compiling module ledg_pio_s1_arbitrator  
  50. # -- Compiling module onchip_mem_s1_arbitrator  
  51. # -- Compiling module sysid_control_slave_arbitrator  
  52. # -- Compiling module nios_ii_reset_clk_domain_synch_module  
  53. # -- Compiling module nios_ii  
  54. # -- Compiling module lcell  
  55. # -- Compiling module ALTERA_MF_MEMORY_INITIALIZATION  
  56. # -- Compiling module ALTERA_MF_HINT_EVALUATION  
  57. # -- Compiling module ALTERA_DEVICE_FAMILIES  
  58. # -- Compiling module dffp  
  59. # -- Compiling module pll_iobuf  
  60. # -- Compiling module stx_m_cntr  
  61. # -- Compiling module stx_n_cntr  
  62. # -- Compiling module stx_scale_cntr  
  63. # -- Compiling module MF_pll_reg  
  64. # -- Compiling module MF_stratix_pll  
  65. # -- Compiling module arm_m_cntr  
  66. # -- Compiling module arm_n_cntr  
  67. # -- Compiling module arm_scale_cntr  
  68. # -- Compiling module MF_stratixii_pll  
  69. # -- Compiling module ttn_m_cntr  
  70. # -- Compiling module ttn_n_cntr  
  71. # -- Compiling module ttn_scale_cntr  
  72. # -- Compiling module MF_stratixiii_pll  
  73. # -- Compiling module cda_m_cntr  
  74. # -- Compiling module cda_n_cntr  
  75. # -- Compiling module cda_scale_cntr  
  76. # -- Compiling module MF_cycloneiii_pll  
  77. # -- Compiling module altpll  
  78. # -- Compiling module altlvds_rx  
  79. # -- Compiling module stratix_lvds_rx  
  80. # -- Compiling module stratixgx_dpa_lvds_rx  
  81. # -- Compiling module stratixii_lvds_rx  
  82. # -- Compiling module flexible_lvds_rx  
  83. # -- Compiling module stratixiii_lvds_rx  
  84. # -- Compiling module stratixiii_lvds_rx_channel  
  85. # -- Compiling module stratixiii_lvds_rx_dpa  
  86. # -- Compiling module altlvds_tx  
  87. # -- Compiling module stratix_tx_outclk  
  88. # -- Compiling module stratixii_tx_outclk  
  89. # -- Compiling module flexible_lvds_tx  
  90. # -- Compiling module altaccumulate  
  91. # -- Compiling module altmult_accum  
  92. # -- Compiling module altmult_add  
  93. # -- Compiling module altfp_mult  
  94. # -- Compiling module altsqrt  
  95. # -- Compiling module altclklock  
  96. # -- Compiling module altddio_in  
  97. # -- Compiling module altddio_out  
  98. # -- Compiling module altddio_bidir  
  99. # -- Compiling module hssi_pll  
  100. # -- Compiling module MF_ram7x20_syn  
  101. # -- Compiling module hssi_fifo  
  102. # -- Compiling module hssi_rx  
  103. # -- Compiling module hssi_tx  
  104. # -- Compiling module altcdr_rx  
  105. # -- Compiling module altcdr_tx  
  106. # -- Compiling module altcam  
  107. # -- Compiling module altdpram  
  108. # -- Compiling module altsyncram  
  109. # -- Compiling module alt3pram  
  110. # -- Compiling module altqpram  
  111. # -- Compiling module parallel_add  
  112. # -- Compiling module scfifo  
  113. # -- Compiling module dcfifo_dffpipe  
  114. # -- Compiling module dcfifo_fefifo  
  115. # -- Compiling module dcfifo_async  
  116. # -- Compiling module dcfifo_sync  
  117. # -- Compiling module dcfifo_low_latency  
  118. # -- Compiling module dcfifo_mixed_widths  
  119. # -- Compiling module dcfifo  
  120. # -- Compiling module altshift_taps  
  121. # -- Compiling module a_graycounter  
  122. # -- Compiling module altsquare  
  123. # -- Compiling module signal_gen  
  124. # -- Compiling module jtag_tap_controller  
  125. # -- Compiling module dummy_hub  
  126. # -- Compiling module sld_virtual_jtag  
  127. # -- Compiling module sld_signaltap  
  128. # -- Compiling module altstratixii_oct  
  129. # -- Compiling module altparallel_flash_loader  
  130. # -- Compiling module altserial_flash_loader  
  131. # -- Compiling module LPM_MEMORY_INITIALIZATION  
  132. # -- Compiling module LPM_HINT_EVALUATION  
  133. # -- Compiling module LPM_DEVICE_FAMILIES  
  134. # -- Compiling module lpm_constant  
  135. # -- Compiling module lpm_inv  
  136. # -- Compiling module lpm_and  
  137. # -- Compiling module lpm_or  
  138. # -- Compiling module lpm_xor  
  139. # -- Compiling module lpm_bustri  
  140. # -- Compiling module lpm_mux  
  141. # -- Compiling module lpm_decode  
  142. # -- Compiling module lpm_clshift  
  143. # -- Compiling module lpm_add_sub  
  144. # -- Compiling module lpm_compare  
  145. # -- Compiling module lpm_mult  
  146. # -- Compiling module lpm_divide  
  147. # -- Compiling module lpm_abs  
  148. # -- Compiling module lpm_counter  
  149. # -- Compiling module lpm_latch  
  150. # -- Compiling module lpm_ff  
  151. # -- Compiling module lpm_shiftreg  
  152. # -- Compiling module lpm_ram_dq  
  153. # -- Compiling module lpm_ram_dp  
  154. # -- Compiling module lpm_ram_io  
  155. # -- Compiling module lpm_rom  
  156. # -- Compiling module lpm_fifo  
  157. # -- Compiling module lpm_fifo_dc_dffpipe  
  158. # -- Compiling module lpm_fifo_dc_fefifo  
  159. # -- Compiling module lpm_fifo_dc_async  
  160. # -- Compiling module lpm_fifo_dc  
  161. # -- Compiling module lpm_inpad  
  162. # -- Compiling module lpm_outpad  
  163. # -- Compiling module lpm_bipad  
  164. # -- Compiling module oper_add  
  165. # -- Compiling module oper_addsub  
  166. # -- Compiling module mux21  
  167. # -- Compiling module io_buf_tri  
  168. # -- Compiling module io_buf_opdrn  
  169. # -- Compiling module oper_mult  
  170. # -- Compiling module tri_bus  
  171. # -- Compiling module oper_div  
  172. # -- Compiling module oper_mod  
  173. # -- Compiling module oper_left_shift  
  174. # -- Compiling module oper_right_shift  
  175. # -- Compiling module oper_rotate_left  
  176. # -- Compiling module oper_rotate_right  
  177. # -- Compiling module oper_less_than  
  178. # -- Compiling module oper_mux  
  179. # -- Compiling module oper_selector  
  180. # -- Compiling module oper_decoder  
  181. # -- Compiling module oper_bus_mux  
  182. # -- Compiling module oper_latch  
  183. # -- Compiling module onchip_mem  
  184. # -- Compiling module cpu_test_bench  
  185. # -- Compiling module cpu_mult_cell  
  186. # -- Compiling module cpu_jtag_debug_module  
  187. # -- Compiling module cpu_jtag_debug_module_wrapper  
  188. # -- Compiling module cpu  
  189. # -- Compiling module sysid  
  190. # -- Compiling module jtag_uart_log_module  
  191. # -- Compiling module jtag_uart_sim_scfifo_w  
  192. # -- Compiling module jtag_uart_scfifo_w  
  193. # -- Compiling module jtag_uart_drom_module  
  194. # -- Compiling module jtag_uart_sim_scfifo_r  
  195. # -- Compiling module jtag_uart_scfifo_r  
  196. # -- Compiling module jtag_uart  
  197. # -- Compiling module ledg_pio  
  198. # -- Compiling module button_pio  
  199. # -- Compiling module test_bench  
  200.  
  201. # Top level modules:  
  202. #     lcell  
  203. #     altpll  
  204. #     altlvds_rx  
  205. #     altlvds_tx  
  206. #     altaccumulate  
  207. #     altmult_accum  
  208. #     altfp_mult  
  209. #     altsqrt  
  210. #     altddio_bidir  
  211. #     altcdr_rx  
  212. #     altcdr_tx  
  213. #     altcam  
  214. #     altdpram  
  215. #     alt3pram  
  216. #     altqpram  
  217. #     parallel_add  
  218. #     scfifo  
  219. #     dcfifo  
  220. #     altshift_taps  
  221. #     a_graycounter  
  222. #     altsquare  
  223. #     sld_virtual_jtag  
  224. #     sld_signaltap  
  225. #     altstratixii_oct  
  226. #     altparallel_flash_loader  
  227. #     altserial_flash_loader  
  228. #     lpm_constant  
  229. #     lpm_inv  
  230. #     lpm_and  
  231. #     lpm_or  
  232. #     lpm_xor  
  233. #     lpm_bustri  
  234. #     lpm_compare  
  235. #     lpm_abs  
  236. #     lpm_counter  
  237. #     lpm_latch  
  238. #     lpm_ff  
  239. #     lpm_shiftreg  
  240. #     lpm_ram_dq  
  241. #     lpm_ram_dp  
  242. #     lpm_ram_io  
  243. #     lpm_rom  
  244. #     lpm_fifo  
  245. #     lpm_fifo_dc  
  246. #     lpm_inpad  
  247. #     lpm_outpad  
  248. #     lpm_bipad  
  249. #     oper_addsub  
  250. #     mux21  
  251. #     io_buf_tri  
  252. #     io_buf_opdrn  
  253. #     oper_mult  
  254. #     tri_bus  
  255. #     oper_div  
  256. #     oper_mod  
  257. #     oper_left_shift  
  258. #     oper_right_shift  
  259. #     oper_rotate_left  
  260. #     oper_rotate_right  
  261. #     oper_mux  
  262. #     oper_selector  
  263. #     oper_decoder  
  264. #     oper_bus_mux  
  265. #     oper_latch  
  266. #     test_bench  
  267. # vsim +nowarnTFMPC -L lpm_ver -L sgate_ver -L altera_mf_ver -L altgxb_ver -L stratixiigx_hssi_ver -L stratixgx_ver -L stratixgx_gxb_ver -L stratixiigx -L altera_ver -L stratixiii_ver -L stratixii_ver -L cycloneii_ver -L cycloneiii_ver -t ps test_bench   
  268. # //  ModelSim ALTERA 6.1g Aug 12 2006   
  269. # //  
  270. # //  Copyright 2006 Mentor Graphics Corporation  
  271. # //              All Rights Reserved.  
  272. # //  
  273. # //  THIS WORK CONTAINS TRADE SECRET AND   
  274. # //  PROPRIETARY INFORMATION WHICH IS THE PROPERTY  
  275. # //  OF MENTOR GRAPHICS CORPORATION OR ITS LICENSORS  
  276. # //  AND IS SUBJECT TO LICENSE TERMS.  
  277. # //  
  278. # Loading work.test_bench  
  279. # Loading work.nios_ii  
  280. # Loading work.button_pio_s1_arbitrator  
  281. # Loading work.button_pio  
  282. # Loading work.cpu_jtag_debug_module_arbitrator  
  283. # Loading work.cpu_data_master_arbitrator  
  284. # Loading work.cpu_instruction_master_arbitrator  
  285. # Loading work.cpu  
  286. # Loading C:\altera\72\modelsim_ae\win32aloem/../altera/verilog/altera_mf.altsyncram  
  287. # Loading C:\altera\72\modelsim_ae\win32aloem/../altera/verilog/altera_mf.ALTERA_DEVICE_FAMILIES  
  288. # Loading C:\altera\72\modelsim_ae\win32aloem/../altera/verilog/altera_mf.ALTERA_MF_MEMORY_INITIALIZATION  
  289. # Loading work.cpu_jtag_debug_module_wrapper  
  290. # Loading work.cpu_jtag_debug_module  
  291. # Loading work.cpu_mult_cell  
  292. # Loading C:\altera\72\modelsim_ae\win32aloem/../altera/verilog/altera_mf.altmult_add  
  293. # Loading work.cpu_test_bench  
  294. # Loading C:\altera\72\modelsim_ae\win32aloem/../altera/verilog/sgate.oper_add  
  295. # Loading C:\altera\72\modelsim_ae\win32aloem/../altera/verilog/220model.lpm_add_sub  
  296. # Loading C:\altera\72\modelsim_ae\win32aloem/../altera/verilog/sgate.oper_less_than  
  297. # Loading work.jtag_uart_avalon_jtag_slave_arbitrator  
  298. # Loading work.jtag_uart  
  299. # Loading work.jtag_uart_scfifo_w  
  300. # Loading work.jtag_uart_sim_scfifo_w  
  301. # Loading work.jtag_uart_log_module  
  302. # Loading work.jtag_uart_scfifo_r  
  303. # Loading work.jtag_uart_sim_scfifo_r  
  304. # Loading work.jtag_uart_drom_module  
  305. # Loading work.ledg_pio_s1_arbitrator  
  306. # Loading work.ledg_pio  
  307. # Loading work.onchip_mem_s1_arbitrator  
  308. # Loading work.onchip_mem  
  309. # Loading work.sysid_control_slave_arbitrator  
  310. # Loading work.sysid  
  311. # Loading work.nios_ii_reset_clk_domain_synch_module  
  312.  
  313. VSIM 3>  


第二步:显示JTAG UART视窗
      输入jtag_uart_drive,printf()的结果将显示在这里
 

 

第三步:显示waveform window
      输入载入wave_presets.do,将载入预设要仿真的信号,也可以自行在加入其他信号。图中的out_port_from_the_ledg_pio就是自行加入的。

第四步:开始仿真
输入 run 800 us,表示开始仿真800 us,结果如下图所示。
 

 
      之前在hello_world.c中,我們曾经
 
  1. for(i = 0; i < 256; i++)  
  2.   IOWR_ALTERA_AVALON_PIO_DATA(LEDG_PIO_BASE, i); 

      若真的在DE2跑起來,只会发现LEDG是全亮的,因为0到255的变化人眼无法辨认,但在ModelSim-Altera就可以看到out_port_from_the_ledg_pio从0、1、2....不断的变化。

结束语
      又是一次很神奇的经验,竟然让ModelSim和Nios II結合在一起,这个对debug帮助很大,不过ModelSim-Altera与Nios II的整合似乎有待加强,也或许是我功力不足,更复杂的Nios II系統,我也沒把握能在ModelSim-Altera仿真成功,毕竟连Nios II Reference Design都过不了,实在令人担心,或许要对Verilog RTL做些修正才能成功仿真。

(责任编辑:admin)
顶一下
(2)
100%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名:密码: 验证码:点击我更换图片
发布者资料
芯合 查看详细资料 发送留言 加为好友 用户等级:注册会员 注册时间:2009-12-17 15:12 最后登录:2010-01-28 14:01
推荐内容