• 1

    ..

  • 2

    ...

  • 3

    ...

Wednesday 23 December 2015

Download Verilog codes for SPI Master and Slave modules



Sharing below the links for SPI Verilog codes for Master and Slave modules.


SPI means Serial Pheripheral Interface, is a synchronous serial data link operating in full duplex mode.

For detailed information of the Verilog code of SPI Master and Slaves modules, proceed to the below links.

 For Verilog code of SPI Master and Slaves modules code download & discussions, click here.



Monday 2 November 2015

PERL TUTORIAL PART 4 - Working with files

FILE HANDLING


     The basics of handling files are simple, just associate a filehandle with an external file and then use a variety of operators and functions within Perl to read and update the data stored within the data stream associated with the filehandle. The filehandle is the name for an I/O connection between the Perl process and the outside world.
     A filehandle is a named internal Perl structure that associates a physical file with a name. The mode of operation must be specified for the filehandle is opened.
     Three basic file handles are - STDIN, STDOUT, and STDERR which represent standard input, standard output and standard error devices respectively. Apart from these, any number of filehandles can be added in the code.
The different file operations are:
1) Opening a file
2) Closing the file
3) File Reading
4) File Writing
5) File tests

1) Opening a file

The syntax for opening a file is as follows:
open(FILEHANDLE,"<mode>file_name");
or simply
open(FILEHANDLE,"mode","file_name");
where mode specifies the type of file access.
MODE SYMBOL
ACCESS TYPE
< or r
Read Only Access
> or w
Creates, Writes, and Truncates
>> or a
Writes, Appends, and Creates
+< or r+
Reads and Writes
+> or w+
Reads, Writes, Creates, and Truncates
+>> or a+
Reads, Writes, Appends, and Creates
Most commonly used are <, >, >>.
It is a good practice to use capital letters for filehandles. And for safe operation, it is always recommended to use the DIE(....) function for file open which will terminate the program when it fails to open the file.
open(FILEHANDLE,"mode","file_name") or die "Unable to open the file(file_name)";

Example:
open(FH1R,"<","file1.txt") or die "Unable to open the file(file1.txt) in read mode!";
open(FH2W,">file2.txt") || die "Unable to open the file(file2.txt) to write!";
$logfilename="log.txt"
open(LOG,">>",$logfilename) || die "Unable to open the file(log.txt) in append mode!!!";

2) Closing the file

To close a file simply call the CLOSE(...) function with the filehandle as input. All the filehanldes are automatically closed when the Perl program terminates. The syntax is
close(FILEHANDLE);

3) Reading from a file

To read the contents from the file, <> operator is used, just like STDIN.
Example:
$line_1=<FH1R>; #reads only one line
@lines=<FH1R>; #reads the entire file, & places in the array

4) Writing to a file

Writing data to a file is simply like printing to STDOUT, except the filehandle is used between the print keyword & data.
Example:
print FH2W "Hello!! This is 1st line...\n";

5) File testing

File tests are performed on file handles to determine the file properties. For example –e FileHandle returns true if the file pointed by FileHandle exists in the system. The below table shows the different file test that can be performed in Perl. Note that the CAPITAL and small letter tests produces different results.
PARAMETER
DESCRIPTION
-r
File or directory is readable
-w
File or directory is writable
-x
File or directory is executable
-o
File or directory is owned by user
-R
File or directory is readable by real user, not effective user
(differs from -r for setuid programs)
-W
File or directory is writable by real user, not effective user
(differs from -w for setuid programs)
-X
File or directory is executable by real user, not effective user
(differs from -x for setuid programs)
-O
File or directory is owned by real user, not effective user
(differs from -o for setuid programs)
-e
File or directory exists
-z
File exists and has zero size (directories are never empty)
-s
File or directory exists and has nonzero size (the value is the size in bytes)
-f
Entry is a plain file
-d
Entry is a directory
-S
Entry is a socket
-p
Entry is a named pipe (a "fifo")
-t
isatty() on the filehandle is true
-T
File is "text"
-B
File is "binary"
-c
Entry is a character-special file
-M
Modification age in days
-A
Access age in days
-C
Inode -modification age in days

Example:
if (-e FH1)
print "File FH1 exists\n";
if (-T FH1)
print "File FH1 exists & is a Text file\n";
$size= -s FH1;
print "File size is $size bytes...\n";
We welcome your valuable comments and suggestion.
It helps us to do better in future.
Thank you.

Saturday 17 October 2015

Sort numbers using C# with and without .net feature.

The following Program is a Example of getting 10 integer numbers (from -1000 to 1000) from User and Store it in an array and sort them and Display. .



WITH .NET Feature :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication5
{
   class Program
   {
       static void Main(string[] args)
       {
           String num_str;
           int[] num = new int[10];
           int temp;
           bool num_flag = false;

           Console.WriteLine("Enter 10 integer number:");
           for(int i = 0 ; i < 10 ; i++)
           {
               Console.WriteLine("enter {0} number",i);
               num_str = Console.ReadLine();
               num_flag = int.TryParse(num_str, out temp);

               while (num_flag == false)
               {
                    Console.WriteLine("please Enter interger");
                    num_str = Console.ReadLine();
                    num_flag = int.TryParse(num_str, out temp);
               }
               if ((temp >= -1000) && (temp <= 1000))
               {
                   num[i] = temp;
               }
               else
               {
                   Console.WriteLine("Please Enter number (-1000 <= x  <= 1000");
                   i--;
               }
           }
           
           Array.Sort(num);
       foreach (int value in num)
       {
           Console.Write(value);
           Console.Write(' ');
       }
           Console.ReadLine();
       }
   }
}

WITHOUT .NET Feature :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
   class Program
   {
       
           static void Main(string[] args)
           {
           String num_str;
           int[] num = new int[10];
           int temp;
           bool num_flag = false;

           Console.WriteLine("Enter 10 integer number:");
           for(int i = 0 ; i < 10 ; i++)
           {
               Console.WriteLine("enter {0} number",i);
               num_str = Console.ReadLine();
               num_flag = int.TryParse(num_str, out temp);

               while (num_flag == false)
               {
                    Console.WriteLine("please Enter interger");
                    num_str = Console.ReadLine();
                    num_flag = int.TryParse(num_str, out temp);
               }
               if ((temp >= -1000) && (temp <= 1000))
               {
                   num[i] = temp;
               }
               else
               {
                   Console.WriteLine("Please Enter number (-1000 <= x  <= 1000");
                   i--;
               }
           }
             
           //Array.Sort(num);

           for (int x = 0; x < num.Length; x++)
           {
               for (int y = 0; y < num.Length - 1; y++)
               {
                   if (num[y] > num[y + 1])
                   {
                       int temp1 = num[y + 1];
                       num[y + 1] = num[y];
                       num[y] = temp1;
                   }
               }
           }
       foreach (int value in num)
       {
           Console.Write(value);
           Console.Write(' ');
       }
           Console.ReadLine();

       }
   }
}


If you enjoyed this post plz let us know your views via comments.
This helps us to do much more better.
Thankyou.
 

Saturday 29 August 2015

APPLICATION WAIT TIMER USING VBSCRIPT

tim = InputBox("Please enter wait time [min:sec]")
a=Split(tim,":")
sec=a(1)*1000
min=a(0)*60*1000
Wscript.sleep (min + sec)
msgbox "Hey! " & a(0) & " min " & a(1) & " secs elapsed!!!"




If you enjoyed this post plz let us know your views via comments.
This helps us to do much more better.
Thankyou.

join us 

Saturday 7 March 2015

VHDL Reserved Words - ELECDUDE

VHDL Reserved Words

KEYWORD
DESCRIPTION
abs
operator, absolute value of right operand. No () needed.
access
used to define an access type, pointer
after
specifies a time after NOW
alias
create another name for an existing identifier
all
dereferences what precedes the .all
and
operator, logical "and" of left and right operands
architecture
a secondary design unit
array
used to define an array, vector or matrix
assert
used to have a program check on itself
attribute
used to declare attribute functions
begin
start of a begin end pair
block
start of a block structure
body
designates a procedure body rather than declaration
buffer
a mode of a signal, holds a value
bus
a mode of a signal, can have multiple drivers
case
part of a case statement
component
starts the definition of a component
configuration
a primary design unit
constant
declares an identifier to be read only
disconnect
signal driver condition
downto
middle of a range 31 downto 0
else
part of "if" statement, if cond then ... else ... endif;
elsif
part of "if" statement, if cond then ... elsif cond ...
end
part of many statements, may be followed by word andid
entity
a primary design unit
exit
sequential statement, used in loops
file
used to declare a file type
for
start of a for type loop statement
function
starts declaration and body of a function
generate
make copies, possibly using a parameter
generic
introduces generic part of a declaration
group
collection of types that can get an attribute
guarded
causes a wait until a signal changes from False to True
if
used in "if" statements
impure
an impure function is assumed to have side effects
in
indicates a parameter in only input, not changed
inertial
signal characteristic, holds a value
inout
indicates a parameter is used and computed in and out
is
used as a connective in various statements
label
used in attribute statement as entity specification
library
context clause, designates a simple library name
linkage
a mode for a port, used like buffer and inout
literal
used in attribute statement as entity specification
loop
sequential statement, loop ... end loop;
map
used to map actual parameters, as in port map
mod
operator, left operand modulo right operand
nand
operator, "nand" of left and right operands
new
allocates memory and returns access pointer
next
sequential statement, used in loops
nor
operator, "nor" of left and right operands
not
operator, complement of right operand
null
sequential statement and a value
of
used in type declarations, of Real ;
on
used as a connective in various statements
open
initial file characteristic
or
operator, logical "or" of left and right operands
others
fill in missing, possibly all, data
out
indicates a parameter is computed and output
package
a design unit, also package body
port
interface definition, also port map
postponed
make process wait for all non postponed process to suspend
procedure
typical programming procedure
process
sequential or concurrent code to be executed
pure
a pure function may not have side effects
range
used in type definitions, range 1 to 10;
record
used to define a new record type
register
signal parameter modifier
reject
clause in delay mechanism, followed be a time
rem
operator, remainder of left operand divided by rightop
report
statement and clause in assert statement, string output
return
statement in procedure or function
rol
operator, left operand rotated left by right operand
ror
operator, left operand rotated right by right operand
select
used in selected signal assignment statement
severity
used in assertion and reporting, followed by a severity
signal
declaration that an object is a signal
shared
used to declare shared objects
sla
operator, left operand shifted left arithmetic by right op
sll
operator, left operand shifted left logical by rightop
sra
operator, left operand shifted right arithmetic by right
srl
operator, left operand shifted right logical by rightop
subtype
declaration to restrict an existing type
then
part of if condition then ...
to
middle of a range 1 to 10
transport
signal characteristic
type
declaration to create a new type
unaffected
used in signal waveform
units
used to define new types of units
until
used in wait statement
use
make a package available to this design unit
variable
declaration that an object is a variable
wait
sequential statement, also used in case statement
when
used for choices in case and other statements
while
kind of loop statement
with
used in selected signal assignment statement
xnor
operator, exclusive "nor" of left and right operands
xor
operator, exclusive "or" of left and right operands

Search Here...