Line 16... |
Line 16... |
//// - Simon Teran, simont@opencores.org ////
|
//// - Simon Teran, simont@opencores.org ////
|
//// - Jaka Simsic, jakas@opencores.org ////
|
//// - Jaka Simsic, jakas@opencores.org ////
|
//// - Dinesh Annayya, dinesha@opencores.org ////
|
//// - Dinesh Annayya, dinesha@opencores.org ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
|
//// v0.0 - Dinesh A, 5th Jan 2017
|
|
//// 1. Active edge of reset changed from High to Low
|
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
//// Copyright (C) 2000 Authors and OPENCORES.ORG ////
|
//// ////
|
//// ////
|
//// 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 ////
|
Line 67... |
Line 70... |
|
|
`include "top_defines.v"
|
`include "top_defines.v"
|
|
|
|
|
|
|
module oc8051_int (clk, rst,
|
module oc8051_int (clk, resetn,
|
wr_addr,
|
wr_addr,
|
data_in, bit_in,
|
data_in, bit_in,
|
wr, wr_bit,
|
wr, wr_bit,
|
//timer interrupts
|
//timer interrupts
|
tf0, tf1, t2_int,
|
tf0, tf1, t2_int,
|
Line 84... |
Line 87... |
intr, reti, int_vec, ack,
|
intr, reti, int_vec, ack,
|
//registers
|
//registers
|
ie, tcon, ip);
|
ie, tcon, ip);
|
|
|
input [7:0] wr_addr, data_in;
|
input [7:0] wr_addr, data_in;
|
input wr, tf0, tf1, t2_int, ie0, ie1, clk, rst, reti, wr_bit, bit_in, ack, uart_int;
|
input wr, tf0, tf1, t2_int, ie0, ie1, clk, resetn, reti, wr_bit, bit_in, ack, uart_int;
|
|
|
output tr0, tr1, intr;
|
output tr0, tr1, intr;
|
output [7:0] int_vec,
|
output [7:0] int_vec,
|
ie,
|
ie,
|
tcon,
|
tcon,
|
Line 152... |
Line 155... |
assign intr = |int_vec;
|
assign intr = |int_vec;
|
|
|
|
|
//
|
//
|
// IP
|
// IP
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or negedge resetn)
|
begin
|
begin
|
if (rst) begin
|
if (resetn == 1'b0) begin
|
ip <=#1 `OC8051_RST_IP;
|
ip <=#1 `OC8051_RST_IP;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_IP)) begin
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_IP)) begin
|
ip <= #1 data_in;
|
ip <= #1 data_in;
|
end else if ((wr) & (wr_bit) & (wr_addr[7:3]==`OC8051_SFR_B_IP))
|
end else if ((wr) & (wr_bit) & (wr_addr[7:3]==`OC8051_SFR_B_IP))
|
ip[wr_addr[2:0]] <= #1 bit_in;
|
ip[wr_addr[2:0]] <= #1 bit_in;
|
end
|
end
|
|
|
//
|
//
|
// IE
|
// IE
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or negedge resetn)
|
begin
|
begin
|
if (rst) begin
|
if (resetn == 1'b0) begin
|
ie <=#1 `OC8051_RST_IE;
|
ie <=#1 `OC8051_RST_IE;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_IE)) begin
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_IE)) begin
|
ie <= #1 data_in;
|
ie <= #1 data_in;
|
end else if ((wr) & (wr_bit) & (wr_addr[7:3]==`OC8051_SFR_B_IE))
|
end else if ((wr) & (wr_bit) & (wr_addr[7:3]==`OC8051_SFR_B_IE))
|
ie[wr_addr[2:0]] <= #1 bit_in;
|
ie[wr_addr[2:0]] <= #1 bit_in;
|
end
|
end
|
|
|
//
|
//
|
// tcon_s
|
// tcon_s
|
//
|
//
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or negedge resetn)
|
begin
|
begin
|
if (rst) begin
|
if (resetn == 1'b0) begin
|
tcon_s <=#1 4'b0000;
|
tcon_s <=#1 4'b0000;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TCON)) begin
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TCON)) begin
|
tcon_s <= #1 {data_in[6], data_in[4], data_in[2], data_in[0]};
|
tcon_s <= #1 {data_in[6], data_in[4], data_in[2], data_in[0]};
|
end else if ((wr) & (wr_bit) & (wr_addr[7:3]==`OC8051_SFR_B_TCON)) begin
|
end else if ((wr) & (wr_bit) & (wr_addr[7:3]==`OC8051_SFR_B_TCON)) begin
|
case (wr_addr[2:0]) /* synopsys full_case parallel_case */
|
case (wr_addr[2:0]) /* synopsys full_case parallel_case */
|
Line 196... |
Line 199... |
end
|
end
|
|
|
//
|
//
|
// tf1 (tmod.7)
|
// tf1 (tmod.7)
|
//
|
//
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or negedge resetn)
|
begin
|
begin
|
if (rst) begin
|
if (resetn == 1'b0) begin
|
tcon_tf1 <=#1 1'b0;
|
tcon_tf1 <=#1 1'b0;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TCON)) begin
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TCON)) begin
|
tcon_tf1 <= #1 data_in[7];
|
tcon_tf1 <= #1 data_in[7];
|
end else if ((wr) & (wr_bit) & (wr_addr=={`OC8051_SFR_B_TCON, 3'b111})) begin
|
end else if ((wr) & (wr_bit) & (wr_addr=={`OC8051_SFR_B_TCON, 3'b111})) begin
|
tcon_tf1 <= #1 bit_in;
|
tcon_tf1 <= #1 bit_in;
|
Line 214... |
Line 217... |
end
|
end
|
|
|
//
|
//
|
// tf0 (tmod.5)
|
// tf0 (tmod.5)
|
//
|
//
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or negedge resetn)
|
begin
|
begin
|
if (rst) begin
|
if (resetn == 1'b0) begin
|
tcon_tf0 <=#1 1'b0;
|
tcon_tf0 <=#1 1'b0;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TCON)) begin
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TCON)) begin
|
tcon_tf0 <= #1 data_in[5];
|
tcon_tf0 <= #1 data_in[5];
|
end else if ((wr) & (wr_bit) & (wr_addr=={`OC8051_SFR_B_TCON, 3'b101})) begin
|
end else if ((wr) & (wr_bit) & (wr_addr=={`OC8051_SFR_B_TCON, 3'b101})) begin
|
tcon_tf0 <= #1 bit_in;
|
tcon_tf0 <= #1 bit_in;
|
Line 233... |
Line 236... |
|
|
|
|
//
|
//
|
// ie0 (tmod.1)
|
// ie0 (tmod.1)
|
//
|
//
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or negedge resetn)
|
begin
|
begin
|
if (rst) begin
|
if (resetn == 1'b0) begin
|
tcon_ie0 <=#1 1'b0;
|
tcon_ie0 <=#1 1'b0;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TCON)) begin
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TCON)) begin
|
tcon_ie0 <= #1 data_in[1];
|
tcon_ie0 <= #1 data_in[1];
|
end else if ((wr) & (wr_bit) & (wr_addr=={`OC8051_SFR_B_TCON, 3'b001})) begin
|
end else if ((wr) & (wr_bit) & (wr_addr=={`OC8051_SFR_B_TCON, 3'b001})) begin
|
tcon_ie0 <= #1 bit_in;
|
tcon_ie0 <= #1 bit_in;
|
Line 254... |
Line 257... |
|
|
|
|
//
|
//
|
// ie1 (tmod.3)
|
// ie1 (tmod.3)
|
//
|
//
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or negedge resetn)
|
begin
|
begin
|
if (rst) begin
|
if (resetn == 1'b0) begin
|
tcon_ie1 <=#1 1'b0;
|
tcon_ie1 <=#1 1'b0;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TCON)) begin
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TCON)) begin
|
tcon_ie1 <= #1 data_in[3];
|
tcon_ie1 <= #1 data_in[3];
|
end else if ((wr) & (wr_bit) & (wr_addr=={`OC8051_SFR_B_TCON, 3'b011})) begin
|
end else if ((wr) & (wr_bit) & (wr_addr=={`OC8051_SFR_B_TCON, 3'b011})) begin
|
tcon_ie1 <= #1 bit_in;
|
tcon_ie1 <= #1 bit_in;
|
Line 273... |
Line 276... |
end
|
end
|
end
|
end
|
|
|
//
|
//
|
// interrupt processing
|
// interrupt processing
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or negedge resetn)
|
begin
|
begin
|
if (rst) begin
|
if (resetn == 1'b0) begin
|
int_vec <= #1 8'h00;
|
int_vec <= #1 8'h00;
|
int_dept <= #1 2'b0;
|
int_dept <= #1 2'b0;
|
isrc[0] <= #1 3'h0;
|
isrc[0] <= #1 3'h0;
|
isrc[1] <= #1 3'h0;
|
isrc[1] <= #1 3'h0;
|
int_proc <= #1 1'b0;
|
int_proc <= #1 1'b0;
|
Line 340... |
Line 343... |
int_vec <= #1 8'h00;
|
int_vec <= #1 8'h00;
|
end
|
end
|
end
|
end
|
|
|
|
|
always @(posedge clk or posedge rst)
|
always @(posedge clk or negedge resetn)
|
if (rst) begin
|
if (resetn == 1'b0) begin
|
tf0_buff <= #1 1'b0;
|
tf0_buff <= #1 1'b0;
|
tf1_buff <= #1 1'b0;
|
tf1_buff <= #1 1'b0;
|
ie0_buff <= #1 1'b0;
|
ie0_buff <= #1 1'b0;
|
ie1_buff <= #1 1'b0;
|
ie1_buff <= #1 1'b0;
|
end else begin
|
end else begin
|