1 hw-cpu-ms1 (libcgencpu.la :: cgen_component_library)
5 This component models the Morpho Ms1 processor.
7 ----------------------------------------------------------------------
13 This component models a simplified Ms1 processor.
15 It does not model floating point instructions.
17 It does not model supervisory functions such as exceptions/traps.
19 +-----------------------------------------------------+
21 |-----------------------------------------------------|
22 | initialization|The CPU performs a power-on-reset |
23 | |style of operation when the reset! |
26 | |Other mode settings may be |
27 | |controlled by pins and/or |
28 | |attributes: endian-set!/endian to |
29 | |set endianness, start-pc-set! to set|
30 | |the PC. These are useful if the |
31 | |standard powerup state of the CPU |
32 | |needs to be changed for running a |
33 | |program that expects an initialized |
35 |----------------+------------------------------------|
36 | execution|The component executes zero or more |
37 | |instructions when the step! pin is |
38 | |driven. You can specify the maximum |
39 | |number of instructions to be |
40 | |executed via the step-insn-count |
41 | |attribute. If the yield pin is |
42 | |driven in a reentrant fashion while |
43 | |the instruction loop is active, the |
44 | |loop will be exited at the next |
45 | |opportunity. At the end of the loop,|
46 | |the step-cycles output pin is driven|
47 | |with the number of instructions |
48 | |actually executed, though this value|
49 | |is clamped to be at least 1. The |
50 | |insn-count attribute accumulates the|
51 | |total number of instructions |
52 | |executed since reset. |
54 | |Each instruction is first fetched |
55 | |from memory via the insn-memory |
56 | |accessor, and its decoding traced if|
57 | |the trace-extract? attribute is set |
58 | |to a true value. The decoded form |
59 | |may be cached indefinitely |
60 | |afterwards, although this cache is |
61 | |flushed when the flush-icache pin is|
64 | |The engine-type attribute specifies |
65 | |whether the "scache" ("semantic |
66 | |cache") or "pbb" ("pseudo basic |
67 | |block") dispatching mechanism is |
68 | |used during execution. The "scache" |
69 | |mode executes each instruction in |
70 | |isolation and checks all |
71 | |triggerpoints after each. If the |
72 | |enable-step-trap? attribute is set, |
73 | |after each instruction, a |
74 | |single-stepping trap is signalled as|
75 | |described in the exceptions/traps |
78 | |The "pbb" mode executes a series of |
79 | |sequential instructions in one |
80 | |uninterruptible sequence, and is |
81 | |thus faster. However, it cannot |
82 | |handle triggerpoints or |
83 | |single-stepping, nor can it respond |
84 | |to icache flushing as quickly. The |
85 | |"pbb" mode is temporarily and |
86 | |transparently downgraded to the |
87 | |"scache" mode when needed. |
89 | |During the execution of an |
90 | |instruction, this component may make|
91 | |accesses using the data-memory |
92 | |accessor, may update its simulated |
93 | |registers, and may trigger an |
95 |----------------+------------------------------------|
96 | tracing|The component can be configured to |
97 | |perform certain kinds of tracing as |
98 | |target programs execute. These are |
99 | |controlled by the family of trace-* |
100 | |boolean attributes. By default, |
101 | |trace output is directed to the |
102 | |standard output stream. The |
103 | |trace-filename attribute allows the |
104 | |user to specify the name of a file |
105 | |where trace output will be |
106 | |collected. A special filename of "-"|
107 | |is used to represent standard |
108 | |output. Trace output files are not |
109 | |appended, but overwritten each time |
110 | |they are opened. |
111 |----------------+------------------------------------|
112 |exceptions/traps|When encountering exception/trap |
113 | |conditions such as memory access |
114 | |errors or software interrupts, this |
115 | |component signals the event using |
116 | |the trap pin. (For some traps, the |
117 | |trap-code pin is driven with extra |
118 | |information just beforehand.) An |
119 | |external component may interpret the|
120 | |values in the table below, and |
121 | |declare a disposition for the |
122 | |condition. In the absence of input, |
123 | |the condition will be treated as the|
124 | |hardware would, that is by |
125 | |dispatching to exception vectors, |
126 | |switching processor modes, etc. |
128 | |The trap codes sent on the trap |
131 | |+----------------------------------+|
132 | || trap | cause | trap-code ||
133 | ||------+-------------+-------------||
134 | || 1 | software | instruction ||
135 | || | trap | bitmap ||
136 | ||------+-------------+-------------||
137 | || 2 | breakpoint | bkpt number ||
138 | ||------+-------------+-------------||
139 | || 3 | system call | syscall ||
141 | ||------+-------------+-------------||
142 | || 4 | invalid | n/a ||
143 | || | instruction | ||
144 | ||------+-------------+-------------||
145 | || 5 | memory | faulting ||
146 | || | fault | address ||
147 | ||------+-------------+-------------||
148 | || 6 | arithmetic | faulting ||
149 | || | overflow | address ||
150 | ||------+-------------+-------------||
151 | || 7 | stepped | n/a ||
152 | |+----------------------------------+|
154 | |The disposition codes returned on |
155 | |the trap input pin are: |
157 | |+----------------------------------+|
158 | || trap | effect ||
159 | ||----------+-----------------------||
160 | || 0 or n/a | dispatch as hardware ||
162 | ||----------+-----------------------||
163 | || 1 | handled; continue ||
164 | ||----------+-----------------------||
166 | ||----------+-----------------------||
167 | || | handled; skip ||
168 | || 3 | instruction and ||
170 | |+----------------------------------+|
171 |----------------+------------------------------------|
172 | register access|All 32 general purpose registers are|
173 | |accessible as attribute r0 through |
174 | |r31. The pc attribute is also |
175 | |available. The current endianness is|
176 | |available as attribute endian. |
178 | |This component exports a number of |
179 | |attributes for use by the |
180 | |sw-debug-gdb component. These are |
181 | |the gdb-* attributes, in the |
182 | |"debugger" category. The |
183 | |gdb-register-N group access all |
184 | |registers in gdb's indexing scheme, |
185 | |in raw target byte order. The |
186 | |gdb-register-pc is a special |
187 | |watchable value with no associated |
188 | |attribute. The gdb-num-registers |
189 | |attribute provides the limit for N. |
190 | |The gdb-exp-registers attribute |
191 | |provides a semicolon-separated list |
192 | |of "expedited" register numbers. |
194 | |The debugger-bus bus provides access|
195 | |to the target program's address |
196 | |space, and is used by gdb to access |
198 +-----------------------------------------------------+
200 +-------------------------------------------------+
202 |-------------------------------------------------|
203 | functional | supported | - |
204 |-------------------+-----------+-----------------|
205 | save/restore | supported | - |
206 |-------------------+-----------+-----------------|
207 | triggerpoints | supported | Triggerpoints |
208 | | | are supported |
211 |-------------------+-----------+-----------------|
212 | inhibit-recursion | supported | It prevents |
214 | | | recursion from |
215 | | | the step! input |
217 +-------------------------------------------------+
219 ----------------------------------------------------------------------
225 CPUs connect to many components: memory to store data and instructions, a
226 scheduler to provide step! signals, software trap emulators, debugger
227 interfaces. The step-cycles output pin may be used as a N-event-control
228 input for a target scheduler to track an estimate of consumed target time.
232 Some error conditions are signalled by messages to standard error. These
233 include some illegal CPU states caused by the simulated program.
235 ----------------------------------------------------------------------
239 Component: hw-cpu-ms1
241 +-----------------------------------------------------------+
243 |-----------------------------------------------------------|
244 | name |direction| legalvalues | behaviors |
245 |-------------+---------+------------------+----------------|
246 |endian-set! |in |1 (big) / 2 |initialization |
248 |-------------+---------+------------------+----------------|
249 |start-pc-set!|in |any value |initialization |
250 |-------------+---------+------------------+----------------|
251 |reset! |in |0 or 1 |initialization |
252 |-------------+---------+------------------+----------------|
253 |trap |inout |enum values |exceptions/traps|
254 |-------------+---------+------------------+----------------|
255 |trap-code |out |various values |exceptions/traps|
256 |-------------+---------+------------------+----------------|
257 |step-cycles |out |1..step-insn-count|execution |
258 |-------------+---------+------------------+----------------|
259 |step! |in |any value |execution |
260 |-------------+---------+------------------+----------------|
261 |yield |in |any |execution |
262 |-------------+---------+------------------+----------------|
263 |flush-icache |in |any |execution |
264 +-----------------------------------------------------------+
266 +-------------------------------------------------+
268 |-------------------------------------------------|
269 | name | addresses | accesses | behaviors |
270 |--------------+-----------+----------+-----------|
271 | debugger-bus | any | any | debugger |
273 +-------------------------------------------------+
275 +---------------------------------------------------------------------------+
277 |---------------------------------------------------------------------------|
278 | name |category | legal values |default| behaviors ||
280 |-----------------+---------+----------------------+-------+---------------||
281 |endian |register |'1'/'big'/'2'/'little'|big |initialization,||
282 | | | | |register access||
283 |-----------------+---------+----------------------+-------+---------------||
284 |trace-extract? |setting |boolean |false |tracing ||
285 |-----------------+---------+----------------------+-------+---------------||
286 |trace-filename |setting |string |- |tracing ||
287 |-----------------+---------+----------------------+-------+---------------||
288 |trace-result? |setting |boolean |false |tracing ||
289 |-----------------+---------+----------------------+-------+---------------||
290 |engine-type |setting |scache or pbb |pbb |execution ||
291 |-----------------+---------+----------------------+-------+---------------||
292 |insn-count |watchable|number |- |execution ||
294 |-----------------+---------+----------------------+-------+---------------||
295 |step-insn-count |setting |number |1 |execution ||
296 |-----------------+---------+----------------------+-------+---------------||
297 |enable-step-trap?|setting |boolean |false |execution ||
298 |-----------------+---------+----------------------+-------+---------------||
299 |rN |watchable|number |- |register access||
301 |-----------------+---------+----------------------+-------+---------------||
302 |pc |watchable|number |- |register access||
304 |-----------------+---------+----------------------+-------+---------------||
305 |gdb-register-N |debugger |byte array |- |register access||
306 |-----------------+---------+----------------------+-------+---------------||
307 |gdb-num-registers|debugger |number |- |register access||
308 |-----------------+---------+----------------------+-------+---------------||
309 |gdb-exp-registers|debugger |number list |- |register access||
310 |-----------------+---------+----------------------+-------+---------------||
311 |state-snapshot |- |opaque string |- |state ||
312 | | | | |save/restore ||
313 |-----------------+---------+----------------------+-------+---------------||
314 |step-cycles |watchable|number |- |execution ||
316 |-----------------+---------+----------------------+-------+---------------||
317 |trap |watchable|number |- |execution/traps||
319 |-----------------+---------+----------------------+-------+---------------||
320 |trap-code |watchable|number |- |execution/traps||
322 +---------------------------------------------------------------------------+
324 +-------------------------------------------------+
326 |-------------------------------------------------|
327 | name | accesses | behaviors |
328 |-------------+-----------------------+-----------|
329 | data-memory | any | execution |
330 |-------------+-----------------------+-----------|
331 | insn-memory | typically 4-byte | execution |
333 +-------------------------------------------------+