23-02-2017, 10:22 AM
(This post was last modified: 23-02-2017, 10:24 AM by ppppenguin.)
A couple of general point about logic design.
Wherever possible make everything synchronous to clock. This avoids all sorts of trouble. It's not obvious whether the set and clear inputs of the flipflops on your schematic are synchronous or not. In the days of TTL and CMOS most parts were not ideal for good synchronous design. In PLDs and FPGAs it's the natural way of designing.
A corollary of the above is to register all signals if at all possible. Registers are essentially free in programmable logic. Again it avoids all sorts of problems, mainly to do with propagation delays.
Never put a gate in s clock signal unless you really know what you're doing and even then avoid where possible. All flipflops in PLDs and FPGAs have a clock enable input so use a single clock to all of them and control via the CE input. It's nice and easy to do this in VHDL. Even if there isn't a physical CE input the synthsis engine will produce an equivalent result using gates and feedback. Obviously in a 625 to 405 converter there will be 2 clocks, one each for input and output. If any signals have to cross a clock domain boundary then special care is needed.
In the example below I'm using a 54MHz clock for everything on the 625 side which 4x the pixel rate. Then a divide by 4 gives me clock enables at 13.5MHz.
process (CK) begin
if rising_edge(CK) then
if CE='1' then --These run with standard CE (13.5MHz)
-- Central horizontal 13 bit counter. Line length up to 4125 pixels
if HRESET then HCOUNT <= 0; -- Reset at terminal count
else HCOUNT <= HCOUNT + 1 mod 8192; -- Normal count
end if;
end if; -- CE
end if; -- CK
end process;
Wherever possible make everything synchronous to clock. This avoids all sorts of trouble. It's not obvious whether the set and clear inputs of the flipflops on your schematic are synchronous or not. In the days of TTL and CMOS most parts were not ideal for good synchronous design. In PLDs and FPGAs it's the natural way of designing.
A corollary of the above is to register all signals if at all possible. Registers are essentially free in programmable logic. Again it avoids all sorts of problems, mainly to do with propagation delays.
Never put a gate in s clock signal unless you really know what you're doing and even then avoid where possible. All flipflops in PLDs and FPGAs have a clock enable input so use a single clock to all of them and control via the CE input. It's nice and easy to do this in VHDL. Even if there isn't a physical CE input the synthsis engine will produce an equivalent result using gates and feedback. Obviously in a 625 to 405 converter there will be 2 clocks, one each for input and output. If any signals have to cross a clock domain boundary then special care is needed.
In the example below I'm using a 54MHz clock for everything on the 625 side which 4x the pixel rate. Then a divide by 4 gives me clock enables at 13.5MHz.
process (CK) begin
if rising_edge(CK) then
if CE='1' then --These run with standard CE (13.5MHz)
-- Central horizontal 13 bit counter. Line length up to 4125 pixels
if HRESET then HCOUNT <= 0; -- Reset at terminal count
else HCOUNT <= HCOUNT + 1 mod 8192; -- Normal count
end if;
end if; -- CE
end if; -- CK
end process;
www.borinsky.co.uk Jeffrey Borinsky www.becg.tv