Skip to content

Commit a92825c

Browse files
committed
Add block comment statement for testing
1 parent f1b167d commit a92825c

File tree

5 files changed

+98
-8
lines changed

5 files changed

+98
-8
lines changed

nbactions.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
1111
</goals>
1212
<properties>
13-
<exec.args>-classpath %classpath net.ericsonj.verilog.VerilogFormat -p -f verilog/module.v</exec.args>
13+
<exec.args>-classpath %classpath net.ericsonj.verilog.VerilogFormat -f verilog/genrom.v</exec.args>
1414
<exec.executable>java</exec.executable>
1515
<exec.workingdir>/home/ericson/PROJECTS/JAVA/MAVEN/verilog-format</exec.workingdir>
1616
</properties>
@@ -25,7 +25,7 @@
2525
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
2626
</goals>
2727
<properties>
28-
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath net.ericsonj.verilog.VerilogFormat -p -f verilog/module.v</exec.args>
28+
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath net.ericsonj.verilog.VerilogFormat -f verilog/genrom.v</exec.args>
2929
<exec.executable>java</exec.executable>
3030
<jpda.listen>true</jpda.listen>
3131
<exec.workingdir>/home/ericson/PROJECTS/JAVA/MAVEN/verilog-format</exec.workingdir>
@@ -41,7 +41,7 @@
4141
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
4242
</goals>
4343
<properties>
44-
<exec.args>-classpath %classpath net.ericsonj.verilog.VerilogFormat -p -f verilog/module.v</exec.args>
44+
<exec.args>-classpath %classpath net.ericsonj.verilog.VerilogFormat -f verilog/genrom.v</exec.args>
4545
<exec.executable>java</exec.executable>
4646
<exec.workingdir>/home/ericson/PROJECTS/JAVA/MAVEN/verilog-format</exec.workingdir>
4747
</properties>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.util.LinkedList;
44
import net.ericsonj.verilog.statements.Always;
5+
import net.ericsonj.verilog.statements.BlockComment;
56
import net.ericsonj.verilog.statements.Case;
67
import net.ericsonj.verilog.statements.For;
78
import net.ericsonj.verilog.statements.Forever;
@@ -24,6 +25,7 @@ public class IndentationStyle implements StyleImp {
2425
public IndentationStyle() {
2526
this.indents = new LinkedList<>();
2627

28+
this.indents.add(new BlockComment());
2729
this.indents.add(new For());
2830
this.indents.add(new While());
2931
this.indents.add(new Repeat());
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package net.ericsonj.verilog.statements;
2+
3+
import net.ericsonj.verilog.FileFormat;
4+
5+
/**
6+
*
7+
* @author Ericson Joseph <ericsonjoseph@gmail.com>
8+
*
9+
* Create on Feb 28, 2019 12:42:31 AM
10+
*/
11+
public class BlockComment extends AbstractStatement<BlockCommentState> {
12+
13+
@Override
14+
public boolean isInitStatement(FileFormat format, String line) {
15+
return line.matches("/\\*.*");
16+
}
17+
18+
@Override
19+
public BlockCommentState getInitStateElement(FileFormat format, String liine) {
20+
BlockCommentState state = new BlockCommentState();
21+
state.setBaseIndent(format.getCountIndent());
22+
state.setState(BlockCommentState.STATE.INIT);
23+
return state;
24+
}
25+
26+
@Override
27+
public Class<BlockCommentState> getStateType() {
28+
return BlockCommentState.class;
29+
}
30+
31+
@Override
32+
public String stateMachine(FileFormat format, BlockCommentState state, String line) {
33+
switch (state.getState()) {
34+
case INIT:
35+
if (line.matches("/\\*.*") && line.matches(".*\\*/")) {
36+
format.states.poll();
37+
} else if (line.matches("/\\*.*")) {
38+
state.setState(BlockCommentState.STATE.COMMENT);
39+
return indent(format, line);
40+
}
41+
break;
42+
case COMMENT:
43+
if (line.matches(".*\\*/")) {
44+
format.states.poll();
45+
}
46+
return indent(format, " " + line);
47+
default:
48+
throw new AssertionError(state.getState().name());
49+
}
50+
return null;
51+
}
52+
53+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package net.ericsonj.verilog.statements;
2+
3+
import net.ericsonj.verilog.StatementState;
4+
5+
/**
6+
*
7+
* @author Ericson Joseph <ericsonjoseph@gmail.com>
8+
*
9+
* Create on Feb 28, 2019 12:43:30 AM
10+
*/
11+
public class BlockCommentState extends StatementState {
12+
13+
public enum STATE {
14+
INIT,
15+
COMMENT
16+
}
17+
18+
private BlockCommentState.STATE state;
19+
20+
public BlockCommentState() {
21+
super("blockcomment", 0);
22+
this.state = STATE.INIT;
23+
}
24+
25+
public STATE getState() {
26+
return state;
27+
}
28+
29+
public void setState(STATE state) {
30+
this.state = state;
31+
}
32+
33+
}

verilog/genrom.v

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11

22
/**
3-
* File: genrom.v
4-
* Author: Ericson Joseph
5-
*
6-
* Created on January 28, 2019, 8:15 PM
7-
*/
3+
* File: genrom.v
4+
* Author: Ericson Joseph
5+
*
6+
* Created on January 28, 2019, 8:15 PM
7+
*/
88

99
module genrom #(parameter AW = 5,
1010
parameter DW = 4)
1111
(input clk,
1212
input wire [AW-1:0] addr,
1313
output reg [DW-1:0] data);
1414

15+
1516
parameter ROMFILE = "rom1.list";
1617

1718
localparam NPOS = 2 ** AW;
@@ -26,4 +27,5 @@ module genrom #(parameter AW = 5,
2627
$readmemh(ROMFILE, rom);
2728
end
2829

30+
2931
endmodule

0 commit comments

Comments
 (0)