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?

More than 3 years have passed since last update.

windowsでiverilog その58

Last updated at Posted at 2020-07-26

概要

windowsでiverilogやってみた。
配列の作法、調べてみた。

配列の作法

memoryを想定。
2次元は、無い。
initialで、初期化。
wireも、できそうだが、不明。

サンプルコード

module ram(input clk, input load, input [11:0] addr, input [15:0] d, output reg [15:0] q);
	reg [15:0] mem[256:0];
	initial
	begin
		mem[0] = 16'h1000;//push 0
		mem[1] = 16'h300f;//set 15
		mem[2] = 16'h200f;//get 15
		mem[3] = 16'h101a;//push 26
		mem[4] = 16'hf00f;//>
		mem[5] = 16'h5005;//if 5 
		mem[6] = 16'h200f;//get 15
		mem[7] = 16'h1061;//push 97
		mem[8] = 16'hf000;//+
		mem[9] = 16'he000;//out
		mem[10] = 16'h200f;//get 15
		mem[11] = 16'h1001;//push 1
		mem[12] = 16'hf000;//+
		mem[13] = 16'h300f;//set 15
		mem[14] = 16'h4002;//jp  2
		mem[15] = 16'h0000;//i
	end
	always @(posedge clk)
	begin
		if (load)
		begin
			mem[addr] <= d;
		end
		q <= mem[addr];
	end
endmodule

以上。

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?