Wednesday, April 23, 2008

Advanced use of define macro in RVM and VMM of Synopsys

If you have used RVM (Reference Verification Methodology) library for Vera or VMM (Verification Methodology Manual) library for SystemVerilog, implemented by Synopsys, you can recall channel, atomic generator, scenario genertor, rvm_OO_callbacks, vmm_callbacks macros. These macros are generic/reusable macro written using above mentioned two powerful features of define macro.

In VMM for SystemVerilog,
`channel(data_class) // data_class_channel
This macro call creates customized channel class declaration handling object of type data_class.

`atomic_gen(data_class) // data_class_atomic_gen
This macro call creates customized atomic generator class declaration handling object of type data_class.

`scenario_gen(data_class) // data_class_scenario_gen
This macro call creates customized scenario generator class declaration handling object of type data_class.
This macro call all creates classes like 'data_class_scenario', 'data_class_scenario_election', etc.

If you have noticed, implementation of `vmm_callbacks is given in the vmm document.

I hope this information improves your knowledge about using define macro.

$finish;


Reusable Channel using Define Macro

Now, same code can be implemented using define macro as follows.

`define channel(A) class A``_channel ; // Class of type 'A_channel' \
    A queue[$]; \
    semaphore sem; \
    task put_data(A t); \
        sem.get(1); \
        queue.push_back(t); \
        sem.put(1); \
    endtask \
    task get_data(ref A t); \
        sem.get(1); \
        t = queue.pop_back(t); \
        sem.put(1); \
    endtask \
endclass

Using above mentioned code, you can create any type of customized channel between two components.
Like,
Channel passing integer data between two components using,
`channel(integer)
integer_channel int_channel = new();
Channel passing class object of type 'data_class' between two component using,
`channel(data_class)
data_class_channel data_class_channel = new();
As you noted here, `channel(integer) or `channel(data_class) macro calls, creates customized channel class declarations for you and then you can instantiate those class objects.

Another thing to be noticed is the use of `` to create customized data type. In the example above, I have used 'A_``channel'. This expands to 'A_channel'.

Next: Advanced use of define macro in RVM and VMM of Synopsys


Reusable Channel using Parameterized class

Let's consider the example of generic channel using paramerized class,


class channel #(type T = integer);

    T          queue[$];
    semaphore  sem;
    
    task put_data(T t);
        sem.get(1);
        queue.push_back(t);
        sem.put(1);
    endtask
    
    task get_data(ref T t);
        sem.get(1);
        t = queue.pop_back(t);
        sem.put(1);
    endtask

endclass

Using above mentioned code, you can create any type of customized channel between two components.
Like,
Channel passing integer data between two components using,
channel #(integer) int_channel = new();
Channel passing class object of type 'data_class' between two component using,
channel #(data_class) data_class_channel = new();

Next: Reusable Channel using Define Macro




Features of Define Macro in SystemVerilog

Following is the excerpt from SystemVerilog LRM about important features of define macro.

1. In Verilog, the ‘define macro text can include a backslash ( \ ) at the end of a line to show continuation on the next line.

2. In SystemVerilog, the macro text can also include `", `\`" and ``.
An `" overrides the usual lexical meaning of ", and indicates that the expansion should include an actual quotation mark. This allows string literals to be constructed from macro arguments.
A `\`" indicates that the expansion should include the escape sequence \", e.g.
`define msg(x,y) `"x: `\`"y`\`"`"
This expands:
$display(`msg(left side,right side));
to:
$display("left side: \"right side\"");

3. A `` delimits lexical tokens without introducing white space, allowing identifiers to be constructed from arguments,

`define foo(f) f``_suffix
This expands:
`foo(bar)
to:
bar_suffix

These three are most important features because using them we can create customizable data_type and generic or reusable SystemVerilog Components.

For example consider following macro,
`define MY_DATA_TYPE(A) A
Using this macro, I can do following.

Instead of writing,
integer a;
I can write,
`MY_DATA_TYPE(integer) a;

You might think that is it advanced use of Macro? But when you read Reusable Channel using Define Macro of this article, you will realize that how this simple feature of define macro can help in creating generic/reusable components. Here, only intention is to convey that "Using define macro you can 'pass' data_type as argument".
define macro consider its argument as 'text only', it doesn't impose rule of 'keyword' or 'data type' on that. So passing data type as argument to define macro doesn't result into any compilation error.
These features can be used as an alternate option to 'Parameterization feature of SystemVerilog' (Parameterized Classes). If you are using EDA tool or SystemVerilog Compiler that doesn't support 'Parameterized class', you can use define macro as supplement for that, to make generic or reusable components.

Let's go through how to create generic/reusable SystemVerilog components using 'Parameterized Class' and Using 'Define Macro'.

Next: Reusable Channel using Parameterized class

Tuesday, April 22, 2008

ATAUtil: Download ATA Utility

Please read all the information/guideline/usage details given in 'Lock-Unlock Hard Disk', before downloading and running this utility.

Limitations:
This utility doesn't run on 64-bit machine. I have tried it on my laptop which has AMD Athelon 64-bit Processor but it doesn't work. It seems that 64-bit processor doesn't understand the instruction set compiled in the utility.

Warning:
This is very risky utility. Any mistake done by user results in permanent failure of hard disk. User should be extremely careful while running this utility. If user forgot the password after locking hard disk, his hard disk is of no use, until unlocked. So user should be very very careful. Please digest all the information given, before running this utility.

Disclaimer:
Try this utility at your own risk. I have tested it on my hard disks. But I don't know how different makes of hard disk behave on this utility. It is sole responsibility of the user, for any damage done this utility, in any case.

Download:
  1. ATAUtil.exe - Core of Utility
  2. EGAVGA.BGI - This is Graphics library used by 'C' language. Put this file in the same directory where ATAUtil.exe is located.

I hope it will be useful to you and will improve your knowledge.

Index

ATAUtil: How to Use This Utility - 2

Use arrow key to select the option. Lets go through option one by one.

SELECT HARD DISK INTERFACE
Using this option, you can select at which interface your hard disk is connected. There are four locations at which your ATA hard disk can be connected. Primary Master, Primary Slave, Secondary Master and Secondary Slave. Select the option which is appropriate in your case. The option you selected will be reflected at the top of Graphic.
The default option selected is Primary Master.

This command is available even if hard disk is locked.

DISPLAY HARD DISK INFO
This option gives various details about your device. It gives information about Serial no., Firmware revision no., Model no.. It prints no. of User Addressable Sectors, which version of ATA is supported. Most important information about whether your device supports security feature is not, is displayed. If it says it supports security feature, you can go ahead. If it says it doesn't support security feature, don't play with this utility with device selected.
At the end of display, it prints status of command, whether command completed successfully, with error or aborted. If command doesn't completed successfully, don't play with this utility with the device selected. You can select other device on other channel and try on that.

If you don't know about channels at which your hard disk is connected, you can do trial and error. For example, if you selected primary master and then selected this option. If it says command completed with error or aborted that means at primary master CD/DVD ROM is connected or your hard disk might not able to complete the command. Now, repeat same for primary slave and secondary master and slave.

These option is the safe option because in this option nothing is written to hard disk. It just reads information from hard disk. So during this option, if command completes with error or aborted, just come out and select different channel and master-slave. Almost all subsequent options are one or other way writing to hard disk. So, again saying, don't run any of the below mentioned option for which command completed with error/abort or security feature is not supported on the device.

This command is available even if hard disk is locked.

SET USER PASSWORD
Once you get the 'Security Supported' in the device information then you can use this option to enable the security and set the user password. After completion of this command, user password will be set in the hard disk and security will be enabled. Once you give hard reset or restart your machine, your hard disk will be locked.
Rules of password:
Length of password can be maximum 32 characters.
Only use alpha-numeric(a-zA-Z0-9) characters only for password.
In this utility, rest of the characters of password is appended with space. Means if you set password as 'thisismypassword' (length 16), rest of the 16 characters of password are 'space'. This is to ensure that no garbage data will be set as password. When you unlock the device, you don't need to append 'space' after password. Utility will automatically append 'space' in your password, while unlocking also.

This command will not be available once hard disk is locked. It will be completed with error, until hard disk is unlocked.

SET MASTER PASSWORD
Once you get the 'Security Supported' in the device information then you can use this option to set the master password. After completion of this command, master password will be set in the hard disk but security will NOT be enabled. Only setting user password only enables the security. That means if you only set the master password and do not set the user password, and then give hard reset or restart your machine, your hard disk will be still unlocked. But, master password is set. Later on this master password can be used to unlock the hard disk, when disk will be locked.

Since 'maximum' security level is risky, this utility only sets the security level as 'high', and never set it to 'maximum'. Please read information about 'ATA security' in previous blog for more details about security level.

This command will not be available once hard disk is locked. It will be completed with error, until hard disk is unlocked.

UNLOCK USING USER PASSWORD
Once hard disk is locked, you can select this option and provide user password which you set previously, to unlock the hard disk. After successfully completion of this command unlocks the hard disk.

This command is available even if hard disk is locked. It must be enabled otherwise how do you unlock.

UNLOCK USING MASTER PASSWORD
Once hard disk is locked, you can select this option and provide master password which you set previously, to unlock the hard disk. After successfully completion of this command unlocks the hard disk.

This command is available even if hard disk is locked. It must be enabled otherwise how do you unlock.

DISABLE SECURITY USING USER PASSWORD
Once your 'SET USER PASSWORD' command completes successfully, security will be enabled in your hard disk. You can check 'SECURITY STATUS' command after that. It will show that security is enabled. Upto this point security is enabled but device is not locked (will be locked at hard reset or next power on). But at this point if you want you can disable the security using this command. If this command completes successfully security will get disabled and device will not be locked until 'SET USER PASSWORD' command is run again.

This command is not available when hard disk is locked. It will be completed with error.

DISABLE SECURITY USING MASTER PASSWORD
Same as 'DISABLE SECURITY USING USER PASSWORD', but in this case you will disable security using master password instead of user password.

This command is not available when hard disk is locked. It will be completed with error.

SECURITY STATUS
This command gives information about current security status. It prints whether security enabled or not, security level is high or maximum, security is locked or not, security is freezed or not, security count is expired or not (five wrong attempt of either 'user' or 'master' password cause security count to expire. You need to give hard reset to hard disk to again enter the correct password) and Enhanced security erase is supported or not.

This command will run even if hard disk is locked.

READ SECTORS
This command is also disable in this utility because it might create memory allocation issue while reading large no. of sectors.

WRITE SECTORS
This command is disabled in this utility for possible misuse of this option. This option can be used to create boot sector viruses.

QUIT
Using this command, you can come out of utility anytime.

ATAUtil: How to Use This Utility - 1

Index

Please read the information given about 'ATA security' in the previous blog before downloading and running this utility.

Once you run this utility in MS-DOS mode, you will see graphical interface that itself says everything about it. But, still I am explaining it here, to avoid any mistake.

After running utility, following options will be displayed.

SELECT HARD DISK INTERFACE
DISPLAY HARD DISK INFO
SET USER PASSWORD
SET MASTER PASSWORD
UNLOCK USING USER PASSWORD
UNLOCK USING MASTER PASSWORD
DISABLE SECURITY USING USER PASSWORD
DISABLE SECURITY USING MASTER PASSWORD
SECURITY STATUS
READ SECTORS
WRITE SECTORS
QUIT

Index

ATAUtil: Requirement to Run The Utility

Following are the requirements to run the utility.
  1. Bootable CD/floppy using which you can start computer in MS-DOS mode. This utility will not run, when OS (Operating System) is running. Because it is written in pure 'C' language and is using low level APIs of 'C' which are generally blocked by OS.
  2. Copy files (exe and bgi) of this utility to Bootable CD/floppy or you can copy it to your hard disk itself. But copying it in hard disk is risky because once hard disk is locked, you will not be able to access utility from hard disk, after hard reset is applied or computer is restarted. If you have two hard disks, you can store it in other hard disk and make sure that you didn't lock the hard disk in which utility is copied.

In future, I am planning to give image that will contain bootable code + utility, that you can directly burn to your CD or floppy.

Index

ATAUtil: About The Utility

I have coded this utility entirely in 'C' language, which is the best language for accessing any device at low level. It has three layers of code.
1. The top layer deals with graphics for user interaction with the utility.
2. Second layer is for creating command request and completion data, as understood by the ATA protocol.
3. Third layer which is the lowest level deals with actual ATA controller register to perform operation requested by user.

Using this utility user,
1. Can get the information about different device connected to primary (master and slave) and secondary channel (master and slave) of IDE/ATA controller.
2. Will be able to know that whether his hard disk supports Security feature or not.
3. Can set user and master password in his hard disk and lock-unlock hard disk if security feature is supported.
4. Can enable or disable the security feature.
5. Can get information about current security settings.

For any assistance contact me at: sandeep.vaniya@gmail.com
I would encourage to write comment instead of mailing me in case of any issue/query about the utility. So solution will be available to everyone. I will be notified by email whenever you write comment.

Monday, April 21, 2008

Detail of Security Feature of ATA

Introduction

The optional Security Mode feature set is a password system that restricts access to user data stored on a device. The system has two passwords, User and Master, and two security levels, High and Maximum. The security system is enabled by sending a user password to the device with the SECURITY SET PASSWORD command. When the security system is enabled, access to user data on the device is denied after a power cycle until the User password is sent to the device with the SECURITY UNLOCK command. A Master password may be set in addition to the User password. The purpose of the Master password is to allow an administrator to establish a password that is kept secret from the user, and which may be used to unlock the device if the User password is lost. Setting the Master password does not enable the password system.

The security level is set to High or Maximum with the SECURITY SET PASSWORD command. The security level determines device behavior when the Master password is used to unlock the device. When the security level is set to High the device requires the SECURITY UNLOCK command and the Master password to unlock. When the security level is set to Maximum the device requires a SECURITY ERASE PREPARE command and a SECURITY ERASE UNIT command with the masterpassword to unlock. Execution of the SECURITY ERASE UNIT command erases all user data on the device.

The SECURITY FREEZE LOCK command prevents changes to passwords until a following power cycle. The purpose of the SECURITY FREEZE LOCK command is to prevent password setting attacks on the security system.

A device that implements the Security Mode feature set shall implement the following minimum set of commands:
− SECURITY SET PASSWORD
− SECURITY UNLOCK
− SECURITY ERASE PREPARE
− SECURITY ERASE UNIT
− SECURITY FREEZE LOCK
− SECURITY DISABLE PASSWORD
Support of the Security Mode feature set is indicated in IDENTIFY DEVICE data word 82 and data word 128.

Security mode initial setting
When the device is shipped by the manufacturer, the state of the Security Mode feature shall be disabled. The initial Master password value is not defined by this standard. If the Master Password Revision Code feature is supported, the Master Password Revision Code shall be set to FFFEh by the manufacturer.

User password lost
If the User password sent to the device with the SECURITY UNLOCK command does not match the user password previously set with the SECURITY SET PASSWORD command, the device shall not allow the user to access data. If the Security Level was set to High during the last SECURITY SET PASSWORD command, the device shall unlock if the Master password is received. If the Security Level was set to Maximum during the last SECURITY SET PASSWORD command, the device shall not unlock if the Master password is received. The SECURITY ERASE UNIT command shall erase all user data and unlock the device if the Master password matches the last Master password previously set with the SECURITY SET PASSWORD command.

Attempt limit for SECURITY UNLOCK command
The device shall have an attempt limit counter. The purpose of this counter is to defeat repeated trial attacks. After each failed User or Master password SECURITY UNLOCK command, the counter is decremented. When the counter value reaches zero the EXPIRE bit (bit 4) of IDENTIFY DEVICE data word 128 is set to one, and the SECURITY UNLOCK and SECURITY UNIT ERASE commands are command aborted until the device is powered off or hardware reset. The EXPIRE bit shall be cleared to zero after power-on or hardware reset. The counter shall be set to five after a power-on or hardware reset.
Index

Unbreakable Security

The security feature supported in hard disk is unbreakable. Nobody can apply bruteforce/dictionary attack on your locked hard disk because

  1. First of all one don't have low level utility to give unlocking commands to hard disk.
  2. Even if one got the utility and do the bruteforce/dictionary attack, will get mad because at every sixth attempt hard disk needs to be applied hard reset. Security unlock command will be aborted if five wrong attempts are committed. After that, giving security unlock command results in command aborted until hard reset.
  3. Maximum password length can be as long as 32 characters.
  4. It has two security levels, high and maximum. And two password types, user password and master password.

Index

About Locking-Unlocking Capability of Hard Disk

Do you know locking/unlocking capability of your hard disk? If not, read following.


Every hard disk has inbuilt controller, called ATA controller. ATA stands for Advanced Technology Attachment or AT Attachement. ATA is the standard protocol to interact with the hard disk. ATA protocol has several commands using which hard disk can be locked or unlocked.

This lock is the hardware lock. Once hard disk is locked, you can't read/write from your hard disk, until unlocked. Once it is locked, all commands to hard disk will be aborted, except commands for unlocking and some special commands.

Almost all modern hard disk support security feature. By default security feature is disabled. It needs to be enabled and then only hard disk can be locked/unlocked. Some older hard disk might not support this feature.

My Example:
My older hard disk doesn't support security feature. To test this utility, I bought new one which supports security feature and I was able to lock/unlock it.I had installed OS on my older hard disk. Then plugged in both of the hard disks. Newer one I had locked using this utility. When windows boots up, it only able to recognize my older disk, not the newer one. I was not able to see any drives pertaining to my newer disk, in the explorer. Then I booted the PC in DOS mode, run the utility, unlock the newer one disk and reboot again. Now, OS has detected both the disks and able to see drives of newer disk in the windows 'explorer'. It is very easy, if you know password you have used during locking. But if you forget the password, forget your hard disk also!!!

Index

Friday, April 18, 2008

Perl Script for Directory Tree

I have created perl script to have tree view of the directory. It is developed for the shell (linux shell and windows command prompt) which doesn't support 'tree' command. If your shell already have tree command, then this script is of not much importance. But you can do some customization in tree view using this script.

This script scans directory recursively and then displays the tree view. Using "-width" argument tree view can be compressed or expanded. To display how to give arguments to script type "perl tree.pl" or "perl win_tree.pl" on the shell. Follow the instructions displayed in the help. One need to have perl package installed in the system for this script to work. Default $expand_size = 5 and $max_width = 10. expand_size decides how much is the space in between "+" and "name of directory or file". $max_width is the maximum value of expand_size. User can increase default $expand_size and $max_width by editing tree.pl.

I hope it will be useful.

Download tree.pl (For Linux)
Download win_tree.pl (For Windows Command Prompt)

Monday, April 14, 2008

Microsoft Exec: UAC Designed To 'Annoy Users'

If you are using Windows Vista, you know that how annoying UAC (User Account Control) is? Due to UAC, all your action that needs system or core level access of Windows vista, prompted for administrator password.

You might be thinking that UAC is added for security reason. But that is not the only reason. It is added to 'Annoy Users' so that they can understand the importance of administrative privileges.

Read this article in which Microsoft Executive David Cross explains why UAC is added?
UAC Designed To 'Annoy Users'

I like the line in this article that defines UAC as 'zero click' exploits to 'one click' defense.

Ultimately, it is your awareness only which can prevent malicious code to enter in your system. You can allow application which contains malicious code to enter into the systerm because you think that application is clean.

But definitely UAC prevents application which installs themselves silently into the system without your knowledge. At least you will get the prompt that some application is trying to install itself.

Tuesday, April 8, 2008

What is Vcc Vdd Vee Vss?

Vcc and Vdd are the Positive voltages
Vcc - Positive supply voltage of a Bipolar Junction Transistor
Vdd - Positive supply voltage of a Field Effect Transistor

Vee and Vss are the Negative voltages/ground.
Vee - Negative supply voltage of a Bipolar Junction Transistor
Vss - Negative supply voltage of A Field Effect Transisto

The letters c, d, e and s originated from the name of the legs of the transistors Collector, Drain, Emitter and Source, respectively.

Why double suffix instead of single i.e. Why Vss instead of Vs?

The doubled suffix indicates that the voltage is "common", i.e. it is the supply voltage to one or more collectors (in the case of cc) and not just the voltage at a specific collector. Similarily, Vee is a common voltage for all emitters etc.

Reference: http://www.techpowerup.com/articles/overclocking/45

Some Good Links

Linux Manuals:
http://www.comptechdoc.org/os/linux/manual4/smbconf.html

Installing Fonts:
http://www.yolinux.com/TUTORIALS/LinuxListOfFonts.html

What is Sans Serif:
http://www.webopedia.com/TERM/s/sans_serif.html

On-line Verilog HDL Quick Reference Guide.
http://www.sutherland-hdl.com/on-line_ref_guide/vlog_ref_body.html

Tech Facts:
http://www.tech-faq.com/six-sigma.shtml

IPO:
http://nayaissue.blogspot.com/2007/12/bgr-energy-system-india-ltd-ipo-close.html
http://ipoalert.chittorgarh.com/comments.asp?id=297

Moon base:
http://www.liveleak.com/view?i=ccc_1177021380
http://www.sacred-texts.com/ufo/moonbase.htm
http://www.scribd.com/doc/269661/Top-10-Conspiracy-Theories

Alien Moon Base Images:
http://www.theblackvault.com/ftopict-45562.html

UFO:
http://ufonation.org

SV Threads:
http://www.eda.org/sv-ec/hm

Invisibility:
http://home.xtra.co.nz/hosts/Wingmakers/Invisibility.html
http://paranormal.about.com/cs/humanenigmas/a/aa112403_2.htm

Yoga:
http://www.yogavision.in

Third Eye:
http://www.strayreality.com/Lanis_Strayreality/thirdtyepinealgland.htm

Free Download:
http://www.infoworld.com/archives/emailPrint.jsp?R=printThis&A=/article/08/03/24/The-Web-best-free-stuff_1.html

Apache Help:
http://www.ricocheting.com/server/sharing.html

IDE/ATA Primary Secondary:
http://www.pcguide.com/ref/hdd/if/ide/confChannels-c.html

Saturday, April 5, 2008

Java Enabled Mobile Utilities

Following are couple of Java utilities, developed by me, for Java enabled mobile phone. To install this utilities to your mobile phone, download .jar files provided here to your computer and then download it to your mobile phone. Once downloaded to your mobile, run it by clicking on it.

Muhurt
Using this utility you can get Muhurt of given time of the given day of week. Muhurts are changed at every 1.5 hr of the day. In Gujaratee, it is called "Choghadiya".
Download Muhurt.jar

Digit
This utility plays with Numbers. It provides following features.
  1. Total: This feature gives you total of numbers e.g. 99999 has total = 45. You can enter number of any length!! and it will give you total.
  2. Total Range: This feature gives you range of numbers having given total. For that you need to provide three inputs; starting range, ending range and total. It will display all the numbers within starting and ending range, which has total entered by you.
  3. Total Digit: This feature is same as "Total Range". But instead of total it will ask for single digit from 1 to 9. That means, it will return all numbers within starting and ending range, whose total reduces to digit entered by you.
For example, if you enter
Starting range = 100
Ending range = 120
Digit = 2
Then it will return '101, 110, 119'(because 1 + 1 + 9 = 11; 1 + 1 = 2).
Download Digit.jar

Have Fun!!!