private void TestTransferMemBtn_Click(object sender, EventArgs e) { SyncTransferFunctionMem sm = new SyncTransferFunctionMem(2, 1, TransferFunctionWrapper.MemoryActivationType.UNIPOLAR_SIGMOID, "aa"); if (!sm.writeVHDL("")) { MessageBox.Show("Error writing TransferMem file"); return; } MessageBox.Show("File written."); return; }
/// <summary> /// Create a TransferFunctionWrapper entity /// </summary> /// <param name="_numIntBits">The number of integer bits to use</param> /// <param name="_numFracBits">The number of fractional bits to use</param> /// <param name="_activationType">The activation type to implement</param> public TransferFunctionWrapper(int _numIntBits, int _numFracBits, MemoryActivationType _activationType) { this.name = String.Format("TFWrapper_{0}", Utilities.GetDescription <MemoryActivationType>(_activationType)); this.activationType = _activationType; /*Init IO ports*/ this.addr = new Port(Port.portDirection.IN, "addr", Utilities.VHDLDataType.SIGNED_FIXED_POINT, _numIntBits, -1 * _numFracBits); this.clk = new Port(Port.portDirection.IN, "clk", Utilities.VHDLDataType.STD_LOGIC, 0, 0); this.data = new Port(Port.portDirection.OUT, "data", Utilities.VHDLDataType.SIGNED_FIXED_POINT, _numIntBits, -1 * _numFracBits); /*Init internal signals*/ if (activationType == MemoryActivationType.LINEAR) { /*No internal signals needed!*/ this.inverseAddr = null; this.memAddr = null; this.memOut = null; this.memOut_sfixed = null; this.oneMinusMemOut_sfixed = null; this.outSig = null; this.sm = null; this.isLinear = true; } else { this.inverseAddr = new Signal("inverseAddr", Utilities.VHDLDataType.SIGNED_FIXED_POINT, null, _numIntBits, _numFracBits * -1); this.inverseAddrTemp = new Signal("inverseAddrTemp", Utilities.VHDLDataType.UNSIGNED, null, _numIntBits + _numFracBits, 0); this.memAddr = new Signal("memAddr", Utilities.VHDLDataType.STD_LOGIC_VECTOR, null, _numIntBits + _numFracBits - 1, 0); this.memOut = new Signal("memOut", Utilities.VHDLDataType.STD_LOGIC_VECTOR, null, _numFracBits + _numIntBits, 0); this.memOut_sfixed = new Signal("memOut_sfixed", Utilities.VHDLDataType.SIGNED_FIXED_POINT, null, _numIntBits, _numFracBits * -1); this.oneMinusMemOut_sfixed = new Signal("oneMinusMemOut_sfixed", Utilities.VHDLDataType.SIGNED_FIXED_POINT, null, _numIntBits, _numFracBits * -1); this.outSig = new Signal("outSig", Utilities.VHDLDataType.SIGNED_FIXED_POINT, null, _numIntBits, _numFracBits * -1); this.sm = new SyncTransferFunctionMem(_numIntBits, _numFracBits, activationType, String.Format("TFWrap_Mem_{0}", Utilities.GetDescription <MemoryActivationType>(activationType))); this.isLinear = false; } return; }