VADCOP —-1

In Powdr

Related PR

I look at what files are changed

so let’s start with, what is YML?

YAML (YAML Ain’t Markup Language) is a human-readable data serialization format commonly used for configuration files and data exchange between programming languages.

What is the .github Folder and workflow Directory?

The .github folder is a special directory in a GitHub repository that is used to store configuration files related to GitHub-specific features. The workflow directory within .github is where you define automated processes that are run by GitHub Actions.

GitHub Actions is an automation tool integrated into GitHub that allows developers to automate tasks like building, testing, and deploying their code. In the context of deployment on Github server.

the parameter: MAX_DEGREE_LOG is changed. seems define the maximum degree for a machine?

What is a trait?

I found the definition of machine, it is a trait, so, what is a trait again?

In Rust, a trait is a way to define shared behavior across multiple types.

A trait defines a set of methods that the types implementing that trait must provide.

example:

trait Speak {
    fn speak(&self) -> String;
}

struct Dog;
struct Cat;

impl Speak for Dog {
    fn speak(&self) -> String {
        "Woof!".to_string()
    }
}

impl Speak for Cat {
    fn speak(&self) -> String {
        "Meow!".to_string()
    }
}

fn main() {
    let dog = Dog;
    let cat = Cat;

    println!("{}", dog.speak()); // Woof!
    println!("{}", cat.speak()); // Meow!
}

machine trait is defined here

cannot understand anymore, go back to powder riscv machine asm code,

Powdr riscv machine

use predefined machines

CLI for run powdr-rs to compile a rust file to asm file.

powdr-rs compile riscv/tests/riscv_data/sum -o output 

I executed the hello world example

powdr-rs compile riscv/tests/riscv_data/std_hello_world -o output 

let’s check the asm file that is generated:

use std library, there are pre-defined machines, then declare the main machine

The machine concept is the first main concept! check here!

for example, the machine range file:

it defines many range related machine. let me explain the machine byte:

it is an operation Operations enable a constrained machine to expose behavior to the outside. 

Symbols can be defined via let <name> = <value>;, or via let <name>: <type> = <value>;

//let <name>: <type>=<value>;
let BYTE: col= |i| i & 0xff;  

col: for columns in arithmetic circuit

Functions can be constructed using the lambda expression notation. For example |x, y| x + y returns a function that performs addition. The lambda expression || 7 is a function that returns a constant (has no parameters). Lambda functions can capture anything in their environment and thus form closures.

//operation name is check
//<0> is for op_id, if the machine has more operations, they will be <1>, <2> ...
//input is col BYTE, no output
operation check<0> BYTE -> ;

[1]* the * means repetitions see example here

Registers

This is a visual machine, declared by “machine Main with degree: …” , then sub-machines are specified. Machines can also receive submachines as construction parameters.

//byte_binary is the construction parameter of Binary machine
Binary binary(byte_binary);
//the name of the submachine, and its instance
Bit2 bit2;

components of a visual machine:

Register has different types:

Program counter: reg pc[@pc]

At each step execution step, the program counter points to the function line to execute. The program counter behaves like a write register, with the exception that its value is incremented by default after each step.

Assignment register

Use for passing inputs and receive outputs from instructions, as well as in assignments. 

X,Y,Z,W are all assignments registers

Then the next line is also declaring a submachine, it is equivalent to the submachines declared before?

std::machines::memory::Memory memory(byte2);

Instructions

taking notes in next post.

Leave a Reply

Your email address will not be published. Required fields are marked *