// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x287a(%rip), %rdi      # 0xdad8
pushq $0x3
popq %r12
pushq $0x1
popq %r14
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x2861(%rip), %rdi      # 0xdadc
pushq $0x2e
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x287b(%rip), %rdi      # 0xdb0b
pushq $0x1e
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x2885(%rip), %rdi      # 0xdb2a
pushq $0x45
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x28b6(%rip), %r13      # 0xdb70
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x28a2(%rip), %rdi      # 0xdb74
pushq $0x34
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x28c2(%rip), %rdi      # 0xdba9
pushq $0x32
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
movq %r13, %rdi
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x28cf(%rip), %rdi      # 0xdbdc
pushq $0x2b
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x28e6(%rip), %rdi      # 0xdc08
pushq $0x24
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x28f6(%rip), %rdi      # 0xdc2d
pushq $0x20
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x2902(%rip), %rdi      # 0xdc4e
pushq $0x4
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x28f2(%rip), %rsi      # 0xdc53
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1110
leaq 0x3a4e(%rip), %rdi      # 0xedc3
pushq $0x15
popq %r15
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3a4b(%rip), %rdi      # 0xedd9
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x28e8(%rip), %rdi      # 0xdc8b
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3a37(%rip), %rdi      # 0xedef
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3a38(%rip), %rdi      # 0xee05
pushq $0x17
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
cmpl $0x0, 0x81da(%rip)      # 0x135bc
je 0xb49c
leaq 0x28fb(%rip), %rdi      # 0xdcea
pushq $0x19
popq %r14
pushq $0x1
popq %r15
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3a11(%rip), %rdi      # 0xee1d
pushq $0x12
popq %r12
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3a0b(%rip), %rdi      # 0xee30
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x28f8(%rip), %rdi      # 0xdd32
movq %r12, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x39f4(%rip), %rdi      # 0xee43
pushq $0x1a
popq %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x39fa(%rip), %rdi      # 0xee5e
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x2909(%rip), %rdi      # 0xdd82
pushq $0x17
popq %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x39ea(%rip), %rdi      # 0xee78
movq %r14, %rsi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x11c0
cmpl $0x0, 0x8115(%rip)      # 0x135b8
je 0xb561
leaq 0x39e2(%rip), %rdi      # 0xee92
pushq $0x1b
popq %r15
pushq $0x1
popq %r14
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x39e1(%rip), %rdi      # 0xeeae
pushq $0x1c
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x39e9(%rip), %rdi      # 0xeecb
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x39f0(%rip), %rdi      # 0xeee7
pushq $0x24
popq %r15
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x39fc(%rip), %rdi      # 0xef0c
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3a0c(%rip), %rdi      # 0xef31
pushq $0x25
popq %r15
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3a19(%rip), %rdi      # 0xef57
movq %r15, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3a2a(%rip), %rdi      # 0xef7d
pushq $0x26
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3a3c(%rip), %rdi      # 0xefa4
pushq $0x12
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
movq %rbx, %rdi
callq 0xa563
movq %rbx, %rdi
callq 0xa40e
leaq 0x2ed4(%rip), %rdi      # 0xe465
pushq $0x3
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
leaq 0x3a11(%rip), %rdi      # 0xefb7
pushq $0x8
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
movq %rbx, %rdi
callq 0xa3d1
leaq 0x39fd(%rip), %rdi      # 0xefc0
pushq $0xe
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
movq 0x7ff0(%rip), %rdi      # 0x135c8
movq %rbx, %rsi
callq 0x10c0
leaq 0x39e8(%rip), %rdi      # 0xefcf
pushq $0x11
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
movq %rbx, %rdi
callq 0xa4ec
leaq 0x39dd(%rip), %rdi      # 0xefe1
pushq $0xb
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
movq 0x7fa7(%rip), %rdi      # 0x135c0
movq %rbx, %rsi
callq 0x10c0
leaq 0x2aba(%rip), %rdi      # 0xe0e2
pushq $0xa
popq %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x11c0
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop