Skip to content

Commit e6d4e8d

Browse files
committed
Add more documentation, new feactures and fix bugs.
1 parent 3ea6e47 commit e6d4e8d

16 files changed

+414
-214
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
target/
2+
launch-linux/

README.md

Lines changed: 179 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,40 @@
11
# Verilog Format
22

3-
Java console aplication for verilog formatter.
3+
Console application for apply format to verilog file.
44

5-
![sample](images/verilog-format.gif)
5+
![sample](images/verilog-format.gif)
66

7-
## How to use (Linux)
7+
## How to use
8+
9+
Application options:
10+
11+
```
12+
usage: [java -jar verilog-format.jar|./verilog-format|verilog-format.exe]
13+
[-f <pathname>] [-h] [-p] [-s <verilog-format.properties>] [-v]
14+
-f,--format <pathname> verilog file
15+
-h,--help print this message
16+
-p,--print print file formated
17+
-s,--settings <verilog-format.properties> settings config
18+
-v,--version verilog-format version
19+
```
20+
21+
## Examples
22+
23+
```sh
24+
## Print input_file.v formatted
25+
$ ./verilog-format -p -f input_file.v -s verilog-format.properties
26+
27+
## Format input_file.v
28+
$ ./verilog-format -f input_file.v -s verilog-format.properties
29+
30+
## Format input_file.v
31+
## If .verilog-format.properties exist in project folder, this is used,
32+
## otherwise default setting is used..
33+
$ ./verilog-format -f input_file.v
34+
35+
```
36+
37+
## Install in Linux
838

939
1. Clone repository.
1040

@@ -28,7 +58,7 @@ Java console aplication for verilog formatter.
2858

2959
`$ sudo cp /opt/verilog-format/verilog-format /usr/bin/`
3060

31-
## How to use (Windows)
61+
## Install in Windows
3262

3363
1. Clone repository or download [verilog-format-WIN.zip](bin/verilog-format-WIN.zip)
3464

@@ -40,4 +70,148 @@ For build de project, Maven is needed.
4070

4171
`$ cd verilog-format`
4272
`$ mvn clean package`
43-
`$ ls target/`
73+
`$ ls target/`
74+
75+
## Verilog-Format Style Options
76+
77+
This options are setting in `.verilog-format.properties` file.
78+
79+
### Example
80+
81+
```properties
82+
## File .verilog-format.properties
83+
IndentWidth=4
84+
IndentType=space
85+
SpacesBeforeTrailingComments=0
86+
SpacesAfterTrailingComments=0
87+
AlignLineComments=true
88+
AlignNoBlockingAssignments=true
89+
AlignBlockingAssignments=true
90+
SpacesInParentheses=false
91+
SpacesInSquareBrackets=false
92+
```
93+
94+
---
95+
### IndentWidth=[number]
96+
97+
```verilog
98+
// IndentWidth=4 #(default)
99+
always @(posedge clk)
100+
if (load == 1)
101+
bitc <= 0;
102+
else if (load == 0 && clk_baud == 1)
103+
bitc <= bitc + 1;
104+
105+
// IndentWidth=1
106+
always @(posedge clk)
107+
if (load == 1)
108+
bitc <= 0;
109+
else if (load == 0 && clk_baud == 1)
110+
bitc <= bitc + 1;
111+
```
112+
---
113+
### IndentType=[space|tab]
114+
```verilog
115+
// IndentType=space #(default)
116+
always @(posedge clk)
117+
if (load == 1)
118+
bitc <= 0;
119+
else if (load == 0 && clk_baud == 1)
120+
bitc <= bitc + 1;
121+
122+
// IndentType=tab # not recommended yet
123+
always @(posedge clk)
124+
<tab>if (load == 1)
125+
<tab><tab>bitc <= 0;
126+
<tab>else if (load == 0 && clk_baud == 1)
127+
<tab><tab>bitc <= bitc + 1;
128+
```
129+
---
130+
### SpacesInParentheses=[true|false]
131+
```verilog
132+
// SpacesInParentheses=false #(default)
133+
always @(posedge clk)
134+
if (load == 1)
135+
136+
// SpacesInParentheses=true
137+
always @( posedge clk )
138+
if ( load == 1 )
139+
```
140+
---
141+
142+
### SpacesInSquareBrackets=[true|false]
143+
```verilog
144+
// SpacesInSquareBrackets=false #(default)
145+
reg [DW-1:0] rom [0:NPOS-1];
146+
147+
always @(posedge clk) begin
148+
data <= rom[addr];
149+
end
150+
151+
// SpacesInSquareBrackets=true
152+
reg [ DW-1:0 ] rom [ 0:NPOS-1 ];
153+
154+
always @(posedge clk) begin
155+
data <= rom[ addr ];
156+
```
157+
---
158+
### AlignBlockingAssignments=[true|false]
159+
```verilog
160+
// AlignBlockingAssignments=true #(default)
161+
assign load = (state == START) ? 1 : 0;
162+
assign baud_en = (state == IDLE) ? 0 : 1;
163+
164+
// AlignBlockingAssignments=false
165+
assign load = (state == START) ? 1 : 0;
166+
assign baud_en = (state == IDLE) ? 0 : 1;
167+
168+
```
169+
---
170+
### AlignNoBlockingAssignments=[true|false]
171+
```verilog
172+
// AlignNoBlockingAssignments=true #(default)
173+
state_ts <= IDLE;
174+
state_pad <= IDLE;
175+
state_wait <= IDLE;
176+
177+
// AlignNoBlockingAssignments=false
178+
state_ts <= IDLE;
179+
state_pad <= IDLE;
180+
state_wait <= IDLE;
181+
```
182+
---
183+
### AlignLineComments=[true|false]
184+
```verilog
185+
// AlignLineComments=false #(default)
186+
always @(posedge clk) // always
187+
if (load == 1) // if
188+
bitc <= 0; //
189+
else if (load == 0 && clk_baud == 1) // else if
190+
bitc <= bitc + 1; //
191+
192+
// AlignLineComments=true
193+
always @(posedge clk) // always
194+
if (load == 1) // if
195+
bitc <= 0; //
196+
else if (load == 0 && clk_baud == 1) // else if
197+
bitc <= bitc + 1; //
198+
```
199+
---
200+
### SpacesBeforeTrailingComments=[number]
201+
```verilog
202+
// SpacesBeforeTrailingComments=1 #(default)
203+
localparam IDLE = 0; //IDLE
204+
205+
// SpacesBeforeTrailingComments=0
206+
localparam IDLE = 0;//IDLE
207+
```
208+
---
209+
### SpacesAfterTrailingComments=[number]
210+
```verilog
211+
// SpacesAfterTrailingComments=0 #(default)
212+
localparam IDLE = 0; //IDLE
213+
214+
// SpacesAfterTrailingComments=3
215+
localparam IDLE = 0; // IDLE
216+
```
217+
---

bin/verilog-format-LINUX.zip

-94.7 KB
Binary file not shown.

bin/verilog-format-WIN.zip

16.6 KB
Binary file not shown.

build-dist

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
#MOV TO BIN
4+
cd bin/
5+
6+
# BUILD FOR LINUX
7+
cp ../target/*-full.jar verilog-format.jar
8+
cp ../launch-linux/verilog-format .
9+
zip verilog-format-LINUX.zip verilog-format.jar verilog-format
10+
rm verilog-format.jar verilog-format
11+
12+
# BUILD FOR WIN
13+
cp ../target/verilog-format.exe .
14+
zip verilog-format-WIN.zip verilog-format.exe
15+
rm verilog-format.exe

images/verilog-format.gif

94 Bytes
Loading

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>net.ericsonj</groupId>
55
<artifactId>verilog-format</artifactId>
6-
<version>1.0.0</version>
6+
<version>1.0.1</version>
77
<packaging>jar</packaging>
88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

src/main/java/net/ericsonj/verilog/FileFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public FormatSetting getSetting() {
7373
}
7474

7575
public int getSpacesAfterTrailingComments() {
76-
return this.setting.getIntValue(SPACES_AFTER_TRAILING_COMMENTS, 1);
76+
return this.setting.getIntValue(SPACES_AFTER_TRAILING_COMMENTS, 0);
7777
}
7878

7979
public int getSpacesBeforeTrailingComments() {

src/main/java/net/ericsonj/verilog/FormatSetting.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
*/
1515
public class FormatSetting {
1616

17+
public static final String FILE_PROP = "verilog-format.properties";
18+
1719
private File file;
1820
private Properties prop;
1921
private boolean filePresent;
2022

2123
public FormatSetting() {
22-
this(new File("verilog-format.properties"));
24+
this(new File(FILE_PROP));
2325
}
2426

2527
public FormatSetting(File file) {
@@ -46,13 +48,13 @@ public FormatSetting(File file) {
4648
public String getStringValue(String key, String defaultValue) {
4749
return prop.getProperty(key, defaultValue);
4850
}
49-
51+
5052
public int getIntValue(String key, int defaultValue) {
5153
int value = Integer.parseInt(prop.getProperty(key, String.valueOf(defaultValue)));
5254
return value;
5355
}
54-
55-
public boolean getBooleanValue(String key, boolean defaultValue){
56+
57+
public boolean getBooleanValue(String key, boolean defaultValue) {
5658
String value = getStringValue(key, String.valueOf(defaultValue));
5759
return Boolean.valueOf(value);
5860
}

src/main/java/net/ericsonj/verilog/Global.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
*/
99
public class Global {
1010

11-
public static final String VERSION = "1.0.0";
11+
public static final String VERSION = "1.0.1";
1212

1313
}

0 commit comments

Comments
 (0)