--- Quote Start ---
I'm an analogue engineer
--- Quote End ---
Welcome to the "dark side"! Or perhaps we should thank you for coming over from the dark side :)
--- Quote Start ---
i have a DE0 development board which ive been playing about with. however i im a bit stuck with trying to get down in VHDL what im after.
i have a pulse that goes high for 1 us and repeats every second, i have another pulse that also goes high for 2 us and repeats every second. the two rising edges can drift , what i'm trying to do is if the first pulse goes high and the second pulse goes high later than 10 us a 250 ns output will be pulsed.
i think how the circuit will work will be if pulse 1 goes high start a counter that will count 500 clock pulses ( 50 MHz clk). If the second pulse goes high before the count reaches 500 reset an wait for next pulse.
if the second pulse goes high after 500 clock cycles output a 250 ns pulse and reset.
does this sound plausible? if so how do i go about implementing it.
--- Quote End ---
Since you are a beginner, I'll verbally walk you through some general ideas.
1. Learn to use Modelsim to simulate your design.
This will make your life easier, as you'll be able to provide code when you get stuck.
2. 1s is a long time in a simulator, so learn to use VHDL generics to parameterize your circuits.
For example, I have some logic like you describe for monitoring the 1pps output from a GPS unit. When simulating the design, I can change the generics to expect 1ms ticks or 100ms ticks.
3. External signals that are not synchronous to your FPGA clock need to be synchronized.
You do this via a synchronizer component; multiple stages of flip-flops that are used to decrease the probability of metastability.
4. Learn how to write state machines.
Signal generation in a state machine is often generically referred to as Moore (output depends on state) and Mealy (output depends on input and state).
You can use a state machine to track your pulse logic, eg., got an edge, waiting for other pulse, etc.
Take a shot at writing some VHDL code, eg., a testbench that generates your 1pps (or 100ms) pulse, and a synchronizer component that synchronizes that pulse to the DE0 clock. Then figure out a way to detect a rising-edge on that signal (hint, you can use a single register to delay the synchronized signal, and then logic operators and/nand/or/nor/xor/xnor to get a single clock pulse).
That'll help you get familiar with Modelsim. Then you can start working on your real application.
Come back to the forum when you get stuck, you'll get plenty of advice.
Cheers,
Dave