forked from JonathanBelanger/DECaxp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RULES
190 lines (181 loc) · 7.12 KB
/
RULES
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
Project Notes:
The project structure is as follows:
1. Documentation is located in the doc/ folder.
2. Build (makefile) is located in the bld/ folder.
3. Source code is in the src/ folder with the following:
a. comutl/ contains a common set of utilities (used across multiple components).
b. cpu/ contains all the code that implements the emulation of the Digital Alpha AXP 21264 CPU.
c. sys/ contains all the code that implements the system and main function.
c. tst/ contains all the unit testing code.
4. Data files are located in the dat/ folder.
5. Binary files from compiling are placed in the bin/ folder (note: GIT ignores this folder and its contents)
6. Executeable files are placed in the exe/ folder (note: GIT ignores this folder and its contents)
When building the project:
1. Make sure the exe/ and bin/ folders exist.
2. From within the bld/ folder, run 'make depend' prior to trying to build the emulator code.
3. Prior to attempting to check in code, make sure that the binaries and executeables are cleaned out, and
the makefile is restored to its check-in format by running 'make clean'
Coding Rules:
The code is written entirely in the C language. The ANSI C compiler option
should be utilized.
Coding Style:
Basics:
blank lines: Blank lines should not have any whitespace
characters.
tab length: Each tab is 4 space characters long. If possible,
two connected "tabs" will be converted into a single
ASCII tab.
white space: There will be no whitespace characters at the end of a
line.
line length: A line of code should not exceed 80 characters long.
If at all possible, and code clarity is not lost, a
line of code which exceeds 80 characters should be
broken up into multiple lines.
Comments:
module comment: Every module/header file will begin with a
copyright comment, also containing a module/header
description and revision history. The first
revision history entry will be V01.000 and say
"Initially written.".
line comments: Either '//' or '/* */' can be used. Line comments
should either be on their own line or at the and of
a line containing code. If a line comment is on
its own line, then the start of the comment is in
line with the code underneath. Also, these
line comments will be proceeded by a blank line.
multiline comments:
There will be a blank line before a multiline
comment. The comment, itself, will start with '/*',
where the '/' is inline with the underlying code.
The comment start will be on it's own line.
The comment will end with '*/', where the '*' will
be inline with the '*' on on the comment start and
be ib its own line.
Lines in between the start and end comment will
a '*', which is inline with the '*' on both the
comment start and end. If an in-between comment
does not have any text following it, then the white
space rule above shall be followed. Otherwise, one
or more sace/tab characters will follow the '*',
prior to the text of the comment.
There will be no blank line following a multi-line
comment, unless the comment stands along and is not
specifically comment in the subsequent code.
A variation on the multiline comment mat be used,
where the opening comment '/*' be be followed by
multiple '*', and inbetweem comments can contain
space characters prior to a final '*', and the
comment end can be preceeded by mutliple '*', all
to form a box.
function comments:
All functions will be proceeded by a multiline
comment. The function comment will have the
following format:
/*
* functionName
* Function description.
*
* Input Parameters:
* param1:
* Input Param1 description.
* paramn:
* Input Paramn description.
* Output Parameters:
* paramx:
* Output Paramx description.
* paramy:
* Output Paramy description.
*
* Return Value:
* None or a list of potential return values
* and what they mean.
*/
A parameter is this both an input and output
parameter may be listed in both areas.
Files:
header file: After the copyright comment. the first two lines
should be the following:
#ifndef _HEADER_FILE_NAME_DEFS_
#define _HEADER_FILE_NAME_DEFS_
The last line should be the following (note a tab
character between #endif and '/*'):
#endif /* _HEADER_FILE_NAME_DEFS_ */
There shall be at least one header file for each
module. A module file of the name foobar.c, shall
have a header file of foobar.h. This header file
will include all the files needed by the module.
The module will include this header file.
For external entry points, either the module header
file or a separate header file (with a file name
sufficient to determine what the header file
contains) will be utilized.
A header file will contain no code that is compiled
within the header file.
includes: All includes are listed at the top of the header
and module file. Conditional includes may be done
here as well.
A header file should contain all the includes
required for it to be successfully compiled (even
by itself).
module file: A module file will have a similar format to a
header file, except it will not contain the
'#ifndef ... #endif' lines.
A module file can contain everything a header file
includes, plus code that will be compiled into an
executeable.
All global variables (module or beyond), will be
declared at the top of the module (after any
includes).
All functions/routines/procedures will be preceeded
by a function comment (see above).
Code:
All code will have the following format (note locations of '{' and
white space):
/*
* functionName
* Function description.
*
* Input Parameters:
* param1:
* Input Param1 description.
*
* Output Parameters:
* None.
*
* Return Value:
* 1: Item not found.
* 2: Close enough item found.
* 3: Item found.
*/
int funct(int param)
{
int retVal = 1;
int ii;
/*
* Loop until param and retVal are not equal.
*/
while (param == retVal)
{
/*
* Loop through param until we find what we came for.
*/
for (ii = 0; ii < param; ii++)
{
if (param)
retVal = 2; // Preliminary value.
else
{
retVal = 3; // What we came for.
break; // get out of for loop.
}
}
/*
* Retest while condition to see if we are done.
*/
continue;
}
/*
* Return what we found back to the caller.
*/
return(RetVal);
}