Line 16... |
Line 16... |
//// - Dinesh Annayya, dinesha@opencores.org ////
|
//// - Dinesh Annayya, dinesha@opencores.org ////
|
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// v0.0 - Dinesh A, 5th Jan 2017
|
//// v0.0 - Dinesh A, 5th Jan 2017
|
//// 1. Active edge of reset changed from High to Low
|
//// 1. Active edge of reset changed from High to Low
|
|
//// v0.1 - Dinesh A, 19th Jan 2017
|
|
//// 1. Lint Warning fixes
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// 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 ////
|
Line 116... |
Line 118... |
// read or write from one of the addresses in tmod
|
// read or write from one of the addresses in tmod
|
//
|
//
|
always @(posedge clk or negedge resetn)
|
always @(posedge clk or negedge resetn)
|
begin
|
begin
|
if (resetn == 1'b0) begin
|
if (resetn == 1'b0) begin
|
tmod <=#1 `OC8051_RST_TMOD;
|
tmod <=`OC8051_RST_TMOD;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TMOD))
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TMOD))
|
tmod <= #1 data_in;
|
tmod <= data_in;
|
end
|
end
|
|
|
//
|
//
|
// TIMER COUNTER 0
|
// TIMER COUNTER 0
|
//
|
//
|
always @(posedge clk or negedge resetn)
|
always @(posedge clk or negedge resetn)
|
begin
|
begin
|
if (resetn == 1'b0) begin
|
if (resetn == 1'b0) begin
|
tl0 <=#1 `OC8051_RST_TL0;
|
tl0 <=`OC8051_RST_TL0;
|
th0 <=#1 `OC8051_RST_TH0;
|
th0 <=`OC8051_RST_TH0;
|
tf0 <= #1 1'b0;
|
tf0 <= 1'b0;
|
tf1_0 <= #1 1'b0;
|
tf1_0 <= 1'b0;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TL0)) begin
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TL0)) begin
|
tl0 <= #1 data_in;
|
tl0 <= data_in;
|
tf0 <= #1 1'b0;
|
tf0 <= 1'b0;
|
tf1_0 <= #1 1'b0;
|
tf1_0 <= 1'b0;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TH0)) begin
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TH0)) begin
|
th0 <= #1 data_in;
|
th0 <= data_in;
|
tf0 <= #1 1'b0;
|
tf0 <= 1'b0;
|
tf1_0 <= #1 1'b0;
|
tf1_0 <= 1'b0;
|
end else begin
|
end else begin
|
case (tmod[1:0]) /* synopsys full_case parallel_case */
|
case (tmod[1:0]) /* synopsys full_case parallel_case */
|
`OC8051_MODE0: begin // mode 0
|
`OC8051_MODE0: begin // mode 0
|
tf1_0 <= #1 1'b0;
|
tf1_0 <= 1'b0;
|
if (tc0_add)
|
if (tc0_add)
|
{tf0, th0,tl0[4:0]} <= #1 {1'b0, th0, tl0[4:0]}+ 1'b1;
|
{tf0, th0,tl0[4:0]} <= {1'b0, th0, tl0[4:0]}+ 1'b1;
|
end
|
end
|
`OC8051_MODE1: begin // mode 1
|
`OC8051_MODE1: begin // mode 1
|
tf1_0 <= #1 1'b0;
|
tf1_0 <= 1'b0;
|
if (tc0_add)
|
if (tc0_add)
|
{tf0, th0,tl0} <= #1 {1'b0, th0, tl0}+ 1'b1;
|
{tf0, th0,tl0} <= {1'b0, th0, tl0}+ 1'b1;
|
end
|
end
|
|
|
`OC8051_MODE2: begin // mode 2
|
`OC8051_MODE2: begin // mode 2
|
tf1_0 <= #1 1'b0;
|
tf1_0 <= 1'b0;
|
if (tc0_add) begin
|
if (tc0_add) begin
|
if (tl0 == 8'b1111_1111) begin
|
if (tl0 == 8'b1111_1111) begin
|
tf0 <=#1 1'b1;
|
tf0 <=1'b1;
|
tl0 <=#1 th0;
|
tl0 <=th0;
|
end
|
end
|
else begin
|
else begin
|
tl0 <=#1 tl0 + 8'h1;
|
tl0 <=tl0 + 8'h1;
|
tf0 <= #1 1'b0;
|
tf0 <= 1'b0;
|
end
|
end
|
end
|
end
|
end
|
end
|
`OC8051_MODE3: begin // mode 3
|
`OC8051_MODE3: begin // mode 3
|
|
|
if (tc0_add)
|
if (tc0_add)
|
{tf0, tl0} <= #1 {1'b0, tl0} +1'b1;
|
{tf0, tl0} <= {1'b0, tl0} +1'b1;
|
|
|
if (tr1 & pres_ow)
|
if (tr1 & pres_ow)
|
{tf1_0, th0} <= #1 {1'b0, th0} +1'b1;
|
{tf1_0, th0} <= {1'b0, th0} +1'b1;
|
|
|
end
|
end
|
/* default:begin
|
/* default:begin
|
tf0 <= #1 1'b0;
|
tf0 <= 1'b0;
|
tf1_0 <= #1 1'b0;
|
tf1_0 <= 1'b0;
|
end*/
|
end*/
|
endcase
|
endcase
|
end
|
end
|
end
|
end
|
|
|
Line 188... |
Line 190... |
// TIMER COUNTER 1
|
// TIMER COUNTER 1
|
//
|
//
|
always @(posedge clk or negedge resetn)
|
always @(posedge clk or negedge resetn)
|
begin
|
begin
|
if (resetn == 1'b0) begin
|
if (resetn == 1'b0) begin
|
tl1 <=#1 `OC8051_RST_TL1;
|
tl1 <=`OC8051_RST_TL1;
|
th1 <=#1 `OC8051_RST_TH1;
|
th1 <=`OC8051_RST_TH1;
|
tf1_1 <= #1 1'b0;
|
tf1_1 <= 1'b0;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TL1)) begin
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TL1)) begin
|
tl1 <= #1 data_in;
|
tl1 <= data_in;
|
tf1_1 <= #1 1'b0;
|
tf1_1 <= 1'b0;
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TH1)) begin
|
end else if ((wr) & !(wr_bit) & (wr_addr==`OC8051_SFR_TH1)) begin
|
th1 <= #1 data_in;
|
th1 <= data_in;
|
tf1_1 <= #1 1'b0;
|
tf1_1 <= 1'b0;
|
end else begin
|
end else begin
|
case (tmod[5:4]) /* synopsys full_case parallel_case */
|
case (tmod[5:4]) /* synopsys full_case parallel_case */
|
`OC8051_MODE0: begin // mode 0
|
`OC8051_MODE0: begin // mode 0
|
if (tc1_add)
|
if (tc1_add)
|
{tf1_1, th1,tl1[4:0]} <= #1 {1'b0, th1, tl1[4:0]}+ 1'b1;
|
{tf1_1, th1,tl1[4:0]} <= {1'b0, th1, tl1[4:0]}+ 1'b1;
|
end
|
end
|
`OC8051_MODE1: begin // mode 1
|
`OC8051_MODE1: begin // mode 1
|
if (tc1_add)
|
if (tc1_add)
|
{tf1_1, th1,tl1} <= #1 {1'b0, th1, tl1}+ 1'b1;
|
{tf1_1, th1,tl1} <= {1'b0, th1, tl1}+ 1'b1;
|
end
|
end
|
|
|
`OC8051_MODE2: begin // mode 2
|
`OC8051_MODE2: begin // mode 2
|
if (tc1_add) begin
|
if (tc1_add) begin
|
if (tl1 == 8'b1111_1111) begin
|
if (tl1 == 8'b1111_1111) begin
|
tf1_1 <=#1 1'b1;
|
tf1_1 <=1'b1;
|
tl1 <=#1 th1;
|
tl1 <=th1;
|
end
|
end
|
else begin
|
else begin
|
tl1 <=#1 tl1 + 8'h1;
|
tl1 <=tl1 + 8'h1;
|
tf1_1 <= #1 1'b0;
|
tf1_1 <= 1'b0;
|
end
|
end
|
end
|
end
|
end
|
end
|
/* default:begin
|
default:begin
|
tf1_1 <= #1 1'b0;
|
tf1_1 <= 1'b0;
|
end*/
|
end
|
endcase
|
endcase
|
end
|
end
|
end
|
end
|
|
|
|
|
always @(posedge clk or negedge resetn)
|
always @(posedge clk or negedge resetn)
|
if (resetn == 1'b0) begin
|
if (resetn == 1'b0) begin
|
t0_buff <= #1 1'b0;
|
t0_buff <= 1'b0;
|
t1_buff <= #1 1'b0;
|
t1_buff <= 1'b0;
|
end else begin
|
end else begin
|
t0_buff <= #1 t0;
|
t0_buff <= t0;
|
t1_buff <= #1 t1;
|
t1_buff <= t1;
|
end
|
end
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|