-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmem.h
118 lines (104 loc) · 4.13 KB
/
mem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/****************************************************************************
* Copyright (C) 2020 by Ted Kotz *
* *
* This file is part of TernCpuEmu. *
* *
* TernCpuEmu is free software: you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* TernCpuEmu 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 Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with TernCpuEmu. If not, see *
* <http://www.gnu.org/licenses/>. *
****************************************************************************/
/**
* @file mem.h
* @author Ted Kotz <ted@kotz.us>
* @version 0.1
*
* [Description]
*
*/
#ifndef TERNARY_MEM_H
#define TERNARY_MEM_H
/* Includes ******************************************************************/
#include "cpu.h"
#include <stdio.h>
/* Defines *******************************************************************/
// 3^11 Trytes of RAM - simlar address space to a 16-bit memory
// 15-trit might make sense as well as it it divisible by 3
// and would require the same number of total address and
// data lines as an 8-bit era cpu
#define RAM_SIZE 177147
#define BASE_OFFSET (RAM_SIZE/2)
#define RAM_ADDR_MASK ((1<<(11*2))-1)
/* Types *********************************************************************/
typedef enum
{
// __--__--__--
ADDR_UART = 0b000000000011, // -1 ,
ADDR_PC_START2 = 0b000000001101, // -2 ,
ADDR_PC_START1 = 0b000000001100, // -3 ,
ADDR_PC_START0 = 0b000000001111, // -4 ,
ADDR_ERROR_ISR2 = 0b000000110101, // -5 ,
ADDR_ERROR_ISR1 = 0b000000110100, // -6 ,
ADDR_ERROR_ISR0 = 0b000000110111, // -7 ,
ADDR_NMI_ISR2 = 0b000000110001, // -8 ,
ADDR_NMI_ISR1 = 0b000000110000, // -9 ,
ADDR_NMI_ISR0 = 0b000000110011, // -10,
ADDR_EXT_ISR2 = 0b000000111101, // -11,
ADDR_EXT_ISR1 = 0b000000111100, // -12,
ADDR_EXT_ISR0 = 0b000000111111, // -13,
ADDR_RTC2 = 0b000011010101, // -14,
ADDR_RTC1 = 0b000011010100, // -15,
ADDR_RTC0 = 0b000011010111, // -16,
// ADDR_ = 0b000011010001, // -00,
// ADDR_ = 0b000011010000, // -00,
// ADDR_ = 0b000011010011, // -00,
// ADDR_ = 0b000011011101, // -00,
// ADDR_ = 0b000011011100, // -00,
// ADDR_ = 0b000011011111, // -00,
/*BITMAP DISPLAY*/
/*DAC*/
/*ADC*/
/*TIMER_INT*/
} MemMappedDevices;
/* Interfaces ****************************************************************/
/* Data **********************************************************************/
/* Functions *****************************************************************/
/**
* [Description]
*
* @param
* @return
*/
extern Tryte ReadAddr(TriWord addr);
/**
* [Description]
*
* @param
* @return
*/
extern void WriteAddr(TriWord addr, Tryte val);
/**
* [Description]
*
* @param
* @return
*/
extern void resetMem( void );
/**
* [Description]
*
* @param
* @return
*/
extern int readFileIntoMem(FILE* fin, const char* fname, int verbose);
#endif /* TERNARY_MEM_H */
/*****************************************************************************/