From: "Jim Battle"
Sent: Friday, December 19, 2008 12:47 AM
My solution in the emulator is to compute the ratio of
on/off over that
1/60th of a second and then use that to display an image of a lamp.
Actually, I go one better than that. I have a simple first order time
constant model of the lamp so that it doesn't go from 0->100% in 1/60th of
a second. new_intensity = K*old_intensity + (1-K)*new_duty_cycle. Pick K
to approximate the thermal inertia of the lamp.
Oh, to keep from having to compute a tally of all the lamps after each
instruction simulation cycle, I have an array of 256 counters for each
byte of address or data bus. So for a given byte, after each instruction I
just do: histo[byte_value]++. At the time it comes to display each lamp,
I look at all the buckets and figure out the average duty cycle for each
of the 8 lamps in the group.
Those two solve the sampling problem to a sufficient degree that I'm done
tweaking with it.
Cool! A great use of the extra memory and MIPS on your emulation host :-).
There are probably easily enough resources to do the same thing in the
FPGA, though most of the VGA outputs lack enough intensity resolution
to render the brightness directly. So you'd have to use the intensity
to modify the address given to the character generator, and render it
as a different sized dot, or the like.
Vince