Line 69... |
Line 69... |
// Creator: Dan Gisselquist, Ph.D.
|
// Creator: Dan Gisselquist, Ph.D.
|
// Gisselquist Technology, LLC
|
// Gisselquist Technology, LLC
|
//
|
//
|
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Copyright (C) 2015, Gisselquist Technology, LLC
|
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
|
//
|
//
|
// This program is free software (firmware): you can redistribute it and/or
|
// This program is free software (firmware): you can redistribute it and/or
|
// modify it under the terms of the GNU General Public License as published
|
// modify it under the terms of the GNU General Public License as published
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// your option) any later version.
|
// your option) any later version.
|
Line 290... |
Line 290... |
reg opA_alu, opA_mem;
|
reg opA_alu, opA_mem;
|
reg opB_alu, opB_mem;
|
reg opB_alu, opB_mem;
|
`endif
|
`endif
|
`ifdef OPT_ILLEGAL_INSTRUCTION
|
`ifdef OPT_ILLEGAL_INSTRUCTION
|
reg op_illegal;
|
reg op_illegal;
|
|
`else
|
|
wire op_illegal;
|
|
assign op_illegal = 1'b0;
|
`endif
|
`endif
|
reg op_break;
|
reg op_break;
|
wire op_lock;
|
wire op_lock;
|
|
|
|
|
Line 345... |
Line 348... |
assign fpu_ce = (master_ce)&&(~clear_pipeline)&&(opvalid_fpu)
|
assign fpu_ce = (master_ce)&&(~clear_pipeline)&&(opvalid_fpu)
|
&&(~mem_rdbusy)&&(~div_busy)&&(~fpu_busy)
|
&&(~mem_rdbusy)&&(~div_busy)&&(~fpu_busy)
|
&&(set_cond);
|
&&(set_cond);
|
|
|
// ALU, DIV, or FPU CE ... equivalent to the OR of all three of these
|
// ALU, DIV, or FPU CE ... equivalent to the OR of all three of these
|
wire adf_ce;
|
wire adf_ce, adf_ce_unconditional;
|
assign adf_ce = (master_ce)&&(~clear_pipeline)&&(opvalid)
|
assign adf_ce_unconditional = (master_ce)&&(~clear_pipeline)&&(opvalid)
|
&&(~opvalid_mem)&&(~mem_rdbusy)&&(~div_busy)
|
&&(~opvalid_mem)&&(~mem_rdbusy)&&(~div_busy)
|
&&(~fpu_busy)&&(set_cond);
|
&&(~fpu_busy);
|
|
assign adf_ce = (adf_ce_unconditional)&&(set_cond);
|
|
|
//
|
//
|
//
|
//
|
// PIPELINE STAGE #5 :: Write-back
|
// PIPELINE STAGE #5 :: Write-back
|
// Variable declarations
|
// Variable declarations
|
//
|
//
|
Line 459... |
Line 464... |
||((opvalid_alu)&&(wr_reg_ce)&&(wr_reg_id[4] == op_gie)
|
||((opvalid_alu)&&(wr_reg_ce)&&(wr_reg_id[4] == op_gie)
|
&&(wr_write_cc)) // Case 3
|
&&(wr_write_cc)) // Case 3
|
||((opvalid)&&(op_lock)&&(op_lock_stall))
|
||((opvalid)&&(op_lock)&&(op_lock_stall))
|
||((opvalid)&&(op_break))
|
||((opvalid)&&(op_break))
|
||(div_busy)||(fpu_busy);
|
||(div_busy)||(fpu_busy);
|
assign alu_ce = (master_ce)&&((opvalid_alu)||(op_illegal))
|
assign alu_ce = (master_ce)&&(opvalid_alu)&&(~alu_stall)
|
&&(~alu_stall)
|
|
&&(~clear_pipeline);
|
&&(~clear_pipeline);
|
`else
|
`else
|
assign alu_stall = ((~master_ce)&&(opvalid_alu))
|
assign alu_stall = ((~master_ce)&&(opvalid_alu))
|
||((opvalid_alu)&&(op_break));
|
||((opvalid_alu)&&(op_break));
|
assign alu_ce = (master_ce)&&((opvalid_alu)||(op_illegal))&&(~alu_stall)&&(~clear_pipeline);
|
assign alu_ce = (master_ce)&&((opvalid_alu)||(op_illegal))&&(~alu_stall)&&(~clear_pipeline);
|
Line 841... |
Line 845... |
opvalid_alu <= (dcdALU)&&(w_opvalid);
|
opvalid_alu <= (dcdALU)&&(w_opvalid);
|
opvalid_mem <= (dcdM)&&(w_opvalid);
|
opvalid_mem <= (dcdM)&&(w_opvalid);
|
opvalid_div <= (dcdDV)&&(w_opvalid);
|
opvalid_div <= (dcdDV)&&(w_opvalid);
|
opvalid_fpu <= (dcdFP)&&(w_opvalid);
|
opvalid_fpu <= (dcdFP)&&(w_opvalid);
|
`endif
|
`endif
|
end else if ((clear_pipeline)||(adf_ce)||(mem_ce))
|
end else if ((clear_pipeline)||(adf_ce_unconditional)||(mem_ce))
|
begin
|
begin
|
opvalid <= 1'b0;
|
opvalid <= 1'b0;
|
opvalid_alu <= 1'b0;
|
opvalid_alu <= 1'b0;
|
opvalid_mem <= 1'b0;
|
opvalid_mem <= 1'b0;
|
opvalid_div <= 1'b0;
|
opvalid_div <= 1'b0;
|
Line 1131... |
Line 1135... |
reg r_alu_phase;
|
reg r_alu_phase;
|
initial r_alu_phase = 1'b0;
|
initial r_alu_phase = 1'b0;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if (i_rst)
|
if (i_rst)
|
r_alu_phase <= 1'b0;
|
r_alu_phase <= 1'b0;
|
else if ((adf_ce)||(mem_ce))
|
else if ((adf_ce_unconditional)||(mem_ce))
|
r_alu_phase <= op_phase;
|
r_alu_phase <= op_phase;
|
assign alu_phase = r_alu_phase;
|
assign alu_phase = r_alu_phase;
|
`else
|
`else
|
assign alu_phase = 1'b0;
|
assign alu_phase = 1'b0;
|
`endif
|
`endif
|
|
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if (adf_ce)
|
if (adf_ce_unconditional)
|
alu_reg <= opR;
|
alu_reg <= opR;
|
else if ((i_halt)&&(i_dbg_we))
|
else if ((i_halt)&&(i_dbg_we))
|
alu_reg <= i_dbg_reg;
|
alu_reg <= i_dbg_reg;
|
|
|
//
|
//
|
Line 1155... |
Line 1159... |
dbgv <= (~i_rst)&&(i_halt)&&(i_dbg_we)&&(r_halted);
|
dbgv <= (~i_rst)&&(i_halt)&&(i_dbg_we)&&(r_halted);
|
reg [31:0] dbg_val;
|
reg [31:0] dbg_val;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
dbg_val <= i_dbg_data;
|
dbg_val <= i_dbg_data;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if ((adf_ce)||(mem_ce))
|
if ((adf_ce_unconditional)||(mem_ce))
|
alu_gie <= op_gie;
|
alu_gie <= op_gie;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if ((adf_ce)
|
if ((adf_ce_unconditional)
|
||((master_ce)&&(opvalid_mem)&&(~clear_pipeline)
|
||((master_ce)&&(opvalid_mem)&&(~clear_pipeline)
|
&&(~mem_stalled)))
|
&&(~mem_stalled)))
|
alu_pc <= op_pc;
|
alu_pc <= op_pc;
|
|
|
`ifdef OPT_ILLEGAL_INSTRUCTION
|
`ifdef OPT_ILLEGAL_INSTRUCTION
|
Line 1179... |
Line 1183... |
initial r_alu_pc_valid = 1'b0;
|
initial r_alu_pc_valid = 1'b0;
|
initial mem_pc_valid = 1'b0;
|
initial mem_pc_valid = 1'b0;
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|
if (i_rst)
|
if (i_rst)
|
r_alu_pc_valid <= 1'b0;
|
r_alu_pc_valid <= 1'b0;
|
else if (adf_ce) // Includes && (~alu_clear_pipeline)
|
else if (adf_ce_unconditional)//Includes&&(~alu_clear_pipeline)
|
r_alu_pc_valid <= 1'b1;
|
r_alu_pc_valid <= 1'b1;
|
else if (((~alu_busy)&&(~div_busy)&&(~fpu_busy))||(clear_pipeline))
|
else if (((~alu_busy)&&(~div_busy)&&(~fpu_busy))||(clear_pipeline))
|
r_alu_pc_valid <= 1'b0;
|
r_alu_pc_valid <= 1'b0;
|
assign alu_pc_valid = (r_alu_pc_valid)&&((~alu_busy)&&(~div_busy)&&(~fpu_busy));
|
assign alu_pc_valid = (r_alu_pc_valid)&&((~alu_busy)&&(~div_busy)&&(~fpu_busy));
|
always @(posedge i_clk)
|
always @(posedge i_clk)
|