고위 합성 언어 어셈블러를 만든다. 그 10

개요



고위 합성 언어 어셈블러를 만든다.
연습 문제, 해 보았다.

3bit 가산기를 만들 수 있습니다.


make 18
in 0 5
wire 6 13
xor 0 3 14
and 0 3 6
xor 1 4 7
and 1 4 8
xor 6 7 15
and 6 7 9
or 8 9 10
xor 2 5 11
and 2 5 12
xor 10 11 16
and 10 11 13
or 12 13 17
out 14 17

진리표를 표시.





아티팩트



회로도를 표시.





아티팩트



컴파일하고 생성한 verilog


module x(input a, input b, input c, input d, input e, input f, output o, output p, output q, output r);
    assign o = a ^ d;
    assign g = a & d;
    assign h = b ^ e;
    assign i = b & e;
    assign p = g ^ h;
    assign j = g & h;
    assign k = i | j;
    assign l = c ^ f;
    assign m = c & f;
    assign q = k ^ l;
    assign n = k & l;
    assign r = m | n;
endmodule

module testbench;
    reg a, b, c, d, e, f;
    x u(.a(a), .b(b), .c(c), .d(d), .e(e), .f(f), .o(o), .p(p), .q(q), .r(r));
    initial
    begin
        $display("a b c d e f o p q r ");
        $monitor("%b %b %b %b %b %b %b %b %b %b ", a, b, c, d, e, f, o, p, q, r);
        a = 0; b = 0; c = 0; d = 0; e = 0; f = 0; #10;
        a = 0; b = 0; c = 0; d = 0; e = 0; f = 1; #10;
        a = 0; b = 0; c = 0; d = 0; e = 1; f = 0; #10;
        a = 0; b = 0; c = 0; d = 0; e = 1; f = 1; #10;
        a = 0; b = 0; c = 0; d = 1; e = 0; f = 0; #10;
        a = 0; b = 0; c = 0; d = 1; e = 0; f = 1; #10;
        a = 0; b = 0; c = 0; d = 1; e = 1; f = 0; #10;
        a = 0; b = 0; c = 0; d = 1; e = 1; f = 1; #10;
        a = 0; b = 0; c = 1; d = 0; e = 0; f = 0; #10;
        a = 0; b = 0; c = 1; d = 0; e = 0; f = 1; #10;
        a = 0; b = 0; c = 1; d = 0; e = 1; f = 0; #10;
        a = 0; b = 0; c = 1; d = 0; e = 1; f = 1; #10;
        a = 0; b = 0; c = 1; d = 1; e = 0; f = 0; #10;
        a = 0; b = 0; c = 1; d = 1; e = 0; f = 1; #10;
        a = 0; b = 0; c = 1; d = 1; e = 1; f = 0; #10;
        a = 0; b = 0; c = 1; d = 1; e = 1; f = 1; #10;
        a = 0; b = 1; c = 0; d = 0; e = 0; f = 0; #10;
        a = 0; b = 1; c = 0; d = 0; e = 0; f = 1; #10;
        a = 0; b = 1; c = 0; d = 0; e = 1; f = 0; #10;
        a = 0; b = 1; c = 0; d = 0; e = 1; f = 1; #10;
        a = 0; b = 1; c = 0; d = 1; e = 0; f = 0; #10;
        a = 0; b = 1; c = 0; d = 1; e = 0; f = 1; #10;
        a = 0; b = 1; c = 0; d = 1; e = 1; f = 0; #10;
        a = 0; b = 1; c = 0; d = 1; e = 1; f = 1; #10;
        a = 0; b = 1; c = 1; d = 0; e = 0; f = 0; #10;
        a = 0; b = 1; c = 1; d = 0; e = 0; f = 1; #10;
        a = 0; b = 1; c = 1; d = 0; e = 1; f = 0; #10;
        a = 0; b = 1; c = 1; d = 0; e = 1; f = 1; #10;
        a = 0; b = 1; c = 1; d = 1; e = 0; f = 0; #10;
        a = 0; b = 1; c = 1; d = 1; e = 0; f = 1; #10;
        a = 0; b = 1; c = 1; d = 1; e = 1; f = 0; #10;
        a = 0; b = 1; c = 1; d = 1; e = 1; f = 1; #10;
        a = 1; b = 0; c = 0; d = 0; e = 0; f = 0; #10;
        a = 1; b = 0; c = 0; d = 0; e = 0; f = 1; #10;
        a = 1; b = 0; c = 0; d = 0; e = 1; f = 0; #10;
        a = 1; b = 0; c = 0; d = 0; e = 1; f = 1; #10;
        a = 1; b = 0; c = 0; d = 1; e = 0; f = 0; #10;
        a = 1; b = 0; c = 0; d = 1; e = 0; f = 1; #10;
        a = 1; b = 0; c = 0; d = 1; e = 1; f = 0; #10;
        a = 1; b = 0; c = 0; d = 1; e = 1; f = 1; #10;
        a = 1; b = 0; c = 1; d = 0; e = 0; f = 0; #10;
        a = 1; b = 0; c = 1; d = 0; e = 0; f = 1; #10;
        a = 1; b = 0; c = 1; d = 0; e = 1; f = 0; #10;
        a = 1; b = 0; c = 1; d = 0; e = 1; f = 1; #10;
        a = 1; b = 0; c = 1; d = 1; e = 0; f = 0; #10;
        a = 1; b = 0; c = 1; d = 1; e = 0; f = 1; #10;
        a = 1; b = 0; c = 1; d = 1; e = 1; f = 0; #10;
        a = 1; b = 0; c = 1; d = 1; e = 1; f = 1; #10;
        a = 1; b = 1; c = 0; d = 0; e = 0; f = 0; #10;
        a = 1; b = 1; c = 0; d = 0; e = 0; f = 1; #10;
        a = 1; b = 1; c = 0; d = 0; e = 1; f = 0; #10;
        a = 1; b = 1; c = 0; d = 0; e = 1; f = 1; #10;
        a = 1; b = 1; c = 0; d = 1; e = 0; f = 0; #10;
        a = 1; b = 1; c = 0; d = 1; e = 0; f = 1; #10;
        a = 1; b = 1; c = 0; d = 1; e = 1; f = 0; #10;
        a = 1; b = 1; c = 0; d = 1; e = 1; f = 1; #10;
        a = 1; b = 1; c = 1; d = 0; e = 0; f = 0; #10;
        a = 1; b = 1; c = 1; d = 0; e = 0; f = 1; #10;
        a = 1; b = 1; c = 1; d = 0; e = 1; f = 0; #10;
        a = 1; b = 1; c = 1; d = 0; e = 1; f = 1; #10;
        a = 1; b = 1; c = 1; d = 1; e = 0; f = 0; #10;
        a = 1; b = 1; c = 1; d = 1; e = 0; f = 1; #10;
        a = 1; b = 1; c = 1; d = 1; e = 1; f = 0; #10;
        a = 1; b = 1; c = 1; d = 1; e = 1; f = 1; #10;
        $finish;
    end
endmodule




아티팩트



실행 결과



a b c d e f o p q r
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 0 0 1 0
0 0 0 0 1 0 0 1 0 0
0 0 0 0 1 1 0 1 1 0
0 0 0 1 0 0 1 0 0 0
0 0 0 1 0 1 1 0 1 0
0 0 0 1 1 0 1 1 0 0
0 0 0 1 1 1 1 1 1 0
0 0 1 0 0 0 0 0 1 0
0 0 1 0 0 1 0 0 0 1
0 0 1 0 1 0 0 1 1 0
0 0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