Line 8... |
Line 8... |
// Email: admin@ultra-embedded.com
|
// Email: admin@ultra-embedded.com
|
//
|
//
|
// License: LGPL
|
// License: LGPL
|
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
//
|
//
|
// Copyright (C) 2011 - 2013 Ultra-Embedded.com
|
// Copyright (C) 2011 - 2014 Ultra-Embedded.com
|
//
|
//
|
// This source file may be used and distributed without
|
// This source file may be used and distributed without
|
// restriction provided that this copyright statement is not
|
// restriction provided that this copyright statement is not
|
// removed from the file and that any derivative work contains
|
// removed from the file and that any derivative work contains
|
// the original copyright notice and the associated disclaimer.
|
// the original copyright notice and the associated disclaimer.
|
Line 76... |
Line 76... |
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
// Registers
|
// Registers
|
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
|
|
// Register address
|
// Register address
|
reg [4:0] r_w_rd;
|
reg [4:0] rd_q;
|
|
|
// Register writeback value
|
// Register writeback value
|
reg [31:0] r_result;
|
reg [31:0] result_q;
|
|
|
reg [7:0] r_opcode;
|
reg [7:0] opcode_q;
|
|
|
// Register writeback enable
|
// Register writeback enable
|
reg r_w_write_rd;
|
reg write_rd_q;
|
|
|
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
// Writeback
|
// Writeback
|
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
always @ (posedge clk_i or posedge rst_i)
|
always @ (posedge clk_i or posedge rst_i)
|
begin
|
begin
|
if (rst_i == 1'b1)
|
if (rst_i == 1'b1)
|
begin
|
begin
|
r_w_write_rd <= 1'b1;
|
write_rd_q <= 1'b1;
|
r_result <= 32'h00000000;
|
result_q <= 32'h00000000;
|
r_w_rd <= 5'b00000;
|
rd_q <= 5'b00000;
|
r_opcode <= 8'b0;
|
opcode_q <= 8'b0;
|
end
|
end
|
else
|
else
|
begin
|
begin
|
r_w_write_rd <= 1'b0;
|
rd_q <= rd_i;
|
|
result_q <= alu_result_i;
|
|
|
r_w_rd <= rd_i;
|
opcode_q <= {2'b00,opcode_i[31:26]};
|
r_result <= alu_result_i;
|
|
|
|
r_opcode <= {2'b00,opcode_i[31:26]};
|
|
|
|
// Register writeback required?
|
// Register writeback required?
|
if (rd_i != 5'b00000)
|
if (rd_i != 5'b00000)
|
r_w_write_rd <= 1'b1;
|
write_rd_q <= 1'b1;
|
|
else
|
|
write_rd_q <= 1'b0;
|
end
|
end
|
end
|
end
|
|
|
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
// Load result resolve
|
// Load result resolve
|
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
wire load_insn;
|
wire load_inst_w;
|
wire [31:0] load_result;
|
wire [31:0] load_result_w;
|
|
|
altor32_lfu
|
altor32_lfu
|
u_lfu
|
u_lfu
|
(
|
(
|
// Opcode
|
// Opcode
|
.opcode_i(r_opcode),
|
.opcode_i(opcode_q),
|
|
|
// Memory load result
|
// Memory load result
|
.mem_result_i(mem_result_i),
|
.mem_result_i(mem_result_i),
|
.mem_offset_i(mem_offset_i),
|
.mem_offset_i(mem_offset_i),
|
|
|
// Result
|
// Result
|
.load_result_o(load_result),
|
.load_result_o(load_result_w),
|
.load_insn_o(load_insn)
|
.load_insn_o(load_inst_w)
|
);
|
);
|
|
|
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
// Assignments
|
// Assignments
|
//-------------------------------------------------------------------
|
//-------------------------------------------------------------------
|
assign write_enable_o = load_insn ? (r_w_write_rd & mem_ready_i) : r_w_write_rd;
|
assign write_enable_o = load_inst_w ? (write_rd_q & mem_ready_i) : write_rd_q;
|
assign write_data_o = load_insn ? load_result : (mult_i ? mult_result_i : r_result);
|
assign write_data_o = load_inst_w ? load_result_w : (mult_i ? mult_result_i : result_q);
|
assign write_addr_o = r_w_rd;
|
assign write_addr_o = rd_q;
|
|
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|