Skip to content

Commit

Permalink
update funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
adammwest committed Feb 10, 2025
1 parent 1138572 commit 9a06817
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 29 additions & 1 deletion components/asic/common.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "common.h"

# define XTAL_OSC_MHZ 25 // related to version rolling

unsigned char _reverse_bits(unsigned char num)
{
unsigned char reversed = 0;
Expand All @@ -24,4 +26,30 @@ int _largest_power_of_two(int num)
}

return 1 << power;
}
}

int calulate_hcn_max(int chip_addr,int freq) {
return calculate_hcn(chip_addr,freq,1.0);
}

float calculate_cno(int chips) {
float cno = (int)(256.0*256.0/(float)chips);
return cno;
}

int calulate_hcn_from_nonce_percent(int chip_addr,int freq,int cno,float nonce_percent) {
float size = nonce_percent*chip_addr*256*256;
if (cno>0) size = nonce_percent*(float)cno*256.0;
float hcn = size * XTAL_OSC_MHZ / freq;
int hcn_int = (int)hcn;
return hcn_int;
}

float calculate_timeout_ms(int big_cores,int chip_addr,int freq, int cno, float nonce_percent, float timeout_percent,int versions_per_core) {
float hcn = calulate_hcn_from_nonce_percent(chip_addr,freq,cno,nonce_percent);
int big_cores = _largest_power_of_two(big_cores);
int size = 256/big_cores * 256 * 256 * 256
float timeout_s = nonce_percent * size * desired_versions/1000/1000;
float timeout_ms = timeout_s * 1000;
return timeout_ms*timeout_percent;
}
2 changes: 1 addition & 1 deletion components/asic/include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ typedef struct __attribute__((__packed__))
unsigned char _reverse_bits(unsigned char num);
int _largest_power_of_two(int num);
int calulate_hcn_from_nonce_percent(int chip_addr,int freq,float nonce_percent);
float calculate_timeout_ms(int chip_addr,int freq, int cno, float nonce_percent, float timeout_percent,int versions_per_core);
float calculate_timeout_ms(int big_cores,int chip_addr,int freq, int cno, float nonce_percent, float timeout_percent,int versions_per_core);
float calculate_cno(int chips) ;
int calulate_hcn_max(int chip_addr,int freq);

Expand Down

0 comments on commit 9a06817

Please sign in to comment.