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?

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

Last updated at Posted at 2021-01-14

概要

高位合成言語アセンブラを作る。
7セグメントLEDのデコーダを書いてみる。

コードを投入。

lut 12
lin 4
lout 8
code 0 7E
code 1 30
code 2 6d
code 3 79
code 4 33
code 5 5b
code 6 5f
code 7 72
code 8 7f
code 9 7b

生成したコード

module lut(input wire [3:0] data, output reg [7:0] code);
	always @(data)
	begin
		case(data)
		4'h0:
			code = 8'h7E;
		4'h1:
			code = 8'h30;
		4'h2:
			code = 8'h6d;
		4'h3:
			code = 8'h79;
		4'h4:
			code = 8'h33;
		4'h5:
			code = 8'h5b;
		4'h6:
			code = 8'h5f;
		4'h7:
			code = 8'h72;
		4'h8:
			code = 8'h7f;
		4'h9:
			code = 8'h7b;
		endcase
	end
endmodule

module testbench;
	reg [3:0] data;
	wire [7:0] code;
	lut u(.data(data), .code(code));
	initial
	begin
		$display("data code");
		$monitor("%h  %b", data, code);
		data = 4'h0; #10;
		data = 4'h1; #10;
		data = 4'h2; #10;
		data = 4'h3; #10;
		data = 4'h4; #10;
		data = 4'h5; #10;
		data = 4'h6; #10;
		data = 4'h7; #10;
		data = 4'h8; #10;
		data = 4'h9; #10;
		$finish;
	end
endmodule

実行結果


data code
0  01111110
1  00110000
2  01101101
3  01111001
4  00110011
5  01011011
6  01011111
7  01110010
8  01111111
9  01111011


成果物

以上。

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?