Author Archive
Verilog SyntaxHighlighter Brush
by Hanly on May.20, 2010, under Code
I was trying to add some sample Verilog code on my website, but the code syntax highlighter I use did not have a brush. I made my own Verilog brush for Alex Gorbatchev’s SyntaxHighlighter. Feel free to modify and improve the code. The only thing that I ask is that you share the modifications.
/**
* SyntaxHighlighter Verilog Brush
* http://hdelossantos.com/
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/wiki/SyntaxHighlighter:Donate
*
* @version
* 1.0.0 (May 20, 2010)
*
* @copyright
* Copyright (C) 2010 Hanly De Los Santos.
*
* @license
* This file is a SyntaxHighlighter brush and is licensed under
* the same license as SyntaxHighlighter.
*
* SyntaxHighlighter is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* SyntaxHighlighter is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with SyntaxHighlighter. If not, see <http://www.gnu.org/copyleft/lesser.html>.
*/
SyntaxHighlighter.brushes.Verilog = function() {
var keywords = 'always end ifnone or rpmos tranif1 and endcase ' +
'initial output rtran tri assign endmodule inout ' +
'parameter rtranif0 tri0 begin endfunction input ' +
'pmos rtranif1 tri1 buf endprimitive integer ' +
'posedge scalared triand bufif0 endspecify join ' +
'primitive small trior bufif1 endtable large pull0 ' +
'specify trireg case endtask macromodule pull1 ' +
'specparam vectored casex event medium pullup ' +
'strong0 wait casez for module pulldown strong1 ' +
'wand cmos force nand rcmos supply0 weak0 deassign ' +
'forever negedge real supply1 weak1 default for ' +
'nmos realtime table while defparam function nor ' +
'reg task wire disable highz0 not release time wor ' +
'edge highz1 notif0 repeat tran xnor else if ' +
'notif1 rnmos tranif0 xor';
var sysTasks = '$display $monitor $dumpall $dumpfile $dumpflush ' +
'$dumplimit $dumpoff $dumpon $dumpvars $fclose ' +
'$fdisplay $fopen $finish $fmonitor $fstrobe ' +
'$fwrite $fgetc $ungetc $fgets $fscanf $fread ' +
'$ftell $fseek $frewind $ferror $fflush $feof ' +
'$random $readmemb $readmemh $readmemx $signed ' +
'$stime $stop $strobe $time $unsigned $write';
var macros = 'default-net define celldefine default_nettype ' +
'else elsif endcelldefine endif ifdef ifndef ' +
'include line nounconnected_drive resetall ' +
'timescale unconnected_drive undef';
this.regexList = [
{ regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' },
{ regex: /\/\*([^\*][\s\S]*)?\*\//gm, css: 'comments' },
{ regex: /\/\*(?!\*\/)\*[\s\S]*?\*\//gm, css: 'preprocessor' },
{ regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' },
{ regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' },
{ regex: /\b([\d]+(\.[\d]+)?|0x[a-f0-9]+)\b/gi, css: 'value' },
{ regex: /(?!\@interface\b)\@[\$\w]+\b/g, css: 'color1' },
{ regex: /\@interface\b/g, css: 'color2' },
{ regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' },
{ regex: new RegExp(this.getKeywords(macros), 'gm'), css: 'keyword' },
{ regex: new RegExp(this.getKeywords(sysTasks), 'gm'), css: 'keyword' }
];
};
SyntaxHighlighter.brushes.Verilog.prototype = new SyntaxHighlighter.Highlighter();
SyntaxHighlighter.brushes.Verilog.aliases = ['verilog', 'v'];
You can download the Wordpress plugin below. You must have the SyntaxHighlighter plugin installed and active.
Powers of base 2 between 2 values using array in MIPS
by Hanly on Mar.15, 2009, under Computer Science
Program requests and reads in exactly one character, which represents an exponent. If the value is acceptable, then the program reads in another value. The program calculates the base 2 power between the user input values, and then stores the calculated values in an array. It then prints the values in the array.
# Assignment 3: Powers of 2 Assembly utilizing Array # by Hanly De Los Santos # Copyright ©2009, Hanly De Los Santos. All Rights Reserved. # http://www.hdelossantos.com # # Program requests and reads in exactly one character, # which represents an exponent. If the value is acceptable, then the # program reads in another value. The program calculates # the base 2 power between the user input values, and then # stores the calculated values in an array. It then prints the # values in the array. # .text .globl __start # Load acceptable ascii decimal value for number ranges # since input is read in as a character. __start: li $8, 48 # This is the decimal equivalent of 0 li $9, 57 # This is the decimal equivalent of 9 # Prompt the user for input. la $11, prompt puts $11 # Grab user input and store value in register 10 getc $10 la $11, newline # Create new line lb $17, ($11) putc $17 add $15, $10, 0 # Make copy of contents of r10 in r15. sub $15, $15, 48 # Convert char from first input to int. # Test to determine whether or not the user input value is acceptable. # If user input is less than 48 and greater than 57, branches to # exit_donothing, where the user is told the input is wrong. bgt $10, $9, exit_donothing blt $10, $8, exit_donothing sub $10, $10, 48 # After check, convert char to int. # Prompt user for additional input la $11, prompt2 puts $11 # Grab user input and store in r12 getc $12 la $11, newline # Create new line lb $17, ($11) putc $17 add $18, $10, 0 # Make copy of contents of r12 in r18. sub $18, $18, 48 # Convert char to int. # Test to determine whether or not the user input value is acceptable. # If user input is less than 48 and greater than 57, branches to # exit_donothing, where the user is told the input is wrong. bgt $12, $9, exit_donothing blt $12, $8, exit_donothing sub $12, $12, 48 # After check, convert char to int. # Determine if the difference between the two user input values is 0 bnez $10, neqz beqz $12, special_zero # Determine difference between 2 values neqz: sub $21, $12, $10 #Store diff of the two values in r21 bltz $21, exit_printgtr add $21, $21, 1 # If the value was acceptable, proceed to calculate the power. li $11, 2 # Load multiplier value into $11. li $17, 2 # Initialize 17 to multiplier value # Check to see if the second usr input is > 1, if it is modify r10 so that # the calculations can be made properly. This sets r10 = 2. If the second # input is == 1, then print the results. Must also load 2 into 2nd array # location here in case the seond input is 1. la $16, powers li $22, 1 mult $11, $22 mflo $11 sw $11, 4($16) li $23, 1 beq $23, $12, print_result bgt $10, $23, cont_gtn li $10, 2 # Multiplication loop. While $10 != 0 keep multiplying $17 by 2, and # decrement $10 by 1 every time this is done. Once $10 == 0, store # the result. cont_gtn: sub $10, $10, 1 # Since 2^1 has been taken care of add $14, $10, 0 add $24, $10, 0 add $24, $24, 1 multiply_for: mult $17, $11 # Loop to determine the power val mflo $17 sub $10, $10, 1 bnez $10, multiply_for # The result is stored in the location of the user input * 4, which would # give the matching address location on the array. This loops to # multiply_for while the $10 is != $12. nextval: add $10, $14, 0 # Restores r10 from copy mul $14, $24, 4 # Calculation to determine the add $23, $16, $14 # location in which to place the sw $17, ($23) # resulting power in the array. add $10, $10, 1 # Increment the counters for next add $24, $24, 1 # iteration. add $14, $10, 0 li $17, 2 # restore the multiplier value blt $10, $12, multiply_for beq $10, $12, print_result # Display the value of the exponential function. This loops through the # values in the array starting at the first user input until the # difference between the first and last user input is 0. print_result: la $14, str3 puts $14 # Print out "2^" li $v0, 1 move $a0, $15 syscall # Print out value of user input. la $16, str4 puts $16 # Print out '=' li $v0, 1 la $20, powers # Calculation to determine the mul $19, $15, 4 # location of the power value. add $23, $20, $19 lw $17, ($23) move $a0, $17 syscall # Print out result. la $13, newline # Create new line lb $12, ($13) putc $12 sub $21, $21, 1 add $15, $15, 1 bnez $21, print_result b endofline # Print out the result for 2 to the power of 0 if teh two user # inputs are 0 (special case). special_zero: la $14, str3 puts $14 # Print out "2^" li $v0, 1 move $a0, $15 syscall # Print out value of user input. la $16, str4 puts $16 # Print out '=' li $v0, 1 la $20, powers lw $17, ($20) # Print first value of array. move $a0, $17 syscall la $13, newline # Create new line lb $12, ($13) putc $12 b endofline # If second input is less than or not equal to first input, print mbgtrthan. exit_printgtr: la $13, mbgtrthan puts $13 # If the input is not appropriate, print str2 and exit. exit_donothing: la $13, str2 puts $13 b endofline # This is the exit statement. endofline: done # END OF PROGRAM # Define strings which will be used throughout program .data prompt: .asciiz "Enter a digit '0'-'9': " prompt2: .asciiz "Enter another digit '0'-'9': " mbgtrthan: .asciiz "Second digit must be greater than or equal to the first digit.\n" str2: .asciiz "Bad user input. Quitting.\n" str3: .asciiz "2^" str4: .asciiz " = " newline: .byte '\n' .align 4 powers: .word 1:10 # Create a 10-element int array.
Powers of base 2 in MIPS
by Hanly on Mar.01, 2009, under Computer Science
Program requests and reads in exactly one character, which represents an exponent. The program calculates the base 2 power, and then prints the calculated value.
# Assignment 2: Powers of 2 Assembly # by Hanly De Los Santos # Copyright ©2009, Hanly De Los Santos. All Rights Reserved. # http://www.hdelossantos.com # # Program requests and reads in exactly one character, # which represents an exponent. The program calculates # the base 2 power, and then prints the calculated value. # .text .globl __start # Load acceptable ascii decimal value for number ranges # since input is read in as a character. __start: li $8, 48 # This is the decimal equivalent of 0 li $9, 57 # This is the decimal equivalent of 9 # Prompt the user for input. la $11, prompt puts $11 # Grab user input and store value in register 10 getc $10 la $11, newline # Create new line lb $17, ($11) putc $17 add $15, $10, 0 # Make copy of contents of r10 in r15. sub $15, $15, 48 # Convert char to int. # Test to determine whether or not the user input value is acceptable. # If user input is less than 48 and greater than 57, branches to # exit_donothing, where the user is told the input is wrong. bgt $10, $9, exit_donothing blt $10, $8, exit_donothing sub $10, $10, 48 # After check, convert char to int. # If the value was acceptable, proceed to calculate the power. # Checks to determine if $10 is 0 or 1 since they are special cases. # If value is 0 or 1, branches to their respective prints. li $11, 2 # Load multiplier value into $11. beqz $10, result_zero li $17, 1 beq $10, $17, result1 li $17, 2 # Initialize 17 to multiplier value sub $10, $10, 1 # Since 2^1 has been taken care of # Multiplication loop. While $10 != 0 keep multiplying $17 by 2, and # decrement $10 by 1 every time this is done. Once $10 == 0, print_result. multiply_for: mult $17, $11 mflo $17 sub $10, $10, 1 bnez $10, multiply_for beqz $10, print_result # Display the value of the exponential function. print_result: la $14, str3 puts $14 # Print out "2^" li $v0, 1 move $a0, $15 syscall # Print out value of user input. la $16, str4 puts $16 # Print out '=' li $v0, 1 move $a0, $17 syscall # Print out result. la $13, newline # Create new line lb $12, ($13) putc $12 b endofline # Print out the result for 2 to the power of 0 (special case). result_zero: la $14, str3 puts $14 # Print out "2^" li $v0, 1 move $a0, $15 syscall # Print out value of user input. la $16, str4 puts $16 # Print out '=' li $v0, 1 li $a0, 1 syscall la $13, newline # Create new line lb $12, ($13) putc $12 b endofline # Print the result for 2 to the power of 1 (special case). result1: la $14, str3 puts $14 # Print out "2^" li $v0, 1 move $a0, $15 syscall # Print out value of user input. la $16, str4 puts $16 # Print out '=' li $v0, 1 li $a0, 2 syscall la $13, newline # Create new line lb $12, ($13) putc $12 b endofline # If the input is not appropriate, print str2 and exit. exit_donothing: la $13, str2 puts $13 b endofline # This is the exit statement. endofline: done # END OF PROGRAM # Define strings which will be used throughout program .data prompt: .asciiz "Enter a digit '0'-'9': " str2: .asciiz "Bad user input. Quitting.\n" str3: .asciiz "2^" str4: .asciiz " = " newline: .byte '\n'
Powers of base 2 in C
by Hanly on Feb.21, 2009, under Computer Science
This program takes a user input from 1 through 512 (inclusive), and calculates all powers of two that are less than or equal to the value. The program prints out all of these values.
NOTE: Due to my usage of the math library’s log function, it is necessary to compile using -lm under Unix systems for the linker to properly define the log function. Information referenced from: http://c-faq.com/fp/libm.html
/* Assignment1: Powers of 2
* by Hanly De Los Santos
* Copyright ©2009, Hanly De Los Santos. All Rights Reserved.
* http://www.hdelossantos.com
*
* This program takes a user input from 1
* through 512 (inclusive), and calculates all powers of
* two that are less than or equal to the value. The
* program prints out all of these values.
*
* NOTE: Due to my usage of the math library's log function,
* it is necessary to compile using -lm under Unix systems
* for the linker to properly define the log function.
* Information referenced from: http://c-faq.com/fp/libm.html
*/
/* Load standard I/O library */
#include <stdio.h>
#include <math.h>
/* Define macro */
#define ARRAYSIZE 10
/* Declare function prototypes to define the output of the
* following functions.
*/
void printPowers(int ar[], int firstindex, int lastindex);
void setPowers(int userinteger, int ar[], int lastindex);
main(int argc, char *argv[]){
int powers[ARRAYSIZE];
/* This determines whether there are 2 arguments in the command
* line input. If there are less than 2 arguments, then a message
* is printed prompting the user to enter a positive integer value.
*/
if( argc < 2)
printf("Invalid command line. Positive integer value required.\n");
/* If there are 2 variables, then the second variable is tested
* for the required integer values.
*/
else{
int usrval = atoi(argv[1]);
/* If the user input value is within the accepted range
* 1-512, then the operation is done with the user value.
*/
if( usrval >= 1 && usrval <= 512 ){
int maxexp = ((log(usrval))/log(2));
setPowers( usrval, powers, maxexp);
printf("Powers of 2 that are less than or equal to %d are:\n", usrval);
printPowers(powers, 0, maxexp);
}
/* If the value is greater than 512, the operation is done with the
* maximum value of 512
*/
else if ( usrval > 512 ){
printf("Powers of 2 that are less than or equal to 512 are:\n", usrval);
setPowers( 512, powers, 9);
printPowers(powers, 0, 9);
printf("argc is equal to: %d", argc);
}
/* If a character/negative number is entered instead of an integer, the user is
* prompted that a positive integer is required to complete the
* operation.
*/
else if ( !isdigit(usrval) || usrval <= 0 ){
printf("Invalid command line. Positive integer value required.\n");
printf("argc is equal to: %d", argc);
}
}
return 0;
}
/* This function sets the array's values; only the array elements
* whose values are less than or equal to the userinteger are set.
* It calls function power() for each value.
*/
void setPowers(int userinteger, int ar[], int lastindex){
int i;
for( i = 0; i <= lastindex; i++)
ar[i] = power( 2, i );
}
/*This function calculates and returns baseexponent utilizing the
* math library function 'pow'.
*/
int power(int base, int exponent){
int e;
e = pow(base, exponent);
return e;
}
/* This function prints the program's output. For each array
* element in the range of integers defined by firstindex and
* lastindex, the function prints one line of the output.
*/
void printPowers(int ar[], int firstindex, int lastindex){
int p;
for( p = 0; p <= lastindex; p++)
printf("2^%d = %d\n", p, ar[p] );
}
Previous Work Samples
by Hanly on Dec.22, 2008, under Sample Work
These are PDF files upwards of 30 MB, please use a high speed connection when viewing.
This is a project my friend, Stacie Gonzalez and I started in order to bring attention to the deplorable condition of the network at our high school (Miami Lakes Educational Center). We initially started it as a letter and petition to the school’s principal stating the the weaknesses of the then current infrastructure, which caused daily problems when attempting to get online (The letter is included in the PDF). Our school’s principal then gave us the task of designing several alternatives to correct the situation, which we made our Capstone Graduation Project. We then presented the design to the CIO of Miami-Dade County Public Schools (M-DCPS) and her subordinates, the administrators of: security, finance, and network infrastructure. Our proposal was then used as the basis for upgrading the school’s infrastructure. For our work with both the school and the Miami-Dade County Public Schools staff, we were awarded the Cisco Networking Academy ‘3R’ award.
During an internship with the (M-DCPS) Cisco Academy Apprenticeship Program (CAAP) I led a team of five other students in completing our network design project. We were asked to design a ficticious school and its network. Our design was teh winning design during the 2006 summer intership.

