[myhdl-list] strange problem
Brought to you by:
jandecaluwe
From: Neal B. <ndb...@gm...> - 2009-03-17 15:00:04
|
I'm still trying to wrap my head around myhdl. This one is weird. In my testbench/monitor, which was working, I just added a variable 'input_sample_cnt': input_sample_cnt = 0 @instance def stimulus(): while (1): yield clock.negedge if (en): in_i.next = in_i_iter.next() in_q.next = in_q_iter.next() input_sample_cnt += 1 reset.next = 0 I get: input_sample_cnt += 1 UnboundLocalError: local variable 'input_sample_cnt' referenced before assignment But I've had this all along: result_fd = file ('result', 'w') count_fd = file ('count', 'w') reset_fd = file ('reset', 'w') x_fd = file ('x', 'w') en_fd = file ('en', 'w') oe_fd = file ('oe', 'w') @instance def monitor(): while 1: yield clock.posedge ##print 'reset:', reset, 'en:', en, 'x:', x, 'count:', to_hex(count), 'result:', to_hex(result) if (oe): print >> result_fd, to_hex (result_i), to_hex (result_q) print >> count_fd, to_hex (count) print >> x_fd, to_hex (in_i), to_hex (in_q) print >> reset_fd, to_hex (reset) print >> en_fd, to_hex (en) print >> oe_fd, to_hex (oe) This seems functionally the same thing (other than using +=). Why does this latter work, but the former not? What should I be doing instead? |