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?

More than 1 year has passed since last update.

概要

paiza.ioでelixirやってみた。
FPGAの高位合成書いてみた。
練習問題やってみた。

練習問題

活性化関数reluテーブルを合成せよ。

サンプルコード



IO.puts """
module Relu(input [7:0] in, output reg [7:0] out);
	always @ *
	begin
	case (in)
"""	
for i <- -127..127 do
    if i < 0 do
        IO.puts "-8'sd #{abs(i)}: out<= 8'sd 0;"
    else
	    IO.puts "8'sd #{i}: out<= 8'sd #{i};"
    end
end
	IO.puts """
	endcase
	end
endmodule
"""


実行結果

module Relu(input [7:0] in, output reg [7:0] out);
	always @ *
	begin
	case (in)

-8'sd 127: out<= 8'sd 0;
-8'sd 126: out<= 8'sd 0;
-8'sd 125: out<= 8'sd 0;
-8'sd 124: out<= 8'sd 0;
-8'sd 123: out<= 8'sd 0;
-8'sd 122: out<= 8'sd 0;
-8'sd 121: out<= 8'sd 0;
-8'sd 120: out<= 8'sd 0;
-8'sd 119: out<= 8'sd 0;
-8'sd 118: out<= 8'sd 0;
-8'sd 117: out<= 8'sd 0;
-8'sd 116: out<= 8'sd 0;
-8'sd 115: out<= 8'sd 0;
-8'sd 114: out<= 8'sd 0;
-8'sd 113: out<= 8'sd 0;
-8'sd 112: out<= 8'sd 0;
-8'sd 111: out<= 8'sd 0;
-8'sd 110: out<= 8'sd 0;
-8'sd 109: out<= 8'sd 0;
-8'sd 108: out<= 8'sd 0;
-8'sd 107: out<= 8'sd 0;
-8'sd 106: out<= 8'sd 0;
-8'sd 105: out<= 8'sd 0;
-8'sd 104: out<= 8'sd 0;
-8'sd 103: out<= 8'sd 0;
-8'sd 102: out<= 8'sd 0;
-8'sd 101: out<= 8'sd 0;
-8'sd 100: out<= 8'sd 0;
-8'sd 99: out<= 8'sd 0;
-8'sd 98: out<= 8'sd 0;
-8'sd 97: out<= 8'sd 0;
-8'sd 96: out<= 8'sd 0;
-8'sd 95: out<= 8'sd 0;
-8'sd 94: out<= 8'sd 0;
-8'sd 93: out<= 8'sd 0;
-8'sd 92: out<= 8'sd 0;
-8'sd 91: out<= 8'sd 0;
-8'sd 90: out<= 8'sd 0;
-8'sd 89: out<= 8'sd 0;
-8'sd 88: out<= 8'sd 0;
-8'sd 87: out<= 8'sd 0;
-8'sd 86: out<= 8'sd 0;
-8'sd 85: out<= 8'sd 0;
-8'sd 84: out<= 8'sd 0;
-8'sd 83: out<= 8'sd 0;
-8'sd 82: out<= 8'sd 0;
-8'sd 81: out<= 8'sd 0;
-8'sd 80: out<= 8'sd 0;
-8'sd 79: out<= 8'sd 0;
-8'sd 78: out<= 8'sd 0;
-8'sd 77: out<= 8'sd 0;
-8'sd 76: out<= 8'sd 0;
-8'sd 75: out<= 8'sd 0;
-8'sd 74: out<= 8'sd 0;
-8'sd 73: out<= 8'sd 0;
-8'sd 72: out<= 8'sd 0;
-8'sd 71: out<= 8'sd 0;
-8'sd 70: out<= 8'sd 0;
-8'sd 69: out<= 8'sd 0;
-8'sd 68: out<= 8'sd 0;
-8'sd 67: out<= 8'sd 0;
-8'sd 66: out<= 8'sd 0;
-8'sd 65: out<= 8'sd 0;
-8'sd 64: out<= 8'sd 0;
-8'sd 63: out<= 8'sd 0;
-8'sd 62: out<= 8'sd 0;
-8'sd 61: out<= 8'sd 0;
-8'sd 60: out<= 8'sd 0;
-8'sd 59: out<= 8'sd 0;
-8'sd 58: out<= 8'sd 0;
-8'sd 57: out<= 8'sd 0;
-8'sd 56: out<= 8'sd 0;
-8'sd 55: out<= 8'sd 0;
-8'sd 54: out<= 8'sd 0;
-8'sd 53: out<= 8'sd 0;
-8'sd 52: out<= 8'sd 0;
-8'sd 51: out<= 8'sd 0;
-8'sd 50: out<= 8'sd 0;
-8'sd 49: out<= 8'sd 0;
-8'sd 48: out<= 8'sd 0;
-8'sd 47: out<= 8'sd 0;
-8'sd 46: out<= 8'sd 0;
-8'sd 45: out<= 8'sd 0;
-8'sd 44: out<= 8'sd 0;
-8'sd 43: out<= 8'sd 0;
-8'sd 42: out<= 8'sd 0;
-8'sd 41: out<= 8'sd 0;
-8'sd 40: out<= 8'sd 0;
-8'sd 39: out<= 8'sd 0;
-8'sd 38: out<= 8'sd 0;
-8'sd 37: out<= 8'sd 0;
-8'sd 36: out<= 8'sd 0;
-8'sd 35: out<= 8'sd 0;
-8'sd 34: out<= 8'sd 0;
-8'sd 33: out<= 8'sd 0;
-8'sd 32: out<= 8'sd 0;
-8'sd 31: out<= 8'sd 0;
-8'sd 30: out<= 8'sd 0;
-8'sd 29: out<= 8'sd 0;
-8'sd 28: out<= 8'sd 0;
-8'sd 27: out<= 8'sd 0;
-8'sd 26: out<= 8'sd 0;
-8'sd 25: out<= 8'sd 0;
-8'sd 24: out<= 8'sd 0;
-8'sd 23: out<= 8'sd 0;
-8'sd 22: out<= 8'sd 0;
-8'sd 21: out<= 8'sd 0;
-8'sd 20: out<= 8'sd 0;
-8'sd 19: out<= 8'sd 0;
-8'sd 18: out<= 8'sd 0;
-8'sd 17: out<= 8'sd 0;
-8'sd 16: out<= 8'sd 0;
-8'sd 15: out<= 8'sd 0;
-8'sd 14: out<= 8'sd 0;
-8'sd 13: out<= 8'sd 0;
-8'sd 12: out<= 8'sd 0;
-8'sd 11: out<= 8'sd 0;
-8'sd 10: out<= 8'sd 0;
-8'sd 9: out<= 8'sd 0;
-8'sd 8: out<= 8'sd 0;
-8'sd 7: out<= 8'sd 0;
-8'sd 6: out<= 8'sd 0;
-8'sd 5: out<= 8'sd 0;
-8'sd 4: out<= 8'sd 0;
-8'sd 3: out<= 8'sd 0;
-8'sd 2: out<= 8'sd 0;
-8'sd 1: out<= 8'sd 0;
8'sd 0: out<= 8'sd 0;
8'sd 1: out<= 8'sd 1;
8'sd 2: out<= 8'sd 2;
8'sd 3: out<= 8'sd 3;
8'sd 4: out<= 8'sd 4;
8'sd 5: out<= 8'sd 5;
8'sd 6: out<= 8'sd 6;
8'sd 7: out<= 8'sd 7;
8'sd 8: out<= 8'sd 8;
8'sd 9: out<= 8'sd 9;
8'sd 10: out<= 8'sd 10;
8'sd 11: out<= 8'sd 11;
8'sd 12: out<= 8'sd 12;
8'sd 13: out<= 8'sd 13;
8'sd 14: out<= 8'sd 14;
8'sd 15: out<= 8'sd 15;
8'sd 16: out<= 8'sd 16;
8'sd 17: out<= 8'sd 17;
8'sd 18: out<= 8'sd 18;
8'sd 19: out<= 8'sd 19;
8'sd 20: out<= 8'sd 20;
8'sd 21: out<= 8'sd 21;
8'sd 22: out<= 8'sd 22;
8'sd 23: out<= 8'sd 23;
8'sd 24: out<= 8'sd 24;
8'sd 25: out<= 8'sd 25;
8'sd 26: out<= 8'sd 26;
8'sd 27: out<= 8'sd 27;
8'sd 28: out<= 8'sd 28;
8'sd 29: out<= 8'sd 29;
8'sd 30: out<= 8'sd 30;
8'sd 31: out<= 8'sd 31;
8'sd 32: out<= 8'sd 32;
8'sd 33: out<= 8'sd 33;
8'sd 34: out<= 8'sd 34;
8'sd 35: out<= 8'sd 35;
8'sd 36: out<= 8'sd 36;
8'sd 37: out<= 8'sd 37;
8'sd 38: out<= 8'sd 38;
8'sd 39: out<= 8'sd 39;
8'sd 40: out<= 8'sd 40;
8'sd 41: out<= 8'sd 41;
8'sd 42: out<= 8'sd 42;
8'sd 43: out<= 8'sd 43;
8'sd 44: out<= 8'sd 44;
8'sd 45: out<= 8'sd 45;
8'sd 46: out<= 8'sd 46;
8'sd 47: out<= 8'sd 47;
8'sd 48: out<= 8'sd 48;
8'sd 49: out<= 8'sd 49;
8'sd 50: out<= 8'sd 50;
8'sd 51: out<= 8'sd 51;
8'sd 52: out<= 8'sd 52;
8'sd 53: out<= 8'sd 53;
8'sd 54: out<= 8'sd 54;
8'sd 55: out<= 8'sd 55;
8'sd 56: out<= 8'sd 56;
8'sd 57: out<= 8'sd 57;
8'sd 58: out<= 8'sd 58;
8'sd 59: out<= 8'sd 59;
8'sd 60: out<= 8'sd 60;
8'sd 61: out<= 8'sd 61;
8'sd 62: out<= 8'sd 62;
8'sd 63: out<= 8'sd 63;
8'sd 64: out<= 8'sd 64;
8'sd 65: out<= 8'sd 65;
8'sd 66: out<= 8'sd 66;
8'sd 67: out<= 8'sd 67;
8'sd 68: out<= 8'sd 68;
8'sd 69: out<= 8'sd 69;
8'sd 70: out<= 8'sd 70;
8'sd 71: out<= 8'sd 71;
8'sd 72: out<= 8'sd 72;
8'sd 73: out<= 8'sd 73;
8'sd 74: out<= 8'sd 74;
8'sd 75: out<= 8'sd 75;
8'sd 76: out<= 8'sd 76;
8'sd 77: out<= 8'sd 77;
8'sd 78: out<= 8'sd 78;
8'sd 79: out<= 8'sd 79;
8'sd 80: out<= 8'sd 80;
8'sd 81: out<= 8'sd 81;
8'sd 82: out<= 8'sd 82;
8'sd 83: out<= 8'sd 83;
8'sd 84: out<= 8'sd 84;
8'sd 85: out<= 8'sd 85;
8'sd 86: out<= 8'sd 86;
8'sd 87: out<= 8'sd 87;
8'sd 88: out<= 8'sd 88;
8'sd 89: out<= 8'sd 89;
8'sd 90: out<= 8'sd 90;
8'sd 91: out<= 8'sd 91;
8'sd 92: out<= 8'sd 92;
8'sd 93: out<= 8'sd 93;
8'sd 94: out<= 8'sd 94;
8'sd 95: out<= 8'sd 95;
8'sd 96: out<= 8'sd 96;
8'sd 97: out<= 8'sd 97;
8'sd 98: out<= 8'sd 98;
8'sd 99: out<= 8'sd 99;
8'sd 100: out<= 8'sd 100;
8'sd 101: out<= 8'sd 101;
8'sd 102: out<= 8'sd 102;
8'sd 103: out<= 8'sd 103;
8'sd 104: out<= 8'sd 104;
8'sd 105: out<= 8'sd 105;
8'sd 106: out<= 8'sd 106;
8'sd 107: out<= 8'sd 107;
8'sd 108: out<= 8'sd 108;
8'sd 109: out<= 8'sd 109;
8'sd 110: out<= 8'sd 110;
8'sd 111: out<= 8'sd 111;
8'sd 112: out<= 8'sd 112;
8'sd 113: out<= 8'sd 113;
8'sd 114: out<= 8'sd 114;
8'sd 115: out<= 8'sd 115;
8'sd 116: out<= 8'sd 116;
8'sd 117: out<= 8'sd 117;
8'sd 118: out<= 8'sd 118;
8'sd 119: out<= 8'sd 119;
8'sd 120: out<= 8'sd 120;
8'sd 121: out<= 8'sd 121;
8'sd 122: out<= 8'sd 122;
8'sd 123: out<= 8'sd 123;
8'sd 124: out<= 8'sd 124;
8'sd 125: out<= 8'sd 125;
8'sd 126: out<= 8'sd 126;
8'sd 127: out<= 8'sd 127;
	endcase
	end
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?