/** @date      Mon, 21 Apr 2008 09:11
 * 
 * @brief     The ArchC nios32 cycle-accurate model.
 * 
 * @attention Copyright (C) 2002-2006 --- Renato Herebia
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

AC_ARCH(nios32){

	ac_wordsize 32;
	ac_mem   DM:5M;
	ac_regbank RB:128;
	
	ac_format F_IF_ID = "%npc:32 opcode:5";
	ac_format F_ID_EX = "%npc:32 %data1:32 %data2:32 %imm:32:s %ra:5 %rb:5 %regwrite:1 %memread:1 %memwrite:1";
	ac_format F_EX_MEM = "%imm:32 %wdata:32 %rdest:5 %regwrite:1 %memread:1 %memwrite:1";
	ac_format F_MEM_WB = "%rdest:5 %wdata:32 %regwrite:1";
	
	ac_reg<F_IF_ID>  IF_ID;
	ac_reg<F_ID_EX>  ID_EX;
	ac_reg<F_EX_MEM> EX_MEM;
	ac_reg<F_MEM_WB> MEM_WB;
	
	ac_pipe pipe = {IF,ID,EX,MEM,WB};

	/* Control Registers of Altera/NIOS
	 *
	 */
	ac_format F_STATUS = "%dc:1 %ic:1 %ie:1 %ipri:6 %cwp:5 %n:1 %v:1 %z:1 %c:1";
	ac_format F_WVALID = "%nu:22 %hi_limit:5 %lo_limit:5";
	ac_format F_ISTATUS = "%nu:14 %savedstatus:18";
	ac_format F_K = "%k:11";
	
	ac_reg<F_STATUS> ctl0;
	ac_reg<F_ISTATUS> ctl1;
	ac_reg<F_WVALID> ctl2;
	ac_reg ctl3, ctl4, ctl5, ctl6, ctl7, ctl8, ctl9, pc;
	ac_reg<F_K> k;


	ARCH_CTOR(nios32) {

		ac_isa("nios32_isa.ac");
		set_endian("big"); 
	};

};
