File tree Expand file tree Collapse file tree 11 files changed +192
-13
lines changed
Expand file tree Collapse file tree 11 files changed +192
-13
lines changed Original file line number Diff line number Diff line change 1- TEST =test.py
2- ARGS =
3-
4- PYTHON =python3
5- # PYTHON=python
6- # OPT=-m pdb
7- # OPT=-m cProfile -s time
8- # OPT=-m cProfile -o profile.rslt
9-
101.PHONY : all
11- all : test
2+ all : clean
123
134.PHONY : test
145test :
15- $( PYTHON ) -m pytest -vv $( TEST )
6+ find . -maxdepth 1 -type d | grep " ./ " | xargs -I {} make test -C {}
167
178.PHONY : clean
189clean :
19- rm -rf * .pyc __pycache__ parsetab.py * .out
10+ find . -maxdepth 1 -type d | grep " ./ " | xargs -I {} make clean -C {}
Original file line number Diff line number Diff line change 1+ TEST =test.py
2+ ARGS =
3+
4+ PYTHON =python3
5+ # PYTHON=python
6+ # OPT=-m pdb
7+ # OPT=-m cProfile -s time
8+ # OPT=-m cProfile -o profile.rslt
9+
10+ .PHONY : all
11+ all : test
12+
13+ .PHONY : test
14+ test :
15+ $(PYTHON ) -m pytest -vv $(TEST )
16+
17+ .PHONY : clean
18+ clean :
19+ rm -rf * .pyc __pycache__ parsetab.py * .out
Original file line number Diff line number Diff line change 1+ `timescale 1ns / 1ps
2+
3+ module main #
4+ (
5+ parameter STEP = 10
6+ )
7+ (
8+ input CLK,
9+ input RST,
10+ output reg [7 :0 ] LED
11+ );
12+
13+ localparam DELAY = 10 ;
14+
15+ reg [31 :0 ] count;
16+
17+ always @(posedge CLK) begin
18+ if (RST) begin
19+ count <= 0 ;
20+ LED <= 0 ;
21+ end else begin
22+ if (count == STEP - 1 ) begin
23+ count <= 0 ;
24+ LED <= #DELAY LED + 1 ;
25+ end else begin
26+ count <= count + 1 ;
27+ end
28+ end
29+ end
30+ endmodule
Original file line number Diff line number Diff line change 1+ ../../../pyverilog
Original file line number Diff line number Diff line change 1+ import os
2+ import sys
3+ from pyverilog .vparser .parser import VerilogCodeParser
4+
5+ try :
6+ from StringIO import StringIO
7+ except :
8+ from io import StringIO
9+
10+ expected = """\
11+ Source:
12+ Description:
13+ ModuleDef: main
14+ Paramlist:
15+ Decl:
16+ Parameter: STEP, False
17+ Rvalue:
18+ IntConst: 10
19+ Portlist:
20+ Ioport:
21+ Input: CLK, False
22+ Width:
23+ IntConst: 0
24+ IntConst: 0
25+ Ioport:
26+ Input: RST, False
27+ Width:
28+ IntConst: 0
29+ IntConst: 0
30+ Ioport:
31+ Output: LED, False
32+ Width:
33+ IntConst: 7
34+ IntConst: 0
35+ Reg: LED, False
36+ Width:
37+ IntConst: 7
38+ IntConst: 0
39+ Decl:
40+ Localparam: DELAY, False
41+ Rvalue:
42+ IntConst: 10
43+ Decl:
44+ Reg: count, False
45+ Width:
46+ IntConst: 31
47+ IntConst: 0
48+ Always:
49+ SensList:
50+ Sens: posedge
51+ Identifier: CLK
52+ Block: None
53+ IfStatement:
54+ Identifier: RST
55+ Block: None
56+ NonblockingSubstitution:
57+ Lvalue:
58+ Identifier: count
59+ Rvalue:
60+ IntConst: 0
61+ NonblockingSubstitution:
62+ Lvalue:
63+ Identifier: LED
64+ Rvalue:
65+ IntConst: 0
66+ Block: None
67+ IfStatement:
68+ Eq:
69+ Identifier: count
70+ Minus:
71+ Identifier: STEP
72+ IntConst: 1
73+ Block: None
74+ NonblockingSubstitution:
75+ Lvalue:
76+ Identifier: count
77+ Rvalue:
78+ IntConst: 0
79+ NonblockingSubstitution:
80+ Lvalue:
81+ Identifier: LED
82+ Rvalue:
83+ Plus:
84+ Identifier: LED
85+ IntConst: 1
86+ DelayStatement:
87+ Identifier: DELAY
88+ Block: None
89+ NonblockingSubstitution:
90+ Lvalue:
91+ Identifier: count
92+ Rvalue:
93+ Plus:
94+ Identifier: count
95+ IntConst: 1
96+ Line 1 : `timescale 1ns / 1ps
97+ """
98+
99+ def test ():
100+ filelist = ['main.v' ]
101+ output = 'preprocess.out'
102+ include = None
103+ define = None
104+
105+ parser = VerilogCodeParser (filelist ,
106+ preprocess_include = include ,
107+ preprocess_define = define )
108+ ast = parser .parse ()
109+ directives = parser .get_directives ()
110+
111+ output = StringIO ()
112+ ast .show (buf = output )
113+
114+ for lineno , directive in directives :
115+ output .write ('Line %d : %s' % (lineno , directive ))
116+
117+ rslt = output .getvalue ()
118+
119+ assert (rslt == expected )
Original file line number Diff line number Diff line change 1+ TEST =test.py
2+ ARGS =
3+
4+ PYTHON =python3
5+ # PYTHON=python
6+ # OPT=-m pdb
7+ # OPT=-m cProfile -s time
8+ # OPT=-m cProfile -o profile.rslt
9+
10+ .PHONY : all
11+ all : test
12+
13+ .PHONY : test
14+ test :
15+ $(PYTHON ) -m pytest -vv $(TEST )
16+
17+ .PHONY : clean
18+ clean :
19+ rm -rf * .pyc __pycache__ parsetab.py * .out
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1+ ../../../pyverilog
File renamed without changes.
You can’t perform that action at this time.
0 commit comments