Line 43... |
Line 43... |
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//
|
//
|
// CVS Revision History
|
// CVS Revision History
|
//
|
//
|
// $Log: not supported by cvs2svn $
|
// $Log: not supported by cvs2svn $
|
|
// Revision 1.9 2002/03/09 03:43:27 lampret
|
|
// Interrupt is asserted only when an input changes (code patch by Jacob Gorban)
|
|
//
|
// Revision 1.8 2002/01/14 19:06:28 lampret
|
// Revision 1.8 2002/01/14 19:06:28 lampret
|
// Changed registered WISHBONE outputs wb_ack_o/wb_err_o to follow WB specification.
|
// Changed registered WISHBONE outputs wb_ack_o/wb_err_o to follow WB specification.
|
//
|
//
|
// Revision 1.7 2001/12/25 17:21:21 lampret
|
// Revision 1.7 2001/12/25 17:21:21 lampret
|
// Fixed two typos.
|
// Fixed two typos.
|
Line 92... |
Line 95... |
|
|
// Auxiliary inputs interface
|
// Auxiliary inputs interface
|
aux_i,
|
aux_i,
|
|
|
// External GPIO Interface
|
// External GPIO Interface
|
in_pad_i, ext_clk_pad_i, out_pad_o, oen_padoen_o
|
ext_pad_i, clk_pad_i, ext_pad_o, ext_padoen_o
|
);
|
);
|
|
|
parameter dw = 32;
|
parameter dw = 32;
|
parameter aw = `GPIO_ADDRHH+1;
|
parameter aw = `GPIO_ADDRHH+1;
|
parameter gw = `GPIO_IOS;
|
parameter gw = `GPIO_IOS;
|
Line 121... |
Line 124... |
input [gw-1:0] aux_i; // Auxiliary inputs
|
input [gw-1:0] aux_i; // Auxiliary inputs
|
|
|
//
|
//
|
// External GPIO Interface
|
// External GPIO Interface
|
//
|
//
|
input [gw-1:0] in_pad_i; // GPIO Inputs
|
input [gw-1:0] ext_pad_i; // GPIO Inputs
|
input ext_clk_pad_i; // GPIO Eclk
|
input clk_pad_i; // GPIO Eclk
|
output [gw-1:0] out_pad_o; // GPIO Outputs
|
output [gw-1:0] ext_pad_o; // GPIO Outputs
|
output [gw-1:0] oen_padoen_o; // GPIO output drivers enables
|
output [gw-1:0] ext_padoen_o; // GPIO output drivers enables
|
|
|
`ifdef GPIO_IMPLEMENTED
|
`ifdef GPIO_IMPLEMENTED
|
|
|
//
|
//
|
// GPIO Input Register (or no register)
|
// GPIO Input Register (or no register)
|
Line 225... |
Line 228... |
reg wb_inta_o; // WB Interrupt
|
reg wb_inta_o; // WB Interrupt
|
reg [dw-1:0] wb_dat_o; // WB Data out
|
reg [dw-1:0] wb_dat_o; // WB Data out
|
`endif
|
`endif
|
wire [gw-1:0] out_pad; // GPIO Outputs
|
wire [gw-1:0] out_pad; // GPIO Outputs
|
`ifdef GPIO_REGISTERED_IO_OUTPUTS
|
`ifdef GPIO_REGISTERED_IO_OUTPUTS
|
reg [gw-1:0] out_pad_o; // GPIO Outputs
|
reg [gw-1:0] ext_pad_o; // GPIO Outputs
|
`endif
|
`endif
|
wire [gw-1:0] extc_in; // Muxed inputs sampled by external clock
|
wire [gw-1:0] extc_in; // Muxed inputs sampled by external clock
|
wire pext_clk; // External clock for posedge flops
|
wire pext_clk; // External clock for posedge flops
|
reg [gw-1:0] pextc_sampled; // Posedge external clock sampled inputs
|
reg [gw-1:0] pextc_sampled; // Posedge external clock sampled inputs
|
`ifdef GPIO_NO_NEGEDGE_FLOPS
|
`ifdef GPIO_NO_NEGEDGE_FLOPS
|
Line 407... |
Line 410... |
`endif
|
`endif
|
|
|
//
|
//
|
// Mux inputs directly from input pads with inputs sampled by external clock
|
// Mux inputs directly from input pads with inputs sampled by external clock
|
//
|
//
|
assign in_muxed = rgpio_ctrl[`GPIO_RGPIO_CTRL_ECLK] ? extc_in : in_pad_i;
|
assign in_muxed = rgpio_ctrl[`GPIO_RGPIO_CTRL_ECLK] ? extc_in : ext_pad_i;
|
|
|
//
|
//
|
// Posedge pext_clk is inverted by NEC bit if negedge flops are not allowed.
|
// Posedge pext_clk is inverted by NEC bit if negedge flops are not allowed.
|
// If negedge flops are allowed, pext_clk only clocks posedge flops.
|
// If negedge flops are allowed, pext_clk only clocks posedge flops.
|
//
|
//
|
`ifdef GPIO_NO_NEGEDGE_FLOPS
|
`ifdef GPIO_NO_NEGEDGE_FLOPS
|
assign pext_clk = rgpio_ctrl[`GPIO_RGPIO_CTRL_NEC] ? ~ext_clk_pad_i : ext_clk_pad_i;
|
assign pext_clk = rgpio_ctrl[`GPIO_RGPIO_CTRL_NEC] ? ~clk_pad_i : clk_pad_i;
|
`else
|
`else
|
assign pext_clk = ext_clk_pad_i;
|
assign pext_clk = clk_pad_i;
|
`endif
|
`endif
|
|
|
//
|
//
|
// If negedge flops are allowed, ext_in is mux of negedge and posedge external clocked flops.
|
// If negedge flops are allowed, ext_in is mux of negedge and posedge external clocked flops.
|
//
|
//
|
Line 435... |
Line 438... |
//
|
//
|
always @(posedge pext_clk or posedge wb_rst_i)
|
always @(posedge pext_clk or posedge wb_rst_i)
|
if (wb_rst_i)
|
if (wb_rst_i)
|
pextc_sampled <= #1 {gw{1'b0}};
|
pextc_sampled <= #1 {gw{1'b0}};
|
else
|
else
|
pextc_sampled <= #1 in_pad_i;
|
pextc_sampled <= #1 ext_pad_i;
|
|
|
//
|
//
|
// Latch using negedge external clock
|
// Latch using negedge external clock
|
//
|
//
|
`ifdef GPIO_NO_NEGEDGE_FLOPS
|
`ifdef GPIO_NO_NEGEDGE_FLOPS
|
`else
|
`else
|
always @(negedge ext_clk_pad_i or posedge wb_rst_i)
|
always @(negedge clk_pad_i or posedge wb_rst_i)
|
if (wb_rst_i)
|
if (wb_rst_i)
|
nextc_sampled <= #1 {gw{1'b0}};
|
nextc_sampled <= #1 {gw{1'b0}};
|
else
|
else
|
nextc_sampled <= #1 in_pad_i;
|
nextc_sampled <= #1 ext_pad_i;
|
`endif
|
`endif
|
|
|
//
|
//
|
// Mux all registers when doing a read of GPIO registers
|
// Mux all registers when doing a read of GPIO registers
|
//
|
//
|
Line 506... |
Line 509... |
always @(posedge wb_clk_i or posedge wb_rst_i)
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
if (wb_rst_i)
|
if (wb_rst_i)
|
rgpio_ints <= #1 {gw{1'b0}};
|
rgpio_ints <= #1 {gw{1'b0}};
|
else if (rgpio_ints_sel && wb_we_i)
|
else if (rgpio_ints_sel && wb_we_i)
|
rgpio_ints <= #1 wb_dat_i[gw-1:0];
|
rgpio_ints <= #1 wb_dat_i[gw-1:0];
|
else if (rgpio_ctrl[`GPIO_RGPIO_CTRL_INTE] && rgpio_in != in_pad_i)
|
else if (rgpio_ctrl[`GPIO_RGPIO_CTRL_INTE] && rgpio_in != ext_pad_i)
|
rgpio_ints <= #1 (rgpio_ints | (in_pad_i ^ ~rgpio_ptrig) & rgpio_inte);
|
rgpio_ints <= #1 (rgpio_ints | (ext_pad_i ^ ~rgpio_ptrig) & rgpio_inte);
|
`else
|
`else
|
assign rgpio_ints = (in_pad_i ^ ~rgpio_ptrig) & rgpio_inte;
|
assign rgpio_ints = (ext_pad_i ^ ~rgpio_ptrig) & rgpio_inte;
|
`endif
|
`endif
|
|
|
//
|
//
|
// Generate interrupt request
|
// Generate interrupt request
|
//
|
//
|
Line 533... |
Line 536... |
`endif
|
`endif
|
|
|
//
|
//
|
// Output enables are RGPIO_OE bits
|
// Output enables are RGPIO_OE bits
|
//
|
//
|
assign oen_padoen_o = rgpio_oe;
|
assign ext_padoen_o = rgpio_oe;
|
|
|
//
|
//
|
// Generate GPIO outputs
|
// Generate GPIO outputs
|
//
|
//
|
assign out_pad = rgpio_out & ~rgpio_aux | aux_i & rgpio_aux;
|
assign out_pad = rgpio_out & ~rgpio_aux | aux_i & rgpio_aux;
|
Line 546... |
Line 549... |
// Optional registration of GPIO outputs
|
// Optional registration of GPIO outputs
|
//
|
//
|
`ifdef GPIO_REGISTERED_IO_OUTPUTS
|
`ifdef GPIO_REGISTERED_IO_OUTPUTS
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
always @(posedge wb_clk_i or posedge wb_rst_i)
|
if (wb_rst_i)
|
if (wb_rst_i)
|
out_pad_o <= #1 {gw{1'b0}};
|
ext_pad_o <= #1 {gw{1'b0}};
|
else
|
else
|
out_pad_o <= #1 out_pad;
|
ext_pad_o <= #1 out_pad;
|
`else
|
`else
|
assign out_pad_o = out_pad;
|
assign ext_pad_o = out_pad;
|
`endif
|
`endif
|
|
|
`else
|
`else
|
|
|
//
|
//
|
Line 562... |
Line 565... |
// is cleared and WISHBONE transfers complete with errors
|
// is cleared and WISHBONE transfers complete with errors
|
//
|
//
|
assign wb_inta_o = 1'b0;
|
assign wb_inta_o = 1'b0;
|
assign wb_ack_o = 1'b0;
|
assign wb_ack_o = 1'b0;
|
assign wb_err_o = wb_cyc_i & wb_stb_i;
|
assign wb_err_o = wb_cyc_i & wb_stb_i;
|
assign oen_padoen_o = {gw{1'b1}};
|
assign ext_padoen_o = {gw{1'b1}};
|
assign out_pad_o = {gw{1'b0}};
|
assign ext_pad_o = {gw{1'b0}};
|
|
|
//
|
//
|
// Read GPIO registers
|
// Read GPIO registers
|
//
|
//
|
assign wb_dat_o = {dw{1'b0}};
|
assign wb_dat_o = {dw{1'b0}};
|