J
john
Hello,
I have a setup that generates a clock and valid data on each rising
edge of the clock. I tried to write the data for each clock cycle to
the RAM on the falling edge of the clock plus increments the counter on
the falling edge too.
I ran the simulator and saw that when I try to write data on the
falling edge and also increment the counter on the falling edge then I
could loose data because of close edges of the counter and clock.
Can I use the same clock to run two different state machines. One
machine will be writing the 8 bit data to a RAM on the falling edge of
the clock and the other machine will be generating the addresses or
incrementing the counter on the rising edge of the clock. Is it a good
idea or bad idea? I am also attaching the code.
Thanks
John
Process ( State_A, USB_CLK )
Begin
Case State_A is
When A0=>
inc<='0';
Data_Bus ( 13 downto 8)<=USB_Data ( 5 downto 0 );
UBL <='0';
LBL <='0';
sec_reset <='1';
nextstate_A <=A1;
When A1 =>
inc<='0';
Data_Bus ( 7 downto 0)<= USB_Data ( 7 downto 0 );
UBL <='0';
LBL <='0';
sec_reset <='0';
nextstate_A<=A2;
When A2 =>
inc <='1';
Data_Bus ( 13 downto 8)<= USB_Data ( 5 downto 0 );
UBL <='0';
LBL <='0';
sec_reset <='0';
nextstate_A<=A3;
When A3 =>
inc<='0';
Data_Bus ( 7 downto 0)<= USB_Data ( 7 downto 0 );
UBL <='0';
LBL <='0';
sec_reset <='0';
nextstate_A<=A2;
When others =>
nextstate_A <=A0;
End case;
End Process;
------------------------------------------------------
Process (USB_CLK, Reset)
Begin
If(Reset = '1' )Then
Indicator_LED <= '1';
State_A <= A0;
elsif (USB_CLK 'Event And USB_CLK = '0')Then
State_A <= nextstate_A;
Else
End If;
End Process;
-------------------------------------------------------
Process (USB_CLK)
Begin
If(Reset = '1' )Then
sec_counter <= ( others=>'0');
elsif (USB_CLK 'Event And USB_CLK = '1')Then
If ( inc = '1')Then
sec_counter<= sec_counter + 1;
End If;
End If;
End Process;
I have a setup that generates a clock and valid data on each rising
edge of the clock. I tried to write the data for each clock cycle to
the RAM on the falling edge of the clock plus increments the counter on
the falling edge too.
I ran the simulator and saw that when I try to write data on the
falling edge and also increment the counter on the falling edge then I
could loose data because of close edges of the counter and clock.
Can I use the same clock to run two different state machines. One
machine will be writing the 8 bit data to a RAM on the falling edge of
the clock and the other machine will be generating the addresses or
incrementing the counter on the rising edge of the clock. Is it a good
idea or bad idea? I am also attaching the code.
Thanks
John
Process ( State_A, USB_CLK )
Begin
Case State_A is
When A0=>
inc<='0';
Data_Bus ( 13 downto 8)<=USB_Data ( 5 downto 0 );
UBL <='0';
LBL <='0';
sec_reset <='1';
nextstate_A <=A1;
When A1 =>
inc<='0';
Data_Bus ( 7 downto 0)<= USB_Data ( 7 downto 0 );
UBL <='0';
LBL <='0';
sec_reset <='0';
nextstate_A<=A2;
When A2 =>
inc <='1';
Data_Bus ( 13 downto 8)<= USB_Data ( 5 downto 0 );
UBL <='0';
LBL <='0';
sec_reset <='0';
nextstate_A<=A3;
When A3 =>
inc<='0';
Data_Bus ( 7 downto 0)<= USB_Data ( 7 downto 0 );
UBL <='0';
LBL <='0';
sec_reset <='0';
nextstate_A<=A2;
When others =>
nextstate_A <=A0;
End case;
End Process;
------------------------------------------------------
Process (USB_CLK, Reset)
Begin
If(Reset = '1' )Then
Indicator_LED <= '1';
State_A <= A0;
elsif (USB_CLK 'Event And USB_CLK = '0')Then
State_A <= nextstate_A;
Else
End If;
End Process;
-------------------------------------------------------
Process (USB_CLK)
Begin
If(Reset = '1' )Then
sec_counter <= ( others=>'0');
elsif (USB_CLK 'Event And USB_CLK = '1')Then
If ( inc = '1')Then
sec_counter<= sec_counter + 1;
End If;
End If;
End Process;