1. handle multiple files:
:bn - jump to next file
:bp - jump to previous file
:bw - close current file
Ctrl ^ - toggle tween current and previous files
:e# - jump to previous file
:b1 - jump to the first file
1. column edit (visual mode):
v - visual mode
Ctrl v - visual-block mode
V - visual-line
4/27/2007
Embed Perl into C/C++
1. Compile the interpreter:
gcc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
`perl -MExtUtils::Embed -e ccopts -e ldopts` is used to set the options fro gcc
interp.c:
#include /* from the Perl distribution */
#include /* from the Perl distribution */
static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
int main(int argc, char **argv, char **env)
{
PERL_SYS_INIT3(&argc,&argv,&env);
my_perl = perl_alloc();
perl_construct(my_perl);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
PERL_SYS_TERM();
}
2. Run the interpreter:
$interp
print "Pretty Good Perl \n";
print "10890 - 9801 is ", 10890 - 9801;
Pretty Good Perl
10890 - 9801 is 1089
$
gcc -o interp interp.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
`perl -MExtUtils::Embed -e ccopts -e ldopts` is used to set the options fro gcc
interp.c:
#include
#include
static PerlInterpreter *my_perl; /*** The Perl interpreter ***/
int main(int argc, char **argv, char **env)
{
PERL_SYS_INIT3(&argc,&argv,&env);
my_perl = perl_alloc();
perl_construct(my_perl);
PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
perl_parse(my_perl, NULL, argc, argv, (char **)NULL);
perl_run(my_perl);
perl_destruct(my_perl);
perl_free(my_perl);
PERL_SYS_TERM();
}
2. Run the interpreter:
$interp
print "Pretty Good Perl \n";
print "10890 - 9801 is ", 10890 - 9801;
Pretty Good Perl
10890 - 9801 is 1089
$
4/21/2007
Logic Calucation in Veirlog
~z = x;
~X = X;
0&Z = 0&X = 0;
1&Z = 1&X = X;
Z&1 = Z&Z = Z&X = X;
X&1 = X&Z = X&X = X;
Z|0 = Z|Z = Z|X = X;
X|0 = X|Z = X|X = X;
Z^* = X^* = X;
Z~^* = X~^* = X;
~X = X;
0&Z = 0&X = 0;
1&Z = 1&X = X;
Z&1 = Z&Z = Z&X = X;
X&1 = X&Z = X&X = X;
Z|0 = Z|Z = Z|X = X;
X|0 = X|Z = X|X = X;
Z^* = X^* = X;
Z~^* = X~^* = X;
4/09/2007
Ways to assign signals in Verilog
1. Continuous assignment (assign)
wire a;
assign a = 1'b1; //behaves like a wire
2. Procedural assignemnt (always)
a). blocking assignment
reg a, b;
a = 1'b1; //will block next assignment only in sequential blocks
b = 1'b0;
b). non-blocking assignment
reg a, b;
a <= 1'b1; //all non-blocking assignemnts will be executed at b <= 1'b0; //the END of this update event.
Because non-blocking assignments are executed at the end of update event, if they are mixed with blocking assigments, non-blocking assignments will be executed after all blocking assignments.
If multiple non-blocking assignments are used to assign the same variable in a block, the order of assignments will be hornored.
reg a;
a <= 1'b1;
a <= 1'b0; //a is 0 finally If multiple non-blocking/blocking assignments are used to assign the same variable in different blocks, and the order of their executions can not be decided, then the final value of this variable can not be determined.
reg a;
initial a <= 1'b1;
initial a <= 1'b0; //a is uncertain
However, if the order of their executions can be determined, the final value of the variable is determined.
reg a;
initial #8 a <= #8 1'b1; //@16, a is set to 1, scheduled @8
initial #10 a <= #6 1'b0; //@16, a is set to 0, scheduled @10
a would be 0 finally because the second assignemnt is scheduled later.
3. Procedural continuous assignment (assign/deassign, force/release)
assign procedural continuous assignment will override all previous procedural assignments to the same variable. deassign will cancel this assignment.
force/release have the similar function with the exception that they can be used on wires as well.
module dff (q,d,clear, preset, clock);
input d, clear, preset, clock;
output q;
reg q;
always @(clear or preset)
if(!clear) assign q = 0;
else if (!preset) assign q = 1;
else deassign q;
always @(posedge clock)
q = d;
endmodule
wire a;
assign a = 1'b1; //behaves like a wire
2. Procedural assignemnt (always)
a). blocking assignment
reg a, b;
a = 1'b1; //will block next assignment only in sequential blocks
b = 1'b0;
b). non-blocking assignment
reg a, b;
a <= 1'b1; //all non-blocking assignemnts will be executed at b <= 1'b0; //the END of this update event.
Because non-blocking assignments are executed at the end of update event, if they are mixed with blocking assigments, non-blocking assignments will be executed after all blocking assignments.
If multiple non-blocking assignments are used to assign the same variable in a block, the order of assignments will be hornored.
reg a;
a <= 1'b1;
a <= 1'b0; //a is 0 finally If multiple non-blocking/blocking assignments are used to assign the same variable in different blocks, and the order of their executions can not be decided, then the final value of this variable can not be determined.
reg a;
initial a <= 1'b1;
initial a <= 1'b0; //a is uncertain
However, if the order of their executions can be determined, the final value of the variable is determined.
reg a;
initial #8 a <= #8 1'b1; //@16, a is set to 1, scheduled @8
initial #10 a <= #6 1'b0; //@16, a is set to 0, scheduled @10
a would be 0 finally because the second assignemnt is scheduled later.
3. Procedural continuous assignment (assign/deassign, force/release)
assign procedural continuous assignment will override all previous procedural assignments to the same variable. deassign will cancel this assignment.
force/release have the similar function with the exception that they can be used on wires as well.
module dff (q,d,clear, preset, clock);
input d, clear, preset, clock;
output q;
reg q;
always @(clear or preset)
if(!clear) assign q = 0;
else if (!preset) assign q = 1;
else deassign q;
always @(posedge clock)
q = d;
endmodule
Subscribe to:
Posts (Atom)