another newbee question

M

martstev

I am having a mental block thinking about state machine for this
design....

I have a @ 14 Mhz clock, and 4 bit inputs and based on inputs, I want
to genrate several timing signals

so for example "0010" input : T1 PRI is 200us (PRF = 5kHz) (PulseWidth
PW = 500ns) and T2 (PW = 1us) (PRF = 5khz) and T2 pulse starts 10ns
after the leading edge of the T1

another example: input = "0011" T1 PRI is 450us (PRF = 2.22kHz) (PW =
500ns) and T2 (PW =17us) (PRF = 2.22Khz) and again T2 pulse starts
10ns after the leading edge of the T1.

So T1 PW is alwasy constant but PRF changes based on inputs and T2 PW
is changing based on inputs but it alwats starts 10ns after the leading
edge of the T1. PRF of T1 and T2 is same based on the input

T1 and T2 is going to turn on/off LEDs.

how I can design the state machines for this? I wasn't quite sure about
how can I make a counter for this in the state machines!!! Please
help...

thanks,
Mart Steve
 
B

Benjamin Todd

Can you explain a little more? Why do you need such timing if you're
driving LEDs?

ok, from what you said:

1. if the input to your circuit is "0010" you create a 5KHz signal on T1,
but it's not square, it has a 500ns high followed by 199.5us low???
in this case T2 is also 500kHz, but it's width is 1us followed by 199us low?
and it's delayed by 10ns to T1...

ok, so the other inputs combinations change some frequency and width
parameter.

Where I would start is by making a circuit that implements one of the
requirements... using constants to create the counters, i'm sure you don't
need a stae machine for this.

Then have a look and see what you'd need to change your constants to in
order to implement one of the other sequences...

These would be the values modified by a state machine....

It might turn out to be way easier than you thought... you might do away
with the state machine altogether.

Ben
 
K

KJ

I am having a mental block thinking about state machine for this
design....

I have a @ 14 Mhz clock, and 4 bit inputs and based on inputs, I want
to genrate several timing signals

so for example "0010" input : T1 PRI is 200us (PRF = 5kHz) (PulseWidth
PW = 500ns) and T2 (PW = 1us) (PRF = 5khz) and T2 pulse starts 10ns
after the leading edge of the T1

another example: input = "0011" T1 PRI is 450us (PRF = 2.22kHz) (PW =
500ns) and T2 (PW =17us) (PRF = 2.22Khz) and again T2 pulse starts
10ns after the leading edge of the T1.

So T1 PW is alwasy constant but PRF changes based on inputs and T2 PW
is changing based on inputs but it alwats starts 10ns after the leading
edge of the T1. PRF of T1 and T2 is same based on the input

T1 and T2 is going to turn on/off LEDs.

how I can design the state machines for this? I wasn't quite sure about
how can I make a counter for this in the state machines!!! Please
help...
Not quite sure what all of that means but I'm guessing that you're trying to
make two pulse width modulated output signals where for one of the outputs
the overall period is variable (but with a constant pulse time = T1) and a
second output where the pulse width is variable and I'm not sure about the
overall period and there is the additional constraint of T2 having to switch
10 ns after the leading edge of T1.

Assuming that is somewhere in the ballpark then the state machine
controlling 'T1' probably looks like something like the following code.
Some caveats:
- It's only meant to give a general idea, you've still got a few blanks to
fill in but it should get you started.
- It assumes that the clock period comes in on a generic to the entity and
is of type 'time'. As a general rule one should try to avoid embedding too
much application specific knowledge (like the 14 MHz) too deeply.
- The 10 ns after T1 is problematic given a 14 MHz clock....10 ns implies a
50/100 MHz clock

Hope this helps though

KJ

process(Clock)
variable T1_Period_Counter: natural range 0 to ???;
variable T1_High_Time_Counter: natural range 0 to ???;
begin
if rising_edge(Clock) then
if Reset = '1' then
T1_Period_Counter <= 1;
T1_High_Time_Counter <= 500 ns / Clock_Period;
elsif (Load_Input = '1') or (T1_Period_Counter = 0) then
case Input_Selector is
when "0010" => T1_Period_Counter := 200 us /
Clock_Period;
when "0011" => T1_Period_Counter := 450 us /
Clock_Period;
when others => T1_Period_Counter := 1;
end case;
T1_High_Time_Counter := 500 ns / Clock_Period;
T1_Output <= '1';
else
T1_Period_Counter := T1_Period_Counter - 1;
if (T1_High_Time_Counter = 0) then
T1_Output <= '0';
else
T1_High_Time_Counter := T1_High_Time_Counter - 1;
end if;
end if;
end if;
end process;
 
P

Peter

(e-mail address removed) skrev:

So T1 PW is alwasy constant but PRF changes based on inputs and T2 PW
is changing based on inputs but it alwats starts 10ns after the leading
edge of the T1. PRF of T1 and T2 is same based on the input

T1 and T2 is going to turn on/off LEDs.

Hi,

Why do you need the 10 ns delay? Does it have to be exactly 10 ns or is
one period of your 14 MHz clock acceptable?

/Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top