Question: You are given a large array ('bg') representing a background image. You are also given a smaller array ('a') of pixels. You must filter each

You are given a large array ('bg') representing a background image. You are also given a smaller array ('a') of pixels. You must filter each pixel against a portion of the background array for "sum of absolute differences" (SAD). Filter pixel a[j] as: Sum over k of: abs (a[j] - ref[k]), for k = j, j+1, j+2, j+3. There is a new processor microarchitecture. There is a new special-purpose on-chip SRAM _register file_ of length 4. We use this as a programmer-managed cache. When we go to the next pixel, three of the old 'bg' values can be reused; we only need to load one new 'bg' value, which minimizes data movement for the total computation. The filtered pixel and the 'SAD' value for that pixel are the same thing. The 'SAD' values go in array 'b'. Also compute the smallest 'SAD' value for this array of pixels. You may assume that 'SAD' values never exceed 10. Finally, show the final contents of the SRAM register file. You must program this in a restricted high-level language---almost pseudo-assembly. The algorithm is roughly: pre-load SRAM for 1st pixel for every pixel do convolve pixel with SRAM, thereby computing SAD store SAD in array 'b' keep track of SAD minimum You may print the results without any restriction. You may program in any C-like "high-level" programming language (I expect essentially Java, C, or C++), but you must observe a _strict load/store discipline_ that makes it look like you are programming in assembly language. The restrictions are: 1) There is a mandatory prelude. You must copy the prelude verbatim into your program, making only language adjustments as necessary. After the prelude, the restrictions start. For example, almost all computation is done with registers. Registers may be declared and initialized. You may choose register names. By definition, register names are _not indexed_. 2) Your _only_ access to array elements is via load and store as stand-alone statements. The syntax is:  = [] and [] = . You may not access arrays otherwise. 4) You may perform register arithmetic. The syntax is:  = . 5) The only loop in this algorithm is _one_ 'for' loop to loop over pixels. You may use a simple 'for' loop from your high-level language. One other control structure is permitted. You may use _one_ simple 'case' statement if you feel the need. No other control structures are allowed. 6) 'abs', 'min', and 'mod' are allowed in register expressions. 7) Your program output must be appended to your source code as a _comment_. Here is an illustration in C++ (a "high-level" language chosen at random). --- #include  // for std::cout #include  // for std::min int main () { // all submissions _must_ contain this prelude or equivalent int bg[] = {4,2,4,2,4,5,2,7,3,7,3,7,3,2}; // background image int a[] = {0,1,2,3,3,2,1,0}; // pixels int b[8]; // filtered pixels int sr0,sr1,sr2,sr3,sr4; // new on-chip SRAM // register file // load-store restrictions start ... // initial SRAM load int r = 5; int m = 0; // indices for bg ==> SRAM int min_sad = 100; // absurdly high value for // for every pixel do ... ... // convolve ... ... // load _one_ value from bg ... // prepare indices for ... // next bg load } // load-store restrictions released for printing std::cout << " "; std::cout << "The eight original pixels are: " << " "; for( int i = 0; i < 8; i++ ) { std::cout << " " << a[i]; } std::cout << " "; std::cout << "The eight filtered pixels are: " << " "; for( int i = 0; i < 8; i++ ) { std::cout << " " << b[i]; } std::cout << " "; std::cout << "The minimum SAD value is: " << " "; std::cout << " " << min_sad << " "; std::cout << "The final SRAM register values are: " << " "; ... } /* The eight original pixels are: ... The eight filtered pixels are: ... The minimum SAD value is: ... The final SRAM register values are: ... */ 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!