![]() |
|
![]() |
![]() ![]() |
|
![]() |
|
![]() |
|
![]() |
![]() |
2-digit Binary to BCD decoder bin_to_bcd.zip (300.555 Kb) This project gives an example modular design for a custom circuit that translates a 7-bit binary number ranging from 0 to 99 into two four-bit BCD digits (each 0-9). Rather than use the LPM_DIVIDE megafunction, we make an explicit combinational circuit to divide by 10 via repeated subtraction. Since the 10 is hard-coded, this design uses fewer resources than the LPM_DIVIDE version, and so it will be useful to you in Lab #4 if you run into fitting problems with an LPM_DIVIDE based circuit. |
|
![]() |
Example ALU circuit for lab #4 lab4_example_v2.zip (758.909 Kb) This project contains an example design of an ALU & test bench for lab #4. This particular ALU computes the four functions a+b, -a+b, ~a, and a&b. We are careful here to correctly check for signed overflow. This design implements the following policy for displaying results in the prototype test bench: If the signed 8-bit result is between -99 and +99 (inclusive), then we display its absolute value in decimal on the two-digit 7-segment display, and we use a separate LED to indicate the sign. If the absolute value of the result is greater than 99, then we display "Er" on the 7-segment display, and light up various other LEDS to indicate more details about the cause of the error (including whether the signed result of the add overflowed 8 bits), or whether it was -128 and thus its absolute value was too big to pass to the 7-bit divider. However, if a logical operation is being performed, we use the bank of 8 LEDs to display the individual bits of the result, instead of displaying the sign and the type of error. NOTE: You can and should design and implement your OWN, most likely different policy for displaying results! This circuit is just an example to show you one possible way to do things - do not try to mimic it exactly! NOTE: The original version of this example contained several bugs and did not even compile properly. The present version (v2) has been prototype-tested, debugged, repaired, and now works exactly as intended. |