0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

windowsでiverilog その218

0
Posted at

概要 

windowsでiverilogやってみた。
SPI masterな、verilog見つけたので、テストベンチ書いてみた。
$test$plusargs使ってみた。

参考にしたページ

サンプルコード

module test;
	reg clk = 0;
	reg spi_rw;
	reg [6:0] spi_addr;
	reg [7:0] spi_data;
	reg start = 0;
	wire spi_start;
	wire cs, 
		sck, 
		sdo;
	wire [6:0] sdo_addr;
	wire [7:0] spi_rdbk;
	spi_master #(.tsckw(5)) p(.clk(clk), .spi_start(spi_start), .spi_read(spi_rw), .spi_addr(spi_addr), .spi_data(spi_data), .cs(cs), .sck(sck), .sdo(sdo),.sdi(sdi), .sdo_addr(sdo_addr),.spi_rdbk(spi_rdbk));
	strobe_gen t(.I_clk(clk), .I_signal(start), .O_strobe(spi_start));
	initial 
	begin
		if ($test$plusargs("vcd")) 
		begin
			$dumpfile("test.vcd");
			$dumpvars(5, test);
		end
		spi_rw = 0;
		spi_addr = 7'h04;
		spi_data = 8'h21;
		while ($time < 8000) 
		begin
			#10;
		end
		$finish;
	end
	always 
		#5 
			clk = ~clk;
	always @(posedge clk) 
	begin
		if (($time > 50) && ($time < 100))
			start <= 1;
		else
			start <= 0;
	end
endmodule




写真

image.png

以上。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?