Line 37... |
Line 37... |
// You should have received a copy of the GNU Lesser General //
|
// You should have received a copy of the GNU Lesser General //
|
// Public License along with this source; if not, download it //
|
// Public License along with this source; if not, download it //
|
// from http://www.opencores.org/lgpl.shtml //
|
// from http://www.opencores.org/lgpl.shtml //
|
// //
|
// //
|
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
`include "global_defines.v"
|
`include "global_defines.vh"
|
|
|
module a25_decode
|
module a25_decode
|
(
|
(
|
input i_clk,
|
input i_clk,
|
input [31:0] i_fetch_instruction,
|
input [31:0] i_fetch_instruction,
|
Line 129... |
Line 129... |
output reg o_rs_use_read,
|
output reg o_rs_use_read,
|
output reg o_rd_use_read
|
output reg o_rd_use_read
|
|
|
);
|
);
|
|
|
`include "a25_localparams.v"
|
`include "a25_localparams.vh"
|
`include "a25_functions.v"
|
`include "a25_functions.vh"
|
|
|
localparam [4:0] RST_WAIT1 = 5'd0,
|
localparam [4:0] RST_WAIT1 = 5'd0,
|
RST_WAIT2 = 5'd1,
|
RST_WAIT2 = 5'd1,
|
INT_WAIT1 = 5'd2,
|
INT_WAIT1 = 5'd2,
|
INT_WAIT2 = 5'd3,
|
INT_WAIT2 = 5'd3,
|
Line 437... |
Line 437... |
branch ? 4'd15 : // Update the PC
|
branch ? 4'd15 : // Update the PC
|
rds_use_rs ? instruction[11:8] :
|
rds_use_rs ? instruction[11:8] :
|
instruction[15:12] ;
|
instruction[15:12] ;
|
|
|
// Load from memory into registers
|
// Load from memory into registers
|
assign ldm_user_mode = type == MTRANS && {instruction[22:20],instruction[15]} == 4'b1010;
|
assign ldm_user_mode = type == MTRANS && {instruction[22],instruction[20],instruction[15]} == 3'b110;
|
assign ldm_flags = type == MTRANS && rs_sel_nxt == 4'd15 && instruction[20] && instruction[22];
|
assign ldm_flags = type == MTRANS && rs_sel_nxt == 4'd15 && instruction[20] && instruction[22];
|
assign ldm_status_bits = type == MTRANS && rs_sel_nxt == 4'd15 && instruction[20] && instruction[22] && i_execute_status_bits[1:0] != USR;
|
assign ldm_status_bits = type == MTRANS && rs_sel_nxt == 4'd15 && instruction[20] && instruction[22] && i_execute_status_bits[1:0] != USR;
|
assign load_rd_byte = (type == TRANS || type == SWAP) && instruction[22];
|
assign load_rd_byte = (type == TRANS || type == SWAP) && instruction[22];
|
assign load_rd_nxt = {ldm_flags, ldm_status_bits, ldm_user_mode, load_rd_byte, rs_sel_nxt};
|
assign load_rd_nxt = {ldm_flags, ldm_status_bits, ldm_user_mode, load_rd_byte, rs_sel_nxt};
|
|
|
Line 802... |
Line 802... |
barrel_shift_amount_sel_nxt = 2'd1; // Shift amount from Rs registter
|
barrel_shift_amount_sel_nxt = 2'd1; // Shift amount from Rs registter
|
|
|
if ( !immediate_shift_op && !instruction[4] )
|
if ( !immediate_shift_op && !instruction[4] )
|
barrel_shift_amount_sel_nxt = 2'd2; // Shift immediate amount
|
barrel_shift_amount_sel_nxt = 2'd2; // Shift immediate amount
|
|
|
|
// regops that do not change the overflow flag
|
|
if ( opcode == AND || opcode == EOR || opcode == TST || opcode == TEQ ||
|
|
opcode == ORR || opcode == MOV || opcode == BIC || opcode == MVN )
|
|
status_bits_sel_nxt = 3'd5;
|
|
|
if ( opcode == ADD || opcode == CMN ) // CMN is just like an ADD
|
if ( opcode == ADD || opcode == CMN ) // CMN is just like an ADD
|
begin
|
begin
|
alu_out_sel_nxt = 4'd1; // Add
|
alu_out_sel_nxt = 4'd1; // Add
|
end
|
end
|
|
|
Line 998... |
Line 1003... |
// Load or store ?
|
// Load or store ?
|
if ( !instruction[20] ) // Store
|
if ( !instruction[20] ) // Store
|
write_data_wen_nxt = 1'd1;
|
write_data_wen_nxt = 1'd1;
|
|
|
// stm: store the user mode registers, when in priviledged mode
|
// stm: store the user mode registers, when in priviledged mode
|
if ( {instruction[22:20]} == 3'b100 )
|
if ( {instruction[22],instruction[20]} == 2'b10 )
|
o_user_mode_regs_store_nxt = 1'd1;
|
o_user_mode_regs_store_nxt = 1'd1;
|
|
|
// update the base register ?
|
// update the base register ?
|
if ( instruction[21] ) // the W bit
|
if ( instruction[21] ) // the W bit
|
reg_bank_wen_nxt = decode (rn_sel_nxt);
|
reg_bank_wen_nxt = decode (rn_sel_nxt);
|
Line 1203... |
Line 1208... |
|
|
if ( !instruction[20] ) // Store
|
if ( !instruction[20] ) // Store
|
write_data_wen_nxt = 1'd1;
|
write_data_wen_nxt = 1'd1;
|
|
|
// stm: store the user mode registers, when in priviledged mode
|
// stm: store the user mode registers, when in priviledged mode
|
if ( {instruction[22:20]} == 3'b100 )
|
if ( {instruction[22],instruction[20]} == 2'b10 )
|
o_user_mode_regs_store_nxt = 1'd1;
|
o_user_mode_regs_store_nxt = 1'd1;
|
|
|
// write to the pc ?
|
// write to the pc ?
|
if ( instruction[20] && mtrans_reg1 == 4'd15 ) // Write to PC
|
if ( instruction[20] && mtrans_reg1 == 4'd15 ) // Write to PC
|
begin
|
begin
|
Line 1239... |
Line 1244... |
// Store
|
// Store
|
if ( !instruction[20] )
|
if ( !instruction[20] )
|
write_data_wen_nxt = 1'd1;
|
write_data_wen_nxt = 1'd1;
|
|
|
// stm: store the user mode registers, when in priviledged mode
|
// stm: store the user mode registers, when in priviledged mode
|
if ( {instruction[22:20]} == 3'b100 )
|
if ( {instruction[22],instruction[20]} == 2'b10 )
|
o_user_mode_regs_store_nxt = 1'd1;
|
o_user_mode_regs_store_nxt = 1'd1;
|
|
|
// write to the pc ?
|
// write to the pc ?
|
if ( instruction[20] && mtrans_reg1 == 4'd15 ) // Write to PC
|
if ( instruction[20] && mtrans_reg1 == 4'd15 ) // Write to PC
|
begin
|
begin
|
Line 1412... |
Line 1417... |
end
|
end
|
|
|
|
|
// Speed up the long path from u_decode/fetch_instruction_r to u_register_bank/r8_firq
|
// Speed up the long path from u_decode/fetch_instruction_r to u_register_bank/r8_firq
|
// This pre-encodes the firq_s3 signal thats used in u_register_bank
|
// This pre-encodes the firq_s3 signal thats used in u_register_bank
|
// assign firq_not_user_mode_nxt = !user_mode_regs_load_nxt && status_bits_mode_nxt == FIRQ;
|
|
assign firq_not_user_mode_nxt = status_bits_mode_nxt == FIRQ;
|
assign firq_not_user_mode_nxt = status_bits_mode_nxt == FIRQ;
|
|
|
|
|
// ========================================================
|
// ========================================================
|
// Next State Logic
|
// Next State Logic
|
Line 1706... |
Line 1710... |
// ========================================================
|
// ========================================================
|
// Decompiler for debugging core - not synthesizable
|
// Decompiler for debugging core - not synthesizable
|
// ========================================================
|
// ========================================================
|
//synopsys translate_off
|
//synopsys translate_off
|
|
|
`include "debug_functions.v"
|
`include "debug_functions.vh"
|
|
|
a25_decompile u_decompile (
|
a25_decompile u_decompile (
|
.i_clk ( i_clk ),
|
.i_clk ( i_clk ),
|
.i_core_stall ( i_core_stall ),
|
.i_core_stall ( i_core_stall ),
|
.i_instruction ( instruction ),
|
.i_instruction ( instruction ),
|