シミュレーション

Verilogを使ってみた

2011年7月2日

今の時代、デジタル回路を考える際、HDL (Hardware Description Language)を会得するのは必須のようらしい。FGPAなどの応用範囲もある。覚えておいて損はない、言語だろう。

VHDLとVerilogの両方を試してみたが、Verilogの方が自分には合っているようだ。

とりあえず、MacOSXで環境を構築してみた。次の2つのツールが必要。

Icarus Verilog
GTKwave

Verilogの入門としては、以下のサイトが参考になった。

新居良祐サポートページ - Verilog-HDL入門

MacOSXの場合、.bash_profileを編集して、
PATH=/Developer/Simulator/Icarus/bin:/Developer/Simulator/GTKwave/bin:$PATH
export PATH

のようにしておくことが必要。コンパイルは「iverilog -o xxx -s XXX xxx.v 」で、シミュレートは「vvp xxx」で、波形の表示は「gtkwave xxx.vcd」のようにして、すべてコンソールで扱う。GTKwaveでは、波形の表示の際、メニュー:「search」→「signal search tree」から、波形を表示させるシグナルを選択する必要がある。

D-FFも、Verilogでシミュレートできた。ソースコードは以下の通り。
module DFFTEST;

reg d,c;
wire q;

DFF bbb (d,c,q);

initial begin
	$dumpfile("dfftest.vcd");
	$dumpvars(0,DFFTEST);
	$monitor("%t; d=%b, c=%b, q=%b",$time,d,c,q);
	
		d=1;c=0;
	#10	d=1;c=1;
	#10	d=1;c=0;
	#10	d=0;c=0;
	#10	d=0;c=1;
	#10	d=0;c=0;
	#10	$finish;
end

endmodule

module DFF (D,C,Q);

input D, C;
output Q;

wire nc,nnc,o11,o12,o21,o22,o31,o32,o41,o42;

	assign nc=!C;
	assign nnc=!nc;
	assign o11=!(D&nc);
	assign o12=!(o11&nc);
	assign o21=!(o22&o11);
	assign o22=!(o21&o12);
	assign o31=!(o21&nnc);
	assign o32=!(o31&nnc);
	assign o41=!(o42&o31);
	assign o42=!(o41&o32);
	assign Q=o41;

endmodule

実行結果は、以下の通り。
VCD info: dumpfile dfftest.vcd opened for output.
                   0; d=1, c=0, q=x
                  10; d=1, c=1, q=1
                  20; d=1, c=0, q=1
                  30; d=0, c=0, q=1
                  40; d=0, c=1, q=0
                  50; d=0, c=0, q=0

FPGAなどで効率の良い回路を組むためには、もっと勉強しないといけないだろうけれど、自作マイコンのシミュレーターとして使うには、学ぶべき機能は一通りマスターしたように思う。とりあえずは、使ってみよう。プログラミングは習うより慣れろだ。これを使った方が、回路設計が大幅に効率よく進みそうな気がする。HDLとは逆の考え方をするLabViewっていったい何だったのだろう?

コメント

Katsumi (2011年7月2日 20:33:24)

Delayは、
assign #5 nc=!C;
のように。

pandora jewelry (2018年8月15日 14:23:18)

http://www.christianlouboutinredbottoms.us.com/ red bottoms
http://www.chrome--hearts.us.com/ chrome hearts bracelet
http://www.jordan--11.us.com/ jordan retro 11
http://www.nikeairmax-95.us.com/ air max 95 mens
http://www.asics--shoes.us.com/ asics shoes
http://www.mulberrys.org.uk/ mulberry handbags
http://www.coachbags-outlet.us.com/ coach bags
http://www.louboutinredbottoms.us.com/ louboutin shoes
http://www.nike-airmax270.us.com/ air max
http://www.nikeairmax-90.us.com/ air max 90
http://www.northfacejacketoutlets.us.com/ north face outlet
http://www.adidasoriginalsultraboost.us.com/ adidas originals ultra boost
http://www.pandora--jewelrys.us.com/ pandora earrings
http://www.jordans11shoes.us.com/ air jordan
http://www.pandora--rings.us.com/ Pandora Bracelet
http://www.jordan11spacejams.us.com/ jordan 11
http://www.monclerjacket.org.uk/ moncler coat
http://www.moncler--jacket.us.com/ moncler
http://www.mcms.us.com/ mcm backpack
http://www.under-armour-shoes.us.com/ under armour
http://www.barbourjackets.co.uk/ barbour coats
http://www.uggsformen.us.com/ ugg boots
http://www.asicss.us.com/ asics outlet
http://www.air-max-270.us.com/ nike air max 270 men
http://www.nikeairvapormaxflyknit.us.com/ vapormax
http://www.nikeairmax270.org.uk/ air max 270
http://www.nikelebron15.us.com/ lebron
http://www.adidasnmd-womens.us.com/ adidas nmd womens
http://www.curry4-shoes.us.com/ stephen curry shoes
http://www.longchampbag.us.com/ longchamp backpack
http://www.fitflop--shoes.us.com/ fitflop shoes
http://www.adidas-superstarshoes.us.com/ adidas superstar shoes
http://www.lebron15-shoes.us.com/ basketball shoes
http://www.chromeheartsjewelrys.us.com/ chrome hearts bracelet
http://www.nike-huaraches.us.com/ huaraches
http://www.adidasoriginalsnmd.us.com/ adidas nmd r1
http://www.goyardbag.us.com/ goyard bag
http://www.pandora-jewelrybracelet.us.com/ pandora jewelry
http://www.birkenstock--sandals.us.com/ birkenstock sandals
http://www.nike-airmax-2018.us.com/ nike air max 2018
http://www.katespade--outlet.us.com/ kate spade purses
http://www.mbts.us.com/ mbt womens shoes
http://www.huaraches.us.com/ huarache
http://www.skechers--shoes.us.com/ skechers women
http://www.birkenstocksandalssale.us.com/ birkenstock shoes
http://www.yeezyboost350--v2.us.com/ yeezy
http://www.michaelkors-handbagss.us.com/ michael kors handbags
http://www.skecherss.us.com/ skechers
http://www.pandoraearrings.us.com/ pandora earrings
http://www.true--religion.us.com/ true religion outlet
http://www.jimmychooheels.us.com/ jimmy choo shoes
http://www.prada--bags.us.com/ prada wallet
http://www.balenciagas-sneakers.us.com/ balenciaga sneakers
http://www.pandora-charmsjewelry.us.com/ pandora earrings
http://www.bvlgaris.us.com/ bvlgari ring
http://www.rayban--glasses.us.com/ ray ban
http://www.pandoras-jewelrys.us.com/ pandora rings
http://www.swarovskisjewelry.us.com/ swarovski pen
http://www.truereligion--jeans.us.com/ true religion
http://www.skechersuk.co.uk/ skechers
http://www.hermes--belt.us.com/ hermes belt men
http://www.ray--bansunglassess.us.com/ ray ban eyeglasses
http://www.monclers.uk/ moncler jacket womens
http://www.swarovskis.us.com/ swarovski rings
http://www.adidasnmdrunnerr1.us.com/ didas ultra boost
http://www.adidas-yeezy-shoes.us.com/ Yeezy
http://www.fitflopsshoes.us.com/ fitflop sandals
http://www.pandorajewelryrings.us.com/ pandora necklace
http://www.burberrys.org.uk/ burberry scarf
http://www.jordan11.co.uk/ jordan retro
http://www.nikekdshoes.us.com/ nike kd
http://www.monclerjacketwomens.us.com/ moncler jacket mens
http://www.redbottom--shoes.us.com/ louboutin
http://www.airmax90shoes.us.com/ nike air max
http://www.polo-ralph-lauren.org.uk/ ralph lauren shirts
http://www.cartier-bracelet.us.com/ cartier sunglasses
http://www.nikeairmax-97.us.com/ nike air max 97
http://www.nikeairmax97.co.uk/ nike air max 97
http://www.kd10-shoes.us.com/ kd shoes
http://www.kyrie-4.us.com/ nike kyire
http://www.airjordan11spacejam.us.com/ jordan shoes
http://www.kevin-durant-shoes.us.com/ kevin durant shoes
http://www.yeezyboost350v2.co.uk/ adidas yeezy
http://www.northface-jacket.us.com/ north face outlet
http://www.ultra--boost.us.com/ ultra boost
http://www.vapormaxs.us.com/ vapormax
http://www.uggs--boots.us.com/ ugg
http://www.salomonspeedcross3.us.com/ salomon speedcross 3
http://www.katespadepurses.us.com/ kate spade purses
http://www.supremeshirt.us.com/ supreme shirt
http://www.eccoshoesoutlets.us.com/ ecco outlet
http://www.polo-ralphlauren-outlet.us.com/ ralph lauren
http://www.oakley--sunglassess.us.com/ oakley eyeglasses
http://www.pandoras-uk.co.uk/ pandora charms
http://www.goyardbackpack.us.com/ goyard bag
http://www.katespadebags.us.com/ kate spade handbags
http://www.air-max-95.us.com/ nike air max 95
http://www.montblancs.us.com/ mont blanc outlet
http://www.supreme--clothing.us.com/ supreme clothing
http://www.lacosteshirts.us.com/ lacoste shoes
http://www.adidasyeezys.org.uk/ adidas yeezy
http://www.ralphlaurenspoloshirts.us.com/ ralph lauren
http://www.pandorasjewelry.co.uk/ pandora rings
http://www.valentino--shoes.us.com/ valentino sandals
http://www.airmax-2018.us.com/ air max 90
http://www.adidas-yeezyboost350.us.com/ adidas yeezy
http://www.ferragamoshoess.us.com/ ferragamo shoes
http://www.hermesbirkin-handbags.us.com/ Hermes Handbags
http://www.salomon-boots.us.com/ salomon
http://www.ed-hardys.us.com/ ed hardy clothing
http://www.burberry--scarf.us.com/ burberry shirt
http://www.prada--handbags.us.com/ prada purse
http://www.adidasnmds.co.uk/ adidas nmd
http://www.adidasyeezy-350.us.com/ yeezy
http://www.james-hardenshoes.us.com/ james harden shoes
http://www.nike--shoes.co.uk/ nike air max 97
http://www.balenciaga--shoes.us.com/ balenciaga
http://www.adidas-ultraboost.us.com/ adidas ultra boost
http://www.new--balance.us.com/ new balance
http://www.nikeair-max.co.uk/ nike air max 95
http://www.ralphlauren--polo.us.com/ ralph lauren
http://www.redbottoms-louboutin.us.com/ louboutin shoes
http://www.longchampbackpack.us.com/ longchamp handbag
http://www.rayban-glasses.us.com/ ray ban glasses
http://www.airmax95.co.uk/ nike air max 95 mens
http://www.oakley--glasses.us.com/ oakley glasses
http://www.pandora-jewelrysale.us.com/ pandora jewelry official site
http://www.monclerjacketmens.us.com/ moncler,moncler jacket
http://www.jordanretro11-shoes.us.com/ jordan 11
http://www.pandorauk.us.com/ pandora bracelet
http://www.ray--ban.us.com/ ray ban sunglasses
http://www.pandorajewelryscharms.us.com/ pandora Charms
http://www.fitflop--sandals.us.com/ fitflop
http://www.airmax270.co.uk/ nike vapormax
http://www.moncler-coat.us.com/ moncler jacket
http://www.celines.us.com/ celine purse
http://www.uggs-forwomen.us.com/ ugg boots
http://www.adidas--shoes.co.uk/ adidas
http://www.air-max-90.us.com/ air max
http://www.burberry-bags.us.com/ burberry bags
http://www.yeezyboost350shoes.us.com/ adidas yeezy
http://www.salomonshoes.co.uk/ salomon skis
http://www.kyrie-irving-shoes.us.com/ kyrie 4
http://www.nikeair-max90.co.uk/ nike air max 2018
http://www.stephen-curry-shoes.us.com/ curry shoes
http://www.coach--bags.us.com/ coach outlet
http://www.pumarihannafenty.us.com/ puma shoes
http://www.ugg--slippers.us.com/ ugg slippers
http://www.nike--vapormax.us.com/ nike vapormax
http://www.michael-kors-bags.us.com/ michael kors
http://www.chromehearts-jewelry.us.com/ chrome hearts jewelry
http://www.barbours.org.uk/ barbour jacket
http://www.mulberry-handbags.us.com/ mulberry bayswater
http://www.salomon--shoes.us.com/ Salomon xa pro 3d
http://www.air-max-97.us.com/ air max 97
http://www.fitflops-sale.us.com/ fitflop sandals
http://www.mcm--bags.us.com/ mcm backpack
http://www.salvatore-ferragamo.us.com/ ferragamo shoes men
てしまうと

コメント送信