I am trying to have verilog mode indent everything using 2 spaces except decls and always. This is what I added to my .emacs:
;; `define are not indented
(setq verilog-indent-level-directive 0)
;; always, initial etc not indented
(setq verilog-indent-level-module 0)
;; logic declarations are not indented
(setq verilog-indent-level-declaration 0)
;;2 space indent
(setq verilog-indent-level 2)
;; no indent on list and no indent when on multiple lines
(setq verilog-indent-lists nil)
(setq verilog-cexp-indent 0)
These is the result on a test module
`ifndef MY_MODULE_SV
`define MY_MODULE_SV
module my_module #(
parameter MyPar1 = 16,
parameter MyPar2 = 32
) (
input logic clk,
input logic reset,
//comment indented weirdly
output logic [3:0] result
);
logic [3:0] count;
always @(posedge clk) begin
//comment indented ok
if (reset) begin
count <= 0;
result <= 0;
end
else begin
result <= count;
count <= count+1;
end
end
endmodule; // my_module
`endif
The part that is not correct are the port and parameter list.
Also the declaration of count
gets aligned to the port declarations, which is strange.
I would like this to look like:
module my_module #(
parameter MyPar1 = 16,
parameter MyPar2 = 32
) (
input logic clk,
input logic reset,
//result signal
output logic [3:0] result
);
I am using emacs 24.3.1 I am not sure how to tweak this using only the variables provided by the verilog mode, any suggestion?
Recent versions of
verilog-mode
have theverilog-indent-lists
option which when set tonil
results in the desired behavior: