Update turbosound.

This commit is contained in:
sorgelig
2020-05-11 23:43:24 +08:00
parent 5a66d5ec1c
commit c08d8479be
51 changed files with 4523 additions and 3446 deletions

View File

@ -28,7 +28,6 @@ module jt12_timers(
input clk,
input rst,
input clk_en, // clock enable
input fast_timers,
input [9:0] value_A,
input [7:0] value_B,
input load_A,
@ -45,11 +44,11 @@ module jt12_timers(
assign irq_n = ~( (flag_A&enable_irq_A) | (flag_B&enable_irq_B) );
jt12_timer #(.mult_width(1), .mult_max(0), .counter_width(10))
jt12_timer #(.mult_width(5), .mult_max(24), .counter_width(10))
timer_A(
.clk ( clk ),
.rst ( rst ),
.clk_en ( clk_en | fast_timers ),
.clk_en ( clk_en ),
.start_value( value_A ),
.load ( load_A ),
.clr_flag ( clr_flag_A),
@ -57,11 +56,11 @@ timer_A(
.overflow ( overflow_A)
);
jt12_timer #(.mult_width(4), .mult_max(15), .counter_width(8))
jt12_timer #(.mult_width(9), .mult_max(384), .counter_width(8))
timer_B(
.clk ( clk ),
.rst ( rst ),
.clk_en ( clk_en | fast_timers ),
.clk_en ( clk_en ),
.start_value( value_B ),
.load ( load_B ),
.clr_flag ( clr_flag_B),
@ -94,15 +93,17 @@ always@(posedge clk)
reg [mult_width+counter_width-1:0] next, init;
always @(*) begin
if( mult<mult_max )
{overflow, next } <= { {1'b0, cnt}, mult+1'b1 } ;
else
{overflow, next } <= { {1'b0, cnt}+1'b1, {mult_width{1'b0}} };
init <= { start_value, {mult_width{1'b0}} };
if( mult<mult_max ) begin
// mult not meant to overflow in this line
{overflow, next } = { {1'b0, cnt}, mult+1'b1 } ;
end else begin
{overflow, next } = { {1'b0, cnt}+1'b1, {mult_width{1'b0}} };
end
init = { start_value, {mult_width{1'b0}} };
end
always @(posedge clk)
if( load || rst) begin
always @(posedge clk)
if( ~load || rst) begin
mult <= { (mult_width){1'b0} };
cnt <= start_value;
end