move codegen file to cn
use codegen module in main
remove duplicate file open