File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
pyverilog/ast_code_generator/sample Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change
1
+ import sys
2
+ import os
3
+ sys .path .insert (0 , os .path .dirname (os .path .dirname (os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))) )
4
+
5
+ import pyverilog .vparser .ast as vast
6
+ from pyverilog .ast_code_generator .codegen import ASTCodeGenerator
7
+
8
+ params = vast .Paramlist (())
9
+ clk = vast .Ioport ( vast .Input ('CLK' ) )
10
+ rst = vast .Ioport ( vast .Input ('RST' ) )
11
+ width = vast .Width ( vast .IntConst ('7' ), vast .IntConst ('0' ) )
12
+ led = vast .Ioport ( vast .Output ('led' , width = width ) )
13
+ ports = vast .Portlist ( (clk , rst , led ) )
14
+ items = ( vast .Assign ( vast .Identifier ('led' ), vast .IntConst ('8' ) ) ,)
15
+ ast = vast .ModuleDef ("top" , params , ports , items )
16
+
17
+ codegen = ASTCodeGenerator ()
18
+ rslt = codegen .visit (ast )
19
+ print (rslt )
You can’t perform that action at this time.
0 commit comments