From e0330d9534d8cfeffff81f426df1d3277702b835 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 11 Nov 2010 11:21:40 +0100 Subject: Implement basic instruction handling --- nios2.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 nios2.c (limited to 'nios2.c') diff --git a/nios2.c b/nios2.c new file mode 100644 index 0000000..4586c20 --- /dev/null +++ b/nios2.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2010 Tobias Klauser + * + * This file is part of nios2sim-ng. + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ + +#include +#include + +#include "nios2sim-ng.h" +#include "nios2.h" + +void nios2_cpu_reset(struct nios2 *cpu) +{ + memset(cpu, 0x00, sizeof(struct nios2)); +} + +uint32_t nios2_cpu_fetch_instr(struct nios2 *cpu, uint32_t *mem_base) +{ + uint32_t instr = 0; + + return instr; +} + +int nios2_cpu_execute_instr(struct nios2 *cpu, uint32_t instr) +{ + instruction_handler handle_instr = instruction_get_handler(instr); + + if (unlikely(handle_instr == NULL)) { + err("Invalid instruction %08x\n", instr); + return -1; + } + + return handle_instr(cpu, instr); +} -- cgit v1.2.3-54-g00ecf