1 // Copyright (C) 2005 Peio Azkarate, peio@opencores.org
3 // This source file is free software; you can redistribute it
4 // and/or modify it under the terms of the GNU Lesser General
5 // Public License as published by the Free Software Foundation;
6 // either version 2.1 of the License, or (at your option) any
10 (* signal_encoding = "user" *)
11 (* safe_implementation = "yes" *)
13 module pciwbsequ_new ( clk_i, nrst_i, cmd_i, cbe_i, frame_i, irdy_i, devsel_o,
14 trdy_o, adrcfg_i, adrmem_i, pciadrLD_o, pcidOE_o, parOE_o, wbdatLD_o,
15 wbrgdMX_o, wbd16MX_o, wrcfg_o, rdcfg_o, wb_sel_o, wb_we_o, wb_stb_o,
16 wb_cyc_o, wb_ack_i, wb_err_i, debug_init, debug_access );
41 output [1:0] wb_sel_o;
48 output reg debug_init;
49 output reg debug_access;
51 //type PciFSM is ( PCIIDLE, B_BUSY, S_DATA1, S_DATA2, TURN_AR );
52 //wire pst_pci : PciFSM;
53 //wire nxt_pci : PciFSM;
55 // typedef enum reg [2:0] {
56 // RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW
59 // color_t my_color = GREEN;
61 // parameter PCIIDLE = 2'b00;
62 // parameter B_BUSY = 2'b01;
63 // parameter S_DATA1 = 2'b10;
64 // parameter S_DATA2 = 2'b11;
65 // parameter TURN_AR = 3'b100;
103 // always @(nrst_i or clk_i or nxt_pci)
104 always @(negedge nrst_i or posedge clk_i)
112 // always @(negedge nrst_i or posedge clk_i)
113 always @( pst_pci or frame_i or irdy_i or adrcfg_i or adrpci or acking )
146 if ( frame_i == 1 && irdy_i == 0 )
162 // FSM control signals
163 assign adrpci = adrmem_i;
166 ( wb_ack_i == 1 || wb_err_i == 1 ) ||
167 ( adrcfg_i == 1 && irdy_i == 0)
170 // FSM derived Control signals
171 assign idle = ( pst_pci <= PCIIDLE ) ? 1'b1 : 1'b0;
172 assign sdata1 = ( pst_pci <= S_DATA1 ) ? 1'b1 : 1'b0;
173 assign sdata2 = ( pst_pci <= S_DATA2 ) ? 1'b1 : 1'b0;
174 assign idleNX = ( nxt_pci <= PCIIDLE ) ? 1'b1 : 1'b0;
175 assign sdata1NX = ( nxt_pci <= S_DATA1 ) ? 1'b1 : 1'b0;
176 assign sdata2NX = ( nxt_pci <= S_DATA2 ) ? 1'b1 : 1'b0;
177 assign turnarNX = ( nxt_pci <= TURN_AR ) ? 1'b1 : 1'b0;
179 // PCI Data Output Enable
180 // always @( nrst_i or clk_i or cmd_i [0] or sdata1NX or turnarNX )
181 always @(negedge nrst_i or posedge clk_i)
186 if ( sdata1NX == 1 && cmd_i [0] == 0 )
193 assign pcidOE_o = pcidOE;
196 // PCI Read data phase
197 // PAR is valid 1 cicle after data is valid
198 // always @( nrst_i or clk_i or cmd_i [0] or sdata2NX or turnarNX )
199 always @(negedge nrst_i or posedge clk_i)
204 if ( ( sdata2NX == 1 || turnarNX == 1 ) && cmd_i [0] == 0 )
210 // Target s/t/s signals OE control
211 // targOE <= '1' when ( idle = '0' and adrpci = '1' ) else '0';
212 // always @( nrst_i or clk_i or sdata1NX or idleNX )
213 always @(negedge nrst_i or posedge clk_i)
226 assign wb_cyc_o = (adrmem_i == 1 && sdata1 == 1) ? 1'b1 : 1'b0;
227 assign wb_stb_o = (adrmem_i == 1 && sdata1 == 1 && irdy_i == 0 ) ? 1'b1 : 1'b0;
229 // PCI(Little endian) to WB(Big endian)
230 assign wb_sel_o [1] = (! cbe_i [0]) || (! cbe_i [2]);
231 assign wb_sel_o [0] = (! cbe_i [1]) || (! cbe_i [3]);
233 assign wb_we_o = cmd_i [0];
235 // Syncronized PCI outs
236 always @(negedge nrst_i or posedge clk_i)
245 devsel <= devselNX_n;
250 assign devsel_o = ( targOE == 1 ) ? devsel : 1'bZ;
251 assign trdy_o = ( targOE == 1 ) ? trdy : 1'bZ;
253 // rd/wr Configuration Space Registers
263 (sdata1 == 1 || sdata2 == 1)
266 assign rdcfg_o = rdcfg;
268 // LoaD enable signals
269 assign pciadrLD_o = ! frame_i;
270 assign wbdatLD_o = wb_ack_i;
272 // Mux control signals
273 assign wbrgdMX_o = ! rdcfg;
274 assign wbd16MX_o = (cbe_i [3] == 0 || cbe_i [2] == 0) ? 1'b1 : 1'b0;
277 always @(negedge nrst_i or posedge clk_i)
286 always @(negedge nrst_i or posedge clk_i)