Line 29... |
Line 29... |
//
|
//
|
// *Author(s):
|
// *Author(s):
|
// - Olivier Girard, olgirard@gmail.com
|
// - Olivier Girard, olgirard@gmail.com
|
//
|
//
|
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
// $Rev: 54 $
|
// $Rev: 61 $
|
// $LastChangedBy: olivier.girard $
|
// $LastChangedBy: olivier.girard $
|
// $LastChangedDate: 2010-01-27 19:25:43 +0100 (Wed, 27 Jan 2010) $
|
// $LastChangedDate: 2010-02-03 23:14:03 +0100 (Wed, 03 Feb 2010) $
|
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
`include "timescale.v"
|
`include "timescale.v"
|
`include "openMSP430_defines.v"
|
`include "openMSP430_defines.v"
|
|
|
module omsp_frontend (
|
module omsp_frontend (
|
Line 242... |
Line 242... |
//-----------------------------------------
|
//-----------------------------------------
|
|
|
// Program counter
|
// Program counter
|
reg [15:0] pc;
|
reg [15:0] pc;
|
|
|
// Detect if PC needs to be incremented
|
|
wire pc_inc = (~pc_sw_wr & fetch) & ~(i_state==I_IRQ_FETCH) & ~(i_state==I_IRQ_DONE);
|
|
|
|
// Mux between software update and old PC
|
|
wire [15:0] pc_sel = pc_sw_wr ? pc_sw :
|
|
(i_state==I_IRQ_FETCH) ? irq_addr :
|
|
(i_state==I_IRQ_DONE) ? mdb_in : pc;
|
|
|
|
// Compute next PC value
|
// Compute next PC value
|
wire [15:0] pc_nxt = pc_sel + {14'h0000, pc_inc, 1'b0};
|
wire [15:0] pc_incr = pc + {14'h0000, fetch, 1'b0};
|
|
wire [15:0] pc_nxt = pc_sw_wr ? pc_sw :
|
|
(i_state==I_IRQ_FETCH) ? irq_addr :
|
|
(i_state==I_IRQ_DONE) ? mdb_in : pc_incr;
|
|
|
always @(posedge mclk or posedge puc)
|
always @(posedge mclk or posedge puc)
|
if (puc) pc <= 16'h0000;
|
if (puc) pc <= 16'h0000;
|
else pc <= pc_nxt;
|
else pc <= pc_nxt;
|
|
|