/* Copyright (C) 2008 Martin Furter This file is part of wbavr. wbavr is free software/hardware; 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, or (at your option) any later version. wbavr 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 wbavr; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ==============================================================================*/ /* wbavr_consts: Constants used in the other files. */ // no operation `define ALU_NOP 5'b00000 // one input, one output `define ALU_ASR 5'b00001 `define ALU_LSR 5'b00010 `define ALU_ROR 5'b00011 `define ALU_SWAP 5'b00100 // two inputs, one output `define ALU_ADD 5'b01000 // same as ADD except that H and C aren't changed (set data_1_i to 1) `define ALU_INC 5'b01001 `define ALU_ADC 5'b01010 `define ALU_SUB 5'b01100 // same as SUB except that H and C aren't changed (set data_1_i to 1) `define ALU_DEC 5'b01101 // same as SUB except that H isn't changed and C is always 1 (data_0=0xFF) `define ALU_COM 5'b01110 `define ALU_SBC 5'b01111 `define ALU_AND 5'b10000 `define ALU_EOR 5'b10001 `define ALU_OR 5'b10010 // three inputs, two outputs `define ALU_ADDW 5'b10100 `define ALU_SUBW 5'b10101 // two inputs, two outputs `define ALU_FMUL 5'b11000 `define ALU_FMULS 5'b11011 `define ALU_FMULSU 5'b11001 `define ALU_MUL 5'b11000 `define ALU_MULS 5'b11111 `define ALU_MULSU 5'b11101 // data_2_i[2:0] selects the bit // data_1_i[0] specifies the new value for the bit // data_0_i is copied to data_0_o with the specified bit replaced // T contains the old value of the bit `define ALU_BITOP 5'b10111 // flag bit numbers `define FLAG_C_IDX 0 `define FLAG_Z_IDX 1 `define FLAG_N_IDX 2 `define FLAG_V_IDX 3 `define FLAG_S_IDX 4 `define FLAG_H_IDX 5 `define FLAG_T_IDX 6 `define FLAG_I_IDX 7 // control register bit numbers `define CTRL_SELFPRGEN 0 `define CTRL_PGWRT 2 `define ALU_I0_SEL_REG0 0 `define ALU_I0_SEL_FLAGS 1 `define ALU_I0_SEL_DATA 2 `define ALU_I0_SEL_CONST1 3 `define ALU_I0_SEL_SP_LO 4 `define ALU_I0_SEL_SP_HI 5 `define ALU_I0_SEL_CTRL 6 `define ALU_I1_SEL_REG1 0 `define ALU_I1_SEL_CONST1 1 `define ALU_I1_SEL_TFLAG 2 `define ALU_I1_SEL_CODE 3 `define CADR_SEL_PC 0 `define CADR_SEL_TMPREG 1 `define CADR_SEL_GPREG 2 `define DADR_SEL_OPCODE 0 `define DADR_SEL_TMPREG 1 `define DADR_SEL_SP_DEC 2 `define DADR_SEL_SP_INC 3 `define DDAT_SEL_REG0 0 `define DDAT_SEL_TMP_LO 1 `define DDAT_SEL_PC_LO 2 `define DDAT_SEL_PC_HI 3 `define FLAG_SEL_PREV 0 `define FLAG_SEL_ALU 1 `define FLAG_SEL_O0 2 `define FLAG_SEL_CHG_I 3 `define TMP_LO_SEL_PREV 0 `define TMP_LO_SEL_ALU_O0 1 `define TMP_LO_SEL_CODE_RD 2 `define TMP_HI_SEL_PREV 0 `define TMP_HI_SEL_ALU_O1 1 `define TMP_HI_SEL_CODE_RD 2 `define TMP_HI_SEL_DATA_RD 3 `define PC_SEL_PREV 0 `define PC_SEL_INC 1 `define PC_SEL_ABSADDR 2 `define PC_SEL_RELADDR 3 `define PC_SEL_CODE 4 `define PC_SEL_REG 5 `define PC_SEL_THI_DLO 6 `define SP_SEL_PREV 0 `define SP_SEL_INCDEC 1 `define SP_SEL_WR_LO 2 `define SP_SEL_WR_HI 3 `define SKIP_SEL_NONE 0 `define SKIP_SEL_Z_SET 1 `define SKIP_SEL_T_CLR 2 `define SKIP_SEL_T_SET 3