N
nicklas_a74
Guest
Hoi
Ik heb de VHDL-code hieronder.Het beoogde gebruik is om een state machine.
dat begint vanaf 0.Wanneer gebruik ik de schakelaar en een exploitant moet het opslaan van de switch
waarde en de exploitant en ga naar toestand 1.En als ik druk gelijk moet slaan een nieuwe
switch waarde en afhankelijk van welke operator ik heb gebruikt berekenen resultaten, enz.
Maar toen ik het op mijn Nexus 2 boord het Doest werken zoals de bedoeling was.
Please help me met correcties in de code hieronder.
proces (staat, operand, gelijke, switch, clk)
variabele tal1, tal2: std_logic_vector (7 downto 0);
variabele resultaat: std_logic_vector (15 downto 0);
variabele temp_operand: std_logic_vector (2 downto 0);
beginnen
indien rising_edge (clk)
then
geval staat is
wanneer S0 => als operand / = "000", dan
temp_operand: = operandlengte;
dispx (7 downto 0) <= switch (7 downto 0);
dispx (15 downto 8) <= "11101110";
tal1: = switch (7 downto 0);
staat <= s1;
anders
dispx (7 downto 0) <= switch (7 downto 0);
dispx (15 downto 8) <= "11101110";
end if;
wanneer s1 => als gelijke ='1 ', dan
tal2: = switch (7 downto 0);
geval is temp_operand
wanneer "100" => resultaat: = ( "00000000" & tal1) tal2;
dispx <= resultaat;
staat <= S2;
wanneer "010" => resultaat: = ( "00000000" & tal1)-tal2;
dispx <= resultaat;
staat <= S2;
wanneer anderen => resultaat: = tal1 * tal2;
dispx <= resultaat;
staat <= S2;
einde zaak;
anders
dispx (7 downto 0) <= switch (7 downto 0);
dispx (15 downto 8) <= "11101110";
end if;wanneer s2 => als switch / = tal2 vervolgens
staat <= S0;
anders
staat <= S2;
dispx <= resultaat;
end if;
wanneer anderen => staat <= S0;
einde zaak;
end if;
einde proces;
Ik heb de VHDL-code hieronder.Het beoogde gebruik is om een state machine.
dat begint vanaf 0.Wanneer gebruik ik de schakelaar en een exploitant moet het opslaan van de switch
waarde en de exploitant en ga naar toestand 1.En als ik druk gelijk moet slaan een nieuwe
switch waarde en afhankelijk van welke operator ik heb gebruikt berekenen resultaten, enz.
Maar toen ik het op mijn Nexus 2 boord het Doest werken zoals de bedoeling was.
Please help me met correcties in de code hieronder.
proces (staat, operand, gelijke, switch, clk)
variabele tal1, tal2: std_logic_vector (7 downto 0);
variabele resultaat: std_logic_vector (15 downto 0);
variabele temp_operand: std_logic_vector (2 downto 0);
beginnen
indien rising_edge (clk)
then
geval staat is
wanneer S0 => als operand / = "000", dan
temp_operand: = operandlengte;
dispx (7 downto 0) <= switch (7 downto 0);
dispx (15 downto 8) <= "11101110";
tal1: = switch (7 downto 0);
staat <= s1;
anders
dispx (7 downto 0) <= switch (7 downto 0);
dispx (15 downto 8) <= "11101110";
end if;
wanneer s1 => als gelijke ='1 ', dan
tal2: = switch (7 downto 0);
geval is temp_operand
wanneer "100" => resultaat: = ( "00000000" & tal1) tal2;
dispx <= resultaat;
staat <= S2;
wanneer "010" => resultaat: = ( "00000000" & tal1)-tal2;
dispx <= resultaat;
staat <= S2;
wanneer anderen => resultaat: = tal1 * tal2;
dispx <= resultaat;
staat <= S2;
einde zaak;
anders
dispx (7 downto 0) <= switch (7 downto 0);
dispx (15 downto 8) <= "11101110";
end if;wanneer s2 => als switch / = tal2 vervolgens
staat <= S0;
anders
staat <= S2;
dispx <= resultaat;
end if;
wanneer anderen => staat <= S0;
einde zaak;
end if;
einde proces;