SystemVerilog Struct To Python Script

In reply to dave_59:

Hello Dave ! Thanks for the suggestions. Do you mean something like this with custom prints ?

Basic Example:


module hello_system;

int fd;

typedef struct {
    integer c;
    int b;
    string p;
} sub_sv_st;

typedef struct {
    int a;
    string s;
    sub_sv_st sst;
} sv_st;

    initial begin
        sub_sv_st s_d;
        sv_st     p_d;
        
        s_d.c = -20;
        s_d.b = 6;
        s_d.p = "panther";
        
        p_d.a = 3;
        p_d.s = "lion";
        p_d.sst = s_d;

        fd = $fopen("animal.yaml");
        
        $fdisplay(fd, "p_d:");
        $fdisplay(fd, " %0s: %0d", "a", p_d.a);
        $fdisplay(fd, " %0s: %0s", "s", p_d.s);
        $fdisplay(fd, " s_d:");
        $fdisplay(fd, "     %0s: %0d", "c", p_d.sst.c);
        $fdisplay(fd, "     %0s: %0d", "b", p_d.sst.b);
        $fdisplay(fd, "     %0s: %0s", "p", p_d.sst.p);
       

        $fclose(fd);
    end

endmodule: hello_system

Output:


p_d:
 a: 3
 s: lion
 s_d:
     c: -20
     b: 6
     p: panther