Lösung des ESY6/A Praktikums "signal_processing".
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.

task.vhd 1.1KB

1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use ieee.numeric_std.all;
  4. use ieee.math_real.all;
  5. package task is
  6. type State is (
  7. TASK_IDLE,
  8. TASK_RUNNING,
  9. TASK_DONE
  10. );
  11. function to_std_logic_vector( s : State; len : positive ) return std_logic_vector;
  12. constant STREAM_LEN : integer := 1024;
  13. end package task;
  14. package body task is
  15. function to_std_logic_vector( s : State; len : positive ) return std_logic_vector is
  16. constant MIN_LEN : positive := positive( ceil( log2( real( State'pos( State'right ) + 1 ) ) ) );
  17. variable vector : std_logic_vector( MIN_LEN - 1 downto 0 );
  18. variable output : std_logic_vector( len - 1 downto 0 );
  19. begin
  20. vector := std_logic_vector( to_unsigned( State'pos( s ), MIN_LEN ) );
  21. if ( len < MIN_LEN ) then
  22. output := ( others => 'U' );
  23. elsif ( len = MIN_LEN ) then
  24. output := vector;
  25. else
  26. output := ( others => '0' );
  27. output( vector'range ) := vector;
  28. end if;
  29. return output;
  30. end function to_std_logic_vector;
  31. end package body task;