Home.Verilog.Digital Design.Digital Basics.Python.RF Basics.
Custom Search

Legal Disclaimer

Chip Designing for ASIC/ FPGA Design engineers and Students
Digital-logic Design...  Dream for many students… start learning front-end…

Legal Disclaimer

@TYH :- 4G LTE Long Term Evolution Tutorial, CloudComputing
Verilog Tutorial.
Get Noticed:- Submit your own content to be published on fullchipdesign.com

Send it to fullchip@gmail.com

Digital Basics Tutorial.
File read operations.

Class & global var.

File write op's.

Glob module.

Conditional stms.

String 2 hex.

UNIX in Python.

Diamond Pattern.

TypeError - arg.

TyprError - str.

TypeError - strconv.


Function call.

Read bin files.

Python scripting quick reference.

Function for conditional statement ‘for’.

Check the program for the usage of this function

Step to convert string to hexadecimal value

         >> self.idata_f  = int(self.idata, 16)

         >> self.qdata_f = int(self.qdata, 16)

Check the program for the usage

Step to strip off white space at end

     >> self.rfile = string.strip(self.rfile)

Check the program for the usage

Step to convert 12 bit hexadecimal values to 12 bit signed values

            if (self.idata_f > (4096/2 - 1)):

                self.idata_f = self.idata_f - 4096   

            if (self.qdata_f > 4096/2 - 1):

                self.qdata_f = self.qdata_f - 4096

Check the program for the usage

~\Desktop\cond1.py.html def cond_statements(self):
        self.ci = 0
        self.idata = 0
        self.qdata = 0
        for self.ci in range(10, 11, 1):
                self.idata = self.rfile[self.ci] + self.rfile[self.ci+1]+ self.rfile[self.ci+2]
                self.qdata = self.rfile[self.ci+5] + self.rfile[self.ci+6] + self.rfile[self.ci+7]
                print self.idata, self.qdata

Following code snippets are discussed.  

Define a function and use ‘for’ loop in Python

Convert string to hexadecimal value.

Stip-off whitespaces from end.

Conversion of 12 bit hexadecimal values to 12 bit