Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library ieee;
- use ieee.std_logic_1164.all;
- use std.textio.all;
- use ieee.std_logic_textio.all;
- entity file_io is
- port (
- clk: in std_logic;
- Data: out std_logic_vector(7 downto 0)
- );
- end entity;
- architecture behav of file_io is
- signal test_data : std_logic_vector(7 downto 0);
- use ieee.numeric_std.all;
- use std.textio.all;
- use ieee.std_logic_textio.all;
- begin
- File_reader:process(clk)
- file f : text open read_mode is "C:UsersPublicPicturesSample PicturesChrysanthemum.jpg";
- variable L: line;
- variable var_int: integer:= 0;
- variable var_char: character;
- begin
- if rising_edge(clk) then
- while not endfile(f) loop
- readline(f, L);
- read(L, var_char);
- var_int := character'pos(var_char);
- test_data <= std_logic_vector(to_unsigned(var_int, test_data'length));
- end loop;
- end if;
- Data <= test_data;
- end process;
- end architecture behav;
- LIBRARY ieee;
- use ieee.std_logic_1164.ALL;
- use std.textio.all;
- ENTITY file_io_test IS
- END file_io_test;
- ARCHITECTURE behavior OF file_io_test IS
- use work.io.all;
- signal clk: std_logic := '0';
- signal Data: std_logic_vector(7 downto 0);
- -- Clock period definitions
- constant clk_period : time := 10 ns;
- BEGIN
- -- Instantiate the Unit Under Test (UUT)
- UUT:
- entity work.file_io(behav)
- port map (
- clk => clk,
- Data => Data
- );
- -- Clock process definitions( clock with 50% duty cycle is generated here.
- clk_process :process
- begin
- clk <= '1';
- wait for clk_period/2; --for 5 ns signal is '1'.
- clk <= '0';
- wait for clk_period/2; --for next 5 ns signal is '0'.
- end process;
- end behavior;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement