#include "harp1.h" const dw = 8; const de = (1 << dw); const aw = 14; const ae = (1 << aw); void main(chan(in) STDIN : dw, chan(out) STDOUT : dw, eram data[ae] = harp1lram : dw, eram hist[de] = harp1hram : aw) { int addr, accu, x, temp; void input_and_histogram() { addr = 0; STDIN ? x; do par { { delay; STDIN ? x; } { data[addr] = x; addr = addr + 1; } { temp = hist[x]; hist[x] = temp + 1; } } while (addr != 0); } void accumulate_histogram() { x = 0; accu = 0; do { temp = hist[x]; hist[x], accu, x = accu, accu + temp, x + 1; } while (x != 0); } void equalise_and_output() { addr = 0; do par { STDOUT ! hist[data[addr]] \\ (aw - dw); addr = addr + 1; } while (addr != 0); } /* Main program */ input_and_histogram(); accumulate_histogram(); equalise_and_output(); }