Professional Documents
Culture Documents
Module 6
Module Objective
Your objective:
To code your design for optimal Quality of Results
Topics:
Hardcoding compiler optimizations Controlling expression size and dynamics Facilitating scheduler optimizations Current C-to-Silicon known problems and solutions Miscellaneous issues
01/31/2011
6-2
01/31/2011
6-3
Loop-invariant expression moved. max = a > b ? a : b; for (i=0; i<10; i++) { c[i] = max * b; }
Generates 4 x 32 mux.
int sum[10], temp; if (cond1) temp = input1; else if (cond2) temp = input2; else if (cond3) temp = input3; else temp = 0; for (i=0; i<10; i++) sum[i] += temp;
6-4
01/31/2011
6-5
01/31/2011
6-6
Use a constant
01/31/2011
6-7
01/31/2011
6-8
Explicitly size expressions only when needed and be very careful to not induce errors!
01/31/2011
6-9
01/31/2011
6-11
01/31/2011
6-12
number of multiplexors
Rewrite a cascaded if else if statement (priority implementation) as a
switch (value) { case 0: do_this(); break; case 1: do_that(); break; default: do_other(); break; }
6-13
01/31/2011
clock constraint +
01/31/2011 SystemC Synthesis using C-to-Silicon Compiler 6-14
6-15
inoptimal timing
inoptimal area
optimization
01/31/2011
6-16
01/31/2011
6-17
Flexible scheduling.
while (true) { bool sub = subtract.read(); wait(); ... result.write( sub ? a - b : a + b ); }
01/31/2011
6-19
01/31/2011
6-20
01/31/2011
6-21
Potential capacity problem. class mpeg_decoder { // A really big class ... }; SC_MODULE(my_module) { ... private: mpeg_decoder my_decoder; };
May resolve capacity problem. SC_MODULE (mpeg_decoder) { // A really big class ... }; SC_MODULE(my_module) { ... SC_CTOR(my_module) : my_decoder("my_decoder") {...} private: mpeg_decoder my_decoder; };
Make it a module
01/31/2011 SystemC Synthesis using C-to-Silicon Compiler 6-22
Cannot use 1 pointer for 18 objects. SC_MODULE(...) { ... private: int buf00[32]; int buf01[32]; ... int buf19[32]; ... int *ptr00to19; };
Use 1 pointer for maximum 16 objects. SC_MODULE(...) { ... private: int buf00[32]; int buf01[32]; ... int buf19[32]; ... int *ptr00to15; int *ptr16to19; };
Maximum of 16 objects
01/31/2011
6-23
2. Suggest a reason why synthesis might not be able to remove code representing functionality that your device will never use.
01/31/2011
6-26
01/31/2011
6-27
01/31/2011
6-28