4
<title>CodeMirror: Verilog mode</title>
5
<link rel="stylesheet" href="../../lib/codemirror.css">
6
<script src="../../lib/codemirror.js"></script>
7
<script src="verilog.js"></script>
8
<link rel="stylesheet" href="../../doc/docs.css">
9
<style>.CodeMirror {border: 2px inset #dee;}</style>
12
<h1>CodeMirror: Verilog mode</h1>
14
<form><textarea id="code" name="code">
15
/* Verilog demo code */
17
//////////////////////////////////////////////////////////////////////
19
//// wb_master_model.v ////
21
//// This file is part of the SPI IP core project ////
22
//// http://www.opencores.org/projects/spi/ ////
25
//// - Simon Srot (simons@opencores.org) ////
28
//// - i2c/bench/verilog/wb_master_model.v ////
29
//// Copyright (C) 2001 Richard Herveille ////
31
//// All additional information is avaliable in the Readme.txt ////
34
//////////////////////////////////////////////////////////////////////
36
//// Copyright (C) 2002 Authors ////
38
//// This source file may be used and distributed without ////
39
//// restriction provided that this copyright statement is not ////
40
//// removed from the file and that any derivative work contains ////
41
//// the original copyright notice and the associated disclaimer. ////
43
//// This source file is free software; you can redistribute it ////
44
//// and/or modify it under the terms of the GNU Lesser General ////
45
//// Public License as published by the Free Software Foundation; ////
46
//// either version 2.1 of the License, or (at your option) any ////
47
//// later version. ////
49
//// This source is distributed in the hope that it will be ////
50
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
51
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
52
//// PURPOSE. See the GNU Lesser General Public License for more ////
55
//// You should have received a copy of the GNU Lesser General ////
56
//// Public License along with this source; if not, download it ////
57
//// from http://www.opencores.org/lgpl.shtml ////
59
//////////////////////////////////////////////////////////////////////
61
`include "timescale.v"
63
module wb_master_model(clk, rst, adr, din, dout, cyc, stb, we, sel, ack, err, rty);
65
parameter dwidth = 32;
66
parameter awidth = 32;
69
output [awidth -1:0] adr;
70
input [dwidth -1:0] din;
71
output [dwidth -1:0] dout;
74
output [dwidth/8 -1:0] sel;
78
reg [awidth -1:0] adr;
79
reg [dwidth -1:0] dout;
82
reg [dwidth/8 -1:0] sel;
90
dout = {dwidth{1'bx}};
94
sel = {dwidth/8{1'bx}};
98
// Wishbone write cycle
103
input [awidth -1:0] a;
104
input [dwidth -1:0] d;
108
// wait initial delay
109
repeat(delay) @(posedge clk);
111
// assert wishbone signal
118
sel = {dwidth/8{1'b1}};
121
// wait for acknowledge from slave
122
while(~ack) @(posedge clk);
124
// negate wishbone signals
128
adr = {awidth{1'bx}};
129
dout = {dwidth{1'bx}};
131
sel = {dwidth/8{1'bx}};
136
// Wishbone read cycle
141
input [awidth -1:0] a;
142
output [dwidth -1:0] d;
146
// wait initial delay
147
repeat(delay) @(posedge clk);
149
// assert wishbone signals
152
dout = {dwidth{1'bx}};
156
sel = {dwidth/8{1'b1}};
159
// wait for acknowledge from slave
160
while(~ack) @(posedge clk);
162
// negate wishbone signals
166
adr = {awidth{1'bx}};
167
dout = {dwidth{1'bx}};
169
sel = {dwidth/8{1'bx}};
175
// Wishbone compare cycle (read data from location and compare with expected data)
180
input [awidth -1:0] a;
181
input [dwidth -1:0] d_exp;
184
wb_read (delay, a, q);
186
if (d_exp !== q) begin
187
$display("\n--- ERROR: At address 0x%0x, got 0x%0x, expected 0x%0x at time %t", a, q, d_exp, $time);
197
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
200
mode: "text/x-verilog"
204
<p>Simple mode that tries to handle Verilog-like languages as well as it
205
can. Takes one configuration parameters: <code>keywords</code>, an
206
object whose property names are the keywords in the language.</p>
208
<p><strong>MIME types defined:</strong> <code>text/x-verilog</code> (Verilog code).</p>