// File: /workspace/github_c_makefile_star2_O3/aquaxis[P]synverll/src/parser_ir_top.c
// Function: output_top_module
int output_top_module(FILE *fp, char *topname)
{
	fprintf(fp,"/*\n");
	fprintf(fp," * Copyright (C)2005-2015 AQUAXIS TECHNOLOGY.\n");
	fprintf(fp," *  Don't remove this header.\n");
	fprintf(fp," * When you use this source, there is a need to inherit this header.\n");
	fprintf(fp," *\n");
	fprintf(fp," * This software is released under the MIT License.\n");
	fprintf(fp," * http://opensource.org/licenses/mit-license.php\n");
	fprintf(fp," *\n");
	fprintf(fp," * For further information please contact.\n");
	fprintf(fp," *  URI:    http://www.aquaxis.com/\n");
	fprintf(fp," *  E-Mail: info(at)aquaxis.com\n");
	fprintf(fp," */\n");

	fprintf(fp,"module %s(\n", topname);

	fprintf(fp,"\tinput system_clock,\n");
	fprintf(fp,"\tinput system_reset,\n");
	fprintf(fp,"\tinput __func_start,\n");
	fprintf(fp,"\toutput __func_done,\n");
//	fprintf(fp,"\toutput __func_idle,\n");
	fprintf(fp,"\toutput __func_ready,\n\n");

if(use_gm_if){
	fprintf(fp,"\tinput [31:0] __gm_base,\n");
	fprintf(fp,"\toutput __gm_req,\n");
	fprintf(fp,"\toutput __gm_rnw,\n");
	fprintf(fp,"\tinput __gm_done,\n");
	fprintf(fp,"\toutput [31:0] __gm_adrs,\n");
	fprintf(fp,"\toutput [1:0] __gm_leng,\n");
	fprintf(fp,"\tinput [31:0] __gm_di,\n");
	fprintf(fp,"\toutput [31:0] __gm_do,\n\n");
}

	if(use_llvm_memcpy){
		fprintf(fp,"\toutput __llvm_memcpy_req,\n");
		fprintf(fp,"\tinput __llvm_memcpy_ready,\n");
		fprintf(fp,"\tinput __llvm_memcpy_done,\n");
		fprintf(fp,"\toutput [7:0] __llvm_memcpy_args_0,\n");
		fprintf(fp,"\toutput [7:0] __llvm_memcpy_args_1,\n");
		fprintf(fp,"\toutput [31:0] __llvm_memcpy_args_2,\n");
		fprintf(fp,"\toutput [31:0] __llvm_memcpy_args_3,\n");
		fprintf(fp,"\toutput [31:0] __llvm_memcpy_args_4,\n\n");
	}


	// ToDo:
	// 外部信号を入れる
	fprintf(fp,"\t// global signal\n");
	create_top_global(fp);
//	fprintf(fp,"\t// nowire\n");
	create_top_nowire(fp);

//	fprintf(fp,"\n\toutput dummy\n");

	fprintf(fp,");\n");

	// Wire宣言を入れる
	fprintf(fp,"// wire\n");
	create_top_wire(fp);
	fprintf(fp,"// connection\n");
	fprintf(fp,"%s", top_module_assign);

	fprintf(fp,"// system signal\n");
	create_top_nofunc(fp);

	fprintf(fp,"// modules\n");
	fprintf(fp,"%s", top_module_decl);

	fprintf(fp,"endmodule\n");

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x33b3(%rip), %rdi      # 0xeaf8
movl $0x3, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x339e(%rip), %rdi      # 0xeafc
movl $0x2e, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x33b4(%rip), %rdi      # 0xeb2b
movl $0x1e, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x33ba(%rip), %rdi      # 0xeb4a
movl $0x45, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x33e7(%rip), %r15      # 0xeb90
movl $0x3, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x11c0
leaq 0x33cf(%rip), %rdi      # 0xeb94
movl $0x34, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x33eb(%rip), %rdi      # 0xebc9
movl $0x32, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
movl $0x3, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x11c0
leaq 0x33f0(%rip), %rdi      # 0xebfc
movl $0x2b, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3403(%rip), %rdi      # 0xec28
movl $0x24, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x340f(%rip), %rdi      # 0xec4d
movl $0x20, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3417(%rip), %rdi      # 0xec6e
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3403(%rip), %rsi      # 0xec73
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1110
leaq 0x455f(%rip), %rdi      # 0xfde3
movl $0x15, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x455c(%rip), %rdi      # 0xfdf9
movl $0x15, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x33f5(%rip), %rdi      # 0xecab
movl $0x15, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x4540(%rip), %rdi      # 0xfe0f
movl $0x15, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x453d(%rip), %rdi      # 0xfe25
movl $0x17, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
cmpl $0x0, 0x8cbb(%rip)      # 0x145bc
je 0xb9cf
leaq 0x33fc(%rip), %rdi      # 0xed0a
movl $0x19, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x4516(%rip), %rdi      # 0xfe3d
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x4510(%rip), %rdi      # 0xfe50
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x33f9(%rip), %rdi      # 0xed52
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x44f1(%rip), %rdi      # 0xfe63
movl $0x1a, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x44f3(%rip), %rdi      # 0xfe7e
movl $0x19, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x33fe(%rip), %rdi      # 0xeda2
movl $0x17, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x44db(%rip), %rdi      # 0xfe98
movl $0x19, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
cmpl $0x0, 0x8be2(%rip)      # 0x145b8
je 0xbaa4
leaq 0x44cf(%rip), %rdi      # 0xfeb2
movl $0x1b, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x44d2(%rip), %rdi      # 0xfece
movl $0x1c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x44d6(%rip), %rdi      # 0xfeeb
movl $0x1b, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x44d9(%rip), %rdi      # 0xff07
movl $0x24, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x44e5(%rip), %rdi      # 0xff2c
movl $0x24, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x44f1(%rip), %rdi      # 0xff51
movl $0x25, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x44fe(%rip), %rdi      # 0xff77
movl $0x25, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x450b(%rip), %rdi      # 0xff9d
movl $0x26, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x4519(%rip), %rdi      # 0xffc4
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
movq %rbx, %rdi
callq 0xa9e5
movq %rbx, %rdi
callq 0xa886
leaq 0x39b1(%rip), %rdi      # 0xf485
movl $0x3, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
leaq 0x44ea(%rip), %rdi      # 0xffd7
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
movq 0x8aaa(%rip), %r15      # 0x145b0
testq %r15, %r15
je 0xbb2c
leaq 0x2fb4(%rip), %r14      # 0xeac6
movq 0x58(%r15), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1110
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0xbb12
leaq 0x44ad(%rip), %rdi      # 0xffe0
movl $0xe, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
movq 0x8a7c(%rip), %rdi      # 0x145c8
movq %rbx, %rsi
callq 0x10c0
leaq 0x4494(%rip), %rdi      # 0xffef
movl $0x11, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
movq %rbx, %rdi
callq 0xa96c
leaq 0x4485(%rip), %rdi      # 0x10001
movl $0xb, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
movq 0x8a2b(%rip), %rdi      # 0x145c0
movq %rbx, %rsi
callq 0x10c0
leaq 0x355e(%rip), %rdi      # 0xf102
movl $0xa, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11c0
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
nop