Method: HDLRuby::High::Std#initialize_lut
- Defined in:
- lib/HDLRuby/std/function_generator.rb
#initialize_lut(func, otyp, awidth, xrange, yrange) ⇒ Array
Make an array consists of a point of any activation function.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/HDLRuby/std/function_generator.rb', line 125 def initialize_lut(func, otyp, awidth, xrange, yrange) # Compute the x step between discret values. xstep = (xrange.last-xrange.first)/(2 ** awidth) # Generate the discrete set of x values. x_values = xrange.step(xstep) # Generate the table. table = x_values.map do |x_value| ((func.call(x_value)-yrange.first)/(yrange.last-yrange.first)* 2**otyp.width).to_i.to_expr.as(otyp) end return table end |