// File: /workspace/github_c_makefile_star2_O1/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 0x32c3(%rip), %rdi      # 0xeb04
movl $0x3, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x32ae(%rip), %rdi      # 0xeb08
movl $0x2e, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x32c4(%rip), %rdi      # 0xeb37
movl $0x1e, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x32ca(%rip), %rdi      # 0xeb56
movl $0x45, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x32f7(%rip), %r15      # 0xeb9c
movl $0x3, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x11d0
leaq 0x32df(%rip), %rdi      # 0xeba0
movl $0x34, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x32fb(%rip), %rdi      # 0xebd5
movl $0x32, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
movl $0x3, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rbx, %rcx
callq 0x11d0
leaq 0x3300(%rip), %rdi      # 0xec08
movl $0x2b, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x3313(%rip), %rdi      # 0xec34
movl $0x24, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x331f(%rip), %rdi      # 0xec59
movl $0x20, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x3327(%rip), %rdi      # 0xec7a
movl $0x4, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x3313(%rip), %rsi      # 0xec7f
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1120
leaq 0x446f(%rip), %rdi      # 0xfdef
movl $0x15, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x446c(%rip), %rdi      # 0xfe05
movl $0x15, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x3305(%rip), %rdi      # 0xecb7
movl $0x15, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x4450(%rip), %rdi      # 0xfe1b
movl $0x15, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x444d(%rip), %rdi      # 0xfe31
movl $0x17, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
cmpl $0x0, 0x8bcf(%rip)      # 0x145cc
je 0xbacb
leaq 0x330c(%rip), %rdi      # 0xed16
movl $0x19, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x4426(%rip), %rdi      # 0xfe49
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x4420(%rip), %rdi      # 0xfe5c
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x3309(%rip), %rdi      # 0xed5e
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x4401(%rip), %rdi      # 0xfe6f
movl $0x1a, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x4403(%rip), %rdi      # 0xfe8a
movl $0x19, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x330e(%rip), %rdi      # 0xedae
movl $0x17, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x43eb(%rip), %rdi      # 0xfea4
movl $0x19, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
cmpl $0x0, 0x8af6(%rip)      # 0x145c8
je 0xbba0
leaq 0x43df(%rip), %rdi      # 0xfebe
movl $0x1b, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x43e2(%rip), %rdi      # 0xfeda
movl $0x1c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x43e6(%rip), %rdi      # 0xfef7
movl $0x1b, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x43e9(%rip), %rdi      # 0xff13
movl $0x24, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x43f5(%rip), %rdi      # 0xff38
movl $0x24, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x4401(%rip), %rdi      # 0xff5d
movl $0x25, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x440e(%rip), %rdi      # 0xff83
movl $0x25, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x441b(%rip), %rdi      # 0xffa9
movl $0x26, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x4429(%rip), %rdi      # 0xffd0
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
movq %rbx, %rdi
callq 0xaae1
movq %rbx, %rdi
callq 0xa982
leaq 0x38c1(%rip), %rdi      # 0xf491
movl $0x3, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
leaq 0x43fa(%rip), %rdi      # 0xffe3
movl $0x8, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
movq 0x89be(%rip), %r15      # 0x145c0
testq %r15, %r15
je 0xbc28
leaq 0x2ec4(%rip), %r14      # 0xead2
movq 0x58(%r15), %rdx
movq %rbx, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x1120
movq 0x8(%r15), %r15
testq %r15, %r15
jne 0xbc0e
leaq 0x43bd(%rip), %rdi      # 0xffec
movl $0xe, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
movq 0x8990(%rip), %rdi      # 0x145d8
movq %rbx, %rsi
callq 0x10c0
leaq 0x43a4(%rip), %rdi      # 0xfffb
movl $0x11, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
movq %rbx, %rdi
callq 0xaa68
leaq 0x4395(%rip), %rdi      # 0x1000d
movl $0xb, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
movq 0x893f(%rip), %rdi      # 0x145d0
movq %rbx, %rsi
callq 0x10c0
leaq 0x346e(%rip), %rdi      # 0xf10e
movl $0xa, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x11d0
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
nop