J
john
Guest
Hello,
I am trying to interface a USB receiver chip with the FPGA. The USB
chip can only allow unidirection
communications. it just outputs eight bit of data at 12 MHz at each
rising edge of the USB clock in brust
mode. The scheme I used is simple but my State machine is getting lost
and screwing up the count of the counter. some times It works
sometimes it does not work!
I am using the counter to generate addressess for the Dual port RAM.
My VHDL comlplier also ignoring the intialization
of the signal Flag1 and I do not know why? Please Advice!
Thanks very much.
Regards
john
signal State : unsigned(7 downto 0);
signal nextstate : unsigned(7 downto 0);
constant E0 : unsigned(7 downto 0):="00000000";
constant E1 : unsigned(7 downto 0):="00000001";
constant E2 : unsigned(7 downto 0):="00000010";
constant E3 : unsigned(7 downto 0):="00000011";
Signal State1 : unsigned(7 downto 0);
Signal nextstate1 : unsigned (7 downto 0);
constant F0: unsigned(7 downto 0):="00000000";
constant F1: unsigned(7 downto 0):="00000001";
Signal inc: std_logic:='0';
Signal eq_signal : std_logic:='1';
Signal Reset_A : std_logic;
Signal counter_clock : std_logic;
Signal USB_port : unsigned ( 7 downto 0);
Signal Flag1 : std_logic:='0';
Begin
Data_Bus<="00000000000000";
C0: counter port map (Address_bus,
Data_in,DPR_CLK,inc,eq_signal,Reset_A);
Process(State1,nextstate1)
Begin
Case State1 is
When F0 =>
Flag1 <='0';
nextstate1 <= F1;
When F1 =>
Flag1 <='1';
nextstate1<=F0;
When others =>
Null;
End Case;
End Process;
-------------------------------------------
Process(USB_CLK,State1,nextstate1)
Begin
If (USB_CLK'event And USB_CLK='1') Then
State1 <= nextstate1;
End If;
End Process;
------------------------------------------
Process (State,nextstate,SM_DIR,Flag1)
Begin
Case State is
When E0=>
Reset_A<='1';
inc<='0';
UBL <='1';
LBL <='1';
CE0 <='1';
CE1 <='0';
Output_Enable<='1';
Read_write <='1';
nextstate<=E1;
When E1=>
If (Flag1='1')Then
Reset_A<='0';
UBL <='1';
LBL <='1';
CE0 <='1';
CE1 <='0';
Output_Enable<='1';
Read_write <='1';
inc<='1';
nextstate<=E2;
Else
nextstate<=E1;
End If;
When E2=>
Reset_A<='0';
UBL <='0';
LBL <='0';
CE0 <='0';
CE1 <='1';
Output_Enable<='1';
Read_write <='0';
inc<='0';
nextstate<=E3;
When E3=>
If (Flag1='0')Then
Reset_A<='0';
UBL <='0';
LBL <='0';
CE0 <='0';
CE1 <='1';
Output_Enable<='1';
Read_write <='0';
inc<='0';
nextstate<=E1;
Else
nextstate<=E3;
End If;
When others =>
NULL;
End case;
End Process;
Process (DPR_CLK,State,nextstate)
Begin
If (DPR_CLK'event And DPR_CLK='1') Then
State <= nextstate;
End If;
End Process;
End DPR_ARCH;
I am trying to interface a USB receiver chip with the FPGA. The USB
chip can only allow unidirection
communications. it just outputs eight bit of data at 12 MHz at each
rising edge of the USB clock in brust
mode. The scheme I used is simple but my State machine is getting lost
and screwing up the count of the counter. some times It works
sometimes it does not work!
I am using the counter to generate addressess for the Dual port RAM.
My VHDL comlplier also ignoring the intialization
of the signal Flag1 and I do not know why? Please Advice!
Thanks very much.
Regards
john
signal State : unsigned(7 downto 0);
signal nextstate : unsigned(7 downto 0);
constant E0 : unsigned(7 downto 0):="00000000";
constant E1 : unsigned(7 downto 0):="00000001";
constant E2 : unsigned(7 downto 0):="00000010";
constant E3 : unsigned(7 downto 0):="00000011";
Signal State1 : unsigned(7 downto 0);
Signal nextstate1 : unsigned (7 downto 0);
constant F0: unsigned(7 downto 0):="00000000";
constant F1: unsigned(7 downto 0):="00000001";
Signal inc: std_logic:='0';
Signal eq_signal : std_logic:='1';
Signal Reset_A : std_logic;
Signal counter_clock : std_logic;
Signal USB_port : unsigned ( 7 downto 0);
Signal Flag1 : std_logic:='0';
Begin
Data_Bus<="00000000000000";
C0: counter port map (Address_bus,
Data_in,DPR_CLK,inc,eq_signal,Reset_A);
Process(State1,nextstate1)
Begin
Case State1 is
When F0 =>
Flag1 <='0';
nextstate1 <= F1;
When F1 =>
Flag1 <='1';
nextstate1<=F0;
When others =>
Null;
End Case;
End Process;
-------------------------------------------
Process(USB_CLK,State1,nextstate1)
Begin
If (USB_CLK'event And USB_CLK='1') Then
State1 <= nextstate1;
End If;
End Process;
------------------------------------------
Process (State,nextstate,SM_DIR,Flag1)
Begin
Case State is
When E0=>
Reset_A<='1';
inc<='0';
UBL <='1';
LBL <='1';
CE0 <='1';
CE1 <='0';
Output_Enable<='1';
Read_write <='1';
nextstate<=E1;
When E1=>
If (Flag1='1')Then
Reset_A<='0';
UBL <='1';
LBL <='1';
CE0 <='1';
CE1 <='0';
Output_Enable<='1';
Read_write <='1';
inc<='1';
nextstate<=E2;
Else
nextstate<=E1;
End If;
When E2=>
Reset_A<='0';
UBL <='0';
LBL <='0';
CE0 <='0';
CE1 <='1';
Output_Enable<='1';
Read_write <='0';
inc<='0';
nextstate<=E3;
When E3=>
If (Flag1='0')Then
Reset_A<='0';
UBL <='0';
LBL <='0';
CE0 <='0';
CE1 <='1';
Output_Enable<='1';
Read_write <='0';
inc<='0';
nextstate<=E1;
Else
nextstate<=E3;
End If;
When others =>
NULL;
End case;
End Process;
Process (DPR_CLK,State,nextstate)
Begin
If (DPR_CLK'event And DPR_CLK='1') Then
State <= nextstate;
End If;
End Process;
End DPR_ARCH;