[tool] Use Verible's verilog_format as automatic code formatter
This is in the works, just making an official request for it to the current owner within Google. @fangism
Related question: Are there any emacs modefiles that OT people can share? Or scripts (even bad ones)? Cleaning code for a PR takes too much time for me right now.
Even if there are no "final" solutions yet (and I'm not pushing for active development between now and launch) I'd like to hear what stopgap solutions people are using for cleaning their code to match the style guide. @eunchan @asb @tjaychen
I'm VIM person (not trying to debating VIM vs emac :) ). But I don't have any vim configuration for verilog style.
Just a note that there is an open request for a Verilog format tool like exists for C and python. There are some in the works, but have not been staffed heavily due to priorities.
I'm also a vim'r
On Mon, Oct 7, 2019 at 9:37 AM Eunchan Kim [email protected] wrote:
I'm VIM person (not trying to debating VIM vs emac :) ). But I don't have any vim configuration for verilog style.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/56?email_source=notifications&email_token=AJZQKVJC6TCIYWAAN5BUMHTQNNQVVA5CNFSM4ISTJWFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEARABZI#issuecomment-539099365, or mute the thread https://github.com/notifications/unsubscribe-auth/AJZQKVIMX33SIG5ASMQALGTQNNQVVANCNFSM4ISTJWFA .
IIRC @mdhayter has an verilog-mode based emacs config that gets you close to our formatting, but not quite there. Going beyond that is the purpose of this issue.
Thanks @imphil. I'll ask Mark. Honestly any better approximation would be an improvement to what I have now.
There's https://github.com/google/verible now. It's not quite there yet in terms of what we need, @tomroberts-lowrisc can you fill in things that are not working yet for the OT use caes?
@fangism for visibility.
On Tue, Nov 12, 2019 at 01:18:34PM -0800, Philipp Wagner wrote:
There's https://github.com/google/verible now. It's not quite there yet in terms of what we need, @tomroberts-lowrisc can you fill in things that are not working yet for the OT use caes?
I have only had a quick look at the tool. It probably has some further configuration that I haven't figured out yet, but a couple of issues are:
- Horizontal spacing - most (but not all) of the aligned blocks of code get blown away e.g. port list
output logic [31:0] csr_depc_o,
output logic debug_single_step_o,
output logic debug_ebreakm_o,
output logic debug_ebreaku_o,
input logic [31:0] pc_if_i,
Becomes
output logic [31:0] csr_depc_o,
output logic debug_single_step_o,
output logic debug_ebreakm_o,
output logic debug_ebreaku_o,
input logic [31:0] pc_if_i,
- Assignment of structs gets dragged onto a single line
mstatus_d = '{
mie: csr_wdata_int[CSR_MSTATUS_MIE_BIT],
mpie: csr_wdata_int[CSR_MSTATUS_MPIE_BIT],
mpp: priv_lvl_e'(csr_wdata_int[CSR_MSTATUS_MPP_BIT_HIGH:CSR_MSTATUS_MPP_BIT_LOW]),
mprv: csr_wdata_int[CSR_MSTATUS_MPRV_BIT],
tw: csr_wdata_int[CSR_MSTATUS_TW_BIT]
};
Becomes
mstatus_d = '{mie: csr_wdata_int[CSR_MSTATUS_MIE_BIT], mpie: csr_wdata_int[CSR_MSTATUS_MPIE_BIT], mpp: priv_lvl_e'(csr_wdata_int[CSR_MSTATUS_MPP_BIT_HIGH:CSR_MSTATUS_MPP_BIT_LOW]), mprv: csr_wdata_int[CSR_MSTATUS_MPRV_BIT], tw: csr_wdata_int[CSR_MSTATUS_TW_BIT]};
- Some other issues like line breaks getting lost
endcase
end
assign pmp_cfg_wdata[i].exec = csr_wdata_int[(i%4)*PMP_CFG_W+2];
// W = 1, R = 0 is a reserved combination. For now, we force W to 0 if R == 0
Becomes
endcase
end assign pmp_cfg_wdata[i].exec = csr_wdata_int[(i%4) * PMP_CFG_W + 2]; // W = 1, R = 0 is a reserved combination. For now, we force W to 0 if R == 0
Thanks, Tom, for giving it an initial whirl. To set expectations, the Verible formatter is far from a production quality tool at this time. We will happy accept issues filed against it, including comments about severity. But please file at http://github.com/google/verible/issues .
We are now using Ibex as a test bed for Verible format, see lowrisc/ibex#687. Since Ibex and OT use the same coding style, but is significantly smaller, we should be able to iron out the main issues there before doing the same for OpenTitan.