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

Subversion Repositories or1k

[/] [or1k/] [branches/] [oc/] [xess/] [xsv_cpld/] [rtl/] [verilog/] [xsv_cpld_top.v] - Blame information for rev 1771

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

Line No. Rev Author Line
1 767 lampret
//
2
// XC9500 CPLD design which controls the configuration of the XSV Virtex
3
// with data from the Flash chip.
4
//
5
`define ADDR_LEN 21     // number of Flash address bits
6
 
7
module xsv_cpld_top (clk,
8
                a, ceb, oeb, web, resetb,
9
                V_progb, V_cclk, V_csb, V_wrb, V_initb, V_dout,
10
                V_done, V_m,  rxd, txd, ppd, ppc, pps,
11
                eth_leds, eth_ledr, eth_ledt, eth_ledl, eth_ledc,
12
                eth_mf, eth_cfg, eth_mddis, eth_fde
13
);
14
 
15
input                   clk;            // clock from DS1075 prog. osc.
16
 
17
// Flash address and control pins
18
output  [`ADDR_LEN-1:0]  a;              // Flash address
19
output                  ceb;            // Flash chip-enable
20
output                  oeb;            // Flash output-enable
21
output                  web;            // Flash write-enable
22
output                  resetb;         // Flash reset
23
 
24
// Virtex configuration pins
25
output                  V_progb;        // Virtex PROGRAM pin
26
output                  V_cclk;         // Virtex config clock
27
output                  V_csb;          // Virtex config chip-select
28
output                  V_wrb;          // Virtex config write-enable
29
input                   V_initb;        // Virtex config init status
30
input                   V_dout;         // Virtex config busy status
31
input                   V_done;         // Virtex config done status
32
output  [2:0]            V_m;            // Virtex config. mode pins     
33
 
34
// connect UART to virtex FPGA
35
input  rxd;   // From RS232
36
output txd;   // To RS232
37
 
38
// parallel port data, control, and status pins
39
input   [7:0]   ppd;
40
input   [3:0]   ppc;
41
output  [6:3]   pps;
42
 
43
// Ethernet control/status
44
input                   eth_leds, eth_ledr,
45
                                eth_ledt, eth_ledl,
46
                                eth_ledc;
47
output  [4:0]    eth_mf;
48
output  [1:0]    eth_cfg;
49
output                  eth_mddis, eth_fde;
50
 
51
`define LO 1'b0
52
`define HI 1'b1
53
`define FLOAT 1'bz
54
 
55
reg     [3:0]            clk_cnt;
56
wire                    cclk;
57
wire                    programb;
58
reg                     cs;
59
reg     [`ADDR_LEN-1:0]  addr;
60
wire    [`ADDR_LEN-1:0]  next_addr;
61
reg                     poweron_reset;
62
reg     [19:0]           poweron_cnt;
63
wire                    V_busy;
64
wire                    button_progb;
65
 
66
// JTAG pins between CPLD and FPGA
67
wire                    jtag_tdo;
68
wire                    jtag_tdi;
69
wire                    jtag_tms;
70
wire                    jtag_trst;
71
wire                    jtag_tck;
72
 
73
wire                    tdmfrm;
74
wire                    tdmrx;
75
wire                    tdmtx;
76
 
77
wire                    tdm_dout_2;
78
wire                    tdm_dout_3;
79
wire                    tdm_dout_4;
80
wire                    tdm_dout_5;
81
wire                    tdm_dout_6;
82
wire                    tdm_dout_7;
83
 
84
assign V_busy = V_dout;         // give this signal a better name
85
 
86
// set Virtex mode to SelectMAP so it can be configured from Flash
87
//assign V_m = 3'b110;
88
assign V_m = V_done ? 3'b111 : 3'b110;    // SelectMAP before it is configured, slave-serial mode after configuration
89
                                          // We need this to get more pins
90
 
91
// Flash is enabled for reading while Virtex is not yet configured
92
// and then the Flash pins float when configuration is done
93
assign oeb = V_done ? `FLOAT : `LO;
94
assign ceb = V_done ? `FLOAT : `LO;
95
assign web = V_done ? `FLOAT : `HI;     // disable Flash writes
96
assign resetb = `HI;                    // remove Flash reset
97
 
98
// generate configuration clock for Virtex from the XSV clock.
99
// The XSV clock could be as much as 100 MHz, so divide by 16
100
// to exceed the access time of the Flash.
101
always @(posedge clk)
102
        clk_cnt <= #1 clk_cnt + 1;
103
 
104
assign cclk = clk_cnt[3];       // internal configuration clock
105
assign V_cclk = cclk;           // also send config. clock to Virtex
106
 
107
// Apply reset when the power to the XSV Board is first applied.
108
// Remove the power-on reset after the counter reaches 0.
109
always @(posedge cclk)
110
        if (poweron_cnt == 0)
111
                poweron_reset <= #1 `LO;        // remove reset when timeout expires
112
        else begin
113
                poweron_cnt <= #1 poweron_cnt - 1;
114
                poweron_reset <= #1 `HI;
115
        end
116
 
117
// initiate Virtex configuration by lowering the /PROGRAM pin
118
// during the initial power-on reset and then raising it when
119
// the power-on timeout expires and the manual program control is high
120
assign programb = !poweron_reset;
121
assign V_progb = programb;
122
 
123
// Select the Virtex for configuration as long as the /PROGRAM pin
124
// is not held low and the INIT pin is not low.
125
always @(posedge cclk or negedge programb)
126
        if (!programb)
127
                cs <= #1 `LO;
128
        else
129
                cs <= #1 V_initb;
130
 
131
// Select the Virtex for configuration by lowering its chip-select
132
// and write inputs when the internal chip-select is high.  Then
133
// float these pins after the Virtex configuration is done.
134
//assign V_csb = V_done ? `FLOAT : !cs;
135
assign V_csb = V_done ? tdmfrm : !cs;   // UART
136
assign V_wrb = V_done ? tdmtx : !cs;
137
 
138
// increment the Flash address so the next byte of configuration
139
// data is presented to the Virtex.  Stop incrementing if the
140
// Virtex is not selected, signals a config. error (INIT=0), or
141
// is busy.  Reset the address counter to zero whenever the
142
// /PROGRAM pin goes low and a new configuration sequence begins.
143
always @(posedge cclk)
144
        if (cs && V_initb && !V_busy)
145
                addr <= #1 addr + 1;
146
        else if (!programb)
147
                addr <= #1 {`ADDR_LEN{`LO}};
148
 
149
// pass the Flash address out to the Flash chip.  Float the address
150
// lines once configuration is done.
151
assign a = V_done ? {`ADDR_LEN{`FLOAT}} : addr;
152
 
153
 
154
// connect tdmrx to virtex FPGA
155
assign tdmrx = V_initb;
156
 
157
// Aliases for GDB JTAG signals.
158
assign pps[5] = jtag_tdo;
159
assign jtag_tdi = ppd[4];
160
assign jtag_tms = ppd[5];
161
assign jtag_trst = ppd[3];
162
assign jtag_tck = ppd[2];
163
 
164
tdm_master_if i_tdm_master_if
165
    (.clk       ( clk  ),
166
     .rst       (~V_done ),
167
     .tdmfrm    ( tdmfrm                ),
168
     .tdmrx     ( tdmrx                 ),
169
     .tdmtx     ( tdmtx                 ),
170
     .din       ({jtag_tms,
171
                  jtag_tck,
172
                  jtag_trst,
173
                  jtag_tdi,
174
                  rxd,
175
                  3'b000               }),
176
     .dout      ({jtag_tdo,
177
                  txd,
178
                  tdm_dout_2,
179
                  tdm_dout_3,
180
                  tdm_dout_4,
181
                  tdm_dout_5,
182
                  tdm_dout_6,
183
                  tdm_dout_7           }));
184
 
185
// Ethernet control
186
assign eth_mf[0] = 1'b0; // A/N disabled, addr 0
187
assign eth_mf[1] = 1'b0;        // DTE mode, addr 0
188
assign eth_mf[2] = 1'b0;        // nibble mode, addr 0
189
assign eth_mf[3] = 1'b0;        // scrambler enabled, addr 0
190
assign eth_mf[4] = 1'b0;        // TP mode, addr 0
191
assign eth_cfg[0] = 1'b0;        // 10Mbps mode
192
assign eth_cfg[1] = 1'b0;       // In 10Mbps mode, enable Link Test
193
assign eth_mddis = 1'b0;        // enable management
194
assign eth_fde = 1'b0;          // disable full-duplex
195
 
196
endmodule
197
 

powered by: WebSVN 2.1.0

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