diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2010-11-11 11:21:40 +0100 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2010-11-11 11:21:40 +0100 |
commit | e0330d9534d8cfeffff81f426df1d3277702b835 (patch) | |
tree | ba90c33bf555a4921a1279105beb54e9a9064ce5 /nios2.c | |
parent | 556c8e0600546b4edf49d6a70adb5b831cd4e25a (diff) |
Implement basic instruction handling
Diffstat (limited to 'nios2.c')
-rw-r--r-- | nios2.c | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -0,0 +1,39 @@ +/* + * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch> + * + * 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 <stdio.h> +#include <string.h> + +#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); +} |