File tree Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Original file line number Diff line number Diff line change 1+ TARGET =$(shell ls * .py | grep -v test | grep -v parsetab.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 : run
14+ run :
15+ $(PYTHON ) $(OPT ) $(TARGET ) $(ARGS )
16+
17+ .PHONY : test
18+ test :
19+ $(PYTHON ) -m pytest -vv
20+
21+ .PHONY : check
22+ check :
23+ $(PYTHON ) $(OPT ) $(TARGET ) $(ARGS ) > tmp.v
24+ iverilog -tnull -Wall tmp.v
25+ rm -f tmp.v
26+
27+ .PHONY : clean
28+ clean :
29+ rm -rf * .pyc __pycache__ parsetab.py .cache * .out * .png * .dot tmp.v uut.vcd
Original file line number Diff line number Diff line change 1+ from __future__ import absolute_import
2+ from __future__ import print_function
3+ import sys
4+ import os
5+
6+ # the next line can be removed after installation
7+ sys .path .insert (0 , os .path .dirname (os .path .dirname (
8+ os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))))
9+
10+ from veriloggen import *
11+
12+
13+ def mkLed ():
14+ m = Module ('blinkled' )
15+ a = m .Input ('a' )
16+ b = m .Input ('b' )
17+ c = m .Input ('c' )
18+ exp = m .Output ('exp' )
19+
20+ exp .assign (a & b ^ ~ c )
21+
22+ return m
23+
24+ if __name__ == '__main__' :
25+ led = mkLed ()
26+ verilog = led .to_verilog ()
27+ print (verilog )
Original file line number Diff line number Diff line change 1+ from __future__ import absolute_import
2+ from __future__ import print_function
3+ import veriloggen
4+ import logic
5+
6+ expected_verilog = """
7+ module blinkled
8+ (
9+ input a,
10+ input b,
11+ input c,
12+ output exp
13+ );
14+
15+ assign exp = a & b ^ ~c;
16+
17+ endmodule
18+ """
19+
20+ def test ():
21+ veriloggen .reset ()
22+ test_module = logic .mkLed ()
23+ code = test_module .to_verilog ()
24+
25+ from pyverilog .vparser .parser import VerilogParser
26+ from pyverilog .ast_code_generator .codegen import ASTCodeGenerator
27+ parser = VerilogParser ()
28+ expected_ast = parser .parse (expected_verilog )
29+ codegen = ASTCodeGenerator ()
30+ expected_code = codegen .visit (expected_ast )
31+
32+ assert (expected_code == code )
You can’t perform that action at this time.
0 commit comments