Elementary and Middle School Science

In US Curriculum, there is no Science study in Elementary School, except for basic introduction. In middle school too, there is very little science material. All of biology, chemistry and Physics are combined into one as Science. All Science material until Middle School can be covered within a couple of weeks with 20 hours of dedicated study per week. This is in contrast to Science in Indian Schools, where Physics, Chemistry and Biology have vast material in 11th and 12th grade. Even before that up to 10th grade, the material is not easy in Indian Science curriculum.

Khan Academy has very nice sets of videos on Basic Science (unit 1 and 2): https://www.khanacademy.org/science

 

In Texas, Science test is taken as part of STAAR in 5th grade (when you pass Elementary school) and in 8th grade (when you pass middle school). After 8th grade, there is no more Science material in High School. There is a biology test that you take in High School, but the material is that of middle school. You could take a look at the STAAR test questions here for last couple of years (look under 5th and 8th grade for Science).

https://tea.texas.gov/student-assessment/testing/staar/staar-released-test-questions

I'm listing the topics that are considered for passing the Science STAAR test in texas. Here's a link for Science Topics that TEA (Texas Education Agency) lists:

https://tea.texas.gov/academics/subject-areas/science

I've simplified and summarized everything below for all Science material until 8th grade:

  1. Astronomical Science: Various aspects of Astronomy starting from origin of Universe to planets in solar system, stars, etc.
    1. Origin of Universe: Big Bang Theory, evolution of planets, and timeline.
    2. Galaxies: compare spiral, elliptical, irregular, dwarf, and active galaxies.Learn about our Milky way galaxy and other galaxies
  2. Earth Science:
  3. Physics:
  4. Chemistry:
    1. Matter: Learn about Atoms, molecules, ionic and covalent bonding. Know about Electrons, protons and neutrons.
    2. Periodic Table: Know about how many elements are there and how they are arranged in periodic table. How their chemical properties are determined by their valence electrons. Radioactive elements and isotopes.
  5. Biology:

 

ChatGPT

ChatGPT is a revolutionary Genrative AI chat Bot developed by openai.com. GPT stands for "Generative Pre-trained Transformer".

chatGPT link: https://chat.openai.com/chat

You will need to make an account, before you can use it. openai.com has a lot of other tools too, such as

I've a separate section for chatGPT, as looks like it can give answers to all your questions, no matter how badly you phrase it. It's amazing, as to what is causing it to understand questions, and then respond in a human way, not just "matching answers" from it's database.

Here are few basic questions that chatGPT gets totally messed up.

Maths:

1. Simple Geometry question: Given 3 coordinates of a parallelogram, find it's 4 coordinate. Here the trick is that if you solve it in not so smart way, the process may be very long. First you find equations of 2 parallel sides, name . Then you find eqn of 3rd side, and use that to find eqn of 4th side. Then you find intersection of 3rd and 4th side which are not parallel, the solution of which gives you the coordinates. However, simpler solution is to find the midpoint of the parallelogram using 2 of the coordiantes, and then use that midpoint to find other coordiante.

Question: If 3 coordinates of parallelogram as (3,4), (5,7) and (9,0), what's the 4th coordiante?

Answer: chatGPT first uses the complex eqns to determine the solution. It messes up trying to the find the intersection of 2 parallel lines, solves for x as follows (which is total garbage):

3/2 * x - 1/2 = 3/2 * x - 27/2

=> 27/2 - 1/2 = 0

=> x = 2

When you say it's wrong, it tries the midpoint formula and comes up with one possible solution pretty fast. If you ask for other solutions" it says :

"No, there is only one solution for the fourth vertex of the parallelogram given three of its vertices. The fourth vertex is uniquely determined by the geometry of the parallelogram, as it is determined by the intersection of the two diagonals of the parallelogram."

When you confront by saying that the vertices can be in any order, then it comes up with all 3 possible solutions.

Score: PASS

 

Physics:

1. Simple Charge question: Given 2 equal charges of opposite magnitude (+Q1 and -Q1) in a gravity free environment, and the initial distance between them thrown with some initial velocity, how long will it take for them to collide? For the solution, we just need to solve differential equation for electrostatic force between the two charges, and the resulting acceleration between them, and then solve for distance r=0.

 

 

 

 

Home Insurance Plans:

If you ever owned a home or bought a home, you would have heard about home insurance. Home Insurance is an Insurance Plan provided by Insurance companies to compensate in case something bad happens to your home. Typical events include hail damage, fire, hurricane, etc. Your home will be repaired or rebuilt after you pay your deductible. People usually choose a 1% deductible, though the premium is higher for lower deductible compared to higher deductible. These Insurance companies are regulated by the State Government, so they can't deny a valid claim. Or else you can file file a complaint with the appropriate state government department. So, the risk of getting scammed with these Insurance companies is almost negligible.

For ex, in state of Texas, The Texas Department of Insurance (TDI) regulates these Insurance companies. You may file a complaint against an insurer. You can also find information on the TDI website at www.tdi.texas.gov.

Insurance Premiums are usually lower for a new home as new homes are going to have less issues. For a home that is older than 10 years, premiums go up significantly. For a typical new home of $500K, and a deductible of 1%, you may get Insurance plans in range of $1K. For older homes, you may have to pay more or up ypur deductible to 2% to get closer to $1K. Note that these rates are only for Home owners. If you don't live in your home all the time (i.e due to being a vacation home) or if you have rented it out, home insurance plans can easily cost double of what a home owner might pay for the same home. A typical home that you rent out may cost close to $5K as of 2023.

If you ever make an Insurance claim, your premiums will go up. So, be careful of when you make a claim. If the cost of repairing or fixing something is close to what your deductible, don't even bother calling the Insurance Company.

My advice would be get an Insurance plan with the highest deductible (2% or more) and lowest premium. Home Insurance is supposed to help you in case of a catastrophe and not to pay for little damages here or there. I never pay more than $1K/year for any Insurance

I've my home Insurance thru AAA 9American Automobile Association), the same company that provides Towing services. They provide both Home Owner's Insurance as well as Auto Insurance. Being a non profit, their rates are usually the lowest that you can find anywhere. Their customer service and claim processing is also very superior. I've been with them for 20 years with multiple claims filed, never had any issues.

Home Warranty Plans:

Apart from Home Insurance plans, there are also home warranty plans. These plans cover for items inside your house that may need to be fixed or repaired. Home Insurance plans only cover your home, and your personal property if it gets damaged as part of damage to your house. Home Warranty plans cover malfunction and repairs to your appliances inside the house as refrigerator, washer/dryer, microwave, oven, Sewer, swimming pool, etc. These home warranty plans are advertised very heavily everywhere, because they are pure profit for the warranty companies. These Warranty companies are not regulated by state department, nor do they need any license. Even I or you may be able to open a waranty company. If your claim is not honored with a warranty company, the only recourse is to file a lawsuit in a court. These lawsuits are expensive, and warranty companies know that 99% of the people don't file lawsuits, so they take advantage of that.

Scam: I've listed these warranty companies along with other scams under the scam section. These home warranty plans are nothing short of scam. They will pay petty bills here and there, and deny all claims > $200. Or they will offer you flat $200 for replacement of a big ticket item like an AC which may cost $5K to fix. You will pay premium in the order of $1K/year on top of trip fee of $75-$125. Trip fee is a fee that is sort of deductible that you have to pay every time you file a claim, and someone comes to your house to fix it.

I've dealt with at least 3 separate warranty companies. 2 opf them paid for < $200 in claim, and one never paid for any claim filed. They have agents who will say "we'll respond in 24-48 hrs", but will never call back. They purposely talk in difficult to understand accent, and repeat exactly the same scripted sentence in all calls related to a claim. Sometimes they will ask you to pay for arepair, saying that you file for reimbursement later. That re imbursement will never come, because no one will ever respond.

Here's the kicker: If you call your credit card company to dispute the charge for the premium, they will not be able to help you. Most credit card companies only allow you to dispute charges less than 60 days old. These warranty companies don't allow you to file claim for first 30 days. Even if you file after 30 days, they will wil delay the final resolution to over 30 days, so that you are out of protection by your credit card company. Even if you are able to dispute, someone from warranty company will call and ask you to remove the dispute, and offer you a resolution. Never fall for any of these warranty companies. Just avoid them at all cost. Most of the items under repair can be bought new for that price.

There are quite a few warranty companies that I've dealt with, and it's a nightmare. You will never see your money, and you will never get any service. Many of these warranty companies have very good positive reviews on some review websites. These are all "paid" reviews, and search engines show these reviews at top, as I guess they are paid by these Warranty companies to have those reviews on top. You have to go thru multiple pages of search, until you get to real reviews. All these 8/10 or 9/10 rating on many home warranty review websites are plain lie. These sites exist because they get a hefty commission for any clicks (i.e https://www.homewarrantyreviews.com). Best place to get honest review is BBB (Better Business Bureau). Trustpilot review website (trustpilot.com) can't be trusted.

Here are the real reviews for few of them:

1. Select Home warranty: The worst of the lot. Their premiums are lower than others, and the agent at sign up will claim everything is covered. They will try to get you hooked for longer duration plan. Never paid a single dollar for any claim. They will keep on going on and on for 30 days or so, and then one day suddenly deny your claim. Their denial reason is the same for most of the people.

2. American Home Shield (AHS): Most popular and biggest Home insurance company out there. Equally bad, though they do pay petty claims.

3. First American Home Warranty: Another big name with same motto "rip you off".

 

Conclusion:

Home Insurance plans are mandatory if you have a mortgage on your home. They are worth the money as they are regulated by State Government, so genuine claims can't be denied. They serve in case of a catastrophe.

Home Warranty plans are a scam. They are not regulated by state governments, and lawsuit in a court is the only way to recover your money. Instead put that money into "stock market index fund ETF" every yerar, and within a few years, you will have enough to pay for most of the repairs from your saved money.

 

Periodic Table, Atoms and Elements:

Periodic Table is one of the cornerstone of Chemistry. Before we learn periodic table, we should know a bit about atoms and how were they born.

It's believed that a "big bang" took place 14 Gya, and everything came into existence following that. Read more about "Birth of Universe" in Astronomical section.

Over there, we learned about the very first sub atomic particles, and the formation of Hydrogen and Helium atoms. Here we'll see all the atoms and the elements they form.

 

Atoms & Elements:

All matter that we see is atoms. There are atoms of gold, nickel, oxygen, etc. So, we have silver in pure form which consists of silver atoms. We can't divide an atom further down. Each atom has a nucleus in the center which is composed of protons and neutrons, and a cloud around it which is composed of electrons. As we saw above, neutrons and protons are formed from 3 quark particles, and an electron is a lepton. These come together to form an atom, with nucleus in the center and electron revolving around it (just like planets revolve around the sun)

Atoms of different elements have different number of electrons, protons and neutron. The characteristic thing that defines an element is the number of protons. We can't change the number of protons for a given element. If we somehow change it, than that element gets converted into another element which has that many protons. So, number of protons is called as Atomic number (Z) of an element. No 2 elements have same atomic number.

Mass, Charge and size of e, p, n:

Particle mass charge size
Proton (p) 1.67x10^-27 kg = 1.007 amu (atomic mass unit) +1.6x10^-19C (+ve charge) 1.7x10^-15m = 1.7fm (femto meter)
Neutron (n) same mass as proton = 1.008 amu No charge (neutral) same size as proton = 1.7fm
Electron (e) 9.11x10^-31 kg = 1/1800 amu -1.6x10^-19C (-ve charge) point particle (no size)

 

Unified amu: amu is also written as unified amu or "u". So, you will see mass of proton written as 1u too (instead of 1amu). Mass of a proton is actually 1.007u and mass of neutron is 1.008u (so, both are slightly heavier than 1u). 1u = 1.6605x10^-27 kg

All of these electron, proton, neutron would seem like particle, but modern quantum theory states that quantum scale objects have wave-particle duality, and exhibit both wave like and particle like properties. There have been many controversies over this wave-particle nature of objects, but is now generally accepted. Bigger the size of object, it's wave characteristics become so small, that it acts like a particle fr most practical purpose. However, for very small objects, as electrons, wave characteristics are noticeable. Similarly all electromagentic radiation (i.e light, heat), etc are assumed to hold both wave and particle characteristics to help explain many phenomenon which can't be explained by assuming only a particle mode, or only a wave model.

For our purpose, we will treat all electron, proton and neutron as particles, with the understanding that they show wave properties. All of them have mass, but their mass is too small (neutron/proton have 1800 times greater mass than electron, but still small). So, gravitational forces between these masses is too small. They are held together via electrostatic forces (forces b/w opposite charges).

Electron is considered point particle with no size. Size of an atom is around 10^-10m, which is about 100,000 times larger than size of proton and neutron. So, the nuclues of an atom is very small of the order of fm, with 99.99% of the space around it formed by the electron cloud. Two atoms aren't able to get very close to each other because the repulsive force of this electron cloud prevents the nuclei from getting too close. Size of an atom is determined entirely by it's electron cloud.

A neutral atom of an element has same number of protons and electrons, as the atom is electrically neutral. It's mass number (A) is equal to the sum of number of protons and neutrons (since protons and neurons have mass of 1 amu, the atomic weight of atoms is almost same as atomic number, but not always. The man reason for this is presence of isotopes which will be explained later).

Mass number of Atom (A) = p + n

Atomic number of atom (Z) = p

Given Mass Number and Atomic number of atom, we can figure out the number of electrons, protons and neutrons.

Ex: Na has Z=11, A=23 => p=11, e=11, n=23-11=12.

Isotopes: These are elements which have same proton, but different number of neutrons. Look in "Nuclear Chem" section.

 


 

Periodic Table:

We saw above how the number of protons is what defines an element. This wasn't known to mankind, and a lot of thinkers were trying to come up with some theory on what makes an element unique. The first periodic table to become generally accepted was that of the Russian chemist Dmitri Mendeleev in 1869: This wikipedia link has details of all elements in Periodic Table: https://en.wikipedia.org/wiki/Periodic_table

This is a pictorial periodic table: https://periodictable.com/

This is another periodic table that shows certain properties of all atoms in periodic table: https://www.periodic-table.org/

The very first thing to know in a periodic table is that Elements are organized by number of protons they have, which start from 1 proton for Hydrogen, all the way to 110+ protons for some heavier elements. This is known as "Atomic Number". However what determines the properties of any element is NOT the number of protons, but the number of electrons. However, it's not just the raw number of electrons, but electrons in the outer shell (and also the subshell they are in) that mostly determine most of the electrical and chemical behavior of the element. Since elements are neutral in charge, number of electrons is bound to be the same as the number of protons. We can make these atoms lose or gain electrons or share electrons via chemical reactions, in which case they may become charged.

Today, 118 elements are known, the first 94 of which are known to occur naturally on Earth at present.

Periodic Table trend (this will be more relevant once you cover the contents in this section) => https://chem.libretexts.org/Bookshelves/Inorganic_Chemistry/Supplemental_Modules_and_Websites_(Inorganic_Chemistry)/Descriptive_Chemistry/Periodic_Trends_of_Elemental_Properties/Periodic_Trends

 

Electron Orbit:

Atoms have energy shells, which are the shells or space around the nucleus where electrons are to be found. The reason electrons can only be found in these distinct spaces around the nucleus is because electrons can only have certain distinct energies. These distinct spaces are called electron orbital. Pauli's Exclusion principle states that no 2 electrons can have the same energy state, implying each orbital (which is a energy state) can have a max of 2 electrons, one with +ve spin and one with -ve spin. If we had only single spin for electrons, then there could have been only 1 electron per orbital.

Bunch of electron orbitals are grouped into sub shells which are further bundled into shells. There are 4 sub shells named as s,p,d and f. s has only 1 orbital, so can have max of 2 electrons, p has 3 orbitals and so a max of 6 electrons, d has 5 orbitals, and so a max of 10 electrons, and f has 7 orbitals and so a max of 14 electrons. "s" is spherical orbital, "p" is dumb bell shaped, d and f are more complex. These shapes represent the three-dimensional regions within which the electron is likely to be found with a 90% probability. When Scientists in early 1900 started studying atoms, they became aware of the shells (Bohr's model), but didn't know about the existence of sub shells. They knew by looking at spectral lines emitted by these atoms that some spectral lines were more intense than others, but didn't know the reason. Reason turned out to be these sub-shells that were present within a single shell. The designations s, p, d, and f result from those early historical attempts to classify atomic spectral lines. (The letters stand for sharp, principal, diffuse, and fundamental, respectively.) After f, the letters continue alphabetically as g, h, i, j, etc. So, sub-shells can be thought of as finer granularity of a shell => When you look at a shell closely, you see it's not one but rather is composed of bunch of sub shells.

The shells are numbered from shell=1 to shell=7. Each shell can have max of 2*n^2 electrons. So shell1 can have max 2 electrons, shell2=8 electrons, shell3=18 electrons, shell4=32 electrons. shell5=50 electrons and so on. It's not the total number of electrons in an atom, but rather the number of electrons in outer shells (rather outer sub shell) that determines the properties of elements. Hence all elements with same number of electrons in outer sub shell are put into same column, to indicate that they have similar properties. Rows are automatically formed due to this, as the elements are put in increasing order of their Atomic number. So, if an element has 3 electrons in n=2, then elements with 3 electrons in n=3, n=4, n=5 etc will all have similar properties.

Shells are numbered as follows:

  • 1n => 1st shell has only 1 sub shell = 1s (max 2 electrons)
  • 2n => 2nd shell has 2 sub shells s,p = 2s (max 2 electrons)  and 2p (3 of these have max 6 electrons)
  • 3n => 3rd shell has 3 sub shells s,p,d = 3s (max 2 electrons), 3p (max 6 electrons) and 3d (5 of these have max 10 electrons)
  • 4n => 4th shell has 4 sub shells s,p,d,f = 4s (max 2 electrons), 4p (max 6 electrons), 4d (max 10 electrons) and 3f (7 of these have max 14 electrons)
  • 5n to 7n => 5th to 7th shells are filled in slightly intricate ways which are shown in diagram below.

Electrons are filled in orbitals starting from lowest energy orbital to highest energy orbital. It turns out that our numbering system above is not in same order as increasing energy level, i.e we would expect 3d to be lower in energy than 4s based on numbering, but in reality, 4s is lower in energy than 3d. The simple reason is that orbitals for n=3 and higher tend to get closer to each other, and so the energy levels are very close. This results in some subshells from lower "n" having higher energy than subshells in higher "n". Below is the correct order of increasing energy:

1s ≪ 2s < 2p ≪ 3s < 3p ≪ 4s < 3d < 4p ≪ 5s < 4d < 5p ≪ 6s < 4f < 5d < 6p ≪ 7s < 5f < 6d < 7p ≪ ... (Here the sign ≪ means "much less than" as opposed to < meaning just "less than"). The way to remember this sequence is very easy, and is in the wiki link above for periodic tables. It's called the "Aufbau Principle/rule".

Behaviour of electron's is described by 4 quantum numbers (QN):

  • Principal QN (n) => This is the shell number n shown above. This is the main shell that determines the distance from nucleus.
  • Angular Momentum QN (l) => This ranges from 0 to n-1, and relates to shape of orbital (i.e denotes sub shells s, p, d, f, etc). So for n=2, we will have 2 values of l=0, 1. l=0 => s orbital while l=1 => p orbital, and so on.
  • Magnetic QN (m) => this ranges from -l to +l. So for l=1, it has 3 values -1, 0, +1. This determines the orientation of sub shell. Sp, p subshell above can have 3 orientations as m can have 3 values. These 3 orientations are in x, y and z direction.
  • Spin QN (s) => This is the orientation of electron spin, and can have only 2 values => +1/2 and -1/2.

 Pauli's exclusion principle => No 2 electrons can have the same QN. i.e all n. l, m and s can't be same for 2 electrons within an atom.

The electron cloud diagram shows the region where an electron has 90% probability of being found.  S is spherical, p is dumb bell shaped, d and f are more complex shapes.The shapes grow bigger with inc "n" as sub shells are further away from nucleus. The shapes are very important, as that is where the bonding takes place with other atoms. So, the net shape of the compound is dictated by orbitals participating in bonding.

This video has further description => https://www.youtube.com/watch?v=Ewf7RlVNBSA

Below is the Periodic Table showing electron distribution in various shells and sub sells. As can be seen, the order of increasing energy is followed. So, electrons start filling up in above order starting from Hydrogen (first element in periodic table) with only 1 electron, all the way to Oganesson (last element in periodic table) with 118 electrons. There are some elements for which the electrons are filled in higher level sub-shell, before lower level sub-shell are filled (ex: copper, silver, gold, etc have only 1 electron in their "s" sub shell, even though they should have 2. Instead that 1 electron moves to higher "d" subshell). This exception happens because 2 half filled sub shells are more stable than "1 full sub shell and one close to half subshell". This is called "exception to Aufbau Principle" and is particularly seen in higher "n", where diff in energy b/w sub shells is smaller, and hence increasing tendency for this to happen.

Elements are organized in rows and columns. There are 7 rows for 7 shells (n=1 to n=7). Elements in a row don't share any properties in common. There are 18 columns (total number of columns is 32, but they are usually numbered from 1 to 18. The higher columns from 19 to 32 are are not important as they are "f block" elements  and hence not numbered). The 1st column has 1 electron in outermost shell, 2nd column has 2 electrons in outermost shell and so on, until we reach the 32nd column which should have 32 electrons in the outer most shell. But because of the abnormal reordering of energy levels of sub shells, we get to a higher level shell before we are able to completely fill a lower level shell.

  • 1st row: For n=1, max # of electrons is 2, so only 2 entries in 1st row. subshell=1s
  • 2nd row:For n=2, max # of electrons is 8, so only 8 entries in 2nd row. sub shells=2s, 2p
  • 3rd row:For n=3, max # of electrons is 18, so there should be 18 elements, but only 3s and 3p fill up. Before 3d fills up, 4s starts filling up, so only 8 elements are here with sub shells = 3s, 3p
  • 4th row: For n=4, max # of electrons is 32, so there should be 32 elements, but we have 3d left over from n=3. So, we fill 4s, 4p and 3d.
  • 5th row: For n=5, max # of electrons is 50, so there should be 50 elements, but we have 4d and 4f left over from n=4. So, we fill 5s, 4d and 5p.
  • 6th row: For n=6, max # of electrons is 72, so there should be 72 elements, but we don't ever get there as there are already so many sub shells left unfilled from n=4 and n=5. We fill in order of 6s, 4f, 5d and 6p
  • 7th row: For n=7, max # of electrons is 98, so there should be 98 elements, but we don't ever get there as there are already so many sub shells left unfilled from n=5 and n=6. We fill in order of 7s, 5f, 6d and 7p

 

 Periodic Table electron configuration

Atom Formation:

As we saw above, atoms were formed from protons, neutrons and electrons coming together.

 

Hybrid Orbitals:

A very simplistic explanation was shown above where s has single orbital with spherical shape, p has 3 orbitals in 3 dimension of x,y,z, while d has 5 orbitals along 5 orientations, etc. For some elements in periodic table, it was observed that when these atoms came close to each other, the shape of the lattice structure formed didn't match our above theoretical expectation. These newer shapes prompted concept of hybrid orbitals => Some of these s and p orbitals mix up to form hybrid orbitals which are a mix of s and p orbitals. This happens only for 5 elements in 2nd row => Be, B, C, N and O. Of these, C, N and O comprise most of the compounds found in nature, so we'll look at these 3:

C => 2s2 and 2p2 hybridize to 4 2sp3 hybrid orbitals. It forms a tetrahedral shape. Tetrahedral shape allows the 4 vertices in a 3D shape to be equidistant from each other. It's called sp3 orbitals to indicate that it has 25% s character and 75% p character

Proof of tetrahedron 109angle here: https://www.ctralie.com/Teaching/Tetrahedron/

hybrid orbitals => https://www.youtube.com/watch?v=vHXViZTxLXo

  • sp3 hybrid orbitals => For Carbon, 4 sp3 hybridized orbitals with 1 electron in each. The bonds formed are called sigma bonds,
    • sigma bond => single bond with only 1 electron being shared. In CH4, there are 4 single C-H bonds, each of which is sigma bond (4 sp3 hybrid orbitals formed)
  • sp2 hybrid orbitals => For Carbon, 3 sp2 hybridized orbitals with 1 electron in each. One remaining 2p orbital doesn't hybridize and retains it's 2p identity. 1 bond formed b/w 2 C atom is sigma bond, but 1 bond in the double bond is a pi bond.
    • Pi bond => double bond with 2 electrons being shared results in 1 bond being sigma bond and other one being pi bond. In C2H4 , there is 1 double bond b/w C=C (which is 1 sigma bond and 1 pi bond), and then 4 single C-H bonds, each of which is sigma bond (2 sp3 hybrid orbitals formed)
  • sp1 hybrid orbitals => For Carbon, 2 sp hybridized orbitals with 1 electron in each. Two remaining 2p orbital don't hybridize and retain their 2p identity. 1 bond formed b/w 2 C atom is sigma bond, but 2 bonds in the triple bond are pi bonds.
    • Pi bond => triple bond with 3 electrons being shared results in 1 bond being sigma bond and other two being pi bond. In C2H2 , there is 1 triple bond b/w C≡C (which is 1 sigma bond and 2 pi bonds), and then 4 single C-H bonds, each of which is sigma bond (2 sp1 hybrid orbitals formed)

Water's tetrahedral shape => Above vid explains why water has 109 degree angle b/w the 2 H atoms. It's because of hybridization.

 

Bohr's Model:

A very simplistic explanation of various observed properties of Hydrogen like atoms was proposed by Neil Bohr's model in 1913, which matched exactly with what was observed in Experiments. Bohr's model is not correct, nor does it explain behaviour of other atoms, but it was a big step in understanding atoms. It was based on Classical Physics (or Newtonion Physics). In 1926, Schrodinger explained properties of all atoms based on his famous Schrodinger Equation which was a departure from Classical Physics into Quantum Physics. Schrodinger Equation is the one that is the accepted one, however it's very complex and not solvable for larger atoms.

Here's the derivation of Eqn based on Bohr's model: https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Quantum_Chemistry_(Blinder)/01%3A_Chapters/1.07%3A_Hydrogen_Atom

Force b/w proton and electron of hydrogen atom = q1*q2/(4*pi*ε0*r^2) = -e^2/(4*pi*ε0*r^2)

Potential Energy of system at distance r is d(E) = - ∫F.dr => E = - R∫F.dr = - (-(-e^2/4*pi*ε0*r))]∞R = --e^2/(4*pi*ε0*R) (potential energy is -ve meaning it takes energy to separate them. The energy at infinity is 0, so -ve energy means energy is going lower, i.e sytem is losing energy. So, +ve energy has to be supplied or work has to be done to bring it back to 0 energy).

Since electron is moving in a circle, a centripetal force is needed as per Newton's law, i.e m*v^2/R = F => m*v^2/R = e^2/(4*pi*ε0*R^2) => Eqn (1)

Total energy of the Atom = T(Kinetic Energy of electron) + V(Potential Energy of electron-proton) = 1/2*(e^2/4*pi*ε0*R) - e^2/4*pi*ε0*R = -1/2*(e^2/(4*pi*ε0*R)) => (Total energy is -ve, meaning energy was lost in bringing the electron-proton system together. So, energy has to be supplied if we want to break this sytem and take charges to infinity. Energy needed will be +1/2*(e^2/(4*pi*ε0*R). So, where did this energy get lost? Well, there must have been electromagnetic waves that were emitted out when nucleus with proton and electron came close by to form a system of electron orbiting around the proton. This resulted in some energy lost out. This is exactly the energy that has to be provided to this system to break apart this electron-proton system. Usually it's provided by absorbing some light wave.)

Total Energy of atom is -ve => Energy has to be supplied to bring it to 0, i.e break it apart.

There are 2 variables, speed v and Radius R, and we need 1 more eqn to solve this. At this point, Bohr postulated that angular momentum of electron can't be continuous value, and can only take discrete values, i.e mvR = n*h, where h=planck's constant, and n=0,1,2,3,... There were no physics involved in this assumption, nor did he know why it would take only discrete values.

However 10 years later, De Broglie figured out the real reason. Electrons are both particle and wave. For a wave to form constructively in a Radius R, the distance 2*pi*R can only take values of λ, 2λ, 3λ, .. etc. Only then can standing waves be formed in that distance. De Broglie wavelength is also defined as  λ=h/p where p=momentum=m*v, h=planck's constant.

Link: https://phys.libretexts.org/Bookshelves/College_Physics/Book%3A_College_Physics_1e_(OpenStax)/30%3A_Atomic_Physics/30.06%3A_The_Wave_Nature_of_Matter_Causes_Quantization

This yields: 2*pi*R=n*h/(m*v), or mvR=h/2*pi => Eqn (2) same as Bohr's postulate for angular momentum.

Using this 2nd Eqn along with 1st Eqn, we can solve for R. Use v=h/(2*pi*m*R) from 2nd Eqn and substitute in 1st. We get R=n^2*a0 where a0 is the radius of 1st shell for n=1, a= (h/2*pi)^2/(m*e^2) = 0.5Å. Angstrom is the unit that is used for size of atoms, as that's the order of size for most of the atoms. An Angstrom is 1/10 of a nm.

 

Size of atoms:

How does the size vary for larger atoms? For Helium, we have 2 proton and 2 electron. Since the 2nd electron is also in n=1 shell, the radius of atoms doesn't increase, but at the same time, the force b/w the electrons and protons is doubles, since there is charge=+2(e) on 2 protons. So, we would expect size of Helium atom to be smaller. In fact, since going across the periodic table in a given row, the largest shell number remains same, it implies that sizes should decrease, as we get more protons attracting the electrons. This is what we see in reality. Going from 1st group to 18th group, size decreases to almost 1/3.

Also, as we move down the table, sizes should increase as an extra shell gets added. However, at the same time more protons are also getting added, resulting in greater attraction. There's also a shielding effect, that shields outer shell electrons from full charge of nucleus being seen (as inner shell electrons can be considered as part of nucleus, hence effective charge is lowered by the number of electrons). As a result of these 2 opposing effects, we can consider charge remaining almost same as we add extra shells. So sizes end up increasing solely due to extra shell being added. Going from n=1 to n=2, size increases by 3X, but going from n=2 to larger shells, size increases are more modest at 20% per shell added.

In reality, radius of these orbits is not well defined. electrons have a probability cloud around the nucleus, and can be found anywhere, not at a definite radius. So, it's hard to define what is the size of atom. Below link explains various ways, size of atoms are defined and measured.

Size of atoms: https://chem.libretexts.org/Courses/Howard_University/General_Chemistry%3A_An_Atoms_First_Approach/Unit_1%3A__Atomic_Structure/Chapter_3%3A__The_Periodic_Table/Chapter_3.2%3A_Sizes_of_Atoms_and_Ions

Size of Hydrogen is about 50pm=0.5A, while largest element in 6th row has size=300pm=3A. For most of the atoms, size lies in between 1A and 2A, except for atoms in top right and bottom left of the periodic table.

 


 

Ionization energy (IE):

We can solve for Energy for any shell (n) as En = -13.6eV/n^2 where n=1,2,3...

So, energy increases (becomes less -ve) as n increases. Electrons can move from n=1 to n=2 by absorbing energy (from light waves). If enough energy is supplied, electrons may jump to very large "n" shell, which is effectively close to "0" energy. "0" energy implies that electrons and protons are at infinite distance with no attraction b/w them, i.e no force to hold them together, at which point electrons are free to move out from the atom and wander anywhere. So, 13.6eV is the energy needed to free the electron, or in other terms, ionize the Hydrogen atom. You have to supply that energy via some light wave which is absorbed by the atom and frees the electron. This is known as the IE for1st electron to ionize H to H+.

This Bohr's theory explained why each element had it's unique spectral lines. However, it didn't talk about sub-shells s, p, d ,f and so his formula assumed same energy for all electrons in a given shell (which is incorrect).

Energy of any EM wave for a given frequency = h*ν where h=planck's constant, ν=frequency of wave. So, as freq of EM wave goes up, energy goes up. That's why X-ray, Gamma ray are considered harmful to human body, as they have very high freq, resulting in higher energy which can damage human cells.

Energy (in eV)  = h*c/λ = 1240 eV-nm / (λ in nm) => Energy of a photon in visible light wave (λ=700nm to  λ=400nm) = 2eV - 3eV

To convert eV to Joules, we can use defn of Joules which is defined as 1J=1N-m. When 1 coulomb charge moves thru Electric field of 1V/m, then work of 1J is performed. So, 1J=1Coulomb*1V

1 electron's charge = 1.6*10^-19C => 1eV = 1.6*10^-19C*1V = 1.6*10^-19J. => 1eV = 1.6*10^-19J

For any element's atom to absorb or emit photon, it's electron has to move from 1 energy state to another energy state. Since energy states are discrete based on En = -13.6eV/n^2, it implies that

h*ν= -13.6eV*(1/n1^2 - 1/n2^2) where n1 and n2 are two energy states where the electron jumps from/to, and ν is the frequency of wave emitted or absorbed. This matched exactly with the spectral lines observed for Hydrogen atom.

Below link shows how spectral line can be calculated based on energy of electrons jumping from 1 shell to another: https://chem.libretexts.org/Courses/University_of_Arkansas_Little_Rock/Chem_1402%3A_General_Chemistry_1_(Belford)/Text/6%3A_The_Structure_of_Atoms/6.3%3A_Atomic_Line_Spectra_and_Niels_Bohr

Ionization energy is usually expressed in J/mole (defn of mole is explained later below). Energy of 1 electron moving under Voltage 1V = 1 eV =1.6*10^-19J. 1 mole = 6.02*10^23 electrons, so energy = 6.02*1.6*10^4J=96.3KJ/mole.

So, 1eV/atom = 96.3KJ/mole.

IE of H->H+ is = 13.6eV = 13.6*96.3=1310 KJ/mole. This is what we see in the IE table of elements in link below for Hydrogen.

IE Concepts => https://chem.libretexts.org/Bookshelves/General_Chemistry/Map%3A_Chemistry_-_The_Central_Science_(Brown_et_al.)/07%3A_Periodic_Properties_of_the_Elements/7.04%3A_Ionization_Energy

However, as we move to other elements, Bohr's simplistic model no longer works for IE. For next element Helium, the Ionization energy is lot higher at 2400 KJ/mole as He has full shell (1s2) . Same is the case with other noble gases. As we go down the periodic Table, IE goes down as electrons are in shells further away from the nucleus, so less energy is required to free that electron. As we move across a row from left to right, IE increases since effective nuclear charge increases, as well as the radius is smaller due to electrons being pulled closer in.

What we see until now is called the First IE, as it's the very 1st electron that's removed to give the atom a +ve charge. If we remove the 2nd electron, it's called the 2nd IE, and so on for 3rd IE, 4th IE, etc. As expected IE1 < IE2 < IE3 .... as nucleus is already +vely charged after the removal of 1st electron, so removing electron from more +ve species takes more energy. On top of this, if we hit a full shell, and next electron is to be removed from completely full shell, then 10X more energy is required. This excessive energy is not available in chemical reactions, that's why we see atoms losing electrons only upto when they hit the full shell.

IE of diatomic molecules like H2 , O2 , N2  etc is usually higher compared to their atomic parts as energy of molecule is lower (as covalent bond formed more strongly ties the electron to proton), IE1 of H2 is 1488 kJ/mole, while IE1 of single H atom was 1310 kJ/mole. IE2 for H2 is higher than IE1, but is not directly measurable, as H2+ is highly unstable and readily breaks into individual protons. Below link shows IE for few diatomic atoms.

IE of diatomic molecules => https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Supplemental_Modules_(Physical_and_Theoretical_Chemistry)/Atomic_Theory/Ionization_Energies_of_Diatomic_Molecule

Interestingly, we see that IE of F Molecule is lower than that of F atom. There are many such cases, so we need to develop theory of hybrid orbitals.

 


 

Bond Energy (BE)

For atoms, total energy is the energy required to break apart the atom into nucleus (protons+neutrons still intact) and individual electrons. For molecules, this total energy isn't that meaningful, as we are not interested in disassociating molecule into "nucleus" and individual electrons. Rather we are only interested in to breaking that bond and forming individual atoms with their electrons intact. i.e If we are forming H2O from H2 and O2 , we are interested into energy required to break apart H2O into H2 and O2 . This is known as bond energy or bond dissociation energy, and it reflects the energy present in that bond. If we are further interested in bond energy or H molecule or O molecule, then we break apart H2 and O2 into H and O atoms. Bond energy is totally different than IE.

When a molecule forms from individual atoms, usually some energy is released as the total energy of the molecule is lower than the sum of energies of it's atoms. This is because the formation of a molecule itself implies that energy would be lower for the molecule, hence the reason the molecule formation took place. Or seen from other perspective, the bond will require energy to break it, hence energy was released when forming it, implying lower energy of the molecule. Such reactions are called exothermic reaction which are chemical reaction that release energy (so the total energy of the newly formed compound is lower). In contrast the opposite reaction, where the compound is broken into individual atoms needs energy to break the bond, and is called endothermic reaction. For some compounds, even the forming of compounds from it's constituent atoms may need energy or breaking it may release energy. When few compounds react to form few other different compiunds, then it's hard to say whether energy is released or absorbed. It depends on the amount of bond energy present in each compound in the reactants as well as in the final products. We'll discuss how to find that in a separate section later.

Bond dissociation energy of H2 molecule is 436KJ/mole.

H(+Energy) -> H + H (this requires 436KJ/mole of energy for this reaction to happen). This is endothermic reaction

H + H -> H2 (+Energy) (this releases 436KJ/mole of energy when this reaction happens, no external energy is required). This is exoothermic reaction

So, the total energy of H2 molecule is energy of each H atom + energy released. Energy of single H atom is -1310KJ/mole, so 2 H atoms have -2620KJ/mole (or -1310 KJ for half the mole, since 2H atoms combine into one molecule as H2. However, formation of H2 molecule releases 436KJ/mole energy as the bond formed is lower in energy. So, energy of H2 molecule is = -2620 - 436 = -3056 KJ/mole.

Molecules with triple bond have higher BE than those with double bond, which in turn have higher BE than molecule with single bond. BE of most common bonds shown below.

BE link => https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Supplemental_Modules_(Physical_and_Theoretical_Chemistry)/Chemical_Bonding/Fundamentals_of_Chemical_Bonding/Bond_Energies

 

Bond length (BL) in molecules:

Bond length in molecules basically determines the size of the molecules. The closer the individual atoms are when forming the bond, the smaller the molecule size. The length of the bond is determined by the distance where the minimum potential energy occurs for the bond. As an example, for Hydrogen, the 2 atoms at far off distance have 0 PE. As they come closer PE keeps on going down, until it reaches a minima of -436KJ/mole. That is the distance, 74 pm, where the bond is formed, and is called the Bond Length. AS we start getting closer, the PE again starts increasing, and even goes above 0, for very close distances.

Bond order: Bond order refers to the number of bonds formed b/w 2 atoms (see in Bonds section), Double or triple bond are stronger than single bond, and hence require more energy to break them, implying PE of bonds goes lower as the bond order increases. So, N2 which has triple bonds has lower PE and shorter BL, then O2 which has double bonds, and 

Vid (KA) => https://www.khanacademy.org/science/ap-chemistry-beta/x2eef969c74e0d802:molecular-and-ionic-compound-structure-and-properties

Lattice Energy: Compounds like NaCl form a lattice kind of structure with alternating Na and Cl atoms held together via ionic bond. Energy required to break this lattice to separate out the ions is called lattice energy. 

 

 


 

Energy bands:

We saw above that isolated Hydrogen atom will have energy levels as -13.6eV, -13.6/4eV, etc. However, when 2 of such Hydrogen atoms come close together, they start interacting and affecting the fields. As such 1s, 2s, 2p energy levels from different atoms cannot co-exist due to Pauli's exclusion principle. It states that no 2 electrons can occupy the same energy level. In response, these energy levels split into 2 => So, 1s will split into 1s(low) and 1s(high) energy levels. When we have 4 atoms, they will split into 4 very closely spaced levels. For large number of N atoms, these levels will split into N levels, which forms a band. For atoms with multiple orbitals, the outermost orbitals split more than the inner ones. When large number of atoms are brought together in forming a solid, there are so many levels from splitting, that a continuous band of energy is formed. Within this continuum of energy band, there are some regions called as "forbidden energy band" or "band gaps" where no orbitals exist no matter what the temperature is. These band gaps and their widths are determined from the nature of the atoms. Explained below:

Energy bands => https://eng.libretexts.org/Bookshelves/Materials_Science/Supplemental_Modules_(Materials_Science)/Electronic_Properties/Energy_bands_in_solids_and_their_calculations

Thermal and Electrical conducting properties of solids are determined from these Energy Bands. The topmost band with completely filled electrons is called valence band (VB) (since it's filled with valence or outer shell electrons) while the band right above it is called conduction band (CB). Conduction band may be partially or not filled. Number of electrons in Conduction band determine the conductivity of that element. If the conduction band is empty to start with, and if somehow thru thermal excitation, electrons can be made to jump to this band, then that material will start conducting. This gives rise to metals, nonmetals and SemiC.

Supplement (along with sim) => https://eng.libretexts.org/Bookshelves/Materials_Science/Supplemental_Modules_(Materials_Science)/Electronic_Properties/Energy_bands_in_solids_and_their_calculations

  • In Metals, valence band and conduction band overlap each other. VB is filled with electrons while CB always has empty states. In presence of Electric field, VB electrons jump to CB causing it to conduct.
  • In Insulators, valence band and conduction band are separated by large energy gap of several eV. Electrons from VB can't get excited enough to jump to CB, and hence no conductivity.
  • In SemiC, the bandgap is smaller at 1eV, and so with enough Electric field, electrons can get excited to jump to CB, and hence starts conducting a little. Except for this BG difference, SemiC are similar to Insulators.

Fermi Level:

The energy band in the materials is filled with electrons based on a Fermi Dirac distribution curve. This gives the probability of finding an electron at Energy level E, and at Temperature T. using this, we can find the exact distribution of electrons in any energy band. Fermi Energy level (EF) is a hypothetical level within this band, where the probability of finding an electron is 50%. More the electrons above this Fermi level, more the electrons in CB and higher the conductivity. As Temp inc, more and more electrons occupy higher Energy band, and hence are in CB, and start conducting even more. However, as we see in the section on R,L,C, conductivity is determined both by number of electrons in CB as well as the mobility of electrons. In metals, inc in number of electrons in CB is almost negligible with Temp, as most of the electrons are already in CB. However, mobility decreases resulting in lower conductivity. With SemiC, situation changes as exponentially more electrons move into CB with inc temperature. Mobility still decreases but only as i/T^2 while electron conc in CB goes exponentially. So, conductivity of insulators and SemiC increase exponentially with inc in Temp.

Link => https://eng.libretexts.org/Bookshelves/Materials_Science/Supplemental_Modules_(Materials_Science)/Electronic_Properties/Fermi_Energy_and_Fermi_Surface

 


 

Mole and Avagadro Number:

Since the number of atoms is very large even in small amounts of any element, we need to come up with a unit for number of atoms. Mole is such a unit. It's the amount of substance of a system which contains as many elementary entities as there are atoms in 0.012 kilogram of "carbon-12 12
6
C
". We take 12 g of 12
6
C
 in the defn of mole, but we could have easily taken 1g of "Hydrogen-1 1
1
H
" in the defn. 1 atom of "Carbon-12" has 12 amu of weight, while 1 atom of "Hydrogen-1" has 1 amu of weight.

So, 12g of C-12 has = 12g/12amu = 1g/1amu atoms, while 1g of H-1 has 1g/1amu atoms. So, all these elements have same number of atoms for a weight that is normalized depending on how many amu of weight each atoms has for that element compared to H-1 atom. To keep it simple, we say 1 mole is the number of atoms in 1 g of H-1 (or 12g of C-12 to be precise). It turns out 1 mole = 6.02*10^23 (approx), and that is the number of atoms in 1g of Hydrogen. This is also the number of atoms in 4g of He (since each He atom is 4 amu), and 16g of Oxygen (since each Oxygen atom is 16 amu).

The exact number 6.02214076 * 10^23 is also known as "Avagadro number" or "No". The exact number of atoms in a given mass of an element is impossible to determine, since it will vary considerably depending on the shape, crystalline structure, purity, temperature, pressure, etc. However, for sake of definition, we chose this somewhat arbitrary number to 8 decimal places as our reference number for "Avagadro Number".

 


 

 

Before we start with real Verilog coding, we should use an editor which recognizes Verilog mode and formats it appropriately.

We have "verilog mode" in emacs that not only allows formatting, but allows us to write succinct code which can be expanded to real Verilog code. We'll talk about this feature below.

Verilog mode for Emacs:

Verilog-mode.el is the extremely popular free Verilog mode for Emacs. It can be downloaded from link over here (It's not included by default in standard emacs download). https://www.veripool.org/wiki/verilog-mode

Once downloaded and installed, emacs will start showing verilog specific highlighting, indenting, etc. To verify if verilog mode is there in your emacs, open emacs. You would see tabs on top for File, Edit, Options, etc. If verilog mode is installed, there should be a tab for "Verilog". If you click on "verilog" tab, you should see a pull down showing various action tabs as compile, Recompute AUTOs, etc. You can do more customization by reading help section.

Verilog has a lot of redundant typing built into the syntax. Verilog mode for emacs provides "AUTO" keyword that we can put in verilog code within comments. Putting these keywords within comments /* */ guarantees that this code will work seamlessly with any other tool, which has no knowledge of these "AUTO" keywords as they are in comments.Only verilog mode in emacs looks for these special keywords to expand your verilog code. We can always manually edit the code further or make changes that we didn't like that were introduced by AUTO.

Info about AUTO keywords here: https://www.veripool.org/wiki/verilog-mode/verilog-mode_veritedium

To make changes after inserting AUTO* keywords in verilog code, we can use shortcut "Ctrl+c , Ctrl+a", or goto Verilog tab on emacs and click on "Recompute AUTOs". This expands AUTO keywords (still keeps the commented AUTO keyword so that we know ehere the changes happened).

For older designs which don't have AUTO keywords in them, we can use emacs to inject AUTO in them, so that next time if there are more changes, we can just do "Recompute AUTOs". For Inject AUTOs, we can use shortcut "Ctrl+c , Ctrl+z". All of these AUTO keywords would be injected within comments, so they won't affect if used with other tools.

verilog mode also allows us to expand system verilog .* port connections, so it's easy to check and debug in source code.

Few AUTO cmds:

NOTE: there should be no space between /* and AUTO keyword, i.e /*AUTOARG*/ will work, but /* AUTOARG */ may not work due to spaces)

1. AUTOARG: This is to add argument list for any module. It looks at i/p and o/p ports and adds those in port list of module.

ex: module (/* AUTOARG */); input a; output b; ... => gets transformed into => 

module (/* AUTOARG */

//outputs

out_1, out_2, ..., out_n,

//inputs

in_1, in_2, ..., in_n);

input a; output b; ...

NOTE: Even if we declare no input/output ports. AUTOARG expand will look for undriven input signals and floating output signals, and assign them as input/output ports. This is useful to detect ports automatically.

ex: module (/* AUTOARG */); //This will automatically infer all I/O ports and put them here after expansion

NOTE: To distinguish ports inserted manually by the user, vs ports inferred from AUTOARG expansion, verilog adds comments in auto inserted ports. i.e //From mod_1 of mod_1.v or //To mod_1 of mod_1.v

2. AUTOINPUT, AUTOOUTPUT: This looks for undriven input signals and floating output signals, and assign them as input/output ports. This is useful to detect ports automatically.

ex: module (/* AUTOARG */); /* AUTOINPUT */ /* AUTOOUTPUT */ //This will automatically infer all I/O ports and put them here after expansion (along with AUTOARG expansion)

3. AUTOINST: This automatically adds port connections for a submodule by reading module defn. It creates net connections with same names as port names for module defn. NOTE: AUTOARG is for adding ports to module, while AUTOINST is to add port connections to sub-module.

ex: submod I_submod (/* AUTOINST */); => gets transformed into => submod I_submod ( .out(out), .in(in) ...);

However, sometimes we may want connecting wires to be named differently than port name. In that case we can define exceptions by coding those connections ourselves. AUTO won't overwrite those.

ex: submod I_submod ( .a(a_1), /* AUTOINST */); => gets transformed into => submod I_submod ( .a(a_1), .out(out), .in(in) ...); => NOTE: port "a" remain connected to "a_1"

NOTE: To distinguish ports connected manually by the user, vs port connections inferred from AUTOINST expansion, you can put your own comments for manually connected ports (while auto port connections will show no comments)

4. AUTO_TEMPLATE: NOTE: this has a underscore in it. We use this keyword for same situation as AUTOINST, but when there are multiple instantiations of a module. In such a case, writing exceptions for port connections for each submodule become cumbersome, so we use other reserved special char (as @, $, etc) to make complicated renaming possible.

ex: /* submod AUTO_TEMPLATE (.z(out[@]), .a(invec@ [])); */ => NOTE: here whole thing is in comments as opposed to just the keyword AUTO_TEMPLATE. @ in template takes the leading digits from instantiating module's name. empty [] takes the bit range for the bus from module defn. More complicated lisp expressions possible. Regular expressions also supported. @ suffices for most of the cases. AUTO_TEMPLATE is used in conjunction with AUTOINST. AUTO_TEMPLATE does all complicated connections with renaming, and anything left over is taken care of by AUTOINST. However, AUTOINST always overrides AUTO_TEMPLATE connections in case of conflict, so hardcode connections in instantiation of module if you are unsure what the AUTO_TEMPLATE or AUTOINST is going to do (generally it's used where we want to tie port connections to constants, so we hard code those connections in actual inst of module, as you see in ex of AUTOINST above).

ex: submod I_0 (.z1(out_z), .i2(), .. /* AUTOINST */); => This is regular instantiation of submod. Here AUTOINST is used in regular way. However, since AUTO_TEMPLATE is also defined for this module "submod", emacs will attempt to make connections for port "z" and port "a" (port z connected to out[0] and port a connected to invec0[31:0], since @ takes leading digits from I_0 which is 0. If there are more instances like I_BL_1, then connections will be named out[1], invec1[31:0], etc))

ex: /* submod AUTO_TEMPLATE (.sense_\(.*\) (sense@_\1), ..) */ => \( \) is emacs basic regular expression (see in linux regexp section). Anything inside it is put in var \1. So, here for inst I_0, sense_in4 would be connected to sense0_in4, for inst I_1, it would be sense1_in4 and so on.

NOTE: To distinguish ports connected by AUTO_TEMPLATE, verilog adds comments in auto inserted ports. i.e //Templated. Any user comments put in AUTO_TEMPLATE section are not shown in expanded connections.

5. AUTOWIRE, AUTOREG, AUTOLOGIC => AUTOWIRE takes o/p of submodules and declares wires for them. AUTOREG saves having to duplicate reg stmt for nets declared as outputs. AUTOLOGIC declares logic instead of wire or reg.

ex: module ... output y; /* AUTOWIRE */ /*AUTOREG */ wire a; ... => gets transformed into => ... output y; /* AUTOWIRE */ /*AUTOREG */ wire b; reg y; wire a; ...

6. AUTOSENSE (or shortcut AS) => replaces everything with sensitivity list. System Verilog supports @* for sensitivity list, so AS is not needed any more.

ex: always @ (/* AS */) begin ... end => gets transformed into => always @ (/* AS */ a or b or sel) begin ... end

 

Running emacs in batch mode:

Instead of opening emacs and doing it on gui, we can run emacs in batch mode (i.e as cmd line w/o invoking editor) as follows:

emacs -batch my_design.v -f verilog-auto -f save-buffer => same as doing "compute AUTOs" and saving in same file