Procedure:


1.      First we will create a Memory Initialization file.
Create a new Text file in your project folder.
Open this
Notepad file and copy the following to create a Memory Initialization file.

DEPTH = 256;
WIDTH = 24;
ADDRESS_RADIX = HEX;
DATA_RADIX = HEX;
CONTENT
BEGIN

[00..FF] : 00;

END;

Here DEPTH indicates the number of address in the ROM. The WIDTH indicates the word size in bits. The RADIX indicates that you are entering memory content as Hexadecimal numbers.  [00..FF] : 00; make all the memory locations from 0 to 255 as zero.

Rename the file as Bin_to_BCD.mif. Make sure that the format of the file is now changed from .txt to .mif.

2.      It is more convenient to open and further edit this file using Quartus II software. Note that you can also create the Memory Initialization file using Quartus II however the manual approach makes the file simpler and clearer (you can play with auto generated files when you are experienced).

a.       Open Bin_to_BCD.mif file using File > Open menu in Quartus II software.

b.      In the Memory Initialization file copy and paste the memory contents from the excel sheet you created, so that you can show the appropriate 7-segment output for the given binary number. Note that data stored in a block with address 'XXX' with be outputted by the ROM when we provide 'XXX' as input.

c.       To view delimiter spaces, click View > Show Delimiter Spaces. You will now see your inputs as 3 blocks of 2 hexadecimal digits.

d.      To avoid any confusion lets select pin A of the 7-segment display as the LSB in each 8-bit output block.

e.       For an example in address 000 (i.e. to display 000 in BCD) using all three 7-segment displays set the memory content as 40 40 40. Similarly for 1 and 2; 40 40 79  and 40 40 24. Make use of the pre-lab to fill up the rest of the table.

Remember that the 7-segment display in DE board need logic levels to be inverted. So above values are selected based on that.

3.   Create a new project and label it as Lab7. Then add a new Schematic design to your project and save it as Lab7.bdf

4.      Use the following steps to set-up the ROM for this project. This ROM will store the Binary to seven-segment mapping of data. To build the ROM, you will use a megafunction provided by Altera. Magafunction is a complex or high-level building block that can be used to design a complex logic system. We will use MegaWizard Plug-In Manager to build a megafunction.

a.       Open the Symbol dialog box and enter lpm_rom under Name: text box. Then click OK.

b.  Right click >> Properties >> Parameters

c. Enter the following specification in the table

Name
Value
LPM_ADDRESS_CONTROL
"REGISTERED"
LPM_FILE
Bin_to_BCD.mif
LPM_NUMWORDS
256
LPM_OUTDATA
"UNREGISTERED"
LPM_WIDTH
24
LPM_WIDTHAD
8


We are basically specifying ROM parameters as follows:

d.        24 as the width of the output bus (i.e., word size).

e.       256 as How many 24-bit words of memory (i.e., number of addresses). 

f.    8 bits and number of input/ address lines

g.    Type the file name as: Bin_to_BCD.mif. as the memory initialization file


Note that the new ROM has buses instead of individual input/output pins (except for the clock input).

5.      Next we need to add input/output pins to the schematic design. Let's create 2 buses for input and output.

a.       Add 2 input pins and 1 output pin. Label the first input pin as Address[7..0] this will create a 8-bit address bus. Label the output pin as BCD[23..0] this will create a 24-bit output. Connect the second input pin to the clock.

 

6.      Compile your circuit and make sure there are no errors.

7.    When you assign pins select the 7-segemnets in DE board as follows. HEX0 should be the LSB in Decimal and HEX2 should be the MSB in Decimal. Assign switches SW0 to SW7 as the addresses (i.e. inputs to ROM). Connect the clock to KEY0.

8.      Then recompile the circuit.


Challenge