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

Subversion Repositories tv80

[/] [tv80/] [trunk/] [rtl/] [app_localcfg/] [lcfg.v] - Blame information for rev 116

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 101 ghutchis
/* Copyright (c) 2011, Guy Hutchison
2
   All rights reserved.
3
 
4
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
 
6
    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
    * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9
 
10
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11
*/
12
 
13
//----------------------------------------------------------------------
14
//  Author: Guy Hutchison
15
//
16
//  Local Configuration Processor Application
17
//----------------------------------------------------------------------
18
 
19
module lcfg
20
  (input         clk,
21
   input         reset_n,
22 103 ghutchis
   input         lcfg_init,  // initialize memory to all 0
23 101 ghutchis
   input         lcfg_proc_reset,
24
 
25
   // incoming config interface to 
26
   // read/write processor memory
27
   input         cfgi_irdy,
28
   output        cfgi_trdy,
29 105 ghutchis
   input [12:0]  cfgi_addr,
30 101 ghutchis
   input         cfgi_write,
31
   input [31:0]  cfgi_wr_data,
32
   output [31:0] cfgi_rd_data,
33
 
34
   // outgoing config interface to system
35
   // configuration bus
36
   output        cfgo_irdy,
37
   input         cfgo_trdy,
38
   output [15:0] cfgo_addr,
39
   output        cfgo_write,
40
   output [31:0] cfgo_wr_data,
41
   input [31:0]  cfgo_rd_data
42
 
43
   );
44
 
45
  wire [15:0]     addr;
46
  wire [7:0]      dout;
47
  reg [7:0]       di;
48
  wire           mreq_n;
49
  wire           rd_n, wr_n;
50
  wire           iorq_n;
51
 
52
  reg            fw_mode;
53
  wire           ram_wait_n;
54
 
55
  wire           fw_en = (addr[15:13] == {1'b0, !fw_mode, 1'b0}) && !mreq_n;
56
  wire           fw_we = !wr_n;
57
 
58
  wire [7:0]      ram_rd_data;
59
  reg            last_wait;
60
  reg            wait_n;
61
 
62
  wire [7:0]     reg_addr1, reg_addr0;
63
  wire [7:0]     reg_wr_data3;
64
  wire [7:0]     reg_wr_data2;
65
  wire [7:0]     reg_wr_data1;
66
  wire [7:0]     reg_wr_data0;
67
  wire [7:0]     cb_rd_data;
68
  wire [1:0]     cb_control;
69
  reg [1:0]      cb_control_clr;
70
  wire [7:0]     tim_rd_data;
71
  wire [1:0]     fw_up_ctrl;
72
  wire           dma_iorq_n;
73
  wire [7:0]     dma_rd_data;
74
  reg [31:0]     read_hold;
75
  reg            read_latch;
76
  wire           proc_reset_n;
77
  /*AUTOWIRE*/
78
  // Beginning of automatic wires (for undeclared instantiated-module outputs)
79
  wire [7:0]            cd_rdata;               // From cfgo_driver of lcfg_cfgo_driver.v
80
  wire                  cfgo_wait_n;            // From cfgo_driver of lcfg_cfgo_driver.v
81
  // End of automatics
82
  wire           ram_mreq_n;
83
 
84
  assign ram_mreq_n = ~ (~mreq_n & ~addr[15]);
85 103 ghutchis
  assign         proc_reset_n = ~lcfg_proc_reset;
86 101 ghutchis
 
87
  tv80s tv80 (
88
     // Outputs
89
     .dout                              (dout),
90
     .m1_n                              (),
91
     .mreq_n                            (mreq_n),
92
     .iorq_n                            (iorq_n),
93
     .rd_n                              (rd_n),
94
     .wr_n                              (wr_n),
95
     .rfsh_n                            (),
96
     .halt_n                            (),
97
     .busak_n                           (),
98
     .A                                 (addr),
99
     // Inputs
100
     .reset_n                           (proc_reset_n),
101
     .clk                               (clk),
102
     .wait_n                            (wait_n),
103 109 ghutchis
     .int_n                             (1'b1),
104 101 ghutchis
     .nmi_n                             (1'b1),
105
     .busrq_n                           (1'b1),
106
     .di                                (di));
107
 
108
  always @(posedge clk)
109
    begin
110
      last_wait <= #1 wait_n;
111
    end
112
 
113
  always @*
114
    begin
115
      wait_n = 1;
116
 
117
      if (!mreq_n)
118
        begin
119
          if (~ram_mreq_n)
120
            begin
121
              di = ram_rd_data[7:0];
122
              wait_n = ram_wait_n;
123
            end
124
          else
125
            begin
126
              di = 8'h0;
127
            end
128
        end
129
      else if (!iorq_n)
130
        begin
131
          if (addr[7:3] == 0)
132
            begin
133
              di = cd_rdata;
134
              wait_n = cfgo_wait_n;
135
            end
136
          else
137
            di = 8'h0;
138
        end
139
      else
140
        di = 8'h0;
141
    end // always @ *
142
 
143
/*  lcfg_memctl AUTO_TEMPLATE
144
    (
145
     // Outputs
146
     .a_mreq_n                          (ram_mreq_n),
147
     .a_rd_n                            (rd_n),
148
     .a_wr_n                            (wr_n),
149
     .a_addr                            (addr[14:0]),
150
     .a_wdata                           (dout),
151
     .a_wait_n                          (ram_wait_n),
152
     .a_rdata                           (ram_rd_data),
153
 
154
     .b_wait_n                          (),
155
     .b_rdata                           (),
156
     .b_mreq_n                          (1'b1),
157
     .b_wr_n                            (1'b1),
158
     .b_addr                            (13'h0),
159
     .b_wdata                           (32'h0),
160
 
161
    );
162
*/
163 105 ghutchis
  lcfg_memctl #(.mem_asz(13)) memctl
164 101 ghutchis
    (/*AUTOINST*/
165
     // Outputs
166
     .a_wait_n                          (ram_wait_n),            // Templated
167
     .a_rdata                           (ram_rd_data),           // Templated
168
     .b_wait_n                          (),                      // Templated
169
     .b_rdata                           (),                      // Templated
170
     .cfgi_trdy                         (cfgi_trdy),
171
     .cfgi_rd_data                      (cfgi_rd_data[31:0]),
172
     // Inputs
173
     .clk                               (clk),
174
     .reset_n                           (reset_n),
175
     .a_mreq_n                          (ram_mreq_n),            // Templated
176
     .a_rd_n                            (rd_n),                  // Templated
177
     .a_wr_n                            (wr_n),                  // Templated
178
     .a_addr                            (addr[14:0]),            // Templated
179
     .a_wdata                           (dout),                  // Templated
180
     .b_mreq_n                          (1'b1),                  // Templated
181
     .b_wr_n                            (1'b1),                  // Templated
182
     .b_addr                            (13'h0),                 // Templated
183
     .b_wdata                           (32'h0),                 // Templated
184
     .lcfg_init                         (lcfg_init),
185
     .cfgi_irdy                         (cfgi_irdy),
186 105 ghutchis
     .cfgi_addr                         (cfgi_addr[12:0]),
187 101 ghutchis
     .cfgi_write                        (cfgi_write),
188 105 ghutchis
     .cfgi_wr_data                      (cfgi_wr_data[31:0]));
189 101 ghutchis
 
190
 
191
/* lcfg_cfgo_driver AUTO_TEMPLATE
192
 (
193
     .cd_wdata                          (dout[7:0]),
194
 );
195
 */
196
  lcfg_cfgo_driver #(.io_base_addr(8'h0)) cfgo_driver
197
    (/*AUTOINST*/
198
     // Outputs
199
     .cd_rdata                          (cd_rdata[7:0]),
200
     .cfgo_wait_n                       (cfgo_wait_n),
201
     .cfgo_irdy                         (cfgo_irdy),
202
     .cfgo_addr                         (cfgo_addr[15:0]),
203
     .cfgo_write                        (cfgo_write),
204
     .cfgo_wr_data                      (cfgo_wr_data[31:0]),
205
     // Inputs
206
     .clk                               (clk),
207
     .reset_n                           (reset_n),
208
     .addr                              (addr[15:0]),
209
     .cd_wdata                          (dout[7:0]),             // Templated
210
     .rd_n                              (rd_n),
211
     .wr_n                              (wr_n),
212
     .iorq_n                            (iorq_n),
213
     .cfgo_trdy                         (cfgo_trdy),
214
     .cfgo_rd_data                      (cfgo_rd_data[31:0]));
215
 
216
endmodule

powered by: WebSVN 2.1.0

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