0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

blocklyでverilog その3

Posted at

概要

blocklyでverilog、やってみた。
練習問題、やってみた。

練習問題

半加算器を書いて、iverilogで検証せよ。

写真

image.png

生成したコード

module x (input a, input b, output c, output d);
assign c = (a ^ b);
assign d = (a & b);
endmodule

テストベンチを書く。

module test;
	reg a,
		b;
	x u(.a(a), .b(b), .c(c), .d(d));
	initial
	begin
		$display(" a b c d");
		$monitor(" %b %b %b %d", a, b, c, d);
			a = 0;
			b = 0;
		#10;
			a = 0;
			b = 1;
		#10;
			a = 1;
			b = 0;
		#10;
			a = 1;
			b = 1;
		#10;
		$finish;
	end
endmodule

iverilogでコンパイル実行

>iverilog block1.v

>vvp a.out
 a b c d
 0 0 0 0
 0 1 1 0
 1 0 1 0
 1 1 0 1
block1.v:27: $finish called at 40 (1s)

生成したフローのxml

<xml xmlns="http://www.w3.org/1999/xhtml">
  <variables>
    <variable type="" id="kVo~|WbMj?w*jRaeu?IZ">c</variable>
    <variable type="" id="=/oZ/]#8U{fqxA)!ixB$">d</variable>
    <variable type="" id="US6mg:+!q~Nw!qA4u~S)">a</variable>
    <variable type="" id="]wH}w0D?XRXn4i7NX^Wq">b</variable>
  </variables>
  <block type="module_dec" id="4SExhY1)y(jwDTBa0Nj+" x="32" y="21">
    <field name="modName">x</field>
    <field name="varNames">input a, input b, output c, output d</field>
    <next>
      <block type="assign_block" id="PVW_J{B2Etv`jhQBz+6a">
        <field name="var" id="kVo~|WbMj?w*jRaeu?IZ" variabletype="">c</field>
        <value name="NAME">
          <block type="logic_operation" id="bzrS@SuPHa6[u4Z8qCcx">
            <field name="OP">XOR</field>
            <value name="A">
              <block type="variables_get" id="B8;pCVg~4X3%ha/=,V-|">
                <field name="VAR" id="US6mg:+!q~Nw!qA4u~S)" variabletype="">a</field>
              </block>
            </value>
            <value name="B">
              <block type="variables_get" id="xEyk9Z[cB:g~HbM=ZMPm">
                <field name="VAR" id="]wH}w0D?XRXn4i7NX^Wq" variabletype="">b</field>
              </block>
            </value>
          </block>
        </value>
        <next>
          <block type="assign_block" id=";nO;o[],=M)~nH0n0;8C">
            <field name="var" id="=/oZ/]#8U{fqxA)!ixB$" variabletype="">d</field>
            <value name="NAME">
              <block type="logic_operation" id=".c)8pX*$AcfRpLMGhF38">
                <field name="OP">AND</field>
                <value name="A">
                  <block type="variables_get" id="T~_-pvJ5BT)Iz}X_m:pj">
                    <field name="VAR" id="US6mg:+!q~Nw!qA4u~S)" variabletype="">a</field>
                  </block>
                </value>
                <value name="B">
                  <block type="variables_get" id="+{yuU=6cL1oDiC(;*c.2">
                    <field name="VAR" id="]wH}w0D?XRXn4i7NX^Wq" variabletype="">b</field>
                  </block>
                </value>
              </block>
            </value>
            <next>
              <block type="end_module" id="ODsu=)XrOwDd2b~P;iY-"></block>
            </next>
          </block>
        </next>
      </block>
    </next>
  </block>
</xml>

以上。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?