index.html 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <!doctype html>
  2. <title>CodeMirror: Verilog/SystemVerilog mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="../../addon/edit/matchbrackets.js"></script>
  8. <script src="verilog.js"></script>
  9. <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
  10. <div id=nav>
  11. <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
  12. <ul>
  13. <li><a href="../../index.html">Home</a>
  14. <li><a href="../../doc/manual.html">Manual</a>
  15. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  16. </ul>
  17. <ul>
  18. <li><a href="../index.html">Language modes</a>
  19. <li><a class=active href="#">Verilog/SystemVerilog</a>
  20. </ul>
  21. </div>
  22. <article>
  23. <h2>SystemVerilog mode</h2>
  24. <div><textarea id="code" name="code">
  25. // Literals
  26. 1'b0
  27. 1'bx
  28. 1'bz
  29. 16'hDC78
  30. 'hdeadbeef
  31. 'b0011xxzz
  32. 1234
  33. 32'd5678
  34. 3.4e6
  35. -128.7
  36. // Macro definition
  37. `define BUS_WIDTH = 8;
  38. // Module definition
  39. module block(
  40. input clk,
  41. input rst_n,
  42. input [`BUS_WIDTH-1:0] data_in,
  43. output [`BUS_WIDTH-1:0] data_out
  44. );
  45. always @(posedge clk or negedge rst_n) begin
  46. if (~rst_n) begin
  47. data_out <= 8'b0;
  48. end else begin
  49. data_out <= data_in;
  50. end
  51. if (~rst_n)
  52. data_out <= 8'b0;
  53. else
  54. data_out <= data_in;
  55. if (~rst_n)
  56. begin
  57. data_out <= 8'b0;
  58. end
  59. else
  60. begin
  61. data_out <= data_in;
  62. end
  63. end
  64. endmodule
  65. // Class definition
  66. class test;
  67. /**
  68. * Sum two integers
  69. */
  70. function int sum(int a, int b);
  71. int result = a + b;
  72. string msg = $sformatf("%d + %d = %d", a, b, result);
  73. $display(msg);
  74. return result;
  75. endfunction
  76. task delay(int num_cycles);
  77. repeat(num_cycles) #1;
  78. endtask
  79. endclass
  80. </textarea></div>
  81. <script>
  82. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  83. lineNumbers: true,
  84. matchBrackets: true,
  85. mode: {
  86. name: "verilog",
  87. noIndentKeywords: ["package"]
  88. }
  89. });
  90. </script>
  91. <p>
  92. Syntax highlighting and indentation for the Verilog and SystemVerilog languages (IEEE 1800).
  93. <h2>Configuration options:</h2>
  94. <ul>
  95. <li><strong>noIndentKeywords</strong> - List of keywords which should not cause identation to increase. E.g. ["package", "module"]. Default: None</li>
  96. </ul>
  97. </p>
  98. <p><strong>MIME types defined:</strong> <code>text/x-verilog</code> and <code>text/x-systemverilog</code>.</p>
  99. </article>