Skip to content

Commit

Permalink
ARATE almost there
Browse files Browse the repository at this point in the history
  • Loading branch information
jotego committed Jun 4, 2022
1 parent e4e4759 commit 791f026
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
15 changes: 9 additions & 6 deletions hdl/jtopl_eg_pure.v
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,18 @@ reg [ 9:0] ar_sum;
always @(*) begin : ar_calculation
casez( rate[5:2] )
default: ar_sum0 = {2'd0, eg_in[9:4]};
//4'b1011: ar_sum0 = {1'd0, eg_in[9:3]}; // 'hb
4'b1101: ar_sum0 = {1'd0, eg_in[9:3]}; // 'hd
4'b111?: ar_sum0 = eg_in[9:2]; // 'he/f
4'b1011, 4'b1100: ar_sum0 = {1'd0, eg_in[9:3]}; // 'hb
// 4'b1101: ar_sum0 = {1'd0, eg_in[9:3]}; // 'hd
// 4'b111?: ar_sum0 = eg_in[9:2]; // 'he/f
4'b1101, 4'b111?: ar_sum0 = eg_in[9:2]; // 'he/f
endcase
ar_sum1 = ar_sum0+9'd1;
if( rate[5:2] > 4'hb )
if( rate[5:2] == 4'he )
ar_sum = { ar_sum1, 1'b0 };
else if( rate[5:2] > 4'hb )
ar_sum = step ? { ar_sum1, 1'b0 } : { 1'b0, ar_sum1 }; // adds ar_sum1*3/2 max
else if( rate[5:2] == 4'hb )
ar_sum = step ? { ar_sum1, 1'b0 } : 10'd0; // adds ar_sum1 max
// else if( rate[5:2] == 4'hb )
// ar_sum = step ? { ar_sum1, 1'b0 } : 10'd0; // adds ar_sum1 max
else
ar_sum = step ? { 1'b0, ar_sum1 } : 10'd0; // adds ar_sum1/2 max
ar_result = eg_in-ar_sum;
Expand Down
5 changes: 2 additions & 3 deletions ver/jtopl_eg/sweep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) {
top.trace(vcd,99);
vcd->open("test.vcd");
}
for( top.arate_I=3; top.arate_I<16; top.arate_I++ )
for( top.arate_I=3; top.arate_I<15; top.arate_I++ )
{
top.rst = 1;
top.keyon_I = 0;
Expand All @@ -87,8 +87,7 @@ int main(int argc, char *argv[]) {
float delta=(float)main_time-t0;
delta /= 1e6;
float err = (delta-atime[top.arate_I])/atime[top.arate_I]*100.0;
cout << "ARATE " << hex << (int)top.arate_I << dec << " " << delta << " ms (" <<
setprecision(3) << err << "%) " << endl;
printf("ARATE %X %6.2f ms (%4.1f %%)\n", top.arate_I, delta, err );
}
}

Expand Down

0 comments on commit 791f026

Please sign in to comment.