TITLE "Logic for choosing next fifo"; FUNCTION lpm_mux (data[LPM_SIZE-1..0][LPM_WIDTH-1..0], sel[LPM_WIDTHS-1..0], clock, aclr) WITH (LPM_WIDTH, LPM_SIZE, LPM_WIDTHS, LPM_PIPELINE) RETURNS (result[LPM_WIDTH-1..0]); SUBDESIGN choose_fifo ( ren_last[4..0],ffend[4..0],ee_last,notempty[4..0],testmode :INPUT; ren_next[4..0] :OUTPUT; ) VARIABLE done[4..0] :NODE; look[4..0] :NODE; ren_next_test[4..0] :NODE; ren_next_freerun[4..0] :NODE; ren_next_mux :lpm_mux WITH (LPM_WIDTH=5, LPM_SIZE=2, LPM_WIDTHS=1); BEGIN % include most recent data read in list of done fifos % IF (ee_last) THEN done[] = ren_last[] # ffend[]; END IF; IF (!ee_last) THEN done[] = ffend[]; END IF; % look at fifos that are not empty and not done % look[] = notempty[] & (!done[]); % prioritize the fifos looked at % % in freerun mode any nonempty fifo that has not reached end of event is available% ren_next_freerun[0] = look[0]; ren_next_freerun[1] = look[1] & (!look[0]); ren_next_freerun[2] = look[2] & (!look[1]) & (!look[0]); ren_next_freerun[3] = look[3] & (!look[2]) & (!look[1]) & (!look[0]); ren_next_freerun[4] = look[4] & (!look[3]) & (!look[2]) & (!look[1]) & (!look[0]); % in test mode fifo 0 is available until end of event is reached, then fifo 1 is available until end of event is reached, etc.% ren_next_test[0] = look[0]; ren_next_test[1] = look[1] & (done[0]); ren_next_test[2] = look[2] & (done[1]) & (done[0]); ren_next_test[3] = look[3] & (done[2]) & (done[1]) & (done[0]); ren_next_test[4] = look[4] & (done[3]) & (done[2]) & (done[1]) & (done[0]); % two different priority modes are multiplexed% ren_next_mux.data[0][] = ren_next_freerun[]; ren_next_mux.data[1][] = ren_next_test[]; ren_next_mux.sel[] = testmode; ren_next[] = ren_next_mux.result[]; END;