Monday, November 28, 2016

Dear Mr(s) President, I want to be the Ambassador to Ghana.

To current, past and future presidents: I want to become the Ambassador to Ghana. I would be an excellent candidate for the job because I am a skilled political manager. (anyone who gets their Ph.D. has this skill). Primarily, I have found that most Ambassadors are a bit removed from the countries where they are representing the USA. As a fluent Japanese speaker, I would be more qualified for Ambassador to Japan, but if you look at the link, you will find that it's the award for campaign contributions. I'm really unable to find someone in recent years that I could be proud from the standpoint of increasing mutual cooperation. In an effort to be appropriate for Ghana, my Twi is not yet fluent, but it will be.

So why Ghana?
It's refreshing to find a country in Africa that has its act together. I read The Economist every week, and have been to Ghana multiple times. Ghana is one of those places where the people are proud of their achievements and government, and in 50 years I imagine it to be a powerhouse of industry like Japan or China (their VAT is a bit of an issue, but...) The people are hard working and industrious. A good example of the quality of the populous is that the country remained stable during power transition after President Mills died in office. All in all, it's a great country and it would be a privilege to be part of its international rise.

Sunday, November 20, 2016

68060 for the NeXT.

Although this is completely worthless as far as real-world item, I really want to get back to making a 68060 socket for the NeXT Slab. I got up to the point where I reverse engineered the Nitro board, ordered the logic, but I never sent out the board. Maybe one day I can justify the time, but I doubt that day will come. :(

Friday, November 18, 2016

Gate Equivalents (GE) and why you should not use them.

I was introduced to Gate Equivalents (GEs) from using Xilinx layout tools, where the routed graph estimates how many NAND gates would be required for an implementation of a circuit. I keep reading papers were people use GEs as a comparison between designs, but it seems that the GE does not seem to have a standard definition. In many cryptography papers, the GE is used as an area comparison; however, this can be misleading. Let's say that you have a standard cell library with a large NAND gate, which is one GE. Now let's say that you have an XOR that is heavily optimized for area, and in this case, the XOR could have the same area of a NAND gate even though it requires more transistors.

Here is how people seem to game the system when GE is used as area. I make a NAND that is very large. This makes my total design take much less area in GEs for the other optimized cells. I just saw a design on 130nm that has fewer transistors with a higher GE than a design that has more transistors and a lower GE.

Instead of GEs, use transistor count. This just make sense. Here's an example of the layout of 8 transistors in a commercially available 14nm process:


This layout is substantially different from a 130nm equivalent. The attempt to compare different layouts and feature sizes with GEs is just worthless. Just don't do it.

Monday, November 14, 2016

Logic with large numbers in Bash

I found that I was losing information when passing information between commands via bash. Bash cannot seem to deal with numbers larger than 64-bits. The solution was for me to change everything into an ASCII series of 0's and 1's and then run logic on the strings. The code below takes a hexadecimal number, 549b93563bfa04fb, splits it in two, and XOR's the halves. I tried the code on a 4096-bit number and it worked well.
 #!/bin/sh  
 #Before anything else, set the PATH_SCRIPT variable  
      pushd `dirname $0` > /dev/null; PATH_SCRIPT=`pwd -P`; popd > /dev/null  
      PROGNAME=${0##*/}; PROGVERSION=0.1.0   

 lowercase(){  
 # convert the uppercase to lowercase  
   echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"  
 }  
 bashhex2bin()  
 {  
 # Take a value as a hex number and convert it to a binary string  
 #  
  HEXVAL=$1  
  #echo "$@"  
  #echo "$#"  
  if [ "$#" -lt 1 ]; then  
   # this means that the function was run without any arguments  
   : #null command to make BASH happy  
  else  
   #echo "bashhex2bin(): total args passed to me $#"  
   STRSIZE=${#HEXVAL} #the string length of the argument  
   for ((COUNTER1=0; COUNTER1 < STRSIZE ; COUNTER1++))  
   do  
    #echo "Welcome $COUNTER1 times"  
    CHARATINDEX=${HEXVAL:$COUNTER1:1}  
    #convert the hex value to binary  
    bashchar2bin $CHARATINDEX  
   done   
  fi  
 }  
 bashchar2bin()  
 {  
 # Take a nibble as an argument, and return a binary represntation  
 #  
  NIB=$1 #this should be 0 to F  
  NIB=$(lowercase $NIB)  
  case $NIB in  
   "0" )  
     printf "0000" ;;  
   "1" )  
     printf "0001" ;;  
   "2" )  
     printf "0010" ;;  
   "3" )  
     printf "0011" ;;       
   "4" )  
     printf "0100" ;;  
   "5" )  
     printf "0101" ;;  
   "6" )  
     printf "0110" ;;                  
   "7" )  
     printf "0111" ;;   
   "8" )  
     printf "1000" ;;  
   "9" )  
     printf "1001" ;;  
   "a" )  
     printf "1010" ;;  
   "b" )  
     printf "1011" ;;       
   "c" )  
     printf "1100" ;;  
   "d" )  
     printf "1101" ;;  
   "e" )  
     printf "1110" ;;   
   *)   
     printf "1111" ;;   
  esac  
 }  
 xor()   
 {  
      if (( $1 ^ $2 )) ;then  
           printf "1"  
      else  
           printf "0"  
      fi  
 }  
 bashXORbinstring()  
 {  
 # Take a string, such as arguments 1, 2:  
 # 10100001  
 # 10100000  
 # and return the XOR result  
 STRBIN1=$1  
 STRBIN2=$2  
 if [ ${#STRBIN1} -eq ${#STRBIN2} ]; then  
   STRSIZE=${#STRBIN1} #the string length of the argument  
   for ((COUNTER1=0; COUNTER1 < STRSIZE ; COUNTER1++))  
   do  
    xor ${STRBIN1:$COUNTER1:1} ${STRBIN2:$COUNTER1:1}  
   done   
 else  
  echo "ERROR, XOR failed due to different lengths $STRBIN1, $STRBIN2"   
 fi  
 }  

 CMDRESULT=549b93563bfa04fb
 # at this point, CMDRESULT should have a key, such as:  
 # 549b93563bfa04fb  
 #  
 # now need to split the key into two.  
 STRSIZE=${#CMDRESULT}   
 STRHALFSIZE=$(($STRSIZE / 2)) #divide by two  
 #now use BASH to split the string  
 #echo $CMDRESULT  
 XORARG1=${CMDRESULT:0:$STRHALFSIZE}  
 XORARG2=${CMDRESULT:$STRHALFSIZE:STRHALFSIZE}  
 #echo $XORARG1  
 #echo $XORARG2  
 #convert the strings into binary as a string  
 BINARG1=$(bashhex2bin $XORARG1)  
 BINARG2=$(bashhex2bin $XORARG2)  
 #use the XOR function to XOR the ASCII strings  
 RESULTXOR=$(bashXORbinstring $BINARG1 $BINARG2)  
 echo $BINARG1  
 echo $BINARG2  
 echo $RESULTXOR  

Friday, November 11, 2016

Referencing the RFID Gen2 document via BibTeX

One would not think that it would be difficult to reference a document in BibTeX, but there's strangeness when you don't do it just right. I found this link on referencing the CD4007 via bibtex. In the same vein, I came up with:

\usepackage{url} %for the _ in the URL

@misc{EPCglobalGen2-2013,
  author={EPCglobal Inc.},
  title={{EPC}$^{TM}$  {Radio-Frequency Identity Protocols
Generation-2 UHF RFID}},
  howpublished = "\url{http://www.gs1.org/sites/default/files/docs/epc/uhfc1g2_2_0_0_standard_20131101.pdf}",
  publisher={EPCglobal Inc.},
  year={2013}
}
The {} around the author make sure that it doesn't become E. Inc. The resulting render:

Tuesday, November 8, 2016

Merge PDFs with MacOS and the command line.

I use the command line to merge PDFs all of the time, but I have found that with every MacOS release, things move. I made a script, PDFconcatenator.sh, that finds the script join.py in /System/Library and then passes arguments to join.py. join.py seems to move with every MacOS release and this script works as long as you have join.py on the system.

Ad example of three files:
PDFconcatenator.sh -o merged.pdf ../../file1..pdf file3pdf /off/root/3.pdf
#!/bin/bash
#Before anything else, set the PATH_SCRIPT variable
    pushd `dirname $0` > /dev/null; PATH_SCRIPT=`pwd -P`; popd > /dev/null
    PROGNAME=${0##*/}; PROGVERSION=0.1.0
# WHAT DOES THIS DO?
# This script looks at MacOS distribution and tries to find the python script to merge
# pdfs files. It tends to move depending on MacOS releases.

HUNT_DIR="/System/Library/"

usage(){
    echo "$PROGNAME"
    echo "This program finds the PDF concatenation script on MacOS "
    echo "example:"
    echo "$PROGNAME -o PATH/TO/YOUR/MERGED/FILE.pdf /PATH/TO/1.pdf /PATH/TO/2.pdf /3.pdf"
    echo ""
}

# lowercase makes things lowercase. This is an issue because sometime different OS
# have different conventions. bsd and BSD or FreeBSD and freebsd
lowercase(){
    echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}

# This is my canned script to determine the OS
#
getOS(){
OS=`lowercase \`uname\``
KERNEL=`uname -r`
MACH=`uname -m`

if [ "${OS}" = "windowsnt" ]; then
    OS=windows
elif [ "${OS}" = "darwin" ]; then
    OS=mac
else
    OS=`uname`
    if [ "${OS}" = "SunOS" ] ; then
OS=Solaris
ARCH=`uname -p`
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
    elif [ "${OS}" = "AIX" ] ; then
OSSTR="${OS} `oslevel` (`oslevel -r`)"
    elif [ "${OS}" = "Linux" ] ; then
if [ -f /etc/redhat-release ] ; then
DistroBasedOn='RedHat'
DIST=`cat /etc/redhat-release |sed s/\ release.*//`
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/SuSE-release ] ; then
DistroBasedOn='SuSe'
PSUEDONAME=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
elif [ -f /etc/mandrake-release ] ; then
DistroBasedOn='Mandrake'
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/debian_version ] ; then
DistroBasedOn='Debian'
DIST=`cat /etc/lsb-release | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'`
PSUEDONAME=`cat /etc/lsb-release | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }'`
REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'`
fi
if [ -f /etc/UnitedLinux-release ] ; then
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
fi
OS=`lowercase $OS`
DistroBasedOn=`lowercase $DistroBasedOn`
readonly OS
readonly DIST
readonly DistroBasedOn
readonly PSUEDONAME
readonly REV
readonly KERNEL
readonly MACH
fi
fi
}

# start by getting the OS to be sure we can run
getOS

if [ "mac" != "$OS" ]; then
    echo "This script only works on MacOS"
    exit 1
fi

SCRIPT=$(find $HUNT_DIR -name join.py 2>/dev/null)
SCRIPT=$( echo "$SCRIPT" | sed 's/ /\\ /g')

if [ "$#" -eq 0 ]; then
    usage
    exit 2
fi

#run the concatenation
echo "Executing the following command:"
echo "$SCRIPT $@"
#execute the actual command
eval "$SCRIPT $@"


Tuesday, October 4, 2016

Brief: On the design of solid state hard drives

The Solid State Drive (SSD) is a non-volatile storage device that shares a similar function to a traditional hard drive; however, the SSD architecture relies on a FLASH-type storage over a magnetic storage. This note is an executive summary of SSD architecture and throughput.

Introduction

The Solid State Drive (SSD) is a semiconductor-based replacement for the traditional hard drive. The traditional hard drive is bounded by a physical medium of spinning magnetic platters, and this is an example of physically constrained system. As an example, the hard drive is limited by the speed of the platters, the bounds on the head movement and the track width. The SSD is an electrically constrained system and examples of these limits the oxide thickness of a floating- gate transistor, and number of write cycles. SSDs mirror the functionality of hard drives.

Fig. 1. The illustration shows the basic architecture of a SSD. The major components are the cache, controller and FLASH storage. The major routes of communication are by the IO bus, the cache bus and the FLASH bus. The IO bus is connected between a computer interface and the controller, where the purpose of the controller is to mimic the behavior of a storage device and control the writes and reads. The controller also schedules writes between the DRAM cache and FLASH.

The SSD device

The SSD is a device that mimics the traditional hard drive in behavior, but uses solid-state semiconductor components instead of a mechanical medium. The SSD as a system is illustrated in Figure 1, and the device contains a controller and two types of storage, volatile and non-volatile. The purpose of the controller is to mimic the behavior of a hard drive and control writes. The non-volatile storage is the FLASH transistors from where solid state drives get their name. The volatile storage is a cache for temporary storage of data.

Table. 1. Different interface speeds.

Bounding SSD Performance

The SSD is created from several NAND FLASH ICs. As an individual device, the NAND FLASH perform differently be- tween generations; however, this performance can be masked by use of DRAM cache. The NAND in “NAND FLASH” refers to the addressing architecture and the FLASH term refers to the charge storage technique. The threshold of the FLASH MOSFET will shift depending on the charge that is trapped on the gate. The NAND FLASH is arranged in pages and reading and writing is based on this granularity [1]–[3]. Due to the abstraction away from the FLASH performance due to the DRAM cache, the write time of a packaged device is more of an academic exercise, and each 8k bank completes a write in 0.33ms to 0.45ms. The difference in these numbers is the difference between 50MB/sec and 33MB/sec; however, this is also abstracted away by local cache on the FLASH ICs, and possibly the controller. The slower write speed is preferred for endurance. [4], [5]. The bus speed of these devices will remain at approximately 20ns (50MHz) with current interconnect technologies with writes on the order of 200us and “erasing” on the order of 2ms. Bank reads are limited by IO, and thereby are bus limited. Due to the thin oxide and the tunneling process, even if the density of the devices increases, I do not believe that the speed of writing or erasing will increase due to the physics of quantum transport. The only increases that will be seen is interconnect and concurrent writes.

References

[1] A. Goda and K. Parat, “Scaling directions for 2d and 3d nand cells,” in 2012 International Electron Devices Meeting, 2012.
[2] H.-T. Lue, P.-Y. Du, W.-C. Chen, T.-H. Yeh, K.-P. Chang, Y.-H. Hsiao, Y.-H. Shih, C.-H. Hung, and C.-Y. Lu, “A novel dual-channel 3d nand flash featuring both n-channel and p-channel nand characteristics for bit- alterable flash memory and a new opportunity in sensing the stored charge in the wl space,” in 2013 IEEE International Electron Devices Meeting. IEEE, 2013, pp. 3–7. 2
[3] S.-H. Chen, H.-T. Lue, Y.-H. Shih, C.-F. Chen, T.-H. Hsu, Y.-R. Chen, Y.- H. Hsiao, S.-C. Huang, K.-P. Chang, C.-C. Hsieh et al., “A highly scalable 8-layer vertical gate 3d nand with split-page bit line layout and efficient binary-sum milc (minimal incremental layer cost) staircase contacts,” in Electron Devices Meeting (IEDM), 2012 IEEE International. IEEE, 2012, pp. 2–3.
[4] K.-T. Park, S. Nam, D. Kim, P. Kwak, D. Lee, Y.-H. Choi, M.-H. Choi, D.-H. Kwak, D.-H. Kim, M.-S. Kim et al., “Three-dimensional 128 gb mlc vertical nand flash memory with 24-wl stacked layers and 50 mb/s high-speed programming,” IEEE Journal of Solid-State Circuits, vol. 50, no. 1, pp. 204–213, 2015.
[5] W. Kim, J. Y. Seo, Y. Kim, S. H. Park, S. H. Lee, M. H. Baek, J.-H. Lee, and B.-G. Park, “Channel-stacked nand flash memory with layer selection by multi-level operation (lsm),” in 2013 IEEE International Electron Devices Meeting. IEEE, 2013, pp. 3–8.