mspan.h
4.96 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/*
* ms.h - Memory Span Unit (functional not register simulator)
*
* This memspan unit ignores how to talk to the IO unit. It assumes an ideal memory
* that will not stall. Spans are not broken into spanlets. The memory is just accessed
* directly and provides the data to the BL at the correct time.
*
* May do a real register level simulation of Bob's memspan later.
*/
#ifndef MS_INCLD
#include "ints.h"
#define MAIN_MEMORY_SIZE 0x300000
#define HIDDEN_FACTOR 8
#define HIDDEN_MEMORY_SIZE (MAIN_MEMORY_SIZE/HIDDEN_FACTOR)
#define MAX_MEMSPAN_CMDS 5
/* Drawing commands */
/* The following counts are for single cyle mode from NEWSPAN */
/* calculate z & color the clock before they are needed & put on p0 */
#define CLOCKS_TO_START_VALID 1
#define CLOCKS_TO_END_VALID 2
#define CLOCKS_TO_Z_NEEDED ((21 + CLOCKS_TO_END_VALID) - 1 + 5)
#define CLOCKS_TO_COLOR_NEEDED ((22 + CLOCKS_TO_END_VALID) - 1 + 5)
#define CLOCKS_TO_Z_VALID (24 + CLOCKS_TO_END_VALID + 5)
#define CLOCKS_TO_COLOR_VALID (25 + CLOCKS_TO_END_VALID + 5)
#define CLOCKS_2CYCLE_DELAY 2
/* Fill command (no defines, is a software trick) */
/* Copy command */
#define CLOCKS_TO_COPY_VALID (19+5)
/* Load command */
/* clocks from start of command (newspan) */
#define CLOCKS_TO_TCLOAD (10 + 5)
#define CLOCKS_TO_LOAD_NEEDED (16 - 1 + 5)
/* cycle types */
#define CMD_1CYCLE (G_CYC_1CYCLE >> G_MDSFT_CYCLETYPE)
#define CMD_2CYCLE (G_CYC_2CYCLE >> G_MDSFT_CYCLETYPE)
#define CMD_COPY (G_CYC_COPY >> G_MDSFT_CYCLETYPE)
#define CMD_FILL (G_CYC_FILL >> G_MDSFT_CYCLETYPE)
#define CMD_LOAD (CMD_FILL + 1)
#define CMD_LOAD_TLUT (CMD_FILL + 2)
/* other */
#define NUM_COPY_TEXELS 4
enum mscmdstate { MSCMD_IDLE, MSCMD_BUSY };
typedef struct rdram {
unsigned char *main_addr;
unsigned char *hidden_addr;
unsigned long main_size;
unsigned long hidden_size;
} rdram_t;
/*
* data for all types of mspan "commands"
* Could change to union &/or reuse elements, but don't worry about space
*/
typedef struct ms_cmd {
enum mscmdstate state;
/* from ew */
unsigned long startaddr; /* pixel address */
unsigned long endaddr; /* pixel address */
unsigned long length; /* pixel length */
int cmdtype;
int num; /* command number for debugging */
/* clocks in pipe */
unsigned long clocks;
/* calculated */
int dir;
int skipcnt;
int validcnt;
/* z reads */
unsigned long rzaddr; /* pixel address */
int rzskip;
int rzvalidcnt;
int clockszneeded;
/* color reads */
unsigned long rcoloraddr; /* pixel address */
int rcolorskip;
int rcolorvalidcnt;
int clocksclrneeded;
/* z writes */
unsigned long wzaddr; /* pixel address */
int wzskip;
int wzvalidcnt;
int clockszvalid;
/* color writes */
unsigned long wcoloraddr; /* pixel address */
int wcolorskip;
int wcolorvalidcnt;
int clocksclrvalid;
/* load command */
unsigned long loadtexaddr;
int loadtexinc;
int loadtexvalidcnt;
/* copy command */
unsigned long copyaddr;
int copyinc;
int copyvalidcnt;
} ms_cmd_t;
typedef struct mspan
{
/* required by C-sim */
char *label;
char **argv;
int argc;
int gclk_old;
/* Input signals */
int gclk;
int gclk_en;
int reset;
int capture;
/* from EW */
int ew_ms_length;
int ew_ms_addr; /* [25:0] */
int ew_cv_newspan; /* 1 bit */
/* from AT */
int at_color_base; /* [25:0] */
int at_fill_color; /* [31:0] */
int at_color_format; /* 3 bits */
int at_color_size; /* 2 bits */
int at_z_base; /* 26 bits */
int at_cycle_type; /* 2 bits */
int at_color_rmw;
int at_z_rmw;
int at_z_enable;
int strobe_sync_full;
/* from BL */
int bl_r; /* [7:0] */
int bl_g; /* [7:0] */
int bl_b; /* [7:0] */
int bl_a; /* [2:0] */
int bl_color_we;
int bl_z; /* [17:0] */
int bl_z_we;
/* texture interface */
int at_tex_base; /* [25:0] */
int at_tex_width; /* [9:0] */
int at_tex_size; /* [1:0] */
int at_tex_format; /* [2:0] */
int ew_scissor_load; /* should have a mspan_load */
int ms_load_tlut;
int tex_bus_e; /* enable signal for bidirectional bus XXX who drives? */
int64 tex_bus; /* [63:0] */
int tex_data_valid;
/* output signals */
/* to BL */
int bl_mem_r; /* [7:0] */
int bl_mem_g; /* [7:0] */
int bl_mem_b; /* [7:0] */
int bl_mem_a; /* [2:0] */
int bl_mem_z; /* [17:0] */
int exit; /* forces simulation to exit */
int rel_sync_full;
/* Internal state */
/* conflict indexes */
int end_addr_i;
int reset_negedge; /* detect negative edge of reset pulse */
int sync_full;
} mspan_t;
/*
* Function prototypes:
*/
void mspan(mspan_t **pp0, mspan_t **pp1);
void mspan_init(mspan_t *p0, mspan_t *p1);
#endif /* MS_INCLD */