Re: VGA Work
Posted: Wed Oct 29, 2025 11:46 pm
J64C wrote:
Dunno. I tend to avoid the quirky Verilog syntax in favour of the more C style in the example I posted.
Quote:
And with the latter, I'd expect that to be running at half clock rate. Assuming HC increments with the base clock.
Quote:
Did you try my example? As I said, the timing is perfect on that. I wrote it and tested it last night, with a flicker free 640 x 480 60Hz screen right next to me.
I would have no picture to go off of to see if it was still dropping out. (The sync light is very laggy and isn't a good indicator) The timings on the scope might say one thing, but the monitor I'm using could very well paint a very different picture. (No pun intended)
Further, I do need those counts to start at 0 on the visible section; along with all the other signals I'm trying to generate. Thus I would have to make significant changes to make it do what I need, likely breaking it back into the non functioning state.
Quote:
Lastly, there is a crap-ton that can be optimised in your initial Verilog code that can be optimised, freeing up heaps of space. As space is a premium in CPLD's.
barnacle wrote:
Just for curious: are you using the CPLD to generate all the signals? By which I mean not just the syncs and blanking, but the memory addressing and any control signals?
Quote:
I'm pretty certain that whatever you do - unless you have the parallel to serial converter also on the CPLD - you'll need to emit the blanking to the rest of your circuit, but it could easily be a mixed blanking signal, no?
J64C wrote:
Personally, I don't even bother taking the blanking periods in to account. If the horizontal counter isn't within the visible range, don't display anything.
gfoot wrote:
That is what I would expect - though I don't know verilog very well, it is also what would happen in cupl, or for the most part, in a less integrated circuit with individual flipflops. On the rising edge of the clock, all the flipflops that depend on it have their states updated based on their current data input levels, and these data input levels are the levels from before the updates occur. So BLANKb's state is being set based on the existing value of the counters before the clock edge; simultaneously, the counter values are also being updated, but anything synchronous to the same clock signal will have its state set based on the old values.
In Verilog <= is an asynchronous assign. The cupl equivalent of:
Code: Select all
X.d = Y;
A = X; // A would get old value of X (or something like this, might not be correct on syntax)
I somewhat knew about this going into writing this thing, but was not totally clear on how it all fits together in the realm of Verilog, as such my first solution I came upon was to trigger on HC[0], though I highly doubt this is the correct way. (Works on the Arduino clock at human speeds, likely will fail when I speed it back up to 25.175MHz)
Quote:
Your second example was making the BLANKb flipflop be clocked by the low bit of the counter. This might not be a good idea because the other counter bits may be in flux at the time BLANKb is updated, violating setup time requirements for BLANKb. (It might be somehow fine for this device, I am not familiar with it - but in general you should avoid having the input for a registered output be unstable in the lead-up to the clock signal arriving.)
Quote:
In cupl, where I have something like a counter that's being updated on a clock signal and also other registered outputs that depend on the counter's value and are updated on the same clock edge, I often precalculate the new counter value in a cupl internal variable, so that I can use it both as the update value for the counter, and as an input to expressions that determine the states of other registered outputs. Here's an example from a VGA text memory control PLD, with a 3-bit counter C0,C1,C2 and various control signals that need to activate at different points in the count cycle - note that 'nC0', 'nC1', 'nC2' are just cupl variables that represent the 'next' states of the counter bits
Another idea I had was to effectively anticipate when those signals would actually change. I'm not totally sold on this idea though, I fear what that is making me do is second guess what the hardware might do, and that doesn't seem like a solid design.