Code Monkey home page Code Monkey logo

verilog-format's Introduction

Verilog Format

Console application for apply format to verilog file.

sample

How to use

Application options:

usage: [java -jar verilog-format.jar|./verilog-format|verilog-format.exe]
       [-f <pathname>] [-h] [-p] [-s <verilog-format.properties>] [-v]
 -f,--format <pathname>                      verilog file
 -h,--help                                   print this message
 -p,--print                                  print file formated
 -s,--settings <verilog-format.properties>   settings config
 -v,--version                                verilog-format version

Examples

## Print input_file.v formatted
$ ./verilog-format -p -f input_file.v -s verilog-format.properties 

## Format input_file.v
$ ./verilog-format -f input_file.v -s verilog-format.properties

## Format input_file.v
## If .verilog-format.properties exist in project folder, this is used,
## otherwise default setting is used..
$ ./verilog-format -f input_file.v

Install in Linux

  1. Clone repository.

    $ git clone https://github.com/ericsonj/verilog-format.git

  2. Install verilog-format

    $ cd verilog-format/bin/
    $ sudo mkdir /opt/verilog-format
    $ sudo unzip verilog-format-LINUX.zip -d /opt/verilog-format/

  3. Execute like java

    $ java -jar /opt/verilog-format/verilog-format.jar

  4. Execute like linux script

    $ /opt/verilog-format/verilog-format

  5. Install in system

    $ sudo cp /opt/verilog-format/verilog-format /usr/bin/

Install in Windows

  1. Clone repository or download verilog-format-WIN.zip

  2. Unzip and copy in your preferer folder.

Build project

For build de project, Maven is needed.

$ cd verilog-format
$ mvn clean package
$ ls target/

Verilog-Format Style Options

This options are setting in .verilog-format.properties file.

Example

## File .verilog-format.properties
IndentWidth=4
IndentType=space
SpacesBeforeTrailingComments=0
SpacesAfterTrailingComments=0
AlignLineComments=true
AlignNoBlockingAssignments=true
AlignBlockingAssignments=true
SpacesInParentheses=false
SpacesInSquareBrackets=false

IndentWidth=[number]

// IndentWidth=4  #(default)
always @(posedge clk)
    if (load == 1)
        bitc <= 0;
    else if (load == 0 && clk_baud == 1)
        bitc <= bitc + 1;

// IndentWidth=1
always @(posedge clk)
 if (load == 1)
  bitc <= 0;
 else if (load == 0 && clk_baud == 1)
  bitc <= bitc + 1;

IndentType=[space|tab]

// IndentType=space  #(default)
always @(posedge clk)
    if (load == 1)
        bitc <= 0;
    else if (load == 0 && clk_baud == 1)
        bitc <= bitc + 1;

// IndentType=tab  #  not recommended yet
always @(posedge clk)
<tab>if (load == 1)
<tab><tab>bitc <= 0;
<tab>else if (load == 0 && clk_baud == 1)
<tab><tab>bitc <= bitc + 1;

SpacesInParentheses=[true|false]

// SpacesInParentheses=false  #(default)
always @(posedge clk)
    if (load == 1)

// SpacesInParentheses=true
always @( posedge clk )
    if ( load == 1 )

SpacesInSquareBrackets=[true|false]

// SpacesInSquareBrackets=false  #(default)
reg [DW-1:0] rom [0:NPOS-1];

always @(posedge clk) begin
    data <= rom[addr];
end

// SpacesInSquareBrackets=true
reg [ DW-1:0 ] rom [ 0:NPOS-1 ];
    
always @(posedge clk) begin
    data <= rom[ addr ];

AlignBlockingAssignments=[true|false]

// AlignBlockingAssignments=true  #(default)
assign load    = (state == START) ? 1 : 0;
assign baud_en = (state == IDLE) ? 0 : 1;

// AlignBlockingAssignments=false
assign load = (state == START) ? 1 : 0;
assign baud_en = (state == IDLE) ? 0 : 1;

AlignNoBlockingAssignments=[true|false]

// AlignNoBlockingAssignments=true  #(default)
state_ts   <= IDLE;
state_pad  <= IDLE;
state_wait <= IDLE;

// AlignNoBlockingAssignments=false
state_ts <= IDLE;
state_pad <= IDLE;
state_wait <= IDLE;

AlignLineComments=[true|false]

// AlignLineComments=false  #(default)
always @(posedge clk) // always
    if (load == 1)  // if
        bitc <= 0; //
    else if (load == 0 && clk_baud == 1) // else if
        bitc <= bitc + 1; //

// AlignLineComments=true
always @(posedge clk)                    // always
    if (load == 1)                       // if
        bitc <= 0;                       //
    else if (load == 0 && clk_baud == 1) // else if
        bitc <= bitc + 1;                //

SpacesBeforeTrailingComments=[number]

// SpacesBeforeTrailingComments=1  #(default)
localparam IDLE  = 0; //IDLE

// SpacesBeforeTrailingComments=0
localparam IDLE  = 0;//IDLE

SpacesAfterTrailingComments=[number]

// SpacesAfterTrailingComments=0  #(default)
localparam IDLE  = 0; //IDLE

// SpacesAfterTrailingComments=3
localparam IDLE  = 0; //   IDLE

verilog-format's People

Contributors

ericsonj avatar hamster5295 avatar hata6502 avatar huahuay avatar muratovas avatar xiejiss avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.