OpenCores
URL https://opencores.org/ocsvn/mips_enhanced/mips_enhanced/trunk

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [gleichmann/] [dac/] [dac_ahb_ea.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
-----------------------------------------------------------------------------------------
2
-- SIGMA DELTA DAC WITH AHB INTERFACE
3
-----------------------------------------------------------------------------------------
4
 
5
library ieee;
6
use ieee.std_logic_1164.all;
7
library grlib;
8
use grlib.amba.all;
9
use grlib.stdlib.all;
10
use grlib.devices.all;
11
 
12
entity dac_ahb is
13
  generic (
14
    length : integer := 16;
15
    hindex : integer := 0;
16
    haddr  : integer := 0;
17
    hmask  : integer := 16#fff#;
18
    tech   : integer := 0;
19
    kbytes : integer := 1);
20
  port (
21
    rst     : in  std_ulogic;
22
    clk     : in  std_ulogic;
23
    ahbsi   : in  ahb_slv_in_type;
24
    ahbso   : out ahb_slv_out_type;
25
    dac_out : out std_ulogic
26
    );
27
end;
28
 
29
architecture rtl of dac_ahb is
30
 
31
  component sigdelt
32
    generic (
33
      c_dacin_length : positive);
34
    port (
35
      reset   : in  std_logic;
36
      clock   : in  std_logic;
37
      dac_in  : in  std_logic_vector(c_dacin_length-1 downto 0);
38
      dac_out : out std_logic);
39
  end component;
40
 
41
  constant abits : integer := log2(kbytes) + 8;
42
 
43
  constant hconfig : ahb_config_type := (
44
 
45
--    4      => ahb_membar(haddr, '1', '1', hmask), -- memory @ 0xA000_000
46
    4      => ahb_iobar(haddr, hmask),  -- I/O area @ 0xFFFA_0000
47
    others => zero32);
48
 
49
  type reg_type is
50
    record
51
      hwrite : std_ulogic;
52
      hready : std_ulogic;
53
      hsel   : std_ulogic;
54
      addr   : std_logic_vector(abits+1 downto 0);
55
      size   : std_logic_vector(1 downto 0);
56
    end record;
57
 
58
  signal r, c    : reg_type;
59
  signal ramsel  : std_ulogic;
60
  signal write   : std_logic_vector(3 downto 0);
61
  signal ramaddr : std_logic_vector(abits-1 downto 0);
62
  signal ramdata : std_logic_vector(31 downto 0);
63
 
64
  type   mem is array(0 to 15) of std_logic_vector(31 downto 0);
65
  signal memarr : mem;
66
  signal ra     : std_logic_vector(3 downto 0);
67
 
68
  signal rstp : std_ulogic;             -- high-active reset
69
 
70
begin
71
 
72
  rstp <= not rst;
73
 
74
  comb : process (ahbsi, r, rst, ramdata)
75
    variable bs    : std_logic_vector(3 downto 0);
76
    variable v     : reg_type;
77
    variable haddr : std_logic_vector(abits-1 downto 0);
78
  begin
79
    v                                              := r; v.hready := '1'; bs := (others => '0');
80
    if (r.hwrite or not r.hready) = '1' then haddr := r.addr(abits+1 downto 2);
81
    else
82
      haddr := ahbsi.haddr(abits+1 downto 2); bs := (others => '0');
83
    end if;
84
 
85
    if ahbsi.hready = '1' then
86
      v.hsel   := ahbsi.hsel(hindex) and ahbsi.htrans(1);
87
      v.hwrite := ahbsi.hwrite and v.hsel;
88
      v.addr   := ahbsi.haddr(abits+1 downto 0);
89
      v.size   := ahbsi.hsize(1 downto 0);
90
    end if;
91
 
92
    if r.hwrite = '1' then
93
      case r.size(1 downto 0) is
94
        when "00"   => bs (conv_integer(r.addr(1 downto 0))) := '1';
95
        when "01"   => bs                                    := r.addr(1) & r.addr(1) & not (r.addr(1) & r.addr(1));
96
        when others => bs                                    := (others => '1');
97
      end case;
98
      v.hready := not (v.hsel and not ahbsi.hwrite);
99
      v.hwrite := v.hwrite and v.hready;
100
    end if;
101
 
102
    if rst = '0' then v.hwrite := '0'; v.hready := '1'; end if;
103
    write                      <= bs; ramsel <= v.hsel or r.hwrite; ahbso.hready <= r.hready;
104
    ramaddr                    <= haddr; c <= v; ahbso.hrdata <= ramdata;
105
 
106
  end process;
107
 
108
  ahbso.hresp   <= "00";
109
  ahbso.hsplit  <= (others => '0');
110
  ahbso.hirq    <= (others => '0');
111
  ahbso.hcache  <= '1';
112
  ahbso.hconfig <= hconfig;
113
  ahbso.hindex  <= hindex;
114
 
115
--  ra : for i in 0 to 3 generate
116
--    aram : syncram generic map (tech, abits, 8) port map (
117
--      clk, ramaddr, ahbsi.hwdata(i*8+7 downto i*8),
118
--      ramdata(i*8+7 downto i*8), ramsel, write(3-i)); 
119
--  end generate;
120
 
121
  main : process(rst, clk)
122
  begin
123
    if rst = '0' then
124
      memarr <= (others => (others => '0'));
125
      ra <= (others => '0');
126
--    end if;
127
    elsif rising_edge(clk) then
128
      if r.hwrite = '1' then
129
        memarr(conv_integer(ramaddr)) <= ahbsi.hwdata;
130
      end if;
131
      ra <= ramaddr(3 downto 0);
132
    end if;
133
  end process;
134
 
135
  ramdata <= memarr(conv_integer(ra));
136
 
137
  sigdelt_1 : sigdelt
138
    generic map (
139
      c_dacin_length => length)
140
    port map (
141
      reset   => rstp,
142
      clock   => clk,
143
      dac_in  => memarr(0)(length-1 downto 0),
144
      dac_out => dac_out);
145
 
146
  reg : process (clk)
147
  begin
148
    if rising_edge(clk) then r <= c; end if;
149
  end process;
150
 
151
-- pragma translate_off
152
  bootmsg : report_version
153
    generic map ("dac_ahb" & tost(hindex) &
154
                 ": AHB DAC Module rev 0");
155
-- pragma translate_on
156
end;
157
 

powered by: WebSVN 2.1.0

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