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 
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 {
98  int DR;
99  int SR1;
100  int SR2;
101  int bit5;
102  int bit11;
117 } instruction_t;
118 
128 
138 
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