Skip to content

Commit

Permalink
feat: add stats
Browse files Browse the repository at this point in the history
  • Loading branch information
owl-from-hogvarts committed May 7, 2024
1 parent 32cf5a9 commit 1e3bdc0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ asm | acc | neum | mc -> hw | tick -> instr | struct | stream | port | pstr | pr
- [Registers](#registers)
- [ALU](#alu)
- [Control unit](#control-unit)
- [Stats](#stats)


# Language
Expand Down Expand Up @@ -435,3 +436,11 @@ ALU operates on two `u32` values, outputting `u32` result and optionally setting
![](./images/control_unit.svg)


# Stats

```
| Full name | alg | loc | bytes | instr | exec_instr | tick | variant |
|Тернавский Константин Евгеньевич | hello_world | 35 | - | 13 | 105 | 647 | asm | acc | neum | mc -> hw | tick -> instr | struct | stream | port | pstr | prob2 | cache|
|Тернавский Константин Евгеньевич | hello_username | 168 | - | 81 | 434 | 2706 | asm | acc | neum | mc -> hw | tick -> instr | struct | stream | port | pstr | prob2 | cache|
|Тернавский Константин Евгеньевич | prob2 | 137 | - | 48 | 630 | 3896 | asm | acc | neum | mc -> hw | tick -> instr | struct | stream | port | pstr | prob2 | cache|
```
9 changes: 9 additions & 0 deletions cpu/src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ impl CPU {
}

pub fn start(mut self) {
let mut instructions_executed = 0;
let mut micro_instructions_executed = 0;
loop {
// rise
let micro_instruction = self.microcode[self.microcode_program_counter].clone();
Expand Down Expand Up @@ -209,7 +211,14 @@ impl CPU {
_ => unreachable!(),
};

if self.microcode_program_counter == 0 {
instructions_executed += 1;
}

micro_instructions_executed += 1;
}

log::info!("Instructions: {}; MC: {}", instructions_executed, micro_instructions_executed);
}

fn opcode_to_mc(opcode: Opcode) -> MicroInstructionCounter {
Expand Down
7 changes: 0 additions & 7 deletions programs/hello_world.asm
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,4 @@ loop:

break:
halt






0 comments on commit 1e3bdc0

Please sign in to comment.