You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pt1.vhd 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ----------------------------------------------------------------------------------
  2. -- Company:
  3. -- Engineer:
  4. --
  5. -- Create Date: 04/25/2022 01:45:24 PM
  6. -- Design Name:
  7. -- Module Name: pt1 - Behavioral
  8. -- Project Name:
  9. -- Target Devices:
  10. -- Tool Versions:
  11. -- Description:
  12. --
  13. -- Dependencies:
  14. --
  15. -- Revision:
  16. -- Revision 0.01 - File Created
  17. -- Additional Comments:
  18. --
  19. ----------------------------------------------------------------------------------
  20. library IEEE;
  21. use IEEE.STD_LOGIC_1164.ALL;
  22. use IEEE.numeric_std.ALL;
  23. -- Uncomment the following library declaration if using
  24. -- arithmetic functions with Signed or Unsigned values
  25. --use IEEE.NUMERIC_STD.ALL;
  26. -- Uncomment the following library declaration if instantiating
  27. -- any Xilinx leaf cells in this code.
  28. --library UNISIM;
  29. --use UNISIM.VComponents.all;
  30. entity pt1 is
  31. Port (
  32. clk : in STD_LOGIC;
  33. u : in signed(63 downto 0) := to_signed(0, 64);
  34. y : inout signed(63 downto 0) := to_signed(0, 64); -- muss vielleicht initalisiert werden vorher!?
  35. a : in signed(9 downto 0) := to_signed(1, 10);
  36. k : in signed(9 downto 0) := to_signed(1, 10);
  37. stepWidth : signed(9 downto 0) := to_signed(10, 10)); --in us -> 10us
  38. end pt1;
  39. architecture Behavioral of pt1 is
  40. --signal stepWidth : integer := 10; -- in us -> 10 us später berechnet aus Clk und Prescaler
  41. signal prescaler : signed(63 downto 0) := to_signed(1000000, 64); -- prescaler für Zeit
  42. -- Konstanten Streckenparameter
  43. --signal a : integer := 1;
  44. --signal k : integer := 1;
  45. -- signal u : integer := 100000; -- Eingangswert Strecke jetzt u aus port
  46. -- signal x : integer := 0; -- Ausgangssignal Strecke -> Stellgröße jetzt y aus port
  47. begin
  48. process(clk)
  49. variable y_var : signed(83 downto 0) := to_signed(0, 84);
  50. begin
  51. if rising_edge(clk) then
  52. y_var := y + stepWidth * (k * u - a * y) / prescaler; -- durch 1000 wg. milisekunden abtastzeit
  53. y <= y_var(63 downto 0);
  54. end if;
  55. end process;
  56. end Behavioral;