Sunday, August 11, 2013

DIGILENT Basys2 Simple Seven Segment Timer project using Verilog

Hello everyone, This a simple timer i designed using the DIGILENT-Basys2. This module start counting the time at the point of reset and keeps on counting.  I used Xilinx ISE design suite 14.5 for generating the bit file. Here is my verilog code and .ucf file.

Verilog Code

module clock1(
input reset,clock,
output [7:0] ss,
output [3:0] anode
    );
   
//timing
reg [25:0] counter;
reg [7:0] temps;
reg [3:0] an;
reg [3:0] d0;
reg [3:0] d1;
reg [3:0] d2;
reg [3:0] d3;
reg [3:0] num;
initial d0=4'b0000;
initial d1=4'b0000;
initial d2=4'b0000;
initial d3=4'b0000;

always@(posedge clock or posedge reset)
begin
   
    if(reset)
    counter<=0;
    else if(counter==50000000) begin
        counter<=0;
        if(d0==9) begin
            d0<=0;
            if(d1==5) begin
                d1<=0;
                if(d2==9) begin d2<=0;
                    if(d3==9) begin d3<=0;d2<=0;d1<=0;d0<=0;end
                    else d3<=d3+1;
                end
                else d2<=d2+1;
                end
            else d1<=d1+1;
           
        end
        else d0<=d0+1;
       
       
    end
    else
    counter<=counter+1;
end

reg [18:0] sync;

always@(posedge clock or posedge reset)
begin
    if(reset)
    sync<=0;
    else
    sync<=sync+1;

   
end

always@(*)
begin
    if(sync[18:17]==2'b00) begin
    an<=4'b1110;num<=d3; end
    else if(sync[18:17]==2'b01) begin
    an<=4'b1101;num<=d2; end
    else if(sync[18:17]==2'b10) begin
    an<=4'b1011;num<=d1; end
    else begin
    an<=4'b0111;num<=d0; end
end


always@(*)
begin
case(num)
4'b0000 : temps=~(8'b00111111);
4'b0001 : temps=~(8'b00000110);
4'b0010 : temps=~(8'b01011011);
4'b0011 : temps=~(8'b01001111);
4'b0100 : temps=~(8'b01100110);
4'b0101 : temps=~(8'b01101101);
4'b0110 : temps=~(8'b01111101);
4'b0111 : temps=~(8'b00000111);
4'b1000 : temps=~(8'b01111111);
4'b1001 : temps=~(8'b01100111);
4'b1010 : temps=~(8'b01110111);
4'b1011 : temps=~(8'b01111100);
4'b1100 : temps=~(8'b00111001);
4'b1101 : temps=~(8'b01011110);
4'b1110 : temps=~(8'b01111001);
4'b1111 : temps=~(8'b01110001);
endcase
end


assign ss=temps;
assign anode=an;

endmodule


.ucf File 

NET "anode[0]" LOC = K14;
NET "anode[1]" LOC = M13;
NET "anode[2]" LOC = J12;
NET "anode[3]" LOC = F12;
NET "ss[0]" LOC = L14;
NET "ss[1]" LOC = H12;
NET "ss[2]" LOC = N14;
NET "ss[3]" LOC = N11;
NET "ss[4]" LOC = P12;
NET "ss[5]" LOC = L13;
NET "ss[6]" LOC = M12;
NET "ss[7]" LOC = N13;

NET "clock" LOC = B8;
NET "reset" LOC = A7;

Saturday, August 10, 2013

Knight Rider Project using DIGILENT Basys2 FPGA


Verilog Code

module kr(
input clock,reset,
output [7:0] A
    );
reg [20:0] count;
reg [7:0] temp;
reg [3:0] c;
reg dir;
initial dir=1'b1;
parameter a=8'b00000001;
parameter b=8'b10000000;
always@(posedge clock)
begin
    count<=count+1;
    if(reset) begin
        count<=0;
        temp<=0;
        temp<=temp+1;
        c<=0;
       
         end
    else if(count==2097151) begin
        if(dir)begin
        c<=c+1;
        temp<=a<<c;
            if(c==7) begin
                dir<=1'b0;
                c<=0; end
        end
       
        else begin
        c<=c+1;
        temp<=b>>c;
            if(c==7) begin
                dir<=1'b1;
                c<=0; end       
        end
        end
       
end
assign A=temp;
     
endmodule


.ucf File      

NET "clock" LOC = B8;
NET "reset" LOC = A7;
NET "A[0]" LOC = M5;
NET "A[1]" LOC = M11;
NET "A[2]" LOC = P7;
NET "A[3]" LOC = P6;
NET "A[4]" LOC = N5;
NET "A[5]" LOC = N4;
NET "A[6]" LOC = P4;
NET "A[7]" LOC = G1;  






Friday, November 2, 2012

How to overcome the issues in Sri lankan education sector?


William Beattie who was a well-known Politician/Minister in Northern Ireland once said.

“The aim of education should be to teach us rather how to think, than what to think - rather to improve our minds, so as to enable us to think for ourselves, than to load the memory with thoughts of other men.” 

This quotation expresses the true objective of education in much simpler manner. If the final output of a system of education is a dull, unproductive, ROBOT like person who can’t do a single thing independently, there is no need for such kind of a system. Instead the education system must provide people who are resourceful in every possible manner, people who know what to do in a problematic situation and people who have creative ideas that can change the course of the world.
As Sri Lankans, though we have a 90 plus literacy rate(which is quite good figure for a developing nation) and we always try to boast about ourselves comparing it with other under developed countries, the statistics consistently shows some kind of a vast disaster is present in our education system. Every year an average percentage of 50% students out of the total number of students who sit for GCE O/L examination fail to fulfill the minimum qualification for Advanced level studies and out of the total number of students who sit for the GCE A/L examination, approximate percentage of 15-20% gain entrance to university education which is a significantly poor figure. This is not because all the others fail this examination, but the state universities are not capable of accommodating the total amount of students who fulfill the basic requirement for university entrance which is much larger percentage compared to that 15-20%. So what will happen to the 50% who fail to go for AL education?  Are they a set of blacklisted people who lack the ability to pass an ordinary examination? And what are the alternatives available for the people who miss higher education not because of their own fault? Those are some burning issues we are facing as a nation for few decades.
According to my opinion our education must be reformed from its very beginning which is the primary education. The most important step in our primary education is the grade five scholarship examination, according to me it is the reason for most of the problems present in the latter stages of the education. Most of the students try to do well in this to go to well recognized, urban school which has more facilities, but that will be good for those who do well  but not for the students who fall behind and do not get a chance to go for a better school. Unfortunately the students who fail to pass the O/L examination are from this set because most of the rural schools have good primary sections but not good junior secondary sections or A/L sections. Most of the schools lack the facilities such as Laboratories, libraries, buildings and also face a severe deficit of qualified A/L O/L teachers. So obviously the students find it difficult do well in the O/L examination and decide to end their school life as soon as possible. (I have personally witnessed this. Most of my childhood friends ended up in Army or Navy and I who passed the grade V exam am here composing this article). I think this method must be change immediately; the grade five scholarship examination must be eliminated from the system because it creates a huge gap between rural under developed schools and popular schools in the town and also puts a large amount of stress to the young heads in very small age. Instead every school must be gradually developed to equal state in such a way that any school has no superior facilities than any other. Every school must be provided with laboratory, library, sporting ,teaching facilities and other required facilities. Good teachers must be circulated among different schools periodically because some good teachers used to stay at same school for a long time. Then there won’t be a special rush to go for popular schools and also the popularity of rural schools will also be increased because the bright students will remain there. In order to increase the pass rates students’ performance should be well monitored by carrying out assignments; term tests etc. and they must be motivated to do well in exams by explaining them the benefits arise from good education. This can be achieved by a good counseling/carrier guidance programs.
The most controversial stage in our education system is the university education because significantly low number of students becomes eligible for higher education in Sri Lanka. Obviously the state university facilities are not enough, but is that the only excuse? What are the possible alternatives for those students who do not get the chance? It’s true that government carry out some programs such as technical colleges, vocational training centers, colleges of education etc  to help these students to find out their carriers, Students with enough monetary power might go for private educational institutes or even foreign universities. But what about the rest? According to my opinion privatization of higher education is the only efficient and timely solution for this issue. Then the next immediate question will be “What will happen to the free education then?”. But what will happen to it if the current course is continued for long because we are witnessing the violation of free education in front of our eyes. It’s not a secret that private educational institutes are already operating in the island who charge a huge amount of course fee that an average citizen can’t bear. Another thing is that If education is free it must not be limited to people who are bright enough, everyone who is willing to study must have access to higher education even he or she is from a rich family or poor family. The only solution for both of these issues is promoting the private universities/educational institutes in parallel with the development of state universities. Because privatization makes an entity more efficient, profitable and productive. For the ones with monetary power this system is ok, but how to give chance to poor students who are willing to go for higher education? For this scholarship schemes can be introduced. Students who are good at something (science, maths, dancing, singing etc) can be offered with those scholarships to study at well recognized private universities. The state university facilities must also be upgraded to match those private universities and local, foreign students should be attracted to study at them. The standard of education of private/state universities must be well monitored. Although anyone can study at a private university certain criterion must be used to access the eligibility of a student for a given degree program. Otherwise there will be a lot of unskilled graduates all over the place. This is a system carried out by most the countries in the world because only state universities alone cannot fulfill the huge demand for higher education. There must be an alternative and with no doubts it will be the private universities. Another advantage will be that a lot money which is driven abroad for the students who are at foreign universities will remain in the island and it will be good for our economy as well.

Thursday, August 2, 2012

The Theory of Everything – Holy Grail of Physics

by Charitha Saumya



The study about forces which occur between electrically charged particles such as electrons and protons is called Electromagnetism, study about forces that occur between objects which are proportional to the masses of those objects, you call it Gravitation, and the branch of science that describes about any phenomena connected to a flow of electrons is Electricity. One can mention thousands of theories, phenomena, scientific discoveries, inventions because it was the nature of the mankind to be curious about what happens around him and try to explain whatever he observes according to a well-balanced theory. But what if, all those branches of science can be explained by a single unified theory? This may sound strange, but this concept has a fair amount of history and physicists usually call this “The theory of everything” i.e. ToE.

Early Attempts
Many theories were proposed as ToE during the past few centuries but none of them were accepted by the scientific world, hence it remains as an unsolved problem in physics. Archimedes was the first scientist to come up with the idea of explaining every physical observation using some kind of a theory which he called an “Axiom” or principal. Democrates stated that all physical phenomena are caused by the motion of fundamental matter particles or the atoms. In the 17th century Sir Isaac Newton published “Principia” in which he included the laws of gravity, using those laws he was able to unify Galileo’s studies on terrestrial gravity and Kepler’s Laws of planetary motion. In 1814 Laplace came up with the idea that if we know the position and velocity of a particle at any given time we could find the velocity and position of that particle accurately at any other given time using the laws of nature. In 1820 scientist Hans Christian Orsted accidently discovered that electricity and magnetism are interconnected. While carrying out an experiment he observed a sudden deflection in a compass which was kept near a conducting wire. This interesting discovery resulted in the birth of Electromagnetism, which was formulated in to a well- defined theory by James Clerk Maxwell in 1865. In this era the physicists started to suggest that most of the examples of forces i.e. Friction, viscosity, pressure, contact forces are caused by interactions between smallest particles of matter. In each of these attempts physicists’ objective was to find a unified theory to describe gravity and electromagnetism using a single model, but unfortunately none of them succeeded.

Einstein factor
The search for a ToE faced a revolutionary change in 1915 with the introduction of general relativity by Albert Einstein. Newton’s concepts related to gravity and gravitational force were challenged by Einstein’s general relativity. Einstein suggested that gravity is a result of space time being curved due to objects having a massive mass. Further he stated that the motion of objects (even light) is affected by this curvature of space time. Einstein was able to prove his theory by showing that the path of light waves coming from a distance star gets curved when it travels near the sun. For this he had to wait for a solar eclipse because it was hard to observe a star when it is placed near to the Sun on the sky.

“In a curved space time the motion of objects gets very interesting. For example take earth’s surface as the curved surface. The shortest distance between two points on that surface will be a part of a great circle ; a circle which goes through those two points and the center of which is placed at the center of earth. But this path will be a curved line in a flat map!!!”

With the emergence of general relativity the search for a unified field theory to combine gravity with electromagnetism started with a new intensity. Einstein himself wasted the later stages of his life for this, but had no success.
At that time physicists were more interested in the new findings on Nuclear reactions which actually seemed to be another obstacle for the ToE. The reason was that these nuclear interactions were so different from gravity or Electromagnism. In 1967-68 three physicists, namely Sheldon Glashow, Steven Weinberg and Abdus Salam proposed that the first 2 of the three quantum forces; electromagnetic force, weak force, strong force can be combined through a concept called “electroweak force”. This was when the physics world came to know about “Bosons” which you may have heard already. In quantum field theories a force field is said to be made of these “boson” elementary particles. These particles move back and forth between matter particles transmitting the forces. In lower energies the weak forces are carried by bosons and electromagnetic forces are carried by photons which is also an example for bosons. Matter particles are called “fermions” and electrons, quarks are some examples for fermions. Currently many interesting experiments are carried on these elementary particles using advanced particle detectors to check whether they really exist.

Modern approaches
Presently one of the favorite candidates for ToE is the String theory or the M- theory. Actually this is not a complete theory but rather an approach to find a ToE. The theory is mainly based on the premise that the universe consists of many dimensions than we usually observe. We are familiar with the dimensions that are easily observable to us like space and time but this may not be the case. So this theory tries to deal with a large number of dimensions to derive equations for physical phenomena and compare them with known laws of physics to find some similarities. Interestingly this theory can describe the reason for gravity to be so weak compared to other forces, which is the possibility of gravity being leaked to some other unknown dimensions in ways that other forces would not. But the problem with this theory is that it allows a large number of possibilities for a given universe with an arbitrary number of dimensions. One solution proposed is that these universes coexist but small number of them is good enough to live on. The Idea of Causal sets is another interesting concept which is mainly related to quantum gravity. It is based on the idea that space time is discrete not continuous as most of the physicists believe and space time events are related with a partial order.
The challenge on physicists’ hand is to find unification for electroweak force with strong force and finally combine it with gravity, but still the quest for such grand unified theory has achieved a very little amount of success. Modern physicists states that the future of ToE depends on the ongoing experiments on elementary particles and dark matter because the quest requires more input to produce such universal theory.

References:
The Grand Design by Stephen Hawking 

Note : This is an article i wrote for the E-Carrier magazine published by the Electronics and Telecommunication department of university of Moratuwa.

Friday, July 13, 2012

Randoms

Date    : 04.07.2012  

Place : Gangarama Temple ,Colombo


Date : 04.07.2012
Place : Gangarama Temple , Colombo

Place : Victoria Dam

Randenigala - Kandy Road

Paddy fields found on the way to Dehiaththakandiya.

Beauty of Hanthana

View from the top of Hanthana mountain range.

Place : Department of electronics and telecommunication
University of Moratuwa

Place : Department of electronics and telecommunication,University of Moratuwa.