OpenCores
URL https://opencores.org/ocsvn/mjpeg-decoder/mjpeg-decoder/trunk

Subversion Repositories mjpeg-decoder

[/] [mjpeg-decoder/] [trunk/] [mjpeg/] [pcores/] [myipif/] [hdl/] [vhdl/] [fifo_sim32.vhd] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 smanz
library ieee, std, unisim;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_arith.all;
4
use ieee.std_logic_unsigned.all;
5
use ieee.std_logic_textio.all;
6
use std.textio.all;
7
use unisim.vcomponents.all;
8
 
9
 
10
entity fifo_sim32 is
11
generic
12
(
13
        filename        : string := "fifo32.log";
14
        log_time : integer := 1
15
);
16
port
17
(
18
        rst     : in std_logic;
19
        clk     : in std_logic;
20
        din     : in std_logic_vector(31 downto 0);
21
        we              : in std_logic;
22
        full    : out std_logic
23
);
24
end fifo_sim32;
25
 
26
 
27
architecture default of fifo_sim32 is
28
 
29
        file log_file   : text open write_mode is filename;
30
 
31
   function hstr(slv: std_logic_vector) return string is
32
       variable hexlen: integer;
33
       variable longslv : std_logic_vector(127 downto 0) := (others => '0');
34
       variable hex : string(1 to 32);
35
       variable fourbit : std_logic_vector(3 downto 0);
36
     begin
37
       hexlen := (slv'left+1)/4;
38
       if (slv'left+1) mod 4 /= 0 then
39
         hexlen := hexlen + 1;
40
       end if;
41
       longslv(slv'left downto 0) := slv;
42
       for i in (hexlen -1) downto 0 loop
43
         fourbit := longslv(((i*4)+3) downto (i*4));
44
         case fourbit is
45
           when "0000" => hex(hexlen -I) := '0';
46
           when "0001" => hex(hexlen -I) := '1';
47
           when "0010" => hex(hexlen -I) := '2';
48
           when "0011" => hex(hexlen -I) := '3';
49
           when "0100" => hex(hexlen -I) := '4';
50
           when "0101" => hex(hexlen -I) := '5';
51
           when "0110" => hex(hexlen -I) := '6';
52
           when "0111" => hex(hexlen -I) := '7';
53
           when "1000" => hex(hexlen -I) := '8';
54
           when "1001" => hex(hexlen -I) := '9';
55
           when "1010" => hex(hexlen -I) := 'a';
56
           when "1011" => hex(hexlen -I) := 'b';
57
           when "1100" => hex(hexlen -I) := 'c';
58
           when "1101" => hex(hexlen -I) := 'd';
59
           when "1110" => hex(hexlen -I) := 'e';
60
           when "1111" => hex(hexlen -I) := 'f';
61
           when "ZZZZ" => hex(hexlen -I) := 'z';
62
           when "UUUU" => hex(hexlen -I) := 'u';
63
           when "XXXX" => hex(hexlen -I) := 'x';
64
           when others => hex(hexlen -I) := '?';
65
         end case;
66
       end loop;
67
       return hex(1 to hexlen);
68
     end hstr;
69
 
70
 
71
begin
72
 
73
        full <= '0';
74
 
75
        process(clk)
76
                variable TheLine : line;
77
        begin
78
                if rising_edge(clk) then
79
                        if we = '1' then
80
 
81
                                if log_time = 1 then
82
                                        write(TheLine, now);
83
                                        while (TheLine'length < 13) loop
84
                                                write(TheLine, string'(" "));
85
                                        end loop;
86
                                end if;
87
 
88
                                write(TheLine, string'("0x" & hstr(din)));
89
                                writeline(log_file, TheLine);
90
 
91
                        end if;
92
                end if;
93
        end process;
94
 
95
end default;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.