Line 94... |
Line 94... |
`define MBOOT_WRITE 5'h0f
|
`define MBOOT_WRITE 5'h0f
|
`define MBOOT_DESYNC 5'h11
|
`define MBOOT_DESYNC 5'h11
|
module wbicapetwo(i_clk,
|
module wbicapetwo(i_clk,
|
i_wb_cyc, i_wb_stb, i_wb_we, i_wb_addr, i_wb_data,
|
i_wb_cyc, i_wb_stb, i_wb_we, i_wb_addr, i_wb_data,
|
o_wb_ack, o_wb_stall, o_wb_data, o_dbg);
|
o_wb_ack, o_wb_stall, o_wb_data, o_dbg);
|
|
parameter LGDIV = 3; /// Log of the clock divide
|
input i_clk;
|
input i_clk;
|
// Wishbone inputs
|
// Wishbone inputs
|
input i_wb_cyc, i_wb_stb, i_wb_we;
|
input i_wb_cyc, i_wb_stb, i_wb_we;
|
input [4:0] i_wb_addr;
|
input [4:0] i_wb_addr;
|
input [31:0] i_wb_data;
|
input [31:0] i_wb_data;
|
Line 111... |
Line 112... |
|
|
reg wb_req, r_we;
|
reg wb_req, r_we;
|
reg [31:0] r_data;
|
reg [31:0] r_data;
|
reg [4:0] r_addr;
|
reg [4:0] r_addr;
|
|
|
`ifdef DIVIDE_BY_FOUR
|
|
reg [1:0] slow_clk_counter;
|
|
reg clk_stb, clk_stall;
|
reg clk_stb, clk_stall;
|
wire slow_clk;
|
wire slow_clk;
|
|
|
|
generate
|
|
if (LGDIV <= 1)
|
|
begin
|
|
reg r_slow_clk;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
begin
|
begin
|
slow_clk <= slow_clk + 2'b01;
|
r_slow_clk <= (slow_clk + 1'b1);
|
// We'll move on the positive edge of the clock, so therefore
|
// We'll move on the positive edge of the clock,
|
// clk_stb must be true one clock before that, so we test for
|
// so therefore clk_stb must be true one clock before
|
// it one clock before that.
|
// that, so we test for it one clock before that.
|
clk_stb <= (slow_clk_counter == 2'b10);
|
clk_stb <= (slow_clk == 1'b1);
|
// CLK_STALL is set to true two clocks before any cycle that
|
// CLK_STALL is set to true two clocks before any
|
// will, by necessity, stall.
|
// cycle that will, by necessity, stall.
|
clk_stall <= (slow_clk_counter != 2'b01);
|
clk_stall <= (slow_clk != 1'b0); //True all but 1ckcycle
|
end
|
end
|
|
|
assign slow_clk = slow_clk_counter[1];
|
assign slow_clk = r_slow_clk;
|
`else
|
end else begin
|
reg slow_clk, clk_stb, clk_stall;
|
reg [(LGDIV-1):0] slow_clk_counter;
|
|
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
begin
|
begin
|
slow_clk <= (slow_clk + 1'b1);
|
slow_clk_counter <= slow_clk_counter + 1'b1;
|
// We'll move on the positive edge of the clock, so therefore
|
// We'll move on the positive edge of the clock, so therefore
|
// clk_stb must be true one clock before that, so we test for
|
// clk_stb must be true one clock before that, so we test for
|
// it one clock before that.
|
// it one clock before that.
|
clk_stb <= (slow_clk == 1'b1);
|
clk_stb <= (slow_clk_counter=={{(LGDIV){1'b1}},1'b0});
|
// CLK_STALL is set to true two clocks before any cycle that
|
// CLK_STALL is set to true two clocks before any cycle that
|
// will, by necessity, stall.
|
// will, by necessity, stall.
|
clk_stall <= (slow_clk != 1'b0); //True all but one clock
|
clk_stall <= (slow_clk_counter!={{(LGDIV){1'b0}},1'b1});
|
end
|
end
|
`endif
|
|
|
assign slow_clk = slow_clk_counter[(LGDIV-1)];
|
|
end endgenerate
|
|
|
reg [31:0] cfg_in;
|
reg [31:0] cfg_in;
|
reg cfg_cs_n, cfg_rdwrn;
|
reg cfg_cs_n, cfg_rdwrn;
|
wire [31:0] cfg_out;
|
wire [31:0] cfg_out;
|
reg [4:0] state;
|
reg [4:0] state;
|