-
- struct virtual_cpu_register_bank {
- int r1;
- int r2;
- int r3;
- int32_t pc;
- char * name;
- CPU_TYPE type;
- };
-
- struct virtual_cpu_sub_core {
- struct virtual_cpu_register_bank virtual_register;
- int op;
- int status;
- char * name;
- };
-
- struct virtual_cpu_core {
- struct virtual_cpu_sub_core previous;
- struct virtual_cpu_sub_core current;
- int status;
- int power;
- char * cpu_power_state[2];
- char * name;
- bool init;
- };
-
- struct virtual_cpu {
- int core_count;
- struct virtual_cpu_core *core;
- struct Queue *q;
- char ** table_instructions;
- char ** table_types;
- char ** table_registers;
- char ** table_encoding;
- struct instruction * instruction_bank;
- char * name;
- } cpu_default;
-
- void cpu_register_info_minimal(struct virtual_cpu_register_bank *virtual_register) {
- printf("VIRTUAL CPU: INFO : register bank name: %s\n", virtual_register->name);
- printf("VIRTUAL CPU: INFO : size of %s: %zu\n", virtual_register->name, sizeof(*virtual_register));
- printf("VIRTUAL CPU: INFO : %s : r1: %d\n", virtual_register->name, virtual_register->r1);
- printf("VIRTUAL CPU: INFO : %s : r2: %d\n", virtual_register->name, virtual_register->r2);
- printf("VIRTUAL CPU: INFO : %s : r3: %d\n", virtual_register->name, virtual_register->r3);
- printf("VIRTUAL CPU: INFO : %s : pc: %d\n", virtual_register->name, virtual_register->pc);
- printf("VIRTUAL CPU: INFO : %s : name: %s\n", virtual_register->name, virtual_register->name);
- }
-
- void cpu_register_info(struct virtual_cpu *cpu, struct virtual_cpu_core *core, struct virtual_cpu_sub_core *sub_core, struct virtual_cpu_register_bank *virtual_register) {
- printf("VIRTUAL CPU: INFO : %s : %s : %s : register bank name: %s\n", cpu->name, core->name, sub_core->name, virtual_register->name);
- printf("VIRTUAL CPU: INFO : %s : %s : %s : size of %s: %zu\n", cpu->name, core->name, sub_core->name, virtual_register->name, sizeof(*virtual_register));
- printf("VIRTUAL CPU: INFO : %s : %s : %s : %s : r1: %d\n", cpu->name, core->name, sub_core->name, virtual_register->name, virtual_register->r1);
- printf("VIRTUAL CPU: INFO : %s : %s : %s : %s : r2: %d\n", cpu->name, core->name, sub_core->name, virtual_register->name, virtual_register->r2);
- printf("VIRTUAL CPU: INFO : %s : %s : %s : %s : r3: %d\n", cpu->name, core->name, sub_core->name, virtual_register->name, virtual_register->r3);
- printf("VIRTUAL CPU: INFO : %s : %s : %s : %s : pc: %d\n", cpu->name, core->name, sub_core->name, virtual_register->name, virtual_register->pc);
- }
-
- void cpu_sub_core_info(struct virtual_cpu *cpu, struct virtual_cpu_core *core, struct virtual_cpu_sub_core *sub_core) {
- printf("VIRTUAL CPU: INFO : %s : %s : sub core name: %s\n", cpu->name, core->name, sub_core->name);
- printf("VIRTUAL CPU: INFO : %s : %s : size of %s: %zu\n", cpu->name, core->name, sub_core->name, sizeof(*sub_core));
- cpu_register_info(cpu, core, sub_core, &sub_core->virtual_register);
- }
-
- void cpu_core_info(struct virtual_cpu *cpu, struct virtual_cpu_core *core) {
- printf("VIRTUAL CPU: INFO : %s : core name: %s\n", cpu->name, core->name);
- printf("VIRTUAL CPU: INFO : %s : size of %s: %zu\n", cpu->name, core->name,
- sizeof(*core)-
- sizeof(core->cpu_power_state)+
- (
- sizeof(core->cpu_power_state)*env__size(core->cpu_power_state)
- )
- );
- printf("VIRTUAL CPU: INFO : %s : %s : cpu power status: %s\n", cpu->name, core->name, core->cpu_power_state[core->power]);
- printf("VIRTUAL CPU: INFO : %s : %s : status: %d\n", cpu->name, core->name, core->status);
- cpu_sub_core_info(cpu, core, &core->previous);
- cpu_sub_core_info(cpu, core, &core->current);
- }
-
- void cpu_info(struct virtual_cpu *cpu) {
- virtual_cpu_check(cpu);
- printf("VIRTUAL CPU: INFO : cpu name: %s\n", cpu->name);
- printf("VIRTUAL CPU: INFO : cpu cores: %d\n", cpu->core_count);
- printf
- (
- "VIRTUAL CPU: INFO : size of %s: %zu\n", cpu->name,
- (
- sizeof(*cpu)-
- (
- sizeof(cpu->q)+
- sizeof(cpu->core)+
- sizeof(cpu->table_instructions)+
- sizeof(cpu->table_types)+
- sizeof(cpu->table_registers)+
- sizeof(cpu->table_encoding)+
- sizeof(cpu->instruction_bank)
- )+
- (
- (
- sizeof(cpu->core[0])-
- sizeof(cpu->core[0].cpu_power_state)+
- (
- sizeof(cpu->core[0].cpu_power_state)*env__size(cpu->core[0].cpu_power_state)
- )
- ) * cpu->core_count
- )
- ) +
- (
- sizeof(cpu->table_instructions) * env__size(cpu->table_instructions)+
- sizeof(cpu->table_types) *env__size(cpu->table_types)+
- sizeof(cpu->table_registers) * env__size(cpu->table_registers)+
- sizeof(cpu->table_encoding) * env__size(cpu->table_encoding)+
- sizeof(*cpu->instruction_bank) * env__size(&cpu->instruction_bank)
- )
- );
- printf("VIRTUAL CPU: INFO : size of instruction table: %zu\n", sizeof(cpu->table_instructions) * env__size(cpu->table_instructions));
- printf("VIRTUAL CPU: INFO : size of types table: %zu\n", sizeof(cpu->table_types) * env__size(cpu->table_types));
- printf("VIRTUAL CPU: INFO : size of registers table: %zu\n", sizeof(cpu->table_registers) * env__size(cpu->table_registers));
- printf("VIRTUAL CPU: INFO : size of encoding table: %zu\n", sizeof(cpu->table_encoding) * env__size(cpu->table_encoding));
- printf("VIRTUAL CPU: INFO : size of instruction bank: %zu\n", sizeof(*cpu->instruction_bank) * env__size(&cpu->instruction_bank));
- for (int i = 0; i < 1; i++) cpu_core_info(cpu, &cpu->core[i]);
- }
-