Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. library ieee;
  2. use ieee.std_logic_1164.all;
  3. use std.textio.all;
  4. use ieee.std_logic_textio.all;
  5.  
  6. entity file_io is
  7.  
  8. port (
  9. clk: in std_logic;
  10. Data: out std_logic_vector(7 downto 0)
  11. );
  12. end entity;
  13.  
  14. architecture behav of file_io is
  15.  
  16. signal test_data : std_logic_vector(7 downto 0);
  17. use ieee.numeric_std.all;
  18. use std.textio.all;
  19. use ieee.std_logic_textio.all;
  20. begin
  21.  
  22. File_reader:process(clk)
  23. file f : text open read_mode is "C:UsersPublicPicturesSample PicturesChrysanthemum.jpg";
  24. variable L: line;
  25. variable var_int: integer:= 0;
  26. variable var_char: character;
  27.  
  28. begin
  29.  
  30. if rising_edge(clk) then
  31. while not endfile(f) loop
  32. readline(f, L);
  33. read(L, var_char);
  34. var_int := character'pos(var_char);
  35. test_data <= std_logic_vector(to_unsigned(var_int, test_data'length));
  36. end loop;
  37. end if;
  38. Data <= test_data;
  39. end process;
  40. end architecture behav;
  41.  
  42. LIBRARY ieee;
  43. use ieee.std_logic_1164.ALL;
  44. use std.textio.all;
  45.  
  46. ENTITY file_io_test IS
  47. END file_io_test;
  48.  
  49. ARCHITECTURE behavior OF file_io_test IS
  50. use work.io.all;
  51. signal clk: std_logic := '0';
  52. signal Data: std_logic_vector(7 downto 0);
  53.  
  54. -- Clock period definitions
  55. constant clk_period : time := 10 ns;
  56.  
  57. BEGIN
  58. -- Instantiate the Unit Under Test (UUT)
  59. UUT:
  60. entity work.file_io(behav)
  61. port map (
  62. clk => clk,
  63. Data => Data
  64. );
  65.  
  66. -- Clock process definitions( clock with 50% duty cycle is generated here.
  67. clk_process :process
  68. begin
  69. clk <= '1';
  70. wait for clk_period/2; --for 5 ns signal is '1'.
  71. clk <= '0';
  72. wait for clk_period/2; --for next 5 ns signal is '0'.
  73.  
  74. end process;
  75. end behavior;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement