Line 217... |
Line 217... |
|
|
//
|
//
|
// Registered output from the multiplier and
|
// Registered output from the multiplier and
|
// an optional divider
|
// an optional divider
|
//
|
//
|
always @(posedge rst or posedge clk)
|
always @(`OR1200_RST_EVENT rst or posedge clk)
|
if (rst) begin
|
if (rst == `OR1200_RST_VALUE) begin
|
mul_prod_r <= 64'h0000_0000_0000_0000;
|
mul_prod_r <= 64'h0000_0000_0000_0000;
|
div_free <= 1'b1;
|
div_free <= 1'b1;
|
`ifdef OR1200_DIV_IMPLEMENTED
|
`ifdef OR1200_DIV_IMPLEMENTED
|
div_cntr <= 6'b00_0000;
|
div_cntr <= 6'b00_0000;
|
`endif
|
`endif
|
Line 254... |
Line 254... |
|
|
`ifdef OR1200_MAC_IMPLEMENTED
|
`ifdef OR1200_MAC_IMPLEMENTED
|
// Signal to indicate when we should check for new MAC op
|
// Signal to indicate when we should check for new MAC op
|
reg ex_freeze_r;
|
reg ex_freeze_r;
|
|
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or `OR1200_RST_EVENT rst)
|
if (rst)
|
if (rst == `OR1200_RST_VALUE)
|
ex_freeze_r <= 1'b1;
|
ex_freeze_r <= 1'b1;
|
else
|
else
|
ex_freeze_r <= ex_freeze;
|
ex_freeze_r <= ex_freeze;
|
|
|
//
|
//
|
// Propagation of l.mac opcode, only register it for one cycle
|
// Propagation of l.mac opcode, only register it for one cycle
|
//
|
//
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or `OR1200_RST_EVENT rst)
|
if (rst)
|
if (rst == `OR1200_RST_VALUE)
|
mac_op_r1 <= `OR1200_MACOP_WIDTH'b0;
|
mac_op_r1 <= `OR1200_MACOP_WIDTH'b0;
|
else
|
else
|
mac_op_r1 <= !ex_freeze_r ? mac_op : `OR1200_MACOP_WIDTH'b0;
|
mac_op_r1 <= !ex_freeze_r ? mac_op : `OR1200_MACOP_WIDTH'b0;
|
|
|
//
|
//
|
// Propagation of l.mac opcode
|
// Propagation of l.mac opcode
|
//
|
//
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or `OR1200_RST_EVENT rst)
|
if (rst)
|
if (rst == `OR1200_RST_VALUE)
|
mac_op_r2 <= `OR1200_MACOP_WIDTH'b0;
|
mac_op_r2 <= `OR1200_MACOP_WIDTH'b0;
|
else
|
else
|
mac_op_r2 <= mac_op_r1;
|
mac_op_r2 <= mac_op_r1;
|
|
|
//
|
//
|
// Propagation of l.mac opcode
|
// Propagation of l.mac opcode
|
//
|
//
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or `OR1200_RST_EVENT rst)
|
if (rst)
|
if (rst == `OR1200_RST_VALUE)
|
mac_op_r3 <= `OR1200_MACOP_WIDTH'b0;
|
mac_op_r3 <= `OR1200_MACOP_WIDTH'b0;
|
else
|
else
|
mac_op_r3 <= mac_op_r2;
|
mac_op_r3 <= mac_op_r2;
|
|
|
//
|
//
|
// Implementation of MAC
|
// Implementation of MAC
|
//
|
//
|
always @(posedge rst or posedge clk)
|
always @(`OR1200_RST_EVENT rst or posedge clk)
|
if (rst)
|
if (rst == `OR1200_RST_VALUE)
|
mac_r <= 64'h0000_0000_0000_0000;
|
mac_r <= 64'h0000_0000_0000_0000;
|
`ifdef OR1200_MAC_SPR_WE
|
`ifdef OR1200_MAC_SPR_WE
|
else if (spr_maclo_we)
|
else if (spr_maclo_we)
|
mac_r[31:0] <= spr_dat_i;
|
mac_r[31:0] <= spr_dat_i;
|
else if (spr_machi_we)
|
else if (spr_machi_we)
|
Line 311... |
Line 311... |
//
|
//
|
// Stall CPU if l.macrc is in ID and MAC still has to process l.mac instructions
|
// Stall CPU if l.macrc is in ID and MAC still has to process l.mac instructions
|
// in EX stage (e.g. inside multiplier)
|
// in EX stage (e.g. inside multiplier)
|
// This stall signal is also used by the divider.
|
// This stall signal is also used by the divider.
|
//
|
//
|
always @(posedge rst or posedge clk)
|
always @(`OR1200_RST_EVENT rst or posedge clk)
|
if (rst)
|
if (rst == `OR1200_RST_VALUE)
|
mac_stall_r <= 1'b0;
|
mac_stall_r <= 1'b0;
|
else
|
else
|
mac_stall_r <= (|mac_op | (|mac_op_r1) | (|mac_op_r2)) & (id_macrc_op | mac_stall_r)
|
mac_stall_r <= (|mac_op | (|mac_op_r1) | (|mac_op_r2)) & (id_macrc_op | mac_stall_r)
|
`ifdef OR1200_DIV_IMPLEMENTED
|
`ifdef OR1200_DIV_IMPLEMENTED
|
| (|div_cntr)
|
| (|div_cntr)
|