diff --git a/hls4ml/model/types.py b/hls4ml/model/types.py index 07084f8f85..2e94135038 100644 --- a/hls4ml/model/types.py +++ b/hls4ml/model/types.py @@ -104,9 +104,12 @@ def __str__(self): args = [self.width, self.integer, self.rounding_mode, self.saturation_mode, self.saturation_bits] args = ','.join([str(arg) for arg in args if arg is not None]) typestring = '{signed}fixed<{args}>'.format(signed='u' if not self.signed else '', args=args) + typestring = 'ap_{signed}fixed<{args}>'.format(signed='u' if not self.signed else '', args=args) return typestring def __eq__(self, other): + if not isinstance(other, FixedPrecisionType): + return False eq = self.width == other.width eq = eq and self.integer == other.integer eq = eq and self.fractional == other.fractional diff --git a/hls4ml/writer/vivado_accelerator_writer.py b/hls4ml/writer/vivado_accelerator_writer.py index d424fc2f35..dcf9658035 100644 --- a/hls4ml/writer/vivado_accelerator_writer.py +++ b/hls4ml/writer/vivado_accelerator_writer.py @@ -45,7 +45,7 @@ def write_axi_wrapper(self, model): indent + 'in_struct(const T_in& data, const ap_uint<1>& last){this->data = data; this->last = last;};\n' + \ indent + 'in_struct(){this->data = 0; this->last = 0;};\n' + \ indent + 'friend std::ostream& operator<<(std::ostream& stream, const in_struct& in)\n' + \ - indent + '{ return stream << "{ data: " << in.data << ", last: " << in.last << " }" << std::endl; }\n' + \ + indent + '{ return stream << "{ data: " << float(in.data) << ", last: " << float(in.last) << " }" << std::endl; }\n' + \ indent + 'operator float() const {return this->data;}\n' + \ indent + 'operator double() const {return this->data;}\n' + \ indent + 'in_struct(float data) {this->data = data; this->last = 0;}\n' + \ @@ -57,7 +57,7 @@ def write_axi_wrapper(self, model): indent + 'out_struct(const T_out& data, const ap_uint<1>& last){this->data = data; this->last = last;};\n' + \ indent + 'out_struct(){this->data = 0; this->last = 0;};\n' + \ indent + 'friend std::ostream& operator<<(std::ostream& stream, const out_struct& out)\n' + \ - indent + '{ return stream << "{ data: " << out.data << ", last: " << out.last << " }" << std::endl; }\n' + \ + indent + '{ return stream << "{ data: " << float(out.data) << ", last: " << float(out.last) << " }" << std::endl; }\n' + \ indent + 'operator float() const {return this->data;}\n' + \ indent + 'operator double() const {return this->data;}\n' + \ indent + 'out_struct(float data) {this->data = data; this->last = 0;}\n' + \