speed2000 software learning and C++ learning

  1. Only virtual functions can be overridden;
    #include
    #include

using namespace std;

void process(int& i)
{
std::cout<<i<<" is lvalue"<<endl;
}
void process(int&& i)
{
std::cout<<i<<" is rvalue"<<endl;
}

template
void test(T&& i) //Universal references can only occur in templates
{ process(i); }

int main()
{
int i = 0;
process(i);
process(1);
return 0;
}

2) Variable parameter template example:
#include
#include

using namespace std;

template
ostream& printMsg(ostream& os,const T& t)
{
os <<t<<endl;
return os;
}

template<typename T,typename… Args>
ostream& printMsg(ostream& os,const T& t,Args… args )
{
os <<t<<" ";
printMsg(os,args…);
return os;
}

int main(void)
{
printMsg(cout,1,“string”,0.0,3L,“aaa”,“bbb”);
return 0;
}

//Why are the program declaration and definition of the template in the same file: Because module instantiation is performed before linking, if written separately, the definition file cannot be found; class templates can encapsulate general data containers; template parameters are divided
into
" "Type parameter" and "non-type parameter";
aggregate initialization is also called list initialization;

template<class T,size_t N>
class arr
{
public:
T dat[N];
T operator[](size_t n)
{
if(n < N)
{
return dat[n];
}
throw “index out of range!”;
}
};

template
struct A
{
public:
A(T v) : age(v){}
T age;
};

int main(void)
{
Aa = 20;
cout<<a.age<<endl;
return 0;
}

1) Introduction to through-hole processing technology, including resin plugged holes, half-plugged holes, back drilling, etc.;
PCB assembly process, including reflow soldering and wave soldering; main steps: incoming material inspection, component configuration, solder paste rinsing, patching , welding, detecting PCB welding, testing, etc.;
2) Transmission line:
transmission line definition, propagation method, transmission line equation;
two parameters: introduction to lumped parameters and distributed parameters;
in the teacher's courseware, why is the wavelength of alternating current with a frequency of 50hz 6000km? Formulas such as: C= λ f; or V = λ f //λ is read as lambda
300000km÷50=6000km.
The propagation speed of electromagnetic waves in the medium is only related to the dielectric constant of the medium;
the transmission delay τ = √LC;
propagation Method: TEM, TE, TM and an overview of their applications; the
meaning of the transmission line equation: the transmission line equation is also called the telegraph equation. According to the telegraph equation, the characteristic impedance, reflection coefficient, input impedance, etc. can be derived;
characteristic impedance: Z0=√L/ C;
3) Impedance calculation, stacking plan analysis, use of si9000 software;
definition of etching factors and their impact on signals, commonly used board specifications and copper foil specifications;
general principles of stacking: including signal layer and reflow layer, signal layer and signal Layers (pay attention to crosstalk) and various advantages and disadvantages in stack-up design rules;
learned the impedance control of two-layer boards: artificially design a reference plane; the
use of Si software and introduction to various parameters, how to use si9000 software to design a qualified stack-up structure;

//Function template learning
The use of function templates is also called instantiation;
inline and constexpr must be placed after the template parameter list and before the return type;
binding to a non-type integer parameter must be a constant expression. In the template definition, non-type Parameters are constant values;

2) Separate declaration and definition of class template:
#include
#include

using namespace std;

template
class A
{
public:
void printMsg(const T& a);
};

template
void A::printMsg(const T& a)
{
cout<<a<<endl;
}

int main(void)
{
A a;
a.printMsg(4);
return 0;
}

3) Member template case:

Day 3: Level learning:
Commonly used logic levels: TTL, CMOS, LVDS, ECL, PECL, SSTL, POD12; The
parameter relationship that logic levels should meet: Voh>Vih>Vt>Vil>Vol;
Precautions for using TTL : TTL level generally has serious overshoot, and will string 22Ω or 33Ω at the beginning. When the TTL level is floating, it defaults to high level, and a 1K resistor is used for pull-down; transistor-transistor logic level (TTL) transistor transistor logic [ˈɑːksaɪd
]
The full name of CMOS: Complementary metal oxide semiconductor (Complementary metal oxide semiconductor);
CMOS level is composed of pmos circuit and circuit nmos level;
CMOS has a larger noise container than TTL, and the input impedance is much greater than that of TTL ;
The conductivity of holes is lower than electrons, so the rise time of CMOS circuit is longer than the fall time;
sstl level: stub series termination logic; basically the same as HSTL;
[ˈsudoʊ]
POD level: pesudo open drain, pod and sstl maximum The difference lies in the terminal voltage at the receiving end, pod is vddq and sstl is vddq/2. POD can reduce i/o power consumption;

LVDS level: low voltage differential level, its main features are as follows:
low voltage slew rate: about 350mV, low current drive mode means that high-speed transmission can be achieved;
low power consumption: constant current source current drive (3.5mA), so that the transition period It has the least interference and generates less power consumption;
it has a relatively slow edge rate (dV/dt is about 0.3V/0.3nS, or 1V/ns); it has
differential mode input and output, which has anti-interference ability;
idle input Pins should be left floating to prevent input noise; idle output pins should be left floating to reduce power consumption;

ECL level (Emitter coupled logic), emitter coupled logic circuit;
ECL circuit is a non-saturated digital logic circuit. Its internal transistors work in the linear region or cut-off region, so it is one of the fastest circuit forms;
ECL The circuit works with negative voltage, which is characterized by fast speed, strong driving ability, low noise, and easy integration. The disadvantage is large DC power consumption;

CML level (current mode logic) is internally matched, in the form of differential lines, the speed reaches 3G, and can only be point-to-point;
GTL level (Gunning Transceiver Logic) radio transceiver logic, which is characterized by a comparator structure as the input;
HSTL level Mainly used in QDR memory, using input and output comparator structure;

Differential level interconnection:
Take LVDS interconnection as an example: If it is DC matching, you need to add a 100Ω resistor at the receiving end; if it is AC matching, it is not needed, but pay attention to whether there is a DC bias voltage. If there is no need to add an additional 1.2V;

Day 4: Eye diagram, S parameters and reflection learning
. Comparison of high-speed serial bus and parallel bus: the main electrical specifications have changed, and loss dominates;
eye diagram definition: the eye diagram is a series of digital signals superimposed and displayed on an oscilloscope. The graph reflects the overall characteristics of all digital signals in the transmission link;
reflection learning:
T-shaped connection will also cause impedance discontinuity;
the result of reflection is: standing wave for analog signals and ringing for digital signals, which will destroy Signal integrity;
reflection coefficient: The reflection coefficient is divided into source end reflection coefficient (Rs-Z0/Rs+Z0) and end reflection coefficient (Rl-Z0/Rl+Z0); common matching method: source end series connection (Rs
plus The matching resistance of the driving source = the transmission line impedance Z0);
the load end is parallel terminated, Thevenin matched, the diode terminated matched, RC terminated;
the condition of reflection is not considered: when the delay is less than 20% of the rise time, the length of the sudden transmission line is less than Signal rise time, the length of the stub is less than the signal rise time;

The fifth day of learning: Topology and crosstalk learning:
Topology is very important to signal quality. The characteristics of a good topology: ensure signal waveform quality, improve product noise margin, improve product reliability, and facilitate PCB layout; daisy chain topology,
crosstalk Row matching and parallel matching;
fly-by topology;
Fly-by topology is actually a special case of daisy chain topology. When the branch in the daisy chain topology, that is, the "SUB line" is quite short, it can be called "fly-by"; fly-by
plus pull-up resistor;
star topology, remote cluster topology;
crosstalk analysis : odd mode and even mode, crosstalk only occurs when the signal rises or falls and the current changes;
crosstalk is divided into capacitive crosstalk and inductive crosstalk;
near-end crosstalk: when the interference source causes interference to the transmitting end of the interfered source.
Far-end crosstalk: the first interference caused by an interfering source to the receiving end of the interfered source;

//Reification of function template
using namespace std;
class gril
{ public: string name; int age; };



template
void swapNum(T& a,T& b)
{
T tmp = a;
a = b;
b = tmp;
cout<<“function template running”<<endl;
}

template<>
void swapNum(gril& g1,gril& g2) //Specialization of function template
{ int tmp = g1.age; g1.age = g2.age; g2.age = tmp; cout<<“function template detail running”<<endl; }




int main(void)
{
int a = 10,b = 20;
swapNum(a,b);
cout<<"a: “<<a<<” b: "<<b<<endl;

gril g1,g2;
g1.age = 4;
g2.age = 7;
swapNum(g1,g2); //Using the function template's concretization
cout<<"g1.age: "<< g1.age<<" g2.age : "<< g2.age <<endl;
return 0;
}

2) The combination of auto and decltype in the function template uses
template<typename T1, typename T2>
auto fun(T1 x, T2 y) -> decltype(x + y) //After the c++14 standard, "- > decltype(x + y)" can omit the trailing return type;
{ decltype(x + y) tmp; tmp = x + y; return tmp; } int main(void) { auto num = fun(3,4.6); cout<<num<<endl; return 0; }









3) Case of class template
#include
#include
#include

using namespace std;

template<class T1,class T2 = double >
class AA
{ public: AA(T1 a,T2 b) : a_(a),b_(b){} T1 geta() { T1 n = 3; return a_ + n; } T2 getb() { T2 n = 3; return b_ + n;} T1 a_; T2 b_; }; int main(void) { AA aa("3",6); //When using class template, data type Must adapt to the code of the class template; // cout<<aa.geta()<<endl; //If you let it go, a compilation error will occur cout<<aa.getb()<<endl; return 0; }













template<class T1, class T2 = string > //Default template parameters cannot be defined outside the class, so string should be removed!
T1 AA<T1,T2>::geta() { T1 n = 3; return a_ + n;}

auto aptr = new AA<int,int>(5,8); //You can use new to create a template class object
cout<geta()<<endl;
//In the program, the member function of the template class will not be created until it is used ;
//In the program, although the pointer of the class is created, the object of the class is not created, so the constructor will not be called;

4) Using class templates, I wrote a stack-related function. The code is as follows:
#include
#include

using namespace std;

// typedef string DataTpye;
template
class MyStack
{
private:
T* items;
int top; //位置指针
int stackSize;
public:
MyStack(int size) : stackSize(size),top(0)
{
items = new T[stackSize];
}
~MyStack(void)
{
delete[] items; items = nullptr;
}
bool isEmpty(void)
{
return top == 0;
}
bool isFull(void)
{
return top == stackSize;
}
bool push(const T& item)
{
if(top < stackSize)
{
items[top++] = item;
return true;
}
return false;
}
bool pop(T& item)
{
if(top > 0){item = items[–top]; return true;}
return false;
}
};

int main(void)
{
MyStack ss(5);
ss.push(“aaa”); ss.push(“bbb”); ss.push(“ccc”); ss.push(“ddd”); ss.push(“eee”);
string item;
while(ss.isEmpty() == false)
{
ss.pop(item); cout<<"item is: "<<item<<endl;
}
}

5) Case application of template class, application of fixed-length array and variable-length array:
use const to declare the member function, indicating that this function will not modify any data members in the class;
#include
#include
#include <string.h>
using namespace std;

#define MaxLen 10

template
class MyArray
{ private: T arr[MaxLen]; public: MyArray(){ memset(arr,0,sizeof(arr)); } ~MyArray(){} T& operator[](int ii){ return arr[ii ]; } //Overloading the subscript operator can modify the elements in the array const T& operator[](int ii)const { return arr[ii];} //Cannot modify the elements in the array; } ;







template
class Vector
{ private: int len; T* items; //array elements public: Vector(int size = 10) : len(size){ items = new T[len]; } ~Vector() { delete[] items ; items = nullptr; } void resize(int size) //Extend the memory space of the array { if(size < len) return; T* tmp = new T[size]; for (int ii = 0; ii < len; ii++ ) tmp[ii] = items[ii]; delete[] items; // Release the original array. items = tmp; // Let the array pointer point to the new array. len = size; // Extended array length. } T& operator[](int ii) // Overloaded operator[] can modify the elements in the array. { if (ii >= len) { resize(ii + 1); // Expand the array.























cout<<“running extern array function-----”<<endl;
}
return items[ii];
}
};

int main(void)
{ Vector aa(1); aa[0] = "Xi Shi"; aa[1] = "Bingbing"; aa[2] = "Power"; aa[3] = "Golden Lotus"; aa [4] = “小青”; for (int ii=0; ii<5;ii++) cout << “aa[” << ii << “]=” << aa[ii] << endl; }



6) Cases of nested use of template classes:
#include
#include
#include <string.h>
using namespace std;

template
class MyStack
{
private:
T* items;
int top; //位置指针
int stackSize;
public:
MyStack(int size = 3) : stackSize(size),top(0)
{
items = new T[stackSize];
}
~MyStack(void)
{
delete[] items; items = nullptr;
}
bool isEmpty(void)
{
return top == 0;
}
bool isFull(void)
{
return top == stackSize;
}
bool push(const T& item)
{
if(top < stackSize)
{
items[top++] = item;
return true;
}
return false;
}
bool pop(T& item)
{
if(top > 0){item = items[–top]; return true;}
return false;
}
MyStack& operator=(const MyStack& v)
{
delete[] items;
stackSize = v.stackSize;
items = new T[stackSize];
for(int ii = 0; ii < stackSize; ii++) items[ii] = v.items[ii];
top = v.top;
return *this;
}
};

template
class Vector
{ private: int len; T* items; //array elements public: Vector(int size = 2) : len(size){ items = new T[len]; } int size() const { return len; } // Get the array length. ~Vector() { delete[] items; items = nullptr; } void resize(int size) //Extend the memory space of the array { if(size < len) return; T* tmp = new T[size]; for (int ii = 0; ii < len; ii++) tmp[ii] = items[ii]; delete[] items; // Release the original array. items = tmp; // Let the array pointer point to the new array. len = size; // Extended array length. } T& operator[](int ii) // Overloaded operator[] can modify the elements in the array. { if (ii >= len) {























resize(ii + 1); // Expand the array.
cout<<“running extern array function-----”<<endl;
}
return items[ii];
}
};

int main(void)
{
Vector<MyStack> vs;
vs[0].push(“111”);
vs[0].push(“222”);
vs[0].push(“333”);
vs[1].push(“aaa”);
vs[1].push(“bbb”);
vs[1].push(“ccc”);
for (int ii = 0; ii < vs.size(); ii++) // 遍历Vector容器。
{
while (vs[ii].isEmpty() == false) // 遍历Stack容器。
{
string item; vs[ii].pop(item); cout << "item = " << item << endl;
}
}
vs[2].push(“666”);
vs[2].push(“444”);

for (int ii = 0; ii < vs.size(); ii++)         // 遍历Vector容器。
{
	while (vs[ii].isEmpty() == false)      // 遍历Stack容器。
	{
		string item; vs[ii].pop(item); cout << "item = " << item << endl;
	}
}    

}

6) Concrete case of class template:
#include
#include
#include <string.h>
using namespace std;

//Class template concretization is divided into: complete concretization and partial concretization; when together with non-concrete classes, there is a sequence;
template<class T1, class T2> //This class without concretization cannot Shielded, otherwise the template class
class AA
{ public: T1 a1; T2 b1; AA(const T1& a,const T2& b) : a1(a),b1(b){cout<<“class constructor is running "<<endl; } void show() const; }; template<class T1,class T2> void AA<T1,T2>::show()const { cout<<"No reified class:"<<" a1 is: “<<a1<<” b1 is: “<<b1<<endl; }










template
class AA<int,T> //部分具体化
{
public:
int a1;
T b1;
AA(const int& a,const T& b) : a1(a),b1(b){cout<<“class constructor is running”<<endl; }
void show() const;
};
template
void AA<int,T>::show()const
{
cout<<"部分具体化: "<<"a1 is: “<<a1<<” b1 is: "<<b1<<endl;
}

template<>
class AA<int,string> //完全具体化
{
public:
int a1;
string b1;
AA(const int& a,const string& b) : a1(a),b1(b){cout<<“class constructor is running”<<endl; }
void show() const;
};
void AA<int,string>::show()const
{
cout<<"完全具体化: "<<"a1 is: “<<a1<<” b1 is: "<<b1<<endl;
}

int main(void)
{ AA<int,string>aa(3,"abc"); //Priority order of execution: Full concretization first > Partial concretization > No concretization; aa.show() ; return 0; }



1) Speed2000 software settings:
//Select the generator software, then open the relevant software, select the file->new-power ground noise simulation dialog box;
//Select tool->option->edit option->grid and unit dialog box, layout Select mil for unit, check snap object to grid;
//—>electric models, select user-defined maximum frequency extraction parameters;
//—>field solver, select natural boundary conditions;
2) Add network:
//In net manager, Right-click and select new to generate a network. You can change the name. After completion, you can classify it as a power network, a ground network, or a signal network; 3) Add
wires:
In edit, select trace->add, you can add wires. After selecting the wires, You can set the line width, give it a network, and move the wire;
4) Set vias:
Add custom vias: edit->stackup->pad stack->select the new button below to add a new via;
select in shape Circle, width 22, height 22, anti 32mil, out diameter select 10mil, and finally set set as default to make it the default via; 5) The
via is connected to the trace copper foil:
be sure to display the node, so that it is punched on the node hole, the via editing dialog box will appear, select property, select the corresponding network, if the via hole is connected to the corresponding network, the color will change; if you
add a via hole on a wire, you need to add a node and add a via hole;
6) Copper foil treatment:
Select -edit->shape-> to add and delete copper foil, and finally execute the shape process to make the merge copper foil complete;

//Template classes and functions
#include //157 Template classes and functions
using namespace std;

//Template classes and functions
//Template classes are used for function parameters and return values ​​in three forms;
template<class T1, class T2>
class AA
{ public: T1 x; T2 y; AA(const T1 a, const T2 b ) : x(a),y(b){} void show()const { cout<<"show x: "<<x<<"\t\tshow y: "<<y<<endl; } };








class BB
{
public:
void show()const
{
cout<<“show BB class”<<endl;
}
};

// AA<int, string> func(AA<int, string>& aa)
// {
// aa.show();
// cout << “调用了func(AA<int, string> &aa)函数。\n”;
// return aa;
// }

// template<typename T1,typename T2>
// AA<T1, T2> func(AA<T1, T2>& aa)
// { // aa.show(); // cout << "Func() was called AA<T1, T2> &aa) function.\n”; // return aa; // }



template
T func(T& aa)
{ aa.show(); cout << "The func(T& aa)> &aa) function is called. It embodies the essence of the function template\n"; return aa; }



int main(void)
{
AA<int,string> aa(4,“helloworld”);
func(aa);
BB bb;
func(bb);
return 0;
}

6) Template classes and friends
template<class T1, class T2>
class AA
{ public: T1 x; T2 y; AA(const T1 a, const T2 b) : x(a),y(b){} friend void show(const AA<T1,T2>& a) //The essence of this solution is that the compiler uses template parameters to help us generate friend functions; { cout<<" show x: "<<ax<<"\ t\tshow y: "<<ay<<endl; } };








int main(void)
{ AA<int, string> a(88, "I am a silly bird."); show(a);

AA<char, string> b(88, "我是一只傻傻鸟。");
show(b);

return 0;

}

6) Member templates of template classes (member templates include class templates and function templates)
#include //157 Template classes and functions
using namespace std;

//类模板中包含类模板
template<class T1,class T2>
class AA
{
public:
T1 m_x;
T2 m_y;
AA(const T1 a,const T2 b) : m_x(a),m_y(b){}
void show(void)
{
cout<<"show m_x: “<<m_x<<”\tshow m_y: "<<m_y<<endl;
}

template<class T>
class BB	
{
public:
	T m_a;
	T1 m_b;
	BB(){}
	void show(); //只保留声明
	// void show() const {cout<<"show x: "<<m_a<<"\t\tshow y: "<<m_b<<endl;}
};
BB<string> m_bb; //m_bb类AA的一个成员变量

template<class T>
void show(T tt); //类模板AA的成员函数,所以可以访问类A的成员变量;
// {
// 	cout<<"show tt: "<<tt<<endl; 	
// 	cout<<"show x: "<<m_x<<"\t\tshow y: "<<m_y<<endl;
// 	m_bb.show();
// }

};

//Members of template class Extra-class definition of template class
template<class T1, class T2>
template
void AA<T1,T2>::BB::show()
{ cout<<"show x: “<<m_a<< ”\t\tshow y: "<<m_b<<endl; }

//Member template function of the template class is defined outside the class
template<class T1, class T2>
template
void AA<T1,T2>::show(T tt)
{ cout<<"show tt: "<<tt<<endl; cout<<"show x: "<<m_x<<"\t\tshow y: "<<m_y<<endl; m_bb.show(); }



int main(void)
{ AA<int, string> a(88, "I am a silly bird."); a.show(); a.m_bb.m_a = "hello world"; a.m_bb.show (); a.show("111111111111111111"); return 0; }






Seventh day of study
Case practice 1 (calling external power supply signal source): speed2000 simulates a signal passing through a resistor->via->load->ground path, and the observed voltage and current distribution; 1) Open the software and
add The file provided by the teacher, xxx.spd file;
2) Check whether the lamination information, pad information, etc. are standard;
3) Add the stimulus source, the component manager dialog box will appear, click load below, and add the stimulus source with the xxx.ckt file ;
4) Add components to the model, select new to add components;
5) Set the simulation time, generally 10ns;
6) Set the voltage observation point and current observation point, the left mouse button is positive, the right mouse button is negative;
7) Set the grid (The default value is sufficient);
8) Start simulation and check whether it is qualified based on the simulation results;

Case Practice 2 (Simulation Waveform Result Calculation):
The operation steps are basically the same as Practice 1. The difference is: the
previous learning of adding vias is reviewed;
plane noise is added, using methods such as: setup->simulation view- >Layout voltage, now refer to the plane;
proficiency in using speed2000 software is the top priority! ! !

Guess you like

Origin blog.csdn.net/qq_30143193/article/details/131550169