|
1 | 1 | <!doctype html> |
2 | 2 |
|
3 | | -<title>CodeMirror: Verilog mode</title> |
| 3 | +<title>CodeMirror: Verilog/SystemVerilog mode</title> |
4 | 4 | <meta charset="utf-8"/> |
5 | 5 | <link rel=stylesheet href="../../doc/docs.css"> |
6 | 6 |
|
7 | 7 | <link rel="stylesheet" href="../../lib/codemirror.css"> |
8 | 8 | <script src="../../lib/codemirror.js"></script> |
| 9 | +<script src="../../addon/edit/matchbrackets.js"></script> |
9 | 10 | <script src="verilog.js"></script> |
10 | | -<style>.CodeMirror {border: 2px inset #dee;}</style> |
| 11 | +<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> |
11 | 12 | <div id=nav> |
12 | 13 | <a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a> |
13 | 14 |
|
|
18 | 19 | </ul> |
19 | 20 | <ul> |
20 | 21 | <li><a href="../index.html">Language modes</a> |
21 | | - <li><a class=active href="#">Verilog</a> |
| 22 | + <li><a class=active href="#">Verilog/SystemVerilog</a> |
22 | 23 | </ul> |
23 | 24 | </div> |
24 | 25 |
|
25 | 26 | <article> |
26 | | -<h2>Verilog mode</h2> |
27 | | -<form><textarea id="code" name="code"> |
28 | | -/* Verilog demo code */ |
| 27 | +<h2>SystemVerilog mode</h2> |
29 | 28 |
|
30 | | -module butterfly |
31 | | - #( |
32 | | - parameter WIDTH = 32, |
33 | | - parameter MWIDTH = 1 |
34 | | - ) |
35 | | - ( |
36 | | - input wire clk, |
37 | | - input wire rst_n, |
38 | | - // m_in contains data that passes through this block with no change. |
39 | | - input wire [MWIDTH-1:0] m_in, |
40 | | - // The twiddle factor. |
41 | | - input wire signed [WIDTH-1:0] w, |
42 | | - // XA |
43 | | - input wire signed [WIDTH-1:0] xa, |
44 | | - // XB |
45 | | - input wire signed [WIDTH-1:0] xb, |
46 | | - // Set to 1 when new data is present on inputs. |
47 | | - input wire x_nd, |
48 | | - // delayed version of m_in. |
49 | | - output reg [MWIDTH-1:0] m_out, |
50 | | - // YA = XA + W*XB |
51 | | - // YB = XA - W*XB |
52 | | - output wire signed [WIDTH-1:0] ya, |
53 | | - output wire signed [WIDTH-1:0] yb, |
54 | | - output reg y_nd, |
55 | | - output reg error |
56 | | - ); |
| 29 | +<div><textarea id="code" name="code"> |
| 30 | +// Literals |
| 31 | +1'b0 |
| 32 | +1'bx |
| 33 | +1'bz |
| 34 | +16'hDC78 |
| 35 | +'hdeadbeef |
| 36 | +'b0011xxzz |
| 37 | +1234 |
| 38 | +32'd5678 |
| 39 | +3.4e6 |
| 40 | +-128.7 |
57 | 41 |
|
58 | | - // Set wire to the real and imag parts for convenience. |
59 | | - wire signed [WIDTH/2-1:0] xa_re; |
60 | | - wire signed [WIDTH/2-1:0] xa_im; |
61 | | - assign xa_re = xa[WIDTH-1:WIDTH/2]; |
62 | | - assign xa_im = xa[WIDTH/2-1:0]; |
63 | | - wire signed [WIDTH/2-1: 0] ya_re; |
64 | | - wire signed [WIDTH/2-1: 0] ya_im; |
65 | | - assign ya = {ya_re, ya_im}; |
66 | | - wire signed [WIDTH/2-1: 0] yb_re; |
67 | | - wire signed [WIDTH/2-1: 0] yb_im; |
68 | | - assign yb = {yb_re, yb_im}; |
| 42 | +// Macro definition |
| 43 | +`define BUS_WIDTH = 8; |
69 | 44 |
|
70 | | - // Delayed stuff. |
71 | | - reg signed [WIDTH/2-1:0] xa_re_z; |
72 | | - reg signed [WIDTH/2-1:0] xa_im_z; |
73 | | - // Output of multiplier |
74 | | - wire signed [WIDTH-1:0] xbw; |
75 | | - wire signed [WIDTH/2-1:0] xbw_re; |
76 | | - wire signed [WIDTH/2-1:0] xbw_im; |
77 | | - assign xbw_re = xbw[WIDTH-1:WIDTH/2]; |
78 | | - assign xbw_im = xbw[WIDTH/2-1:0]; |
79 | | - // Do summing |
80 | | - // I don't think we should get overflow here because of the |
81 | | - // size of the twiddle factors. |
82 | | - // If we do testing should catch it. |
83 | | - assign ya_re = xa_re_z + xbw_re; |
84 | | - assign ya_im = xa_im_z + xbw_im; |
85 | | - assign yb_re = xa_re_z - xbw_re; |
86 | | - assign yb_im = xa_im_z - xbw_im; |
87 | | - |
88 | | - // Create the multiply module. |
89 | | - multiply_complex #(WIDTH) multiply_complex_0 |
90 | | - (.clk(clk), |
91 | | - .rst_n(rst_n), |
92 | | - .x(xb), |
93 | | - .y(w), |
94 | | - .z(xbw) |
95 | | - ); |
| 45 | +// Module definition |
| 46 | +module block( |
| 47 | + input clk, |
| 48 | + input rst_n, |
| 49 | + input [`BUS_WIDTH-1:0] data_in, |
| 50 | + output [`BUS_WIDTH-1:0] data_out |
| 51 | +); |
| 52 | + |
| 53 | + always @(posedge clk or negedge rst_n) begin |
96 | 54 |
|
97 | | - always @ (posedge clk) |
98 | | - begin |
99 | | - if (!rst_n) |
100 | | - begin |
101 | | - y_nd <= 1'b0; |
102 | | - error <= 1'b0; |
103 | | - end |
104 | | - else |
105 | | - begin |
106 | | - // Set delay for x_nd_old and m. |
107 | | - y_nd <= x_nd; |
108 | | - m_out <= m_in; |
109 | | - if (x_nd) |
110 | | - begin |
111 | | - xa_re_z <= xa_re/2; |
112 | | - xa_im_z <= xa_im/2; |
113 | | - end |
114 | | - end |
| 55 | + if (~rst_n) begin |
| 56 | + data_out <= 8'b0; |
| 57 | + end else begin |
| 58 | + data_out <= data_in; |
115 | 59 | end |
116 | | - |
| 60 | + |
| 61 | + if (~rst_n) |
| 62 | + data_out <= 8'b0; |
| 63 | + else |
| 64 | + data_out <= data_in; |
| 65 | + |
| 66 | + if (~rst_n) |
| 67 | + begin |
| 68 | + data_out <= 8'b0; |
| 69 | + end |
| 70 | + else |
| 71 | + begin |
| 72 | + data_out <= data_in; |
| 73 | + end |
| 74 | + |
| 75 | + end |
| 76 | + |
117 | 77 | endmodule |
118 | | -</textarea></form> |
119 | 78 |
|
120 | | - <script> |
121 | | - var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
122 | | - lineNumbers: true, |
123 | | - mode: "text/x-verilog" |
124 | | - }); |
125 | | - </script> |
| 79 | +// Class definition |
| 80 | +class test; |
| 81 | + |
| 82 | + /** |
| 83 | + * Sum two integers |
| 84 | + */ |
| 85 | + function int sum(int a, int b); |
| 86 | + int result = a + b; |
| 87 | + string msg = $sformatf("%d + %d = %d", a, b, result); |
| 88 | + $display(msg); |
| 89 | + return result; |
| 90 | + endfunction |
| 91 | + |
| 92 | + task delay(int num_cycles); |
| 93 | + repeat(num_cycles) #1; |
| 94 | + endtask |
| 95 | + |
| 96 | +endclass |
| 97 | + |
| 98 | +</textarea></div> |
126 | 99 |
|
127 | | - <p>Simple mode that tries to handle Verilog-like languages as well as it |
128 | | - can. Takes one configuration parameters: <code>keywords</code>, an |
129 | | - object whose property names are the keywords in the language.</p> |
| 100 | +<script> |
| 101 | + var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
| 102 | + lineNumbers: true, |
| 103 | + matchBrackets: true, |
| 104 | + mode: { |
| 105 | + name: "verilog", |
| 106 | + noIndentKeywords: ["package"] |
| 107 | + } |
| 108 | + }); |
| 109 | +</script> |
| 110 | + |
| 111 | +<p> |
| 112 | +Syntax highlighting and indentation for the Verilog and SystemVerilog languages (IEEE 1800). |
| 113 | +<h2>Configuration options:</h2> |
| 114 | + <ul> |
| 115 | + <li><strong>noIndentKeywords</strong> - List of keywords which should not cause identation to increase. E.g. ["package", "module"]. Default: None</li> |
| 116 | + </ul> |
| 117 | +</p> |
130 | 118 |
|
131 | | - <p><strong>MIME types defined:</strong> <code>text/x-verilog</code> (Verilog code).</p> |
132 | | - </article> |
| 119 | +<p><strong>MIME types defined:</strong> <code>text/x-verilog</code> and <code>text/x-systemverilog</code>.</p> |
| 120 | +</article> |
0 commit comments