18 views

Uploaded by 2vij

- CH 1
- A1375953315 20495 2 2017 Logic Gates and Number System
- Hexadecimal
- Anima of a Tree-norio Fukushi
- Ezetrieve Basics
- Math MF2 Chapter 1 (Directed Numbers)
- Visual Math
- Ladder Diagram Instructions3
- Bmsit Mp Labmannulcertificate
- GT06 - GPS Tracker Communication Protocol
- Stld Notes Final
- CS2259
- Python Programming Tutorial
- 1396 Visual MATH See How Math Makes Sense
- CS1500 AMA System
- Base64 Encoding Decoding
- Pi by Scott Hemphill
- Chapter 5
- 008 Student Binary Math Worksheet ANSWER KEY
- Chapt 17

You are on page 1of 6

You should now be familiar with the Binary, Decimal and Hexadecimal Number System. If we view single digit values for hex, the numbers 0 F, they represent the values 0 - 15 in decimal. Often, we wish to use a binary equivalent of the decimal system. This system is called Binary Coded Decimal or BCD. Each decimal digit 0~9 is represented by 4 binary bits 0000 to 1001. In BCD number system, the binary patterns 1010 through 1111 do not represent valid BCD numbers, and cannot be used. For example, a decimal number 26410 can be represented as BCD numbers 001001100100BCD.

To convert from BCD to decimal, simply reverse the process as an example below:

As you can see, BCD number system is designed for the convenience of showing decimal number using binary data.

We will design a combinational circuit to convert an 8-bit binary number to 12-bit BCD. Why 12-bit for the BCD? The 8-bit binary number can present an integer from 0 to 255. Therefore, we need 3 decimal digits. As we see from Section 1, each decimal digit is represented by a 4-bit BCD. Therefore, we need 3*4 = 12-bit BCD. The BCD number is particularly useful when we try to display numbers in decimal format. A binary to BCD converter will be used frequently in our future labs to display numbers. After all, people are so used to the decimal number format. We begin to design the binary to BCD convert by introducin g the shift and add-3 algorithm. 1. Shift the binary number left one bit. 2. If 8 shifts have taken place, the BCD number is in the Hundreds, Tens, and Units column. 3. If the binary value in any of the BCD columns is 5 or greater, add 3 to that value in that BCD column. 4. Go to 1. 1

For example, lets convert FF (11111111) into BCD format by using the above algorithm.

In Verilog, we can also simply list the truth table and the synthesis tool will analyze and implement it in an optimized form. Here is a Verilog module for this truth table.

module add3(in,out); input [3:0] in; output [3:0] out; reg [3:0] out; always @ (in) case (in) 4'b0000: out 4'b0001: out 4'b0010: out 4'b0011: out 4'b0100: out 4'b0101: out 4'b0110: out 4'b0111: out 4'b1000: out 4'b1001: out default: out endcase endmodule

<= <= <= <= <= <= <= <= <= <= <=

4'b0000; 4'b0001; 4'b0010; 4'b0011; 4'b0100; 4'b1000; 4'b1001; 4'b1010; 4'b1011; 4'b1100; 4'b0000;

It consists of 7 add-3 components. To skip all the details, here is a structural Verilog module corresponding to the logic diagram.

module binary_to_BCD(A,ONES,TENS,HUNDREDS); input [7:0] A; output [3:0] ONES, TENS; output [1:0] HUNDREDS; wire [3:0] c1,c2,c3,c4,c5,c6,c7; wire [3:0] d1,d2,d3,d4,d5,d6,d7; assign d1 = {1'b0,A[7:5]}; assign d2 = {c1[2:0],A[4]}; assign d3 = {c2[2:0],A[3]}; assign d4 = {c3[2:0],A[2]}; assign d5 = {c4[2:0],A[1]}; assign d6 = {1'b0,c1[3],c2[3],c3[3]}; assign d7 = {c6[2:0],c4[3]}; add3 m1(d1,c1); add3 m2(d2,c2); add3 m3(d3,c3); add3 m4(d4,c4); add3 m5(d5,c5); add3 m6(d6,c6); add3 m7(d7,c7); assign ONES = {c5[2:0],A[0]}; assign TENS = {c7[2:0],c5[3]}; assign HUNDREDS = {c6[3],c7[3]}; endmodule

module B_BCD ( ena, binary, bcd ); parameter B_SIZE = 11; input binary, ena; output bcd; wire ena; wire [B_SIZE-1 : 0] binary; reg [B_SIZE-1 : 0] bin; reg [B_SIZE+3 : 0] bcd; reg [B_SIZE+3: 0] result; always@( binary or ena ) begin bin = binary; result = 0; if ( ena == 0 ) bcd <= 0; else 4

begin repeat ( B_SIZE-1 ) begin result[0] = bin[B_SIZE-1]; if ( result[3 : 0] > 4 ) result[3 : 0] = result[3 : 0] + 4'd3; if ( result[7 : 4] > 4 ) result[7 : 4] = result[7 : 4] + 4'd3; if ( result[11 : 8] > 4 ) result[11 : 8] = result[11 : 8] + 4'd3; result = result << 1; bin = bin << 1; end result[0] = bin[B_SIZE-1]; bcd <= result; end end endmodule

4. The top level module also includes the LED display diver

module top ( input [7:0] A, input clk, output [3:0] an, output [6:0] disp, output dp ); wire [3:0] ones, tens; 5

wire [3:0] hundreds; wire [3:0] y; B_BCD fsm hex7seg bcd_inst (1'b1, {3'b0,A}, {hundreds, tens, ones}); fsm_inst (clk, ones, tens, hundreds, 4'b0, an, y, dp); hex_inst (y, disp);

endmodule

NET "clk" LOC = "V10" ;

NET "A[0]" LOC = "T10"; NET "A[1]" LOC = "T9"; NET "A[2]" LOC = "V9"; NET "A[3]" LOC = "M8"; NET "A[4]" LOC = "N8"; NET "A[5]" LOC = "U8"; NET "A[6]" LOC = "V8"; NET "A[7]" LOC = "T5";

NET "an[3]" LOC = "P17" ; NET "an[2]" LOC = "P18" ; NET "an[1]" LOC = "N15" ; NET "an[0]" LOC = "N16" ; NET "disp[6]" LOC = "T17" ; NET "disp[5]" LOC = "T18" ; NET "disp[4]" LOC = "U17" ; NET "disp[3]" LOC = "U18" ; NET "disp[2]" LOC = "M14" ; NET "disp[1]" LOC = "N14" ; NET "disp[0]" LOC = "L14" ; NET "dp" LOC = "M13";

- CH 1Uploaded byDanyal Hasnain
- A1375953315 20495 2 2017 Logic Gates and Number SystemUploaded byANKUR SHUKLA
- HexadecimalUploaded byAngel Lawson
- Anima of a Tree-norio FukushiUploaded byPercusion San Juan
- Ezetrieve BasicsUploaded bySreenivas Rao
- Math MF2 Chapter 1 (Directed Numbers)Uploaded bycompeil
- Visual MathUploaded byKriszta
- Ladder Diagram Instructions3Uploaded by03sri03
- Bmsit Mp LabmannulcertificateUploaded bymentalvtu
- GT06 - GPS Tracker Communication ProtocolUploaded bychiddu5
- Stld Notes FinalUploaded byvasu dev
- CS2259Uploaded byNehaKarunya
- Python Programming TutorialUploaded byKoay HV
- 1396 Visual MATH See How Math Makes SenseUploaded byjamblack1234
- CS1500 AMA SystemUploaded bytoanlee04
- Base64 Encoding DecodingUploaded byshivang1313
- Pi by Scott HemphillUploaded bySaurav_D
- Chapter 5Uploaded byGOD
- 008 Student Binary Math Worksheet ANSWER KEYUploaded byAniket pandey
- Chapt 17Uploaded bybarbarossa17
- Beginning Micro Controllers With the Msp430Uploaded bypeemanuk
- TOPIC 1A Numbering SystemUploaded bycyclopsoctopus
- How to Convert From Decimal to BinaryUploaded bycykee
- Maths 2 First Semestral Test Desember 2016Uploaded bydebora dwi
- Lab5 Kalkulator BinerUploaded bysifa
- Complete Adv PLC Simatic 06-02-14 Cover (2)Uploaded bysvhanu4010
- The Power of BinaryUploaded byGhonchu Prasad
- gputilsUploaded byphilrich123
- 10.1.1.126Uploaded byravi_phy
- Matlab Summary and TutorialUploaded bysuraj.atmos458

- Phase 2 EnvironmentUploaded by2vij
- Phase 5 DriverUploaded by2vij
- DpiUploaded by2vij
- PHASE_1_TOPUploaded by2vij
- PHASE_1_TOPUploaded by2vij
- Sri YantraUploaded by2vij
- List of Vlsi Companies in BangloreUploaded by2vij
- Phase 3 ResetUploaded by2vij
- Phase 8 CoverageUploaded by2vij
- ConstructUploaded by2vij
- Phase 9 TestcaseUploaded by2vij
- Phase 4 PacketUploaded by2vij
- FUN_COVEUploaded by2vij
- Phase 6 ReceiverUploaded by2vij
- LINEAR_TBUploaded by2vij
- How to Answer the 64 Toughest Interview QuestionsUploaded byramakrishna533
- Event Cycle SimulationUploaded by2vij
- Verilog SemaphoreUploaded by2vij
- 8838729 Infosys PuzzlesUploaded byshanthimam38
- 8838729 Infosys PuzzlesUploaded byshanthimam38
- Microsoft Word Faq in VlsUploaded by2vij
- CheckerUploaded by2vij
- Error InjuctionUploaded by2vij
- White Gray Black BoxUploaded by2vij
- About Code CoverageUploaded by2vij
- VLSI CMOS interview questions and answersUploaded byrAM
- DebuggingUploaded by2vij
- Microsoft Word AptitudeUploaded by2vij

- Xilinxs IC DesignUploaded bycokelat_k
- OUD-11gR1.pdfUploaded bytonypalmsprings
- mte april2011webUploaded byb_b_y
- Proportional Font SecretsUploaded byrenicito
- sn74avc4t245Uploaded byRsashwin Kumar
- 01 Iec t1s1 Oops Session 01Uploaded bycaininme
- Philips TDA9874.pdfUploaded byMawahidPutra
- MomaReleaseEn03v10Uploaded byRogerioFaria28
- Fm8700 Sme AUploaded byIgorr
- Sappress Inside Web Dynpro for JavaUploaded byourmovies9
- 2Uploaded byAnonymous rY5FB0dz
- AMD APP SDK Installation NotesUploaded byhruehara
- Motherboard Manual p eUploaded byJRainbow
- 00522-G Mon 2000 Software Manual Sec_G 1MB.pdfUploaded byFabio Kjergaard
- Aleph4 ConstructionUploaded byaocta
- 9100manual ProgramatorUploaded byDorynVarga
- Master Components Selector GuideUploaded byherbert3349
- 1783-um007_-en-pUploaded byLiga De Tenis De Mesa Del Magdalena
- License Wizard InstUploaded byangusyoung1
- Instalar Win Desde USB WinSetupFromUSB 1Uploaded byluisabeto
- Wireless Solution ControllerUploaded bybagoes soegab
- Cisco JTAPI Developer Guide for CCM 4.1(3)Uploaded byikorotovskikh
- RISC Processors_all Syllabus5Uploaded bymdf67
- An_Introduction_to_Pseudocode_workbook.docxUploaded byradebp
- ERAFLASH 8 Manual Short 81001Uploaded byestefania
- BU941 Bobina G7Uploaded byMecaSoftware
- ba3308.pdfUploaded byAnghelescu Cristina
- irf7807vd2Uploaded byMartin Torres
- CtoS Coding TipsUploaded byd-jah
- ABAP Objects - Interface in Local ClassUploaded bymagforu