Main Page
Related Pages
Data Structures
Files
File List
Globals
logic.h
Go to the documentation of this file.
1
#ifndef __LOGIC_H__
2
#define __LOGIC_H__
3
4
/* Copyright (c) 2012 by Fritz Sieker.
5
*
6
* Permission to use, copy, modify, and distribute this software and its
7
* documentation for any purpose, without fee, and without written
8
* agreement is hereby granted, provided that the above copyright notice
9
* and the following two paragraphs appear in all copies of this software,
10
* that the files COPYING and NO_WARRANTY are included verbatim with
11
* any distribution, and that the contents of the file README are included
12
* verbatim as part of a file named README with any distribution.
13
*
14
* IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
15
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
16
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR
17
* HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
18
*
19
* THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
20
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
* A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
22
* BASIS, AND THE AUTHOR NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
23
* UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
24
*
25
*/
26
27
#include "
lc3.h
"
28
#include "
hardware.h
"
29
42
#define OK 0
50
LC3_WORD logic_read_reg (int regNum);
51
59
void
logic_write_reg
(
int
regNum,
LC3_WORD
val);
60
66
LC3_WORD
logic_read_memory
(
LC3_WORD
addr);
67
72
void
logic_write_memory
(
LC3_WORD
addr,
LC3_WORD
value);
73
79
#define SR DR
80
#define BaseR SR1
81
#define nzp DR
82
94
typedef
struct
inst_fields
{
95
LC3_WORD
addr
;
96
LC3_WORD
bits
;
97
opcode_t
opcode
;
98
int
DR
;
99
int
SR1
;
100
int
SR2
;
101
int
bit5
;
102
int
bit11
;
103
LC3_WORD
trapvect8
;
104
LC3_WORD
imm5
;
105
LC3_WORD
offset6
;
106
LC3_WORD
PCoffset9
;
107
LC3_WORD
PCoffset11
;
108
LC3_WORD
SR1OUT
;
109
LC3_WORD
SR2MUX
[2];
111
LC3_WORD
SR2MUXval
;
112
LC3_WORD
ADDR1MUX
[2];
115
LC3_WORD
ADDR2MUX
[4];
117
}
instruction_t
;
118
127
void
logic_fetch_instruction
(
instruction_t
* inst);
128
137
int
logic_decode_instruction
(
instruction_t
* inst);
138
145
int
logic_execute_instruction
(
instruction_t
* inst);
146
147
#define SelNotUsed 0
148
#define SelImm 1
149
#define SelReg 0
150
#define SelBaseR 0
151
#define SelPC 1
152
#define SelSEXT11 0
153
#define SelSEXT9 1
154
#define SelSEXT6 2
155
#define SelZero 3
168
LC3_WORD logic_MARMUX (instruction_t* inst, int ADDRMUX1sel, int ADDRMUX2sel);
169
170
#endif
171
Generated on Mon Dec 2 2013 13:47:03 by
1.8.3.1