OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [rtl/] [verilog/] [omsp_execution_unit.v] - Diff between revs 105 and 111

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 105 Rev 111
Line 29... Line 29...
//
//
// *Author(s):
// *Author(s):
//              - Olivier Girard,    olgirard@gmail.com
//              - Olivier Girard,    olgirard@gmail.com
//
//
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
// $Rev: 105 $
// $Rev: 111 $
// $LastChangedBy: olivier.girard $
// $LastChangedBy: olivier.girard $
// $LastChangedDate: 2011-03-10 22:10:30 +0100 (Thu, 10 Mar 2011) $
// $LastChangedDate: 2011-05-20 22:39:02 +0200 (Fri, 20 May 2011) $
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
`ifdef OMSP_NO_INCLUDE
`ifdef OMSP_NO_INCLUDE
`else
`else
`include "openMSP430_defines.v"
`include "openMSP430_defines.v"
`endif
`endif
Line 76... Line 76...
    inst_type,                     // Decoded Instruction type
    inst_type,                     // Decoded Instruction type
    mclk,                          // Main system clock
    mclk,                          // Main system clock
    mdb_in,                        // Memory data bus input
    mdb_in,                        // Memory data bus input
    pc,                            // Program counter
    pc,                            // Program counter
    pc_nxt,                        // Next PC value (for CALL & IRQ)
    pc_nxt,                        // Next PC value (for CALL & IRQ)
    puc                            // Main system reset
    puc_rst                        // Main system reset
);
);
 
 
// OUTPUTs
// OUTPUTs
//=========
//=========
output              cpuoff;        // Turns off the CPU
output              cpuoff;        // Turns off the CPU
Line 117... Line 117...
input         [2:0] inst_type;     // Decoded Instruction type
input         [2:0] inst_type;     // Decoded Instruction type
input               mclk;          // Main system clock
input               mclk;          // Main system clock
input        [15:0] mdb_in;        // Memory data bus input
input        [15:0] mdb_in;        // Memory data bus input
input        [15:0] pc;            // Program counter
input        [15:0] pc;            // Program counter
input        [15:0] pc_nxt;        // Next PC value (for CALL & IRQ)
input        [15:0] pc_nxt;        // Next PC value (for CALL & IRQ)
input               puc;           // Main system reset
input               puc_rst;       // Main system reset
 
 
 
 
//=============================================================================
//=============================================================================
// 1)  INTERNAL WIRES/REGISTERS/PARAMETERS DECLARATION
// 1)  INTERNAL WIRES/REGISTERS/PARAMETERS DECLARATION
//=============================================================================
//=============================================================================
Line 188... Line 188...
    .inst_bw      (inst_bw),      // Decoded Inst: byte width
    .inst_bw      (inst_bw),      // Decoded Inst: byte width
    .inst_dest    (inst_dest),    // Register destination selection
    .inst_dest    (inst_dest),    // Register destination selection
    .inst_src     (inst_src),     // Register source selection
    .inst_src     (inst_src),     // Register source selection
    .mclk         (mclk),         // Main system clock
    .mclk         (mclk),         // Main system clock
    .pc           (pc),           // Program counter
    .pc           (pc),           // Program counter
    .puc          (puc),          // Main system reset
    .puc_rst      (puc_rst),      // Main system reset
    .reg_dest_val (alu_out),      // Selected register destination value
    .reg_dest_val (alu_out),      // Selected register destination value
    .reg_dest_wr  (reg_dest_wr),  // Write selected register destination
    .reg_dest_wr  (reg_dest_wr),  // Write selected register destination
    .reg_pc_call  (reg_pc_call),  // Trigger PC update for a CALL instruction
    .reg_pc_call  (reg_pc_call),  // Trigger PC update for a CALL instruction
    .reg_sp_val   (alu_out_add),  // Stack Pointer next value
    .reg_sp_val   (alu_out_add),  // Stack Pointer next value
    .reg_sp_wr    (reg_sp_wr),    // Stack Pointer write
    .reg_sp_wr    (reg_sp_wr),    // Stack Pointer write
Line 335... Line 335...
// Memory address bus
// Memory address bus
assign      mab       = alu_out_add[15:0];
assign      mab       = alu_out_add[15:0];
 
 
// Memory data bus output
// Memory data bus output
reg  [15:0] mdb_out_nxt;
reg  [15:0] mdb_out_nxt;
always @(posedge mclk or posedge puc)
always @(posedge mclk or posedge puc_rst)
  if (puc)                                            mdb_out_nxt <= 16'h0000;
  if (puc_rst)                                        mdb_out_nxt <= 16'h0000;
  else if (e_state==`E_DST_RD)                        mdb_out_nxt <= pc_nxt;
  else if (e_state==`E_DST_RD)                        mdb_out_nxt <= pc_nxt;
  else if ((e_state==`E_EXEC & ~inst_so[`CALL]) |
  else if ((e_state==`E_EXEC & ~inst_so[`CALL]) |
           (e_state==`E_IRQ_0) | (e_state==`E_IRQ_2)) mdb_out_nxt <= alu_out;
           (e_state==`E_IRQ_0) | (e_state==`E_IRQ_2)) mdb_out_nxt <= alu_out;
 
 
assign      mdb_out = inst_bw ? {2{mdb_out_nxt[7:0]}} : mdb_out_nxt;
assign      mdb_out = inst_bw ? {2{mdb_out_nxt[7:0]}} : mdb_out_nxt;
 
 
// Format memory data bus input depending on BW
// Format memory data bus input depending on BW
reg        mab_lsb;
reg        mab_lsb;
always @(posedge mclk or posedge puc)
always @(posedge mclk or posedge puc_rst)
  if (puc)        mab_lsb <= 1'b0;
  if (puc_rst)    mab_lsb <= 1'b0;
  else if (mb_en) mab_lsb <= alu_out_add[0];
  else if (mb_en) mab_lsb <= alu_out_add[0];
 
 
assign mdb_in_bw  = ~inst_bw ? mdb_in :
assign mdb_in_bw  = ~inst_bw ? mdb_in :
                     mab_lsb ? {2{mdb_in[15:8]}} : mdb_in;
                     mab_lsb ? {2{mdb_in[15:8]}} : mdb_in;
 
 
// Memory data bus input buffer (buffer after a source read)
// Memory data bus input buffer (buffer after a source read)
reg         mdb_in_buf_en;
reg         mdb_in_buf_en;
always @(posedge mclk or posedge puc)
always @(posedge mclk or posedge puc_rst)
  if (puc)  mdb_in_buf_en <= 1'b0;
  if (puc_rst)  mdb_in_buf_en <= 1'b0;
  else      mdb_in_buf_en <= (e_state==`E_SRC_RD);
  else      mdb_in_buf_en <= (e_state==`E_SRC_RD);
 
 
reg         mdb_in_buf_valid;
reg         mdb_in_buf_valid;
always @(posedge mclk or posedge puc)
always @(posedge mclk or posedge puc_rst)
  if (puc)                   mdb_in_buf_valid <= 1'b0;
  if (puc_rst)               mdb_in_buf_valid <= 1'b0;
  else if (e_state==`E_EXEC) mdb_in_buf_valid <= 1'b0;
  else if (e_state==`E_EXEC) mdb_in_buf_valid <= 1'b0;
  else if (mdb_in_buf_en)    mdb_in_buf_valid <= 1'b1;
  else if (mdb_in_buf_en)    mdb_in_buf_valid <= 1'b1;
 
 
reg  [15:0] mdb_in_buf;
reg  [15:0] mdb_in_buf;
always @(posedge mclk or posedge puc)
always @(posedge mclk or posedge puc_rst)
  if (puc)                mdb_in_buf <= 16'h0000;
  if (puc_rst)            mdb_in_buf <= 16'h0000;
  else if (mdb_in_buf_en) mdb_in_buf <= mdb_in_bw;
  else if (mdb_in_buf_en) mdb_in_buf <= mdb_in_bw;
 
 
assign mdb_in_val = mdb_in_buf_valid ? mdb_in_buf : mdb_in_bw;
assign mdb_in_val = mdb_in_buf_valid ? mdb_in_buf : mdb_in_bw;
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.