-- count10a.balsa: an aysnchronous decade counter import [balsa.types.basic] public type C_size is nibble constant max_count = 9 procedure count10(sync aclk; output count: C_size) is local variable count_reg : C_size variable tmp : C_size begin loop select aclk then if count_reg /= max_count then tmp := (count_reg + 1 as C_size) else tmp := 0 end ; count <- count_reg ; count_reg := tmp end -- complete select H/S end -- loop end end