Tesi Robotica Un co-processore per Stereo-Matching: Architettura | Page 97

i i “LP_Tesi” — 2011/9/9 — 21:20 — page 97 — #97 i 4.8. MODULO LOADER i 97 Alg:4.33). Il valore letto viene messo all’interno della FIFO fin che poi andrà in ingresso al modulo Top. Algoritmo 4.32 Loader: rule setUp+writeOnMemory 1 2 rule setUp (storeRam && cnt); String dumpFile =""; 3 4 5 if(init==0) dumpFile = pathLeft; if(init==1) dumpFile = pathRight; 6 7 8 9 10 11 File lfh <- $fopen( dumpFile, "r" ); if ( lfh == InvalidFile ) begin $display("cannot open %s", dumpFile); $finish(0); end 12 13 14 15 fh <= lfh ; cnt<=False; endrule: setUp 16 17 18 19 20 rule writeOnMemory (storeRam==True && !cnt); int ir <- $fgetc(fh); int ig <- $fgetc(fh); int ib <- $fgetc(fh); 21 22 23 24 25 26 27 28 29 30 31 32 33 34 if ( ir!=-1 && ig!=-1 && ib!=-1 && addrWrite<=fromInteger(( width*height)-1)) begin Bit#(8) r = truncate( pack(ir) ); Bit#(8) g = truncate( pack(ig) ); Bit#(8) b = truncate( pack(ib) ); ram.a.put(True, addrWrite, Pixel{red:r,green:g,blue:b}); addrWrite <= addrWrite + 1; readyToRead<=True; end else begin $fclose(fh); storeRam<=False; end endrule: writeOnMemory i i i i