ToB企服应用市场:ToB评测及商务社交产业平台

标题: parameter常数及常数函数的使用 [打印本页]

作者: 慢吞云雾缓吐愁    时间: 2024-5-15 11:36
标题: parameter常数及常数函数的使用
模型功能

模型框图

`timescale 1ns / 1ps
/*
  1. */
  2. // *******************************************************************************
  3. // Company: Fpga Publish
  4. // Engineer: FP
  5. //
  6. // Create Date: 2024/03/24 12:39:43
  7. // Design Name:
  8. // Module Name: verilog_demo
  9. // Project Name:
  10. // Target Devices: ZYNQ7010 | XCZU2CG | Kintex7
  11. // Tool Versions: 2021.1 || 2022.2
  12. // Description:
  13. //         *
  14. // Dependencies:
  15. //         *
  16. // Revision: 0.01
  17. // Revision 0.01 - File Created
  18. // Additional Comments:
  19. //
  20. // *******************************************************************************
  21. module verilog_demo #(
  22.     //mode
  23.     parameter MD_SIM_ABLE = 0,
  24.     //number
  25.     parameter NB_DELAY_CLK = 100,
  26.     //width
  27.     parameter WD_ERR_INFO = 4
  28.    )(
  29.     //! system signals
  30.     input           i_sys_clk   ,  
  31.     input           i_sys_resetn,  
  32.     //! @virtualbus uart_interface @dir out
  33.     output          m_uart_0_mtx, //! uart master tx
  34.     input           m_uart_0_mrx, //! uart master rx
  35.     //! @end
  36.     //! error info feedback
  37.     output   [WD_ERR_INFO-1:0]  m_err_verilog_info1
  38. );
  39. //========================================================
  40. //function to math and logic
  41. function automatic integer LOG2(input integer N);
  42. begin
  43.     N = N - 1;
  44.     for(LOG2 = 0; N > 0; LOG2 = LOG2 + 1)
  45.     begin
  46.         N = N >> 1;
  47.     end
  48. end
  49. endfunction
  50. //========================================================
  51. //localparam to converation and calculate
  52. //========================================================
  53. //register and wire to time sequence and combine
  54. //========================================================
  55. //always and assign to drive logic and connect
  56. //========================================================
  57. //module and task to build part of system
  58. //========================================================
  59. //expand and plug-in part with version
  60. //========================================================
  61. //ila and vio to debug and monitor
  62. endmodule
  63.               
  64. /* end verilog
复制代码
   */
实现步骤






最终效果

调用接口


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4