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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [designs/] [leon3-nuhorizons-3s1500/] [nuhosp3.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
----------------------------------------------------------------------------
2
--  This file is a part of the GRLIB VHDL IP LIBRARY
3
--  Copyright (C) 2004 GAISLER RESEARCH
4
--
5
--  This program is free software; you can redistribute it and/or modify
6
--  it under the terms of the GNU General Public License as published by
7
--  the Free Software Foundation; either version 2 of the License, or
8
--  (at your option) any later version.
9
--
10
--  See the file COPYING for the full details of the license.
11
--
12
-----------------------------------------------------------------------------
13
-- Entity:      nuhosp3
14
-- File:        nuhosp3.vhd
15
-- Author:      Jiri Gaisler - Gaisler Reserch
16
-- Description: 
17
------------------------------------------------------------------------------
18
 
19
library ieee;
20
use ieee.std_logic_1164.all;
21
library grlib;
22
use grlib.amba.all;
23
use grlib.stdlib.all;
24
use grlib.devices.all;
25
library gaisler;
26
use gaisler.misc.all;
27
 
28
entity nuhosp3 is
29
  generic (
30
    hindex : integer := 0;
31
    haddr  : integer := 0;
32
    hmask  : integer := 16#fff#;
33
    ioaddr : integer := 16#200#;
34
    iomask : integer := 16#fff#
35
    );
36
  port (
37
    rst    : in  std_ulogic;
38
    clk    : in  std_ulogic;
39
    ahbsi  : in  ahb_slv_in_type;
40
    ahbso  : out ahb_slv_out_type;
41
    nui    : in  nuhosp3_in_type;
42
    nuo    : out nuhosp3_out_type
43
  );
44
end;
45
 
46
architecture rtl of nuhosp3 is
47
 
48
constant hconfig : ahb_config_type := (
49
 
50
  4 => ahb_membar(haddr, '1', '1', hmask),
51
  5 => ahb_membar(ioaddr, '0', '0', iomask),
52
  others => zero32);
53
 
54
type fstate is (idle, read1, read2, leadout);
55
 
56
type reg_type is record
57
  hwrite : std_ulogic;
58
  hready : std_ulogic;
59
  hsel   : std_ulogic;
60
  haddr   : std_logic_vector(31 downto 0);
61
  hmbsel : std_logic_vector(0 to 1);
62
  ws      : std_logic_vector(2 downto 0);
63
  flash_a : std_logic_vector(20 downto 0);
64
  flash_wd  : std_logic_vector(15 downto 0);
65
  flash_oen : std_ulogic;
66
  flash_wen : std_ulogic;
67
  flash_cen : std_ulogic;
68
  flash_rd  : std_logic_vector(31 downto 0);
69
  flash_state : fstate;
70
  smsc_wd  : std_logic_vector(31 downto 0);
71
  smsc_ncs : std_ulogic;
72
end record;
73
 
74
constant romws : std_logic_vector(2 downto 0) := "011";
75
 
76
signal r, c : reg_type;
77
begin
78
 
79
  comb : process (ahbsi, r, rst, nui)
80
  variable v : reg_type;
81
  begin
82
    v := r;
83
 
84
    if ahbsi.hready = '1' then
85
      v.hsel := ahbsi.hsel(hindex) and ahbsi.htrans(1);
86
      v.hready := not v.hsel;
87
      v.hwrite := ahbsi.hwrite;
88
      v.haddr := ahbsi.haddr;
89
      v.hmbsel := ahbsi.hmbsel(0 to 1);
90
    end if;
91
 
92
    v.flash_rd(15 downto 0) := nui.flash_d;
93
    case r.flash_state is
94
      when idle =>
95
        v.flash_wen := '1'; v.flash_oen := '1';
96
        if (r.hsel = '1') then
97
          v.flash_cen := not r.hmbsel(0);
98
          v.smsc_ncs := not r.hmbsel(1);
99
          v.flash_state := read1;
100
          v.flash_oen := r.hwrite; v.flash_a := r.haddr(20 downto 0);
101
          v.flash_wd := ahbsi.hwdata(31 downto 16);
102
          v.smsc_wd := ahbsi.hwdata(31 downto 0);
103
        end if;
104
      when read1 =>
105
        v.flash_state := read2; v.ws := romws; v.flash_wen := not r.hwrite;
106
        v.flash_rd(31 downto 16) := r.flash_rd(15 downto 0);
107
      when read2 =>
108
        v.ws := r.ws - 1;
109
        if r.ws = "000" then
110
          if (r.flash_a(0) = '0') and (r.hwrite = '0') then
111
            v.flash_state := read1; v.flash_a(0) := '1';
112
          else
113
            v.hready := '1'; v.flash_state := leadout; v.flash_oen := '1';
114
            v.flash_wen := '1'; v.flash_cen := '1'; v.smsc_ncs := '1';
115
          end if;
116
        end if;
117
      when leadout =>
118
        v.flash_state := idle;
119
    end case;
120
 
121
    if rst = '0' then v.hready := '1'; v.flash_state := idle; end if;
122
 
123
    c <= v;
124
 
125
    nuo.flash_oen <= r.flash_oen;
126
    nuo.flash_wen <= r.flash_wen;
127
    nuo.flash_cen <= r.flash_cen;
128
    nuo.flash_a   <= r.flash_a;
129
    nuo.flash_d   <= r.flash_wd;
130
    nuo.smsc_ncs  <= r.smsc_ncs;
131
    nuo.smsc_nbe  <= (others => r.flash_wen);
132
    nuo.smsc_ben  <= r.flash_wen;
133
    nuo.smsc_data <= r.smsc_wd;
134
    nuo.smsc_addr <= r.flash_a(14 downto 0);
135
    ahbso.hready  <= r.hready;
136
    ahbso.hrdata  <= r.flash_rd;
137
 
138
  end process;
139
 
140
  nuo.smsc_resetn <= rst;
141
  nuo.smsc_nwr <= '1';
142
  nuo.smsc_nrd <= '1';
143
  nuo.smsc_wnr <= '1';
144
  nuo.smsc_cycle <= '1';
145
  nuo.smsc_aen <= '1';
146
  nuo.smsc_lclk <= '1';
147
  nuo.smsc_rdyrtn <= '1';
148
  nuo.smsc_nads <= '0';
149
 
150
  nuo.lcd_en <= '0';
151
  nuo.lcd_ben <= '1';
152
  nuo.lcd_backl <= '1';
153
 
154
  ahbso.hresp   <= "00";
155
  ahbso.hsplit  <= (others => '0');
156
  ahbso.hirq    <= (others => '0');
157
  ahbso.hcache  <= '0';
158
  ahbso.hconfig <= hconfig;
159
  ahbso.hindex  <= hindex;
160
 
161
  reg : process (clk, rst)
162
  begin
163
    if rising_edge(clk ) then r <= c; end if;
164
    if rst = '0' then
165
      r.flash_cen <= '1'; r.smsc_ncs <= '1'; r.flash_wen <= '1';
166
     end if;
167
  end process;
168
 
169
-- pragma translate_off
170
    bootmsg : report_version
171
    generic map ("huhosp3" & tost(hindex) &
172
    ": Nuhorizons Spartan3 board interface");
173
-- pragma translate_on
174
end;

powered by: WebSVN 2.1.0

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