1 |
8 |
dgisselq |
////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//
|
3 |
|
|
// Filename: regdefs.h
|
4 |
|
|
//
|
5 |
|
|
// Project: CMod S6 System on a Chip, ZipCPU demonstration project
|
6 |
|
|
//
|
7 |
45 |
dgisselq |
// Purpose: This file defines C constants which can be used when
|
8 |
|
|
// communicating with the FPGA device from the PC host.
|
9 |
8 |
dgisselq |
//
|
10 |
|
|
// Creator: Dan Gisselquist, Ph.D.
|
11 |
|
|
// Gisselquist Technology, LLC
|
12 |
|
|
//
|
13 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
14 |
|
|
//
|
15 |
45 |
dgisselq |
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
|
16 |
8 |
dgisselq |
//
|
17 |
|
|
// This program is free software (firmware): you can redistribute it and/or
|
18 |
|
|
// modify it under the terms of the GNU General Public License as published
|
19 |
|
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
20 |
|
|
// your option) any later version.
|
21 |
|
|
//
|
22 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
23 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
24 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
25 |
|
|
// for more details.
|
26 |
|
|
//
|
27 |
|
|
// You should have received a copy of the GNU General Public License along
|
28 |
|
|
// with this program. (It's in the $(ROOT)/doc directory, run make with no
|
29 |
|
|
// target there if the PDF file isn't present.) If not, see
|
30 |
|
|
// <http://www.gnu.org/licenses/> for a copy.
|
31 |
|
|
//
|
32 |
|
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
33 |
|
|
// http://www.gnu.org/licenses/gpl.html
|
34 |
|
|
//
|
35 |
|
|
//
|
36 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
37 |
|
|
//
|
38 |
|
|
//
|
39 |
|
|
#ifndef REGDEFS_H
|
40 |
|
|
#define REGDEFS_H
|
41 |
|
|
|
42 |
45 |
dgisselq |
#define R_ICONTROL 0x00000400
|
43 |
|
|
#define R_BUSERR 0x00000404
|
44 |
|
|
#define R_ITIMERA 0x00000408
|
45 |
|
|
#define R_ITIMERB 0x0000040c
|
46 |
|
|
#define R_PWM 0x00000410
|
47 |
|
|
#define R_SPIO 0x00000414
|
48 |
|
|
#define R_GPIO 0x00000418
|
49 |
|
|
#define R_UART 0x0000041c
|
50 |
|
|
#define R_VERSION 0x00000420
|
51 |
8 |
dgisselq |
|
52 |
|
|
// WB Scope registers
|
53 |
45 |
dgisselq |
#define R_SCOPE 0x00000800
|
54 |
|
|
#define R_SCOPED 0x00000804
|
55 |
8 |
dgisselq |
//
|
56 |
|
|
// And because the flash driver needs these constants defined ...
|
57 |
45 |
dgisselq |
#define R_QSPI_EREG 0x00000c00
|
58 |
|
|
#define R_QSPI_CREG 0x00000c04
|
59 |
|
|
#define R_QSPI_SREG 0x00000c08
|
60 |
|
|
#define R_QSPI_IDREG 0x00000c0c
|
61 |
8 |
dgisselq |
//
|
62 |
|
|
|
63 |
|
|
// RAM memory space
|
64 |
45 |
dgisselq |
#define LGMEMSZ 14
|
65 |
|
|
#define RAMBASE (1<<LGMEMSZ)
|
66 |
|
|
#define MEMWORDS (1<<(LGMEMSZ-1))
|
67 |
|
|
#define RAMLEN (1<<LGMEMSZ)
|
68 |
11 |
dgisselq |
|
69 |
8 |
dgisselq |
// Flash memory space
|
70 |
45 |
dgisselq |
#define LGFLASHSZ 24 // Log_2 of the number of bytes in flash
|
71 |
|
|
#define SPIFLASH (1<<LGFLASHSZ)
|
72 |
|
|
#define FLASHWORDS (1<<(LGFLASHSZ-2))
|
73 |
|
|
#define FLASHLEN (1<<LGFLASHSZ)
|
74 |
|
|
#define CONFIG_ADDRESS SPIFLASH // Main Xilinx configuration (ZipCPU)
|
75 |
|
|
#define ALTCONFIG_ADDRESS (SPIFLASH+0x100000) // Alt Xilinx config (Dbg)
|
76 |
|
|
#define RESET_ADDRESS (SPIFLASH+0x200000) // ZipCPU Reset address
|
77 |
8 |
dgisselq |
|
78 |
|
|
// Interrupt control constants
|
79 |
11 |
dgisselq |
#define GIE 0x80000000 // Enable all interrupts
|
80 |
|
|
#define SCOPEN 0x80040004 // Enable WBSCOPE interrupts
|
81 |
12 |
dgisselq |
#define ISPIF_EN 0x88000800 // Enable SPI Flash interrupts
|
82 |
|
|
#define ISPIF_DIS 0x08000000 // Disable SPI Flash interrupts
|
83 |
|
|
#define ISPIF_CLR 0x08000800 // Clear pending SPI Flash interrupt
|
84 |
8 |
dgisselq |
|
85 |
|
|
// Flash control constants
|
86 |
|
|
#define ERASEFLAG 0x80000000
|
87 |
|
|
#define DISABLEWP 0x10000000
|
88 |
45 |
dgisselq |
#define ENABLEWP 0x00000000
|
89 |
8 |
dgisselq |
|
90 |
11 |
dgisselq |
// Sectors are defined as 64 kB (16 kW)
|
91 |
45 |
dgisselq |
#define SZPAGEB 256
|
92 |
|
|
#define PGLENB 256
|
93 |
|
|
#define SZPAGEW 64
|
94 |
|
|
#define PGLENW 64
|
95 |
11 |
dgisselq |
#define NPAGES 256 // 64 kB sectors / 256 bytes is ...
|
96 |
45 |
dgisselq |
#define SECTORSZB (NPAGES * SZPAGEB) // In bytes, not words!!
|
97 |
|
|
#define SECTORSZW (NPAGES * SZPAGEW) // In words
|
98 |
|
|
#define NSECTORS (FLASHLEN/SECTORSZB) // 256 sectors
|
99 |
|
|
#define SECTOROF(A) ((A) & (-1<<16))
|
100 |
|
|
#define PAGEOF(A) ((A) & (-1<<8))
|
101 |
8 |
dgisselq |
|
102 |
|
|
// Scop definition/sequences
|
103 |
|
|
#define SCOPE_NO_RESET 0x80000000
|
104 |
|
|
#define SCOPE_TRIGGER (0x08000000|SCOPE_NO_RESET)
|
105 |
45 |
dgisselq |
#define SCOPE_MANUAL SCOPE_TRIGGER
|
106 |
8 |
dgisselq |
#define SCOPE_DISABLE (0x04000000)
|
107 |
|
|
|
108 |
|
|
typedef struct {
|
109 |
|
|
unsigned m_addr;
|
110 |
|
|
const char *m_name;
|
111 |
|
|
} REGNAME;
|
112 |
|
|
|
113 |
|
|
extern const REGNAME *bregs;
|
114 |
|
|
extern const int NREGS;
|
115 |
|
|
// #define NREGS (sizeof(bregs)/sizeof(bregs[0]))
|
116 |
|
|
|
117 |
|
|
extern unsigned addrdecode(const char *v);
|
118 |
|
|
extern const char *addrname(const unsigned v);
|
119 |
|
|
|
120 |
|
|
// #include "ttybus.h"
|
121 |
|
|
// #include "portbus.h"
|
122 |
|
|
// #include "deppbus.h"
|
123 |
|
|
|
124 |
|
|
// typedef DEPPBUS FPGA;
|
125 |
11 |
dgisselq |
#include "ttybus.h"
|
126 |
|
|
typedef TTYBUS FPGA;
|
127 |
8 |
dgisselq |
|
128 |
|
|
#endif
|