1
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?

高位合成言語アセンブラを作る。 その20

Last updated at Posted at 2021-02-15

概要

高位合成言語アセンブラを作る。
俺言語から、verilogコードを生成する。

コードを投入。

10 ?="helloworld"
20 #=20

生成したコード

module ore(input clk, input rst, output reg [7:0] out);
	reg [7:0] pc;
	reg [7:0] mod;
	always @(posedge clk)
	begin
		if (!rst)
		begin
			pc <= 10;
			mod <= 0;
		end
		else
		begin
			case (pc)
			10:
			begin
				out <= "h";
				pc <= 11;
			end
			11:
			begin
				out <= "e";
				pc <= 12;
			end
			12:
			begin
				out <= "l";
				pc <= 13;
			end
			13:
			begin
				out <= "l";
				pc <= 14;
			end
			14:
			begin
				out <= "o";
				pc <= 15;
			end
			15:
			begin
				out <= "w";
				pc <= 16;
			end
			16:
			begin
				out <= "o";
				pc <= 17;
			end
			17:
			begin
				out <= "r";
				pc <= 18;
			end
			18:
			begin
				out <= "l";
				pc <= 19;
			end
			19:
			begin
				out <= "d";
				pc <= 20;
			end
			20:
			begin
				pc <= 20;
			end
  			endcase
		end
	end
endmodule
module test;
	reg clk,
		rst;
	wire [7:0] out;
	ore u(.clk(clk), .rst(rst), .out(out));
	initial
	begin
		clk = 0;
		rst = 1;
		$monitor("%s", out);
		#2
			rst = 0;
		#2
			rst = 1;
		#2500
			$finish;
	end
	always
		#1
			clk = ~clk;
endmodule


成果物

以上。

1
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
1
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?