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?

プロデル、調査 その111

Last updated at Posted at 2025-08-06

概要

プロデルが、CLRらしいので、調べて見た。
練習問題やってみた。

練習問題

verilogを高位合成する、インタープリターを書け。

サンプルコード


[ソース]を、高位合成する手順
	マップは{}
	文は、ソースを「
」で区切ったもの
	文を行へそれぞれ繰り返す
		項目は、行を、「 」で区切ったもの
		項目(1)について分岐
		「lin」の場合
			【n:整数】は、項目(2)
			縦を1からnまで増やしながら繰り返す
				マップ(縦)は{}
				横を1からnまで増やしながら繰り返す
					マップ(縦)(横)は、0
				そして
			そして
		「code」の場合
			【c:整数】は、項目(3)
			項目(2)について分岐
			「00」の場合
				マップ(1)(1)は、c
			「01」の場合
				マップ(1)(2)は、c
			「02」の場合
				マップ(2)(1)は、c
			「03」の場合
				マップ(2)(2)は、c
			その他の場合
			そして
		その他の場合
		そして
	そして
	「module lut(input wire [[]1:0[]] data, output reg  code);
    always @(data)
    begin
        case(data)
        2'h00: 
        	code = 1'h0[マップ(1)(1)];
        2'h01: 
        	code = 1'h0[マップ(1)(2)];
        2'h02: 
        	code = 1'h0[マップ(2)(1)];
        2'h03: 
        	code = 1'h0[マップ(2)(2)];
        endcase
    end
endmodule」を出力して改行	
終わり

「
lut 3
lin 2
lout 1
code 00 00
code 01 01
code 02 01
code 03 00
」を、高位合成する




実行結果

module lut(input wire [1:0] data, output reg  code);
    always @(data)
    begin
        case(data)
        2'h00: 
        	code = 1'h00;
        2'h01: 
        	code = 1'h01;
        2'h02: 
        	code = 1'h01;
        2'h03: 
        	code = 1'h00;
        endcase
    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?