Professional Documents
Culture Documents
Verilog-Mode Veritedium 20090925
Verilog-Mode Veritedium 20090925
Verilog-Mode Veritedium 20090925
9/25/2009
wsnyder
Verilog-Mode
Still Reducing the Veri-Tedium
http://www.veripool.org/papers
/*AUTOAUTHOR*/
Wilson Snyder
wsnyder@wsnyder.org
Agenda wsnyder
Verilog-mode Features
• Wires, Regs, Null Modules, etc…
• Instantiations
module tedium (
input i1, i2,
output o1, o2); Regs still needed for outputs.
reg o1; ( “output reg” somewhat better)
wire o2;
wire inter1; Wires still needed for interconnections.
always @*
o1 = i1 | i2 | inter1; @* - Proposed based on Verilog-Mode!
sub s1 (.i (i1),
.o (o2),
.* - Saves lots of typing,
.*); But can’t see what’s being
connected!
sub s2 (.i (i1),
.o (o2),
.*); When connections aren’t
endmodule
simple, you still need to make
connections by hand
5
9/25/2009
/*AUTOWIRE*/ /*AUTOWIRE*/
wire o; wire o;
C-c C-a
sub s1 (/*AUTOINST*/);(or use menu) sub s1 (/*AUTOINST*/
.i (i),
.o (o));
C-c C-d
(or use menu)
Agenda wsnyder
Verilog-mode Features
• Wires, Regs, Null Modules, etc…
• Instantiations
Verilog-2001 took this idea from Verilog-Mode and created “always @*”
I’d suggest using @* and only use /*AS*/ when you want to see what a large
block is sensitive to.
14
9/25/2009
/*AUTOWIRE*/
/*AUTOWIRE*/ takes the outputs
// Beginning of autos
of sub modules and declares wires wire [1:0] bus; // From a,b
for them (if needed -- you can wire y; // From b
declare them yourself). wire z; // From a
// End of automatics
/*AUTOREG*/
…
/*AUTOWIRE*/ a a (
/*AUTOREG*/ // Outputs
.bus (bus[0]),
a a (// Outputs .z (z));
.bus (bus[0]),
.z (z)); b b (
// Outputs
b b (// Outputs .bus (bus[1]),
.bus (bus[1]), .y (y));
.y (y));
GNU Emacs (Verilog-Mode))
GNU Emacs (Verilog-Mode))
16
9/25/2009
/*AUTOINSERTLISP(insert "//hello")*/
/*AUTOINSERTLISP(insert (shell-command-to-string
"echo //hello"))*/
/*AUTOINSERTLISP(insert "//hello")*/
//hello
/*AUTOINSERTLISP(insert (shell-command-to-string
"echo //hello"))*/
//hello
`ifdefs wsnyder
module m ( module m (
`ifdef c_input `ifdef c_input Why not
c, c, automatic?
`endif `endif
/*AUTOARG*/) /*AUTOARG*/
Obviously, the `ifdefs would
// Inputs
input a; have to be put into the output
a, b) text (for it to work for both the
input b; defined & undefined cases.)
input a;
`ifdef c_input input b; One ifdef would work, but
input c; consider multiple nested ifdefs
each on overlapping signals.
`endif `ifdef c_input The algorithm gets horribly
input c; complex for the other
`endif commands (AUTOWIRE).
GNU Emacs (Verilog-Mode)) GNU Emacs (Verilog-Mode))
22
9/25/2009
Agenda wsnyder
Verilog-mode Features
• Wires, Regs, Null Modules, etc…
• Instantiations
/*AUTOINST*/
Look for the submod.v file,
read its in/outputs. submod s (/*AUTOINST*/
// Outputs
.out (out),
// Inputs
submod s (/*AUTOINST*/);
.in (in));
@ in the template takes the leading [] takes the bit range for the bus
digits from the reference. from the referenced module.
(Or next slide.) Generally, always just add [].
Overriding @ wsnyder
Predefined Variables
@”{lisp_expression}”
Decodes in this case to: See the documentation for variables that are
useful in Lisp templates:
in[31-{the_instant_number}] vl-cell-type, vl-cell-name, vl-modport,
vl-name, vl-width, vl-dir.
AUTOINSTPARAM is
just like AUTOINST, but
“connects” parameters.
submod #(.WIDTH(8))
Often, you want parameters to be i (/*AUTOINST*/
“constant” in the parent module. .out(out[WIDTH-1:0]));
verilog-auto-inst-param-value
controls this. // Local Variables:
// verilog-auto-inst-param-value:nil
submod #(.WIDTH(8)) // End:
i (/*AUTOINST*/);
or
GNU Emacs (Verilog-Mode))
submod #(.WIDTH(8))
i (/*AUTOINST*/
GNU Emacs (Verilog-Mode))
.out(out[7:0]));
// Local Variables:
// verilog-auto-inst-param-value:t
// End:
SystemVerilog .* wsnyder
SystemVerilog .* expands
just like AUTOINST.
1. Old Scheme
// Local Variables:
// verilog-library-directories:("." "dir1" "dir2" ...)
// End:
GNU Emacs (Verilog-Mode)) Jumping: C-c C-d
C-c C-d jumps to the definition of the
2. Better entered module
// Local Variables:
// verilog-auto-library-flags:(”–y dir1 –y dir2”)
// End:
GNU Emacs (Verilog-Mode))
3. Best
// Local Variables:
// verilog-auto-library-flags:(”–f ../../input.vc”)
// End:
GNU Emacs (Verilog-Mode)) // input.vc
-y dir1
Best, as input.vc can (should) be the same -y dir2
file you feed your lint/synth/simulator.
36
9/25/2009
Agenda wsnyder
Verilog-mode Features
• Wires, Regs, Null Modules, etc…
• Instantiations
Homework
• Due Next week:
- Install Verilog-Mode
- Try Inject-Autos
- Use AUTOINST in one module
Additional Tools
• Schedule::Load – Load Balancing (ala LSF)
• SystemPerl – /*AUTOs*/ for SystemC
• Verilog-Mode for Emacs – /*AUTO…*/ Expansion
• Verilog-Perl – Toolkit with Preprocessing, Renaming, etc
• Verilator – Compile SystemVerilog into SystemC
• Vregs – Extract register and class
declarations from documentation