05.07.2013 Views

Script for Laboratory: Designing embedded ASIPs - CES

Script for Laboratory: Designing embedded ASIPs - CES

Script for Laboratory: Designing embedded ASIPs - CES

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

eplacement can be per<strong>for</strong>med. The condition in this example uses some macros (IS_CHAR,<br />

…) and it refers to a node of the source-subtree (add) and accesses some fields of this node<br />

(Type).<br />

With the COST keyword the user can define how expensive a rule shall be. For example the<br />

cost can reflect the execution time of the code that has to be executed to implement the<br />

behavior of this rule. While compilation of the application the code selector determines all<br />

rule combinations that are able to cover the whole LIR with rules and then it chooses the<br />

cheapest coverage concerning the COST clauses.<br />

The last keyword in the example rule is EMIT. If a coverage of the LIR is found, chosen and<br />

scheduled, then the emit parts of all rules are considered. The emit parts contain plain C-code,<br />

but they can also access the properties of the named parts in the rule header. A usual emit part<br />

<strong>for</strong> the above given rule would look like:<br />

EMIT {<br />

fprintf(outfile, “add %s, %s, %s\n”, rd, rs0, rs1);<br />

}<br />

The parameter outfile is expected to be a file, that was opened elsewhere and the parameters<br />

rd, rs0 and rs1 will be replaced by the real register names, after the register allocator has<br />

selected them. In our ASIP Meister examples the emit part looks different, because the<br />

assembly instructions are not immediately written into a file, but they are written into a<br />

temporary data structure, that takes care about inserting the NOP instructions be<strong>for</strong>e the result<br />

is written to a file. This data structure can be accessed by the different versions of the<br />

addInsInfo (speak: Add Instruction In<strong>for</strong>mation) methods, like shown in the example above.<br />

8.2.2 Typical problems while creating the CoSy compiler<br />

While creating the CoSy compiler a tool chain is executed step by step. In this chapter only<br />

the 3 main point of this tool chain will be mentioned, as those 3 main points are also the main<br />

point <strong>for</strong> the typical problems. The entry to this tool chain is ASIP Meister, as it creates the<br />

software description <strong>for</strong> your current CPU. In the next step this software description is<br />

trans<strong>for</strong>med into CoSy rules by the tool “meistercg”, which is created by the developers of<br />

ASIP Meister. The last step is compiling the CoSy compiler with the automatically created<br />

rules.<br />

The typical problems in the first step (ASIP Meister software creation) are explained in<br />

Chapter 4. For the second step with “meistercg” there are very few problems. One example is<br />

an if-then-else construction in the behavior description of an assembly instruction. While<br />

ASIP Meister accepts this, it is not implemented in “meistercg” yet. Newer versions might<br />

support such behavior descriptions, but the current version will abort. The error message<br />

refers to a specific file (usually the instruction_set.arch in the dlx_basis.sw directory) that<br />

manually has to be changed (i.e. delete the corresponding assembly instruction with the ifthen-else)<br />

to solve the problem.<br />

The most problems will appear in the final stage, the compilation of the CoSy compiler itself.<br />

The reasons <strong>for</strong> those problems are typically falsely created rules from “meistercg”. The most<br />

kinds of those falsely created rules are meanwhile automatically detected and fixed by a part<br />

- 72 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!