OSDN Git Service

94d7e4a0f89b8fc3db95713e8e3437000798cece
[fpga-leon-mjpeg/leon-mjpeg.git] / grlib-gpl-1.0.22-b4095 / designs / work_ip / bus_huff.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3
4 library grlib,techmap;
5 use grlib.amba.all;
6 use grlib.stdlib.all;
7 use techmap.gencomp.all;
8 library gaisler;
9 use gaisler.misc.all;
10 --use gaisler.ambatest.all;
11 use gaisler.ahbtbp.all;
12 library kuri;
13 use kuri.mjpeg.all;
14
15 use work.config.all;
16
17 entity bus_huff is
18   port (
19     rstn : in std_ulogic;
20     clk : in std_ulogic;
21     ctrl_in1 : in ahbtbm_ctrl_in_type; 
22     ctrl_out1 : out ahbtbm_ctrl_out_type;
23     data : out std_logic_vector(11 downto 0); 
24     add : out std_logic_vector(5 downto 0);
25     effect : out std_logic);
26 end;
27
28 architecture rtl of bus_huff is
29
30   type control_reg is record
31       out_cnt : std_logic_vector(31 downto 0);
32   end record;
33  
34   signal apbi  : apb_slv_in_type;
35   signal apbo  : apb_slv_out_vector := (others => apb_none);
36   signal ahbsi : ahb_slv_in_type;
37   signal ahbso : ahb_slv_out_vector := (others => ahbs_none);
38   signal ahbmi : ahb_mst_in_type;
39   signal ahbmo : ahb_mst_out_vector := (others => ahbm_none);
40   
41   signal kready : std_logic;
42   signal kstrobe : std_logic;
43   signal kdata : std_logic_vector(11 downto 0);
44   signal kaddress : std_logic_vector(5 downto 0); 
45   signal samp_fact : std_logic;
46   signal error : std_logic_vector(2 downto 0);
47   signal xmcumax : std_logic_vector(5 downto 0);
48   signal ymcumax : std_logic_vector(4 downto 0);
49   signal incaddy : std_logic_vector(15 downto 0);
50   signal incaddmcux : std_logic_vector(15 downto 0);
51   signal incaddmcuy : std_logic_vector(10 downto 0);
52   signal fbstartadd : std_logic_vector(31 downto 0);
53   signal startgen : std_logic;
54   signal kstrobeq : std_logic;
55   signal kdataq : std_logic_vector(7 downto 0);
56   signal kaddq : std_logic_vector(7 downto 0);
57   signal krddataq : std_logic_vector(7 downto 0);
58   signal krdq : std_logic;  
59 --  signal rst : std_ulogic;
60
61   signal r,rin : control_reg;
62
63 begin  -- rtl
64
65 --  rst <= not rstn;
66   kready <= '1';
67   error <= (others => '0');
68   huffinst : huff
69      generic map(shindex => 2, haddr => 16#900#, pindex => 2, paddr => 2, mhindex => 3, hirq => 2)
70      port map (rstn, clk, ahbsi, ahbso(2), apbi, apbo(2), kready, kstrobe, kdata,
71                 kaddress, samp_fact, error, xmcumax, ymcumax, incaddy, incaddmcux, incaddmcuy, 
72                 fbstartadd, startgen, kstrobeq, kdataq, kaddq, krddataq, krdq);         
73   data <= kdata;
74   add <= kaddress;
75   effect <= kstrobe;
76   apb0 : apbctrl
77      generic map (hindex => 4, haddr => 16#800#)
78      port map(rstn, clk, ahbsi, ahbso(4), apbi, apbo);
79    
80   ahbcontroller : ahbctrl                -- AHB arbiter/multiplexer
81      generic map (defmast => CFG_DEFMST, split => CFG_SPLIT, 
82         enbusmon => 0,rrobin => CFG_RROBIN, ioaddr => CFG_AHBIO)
83      port map (rstn, clk, ahbmi, ahbmo, ahbsi, ahbso);
84
85 --  ram0 : ahbram 
86 --     generic map (hindex => 7, haddr => 16#a00#, tech => CFG_MEMTECH, kbytes => 24) 
87 --     port map (rstn, clk, ahbsi, ahbso(7));
88
89   mast_em : ahbtbm
90      generic map(hindex => 0)
91      port map (rstn, clk, ctrl_in1, ctrl_out1, ahbmi, ahbmo(0));
92  
93    cnt_comb : process(r, rstn, kstrobe)
94    variable v : control_reg;
95    begin
96        v := r;
97        if(kstrobe = '1')then
98            v.out_cnt := v.out_cnt + 1;
99        end if;
100        
101        if(rstn = '0')then
102            v.out_cnt := (others => '0');
103        end if;
104        rin <= v;       
105    end process;
106    
107    reg : process(clk)
108    begin
109        if rising_edge(clk) then
110            r <= rin;
111        end if;
112    end process;
113 end rtl;
114