Fix: merge conflict
[myslice.git] / to-be-integrated / third-party / codemirror-3.15 / mode / verilog / index.html
1 <!doctype html>
2 <html>
3   <head>
4     <meta charset="utf-8">
5     <title>CodeMirror: Verilog mode</title>
6     <link rel="stylesheet" href="../../lib/codemirror.css">
7     <script src="../../lib/codemirror.js"></script>
8     <script src="verilog.js"></script>
9     <link rel="stylesheet" href="../../doc/docs.css">
10     <style>.CodeMirror {border: 2px inset #dee;}</style>
11   </head>
12   <body>
13     <h1>CodeMirror: Verilog mode</h1>
14
15 <form><textarea id="code" name="code">
16 /* Verilog demo code */
17
18 module butterfly
19   #(
20     parameter WIDTH = 32,
21     parameter MWIDTH = 1
22     )
23    (
24     input wire                     clk,
25     input wire                     rst_n,
26     // m_in contains data that passes through this block with no change.
27     input wire [MWIDTH-1:0]        m_in,
28     // The twiddle factor.
29     input wire signed [WIDTH-1:0]  w,
30     // XA
31     input wire signed [WIDTH-1:0]  xa,
32     // XB
33     input wire signed [WIDTH-1:0]  xb,
34     // Set to 1 when new data is present on inputs.
35     input wire                     x_nd,
36     // delayed version of m_in.
37     output reg [MWIDTH-1:0]        m_out,
38     // YA = XA + W*XB
39     // YB = XA - W*XB
40     output wire signed [WIDTH-1:0] ya,
41     output wire signed [WIDTH-1:0] yb,
42     output reg                     y_nd,
43     output reg                     error
44     );
45
46    // Set wire to the real and imag parts for convenience.
47    wire signed [WIDTH/2-1:0]        xa_re;
48    wire signed [WIDTH/2-1:0]        xa_im;
49    assign xa_re = xa[WIDTH-1:WIDTH/2];
50    assign xa_im = xa[WIDTH/2-1:0];
51    wire signed [WIDTH/2-1: 0]       ya_re;
52    wire signed [WIDTH/2-1: 0]       ya_im;
53    assign ya = {ya_re, ya_im};
54    wire signed [WIDTH/2-1: 0]       yb_re;
55    wire signed [WIDTH/2-1: 0]       yb_im;
56    assign yb = {yb_re, yb_im};
57
58    // Delayed stuff.
59    reg signed [WIDTH/2-1:0]         xa_re_z;
60    reg signed [WIDTH/2-1:0]         xa_im_z;
61    // Output of multiplier
62    wire signed [WIDTH-1:0]          xbw;
63    wire signed [WIDTH/2-1:0]        xbw_re;
64    wire signed [WIDTH/2-1:0]        xbw_im;
65    assign xbw_re = xbw[WIDTH-1:WIDTH/2];
66    assign xbw_im = xbw[WIDTH/2-1:0];
67    // Do summing
68    // I don't think we should get overflow here because of the
69    // size of the twiddle factors.
70    // If we do testing should catch it.
71    assign ya_re = xa_re_z + xbw_re;
72    assign ya_im = xa_im_z + xbw_im;
73    assign yb_re = xa_re_z - xbw_re;
74    assign yb_im = xa_im_z - xbw_im;
75    
76    // Create the multiply module.
77    multiply_complex #(WIDTH) multiply_complex_0
78      (.clk(clk),
79       .rst_n(rst_n),
80       .x(xb),
81       .y(w),
82       .z(xbw)
83       );
84
85   always @ (posedge clk)
86     begin
87        if (!rst_n)
88          begin
89             y_nd <= 1'b0;
90             error <= 1'b0;
91          end
92        else
93          begin
94             // Set delay for x_nd_old and m.
95             y_nd <= x_nd;
96             m_out <= m_in;
97             if (x_nd)
98               begin
99                  xa_re_z <= xa_re/2;
100                  xa_im_z <= xa_im/2;
101               end
102          end
103     end
104    
105 endmodule
106 </textarea></form>
107
108     <script>
109       var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
110         lineNumbers: true,
111         mode: "text/x-verilog"
112       });
113     </script>
114
115     <p>Simple mode that tries to handle Verilog-like languages as well as it
116     can. Takes one configuration parameters: <code>keywords</code>, an
117     object whose property names are the keywords in the language.</p>
118
119     <p><strong>MIME types defined:</strong> <code>text/x-verilog</code> (Verilog code).</p>
120   </body>
121 </html>