DIC Lab Work 2

De la WikiLabs

Notions and Knowledge Required

Example 1

Make a two-bit decoder using a case block. Test the decoder by connecting the inputs to the switches and led outputs.

Example 2

Make a 7-segment display transcoder using a case block that can display values ​​from 0 to 3. The input of the module will be called value and output out_seg . Test the decoder by applying the input to SW1 and SW0 and displaying the output on the 7-segment display, the digit to the right (Digit0).

Exercises

The following exercises use the 7-segment binary transcoder for displaying in hexadecimal the result of a simple operation. To make sure the transcoder is written correctly, check the operation of the transcoder. The project to be sent to the end is the one in b.


Exercise 1

a. Modify the transcoder of example 2 so that it can display values ​​from 0 to 15 in the base 16 (10=A, 11=b, 12=C, 13=d, 14=E, 15=F) at second right position.

  • Name the module afisaj7seg
  • Bits out_seg match the segments in the following way:
    • Bit 6 corresponds to segment 0
    • Bit 5 corresponds to segment 1
    • Bit 4 corresponds to segment 2
    • Bit 3 corresponds to segment 3
    • Bit 2 corresponds to segment 4
    • Bit 1 corresponds to segment 5
    • Bit 0 corresponds to segment 6

Check the display function on the DE1 board by connecting the input to SW3-SW0. Change the pins to the output so that the value is displayed on Digit 1.

b. Build a circuit that collects two binary numbers on 3 bits, and the 4-bit result will be displayed as a hexadecimal number with the transcoder at a). restrictions:

  • Create a new project where the top-level module is named top.
  • The two inputs will be marked with a and b and will be connected to switches SW2-SW0 (corresponding to the bits 2 → 0 of a in this order), respectively SW9-SW7 bit 2> 0 of b in this order).
  • Outputs will connect to the corresponding pins for the 7-segment display, Digit 1.
  • Sumator and transcoder will be described in different modules (called ' and display' ', written in different files and instantiated in the' top 'module.

Exercise 2

a. Modify the transcoder of example 2 so that it can display values ​​from 0 to 15 in the base 16 (10=A, 11=b, 12=C, 13=d, 14=E, 15=F) to the left position.

  • Name the module afisaj7seg
  • Bits out_seg match the segments in the following way:
    • Bit 6 corresponds to segment 1
    • Bit 5 corresponds to segment 2
    • Bit 4 corresponds to segment 3
    • Bit 3 corresponds to segment 4
    • Bit 2 corresponds to segment 5
    • Bit 1 corresponds to segment 6
    • Bit 0 corresponds to segment 0

Check the display function on the DE1 board by connecting the input to the SW5-SW2. Change the pins to the output so that the value is displayed on Digit 3.

b. Build a circuit that multiplies two binary numbers, a, a, b, and b, and the 4-bit result will be displayed as a hexadecimal number with the transcoder at a). restrictions:

  • Create a new project where the top-level module is named top.
  • The two inputs will be marked with a and b respectively and will be connected to SW9-SW7 switches (corresponding to the bits 2 → 0 of a in this order), respectively SW2-SW1 bits 1-> 0 of b in this order).
  • Outputs will connect to the corresponding pins for the 7-segment display, Digit 3.
  • The multiplier and transcoder will be described in different modules (called product and afisaj7seg , written in different files, and instantiated in the' top 'module.

Note: The product of the two numbers (the output of the multiplier) is a 5-bit number, for example prod . If the result exceeds 15, we will display "error" at the output, which can be symbolized, for example, by a dash on the center position (segment 6). The output of the top module, denoted out, is calculated as follows:

assign out=prod[4] ? 7'b1111101 : out_seg;

Exercise 3

a. Fill and modify the transcoder of example 2 so that it can display values ​​from 0 to 15 in the base 16 (10=A, 11=b, 12=C, 13=d, 14=E, 15=F) on the second left position.

  • Name the module afisaj7seg
  • Bits out_seg match the segments in the following way:
    • Bit 6 corresponds to segment 1
    • Bit 5 corresponds to segment 3
    • Bit 4 corresponds to segment 2
    • Bit 3 corresponds to segment 6
    • Bit 2 corresponds to segment 4
    • Bit 1 corresponds to segment 5
    • Bit 0 corresponds to segment 0

Check the correct operation of the display on the DE1 board by connecting the input to SW4-SW1. Change the pins to the output so that the value is displayed on Digit 2.

b. Make a circuit that performs OR OVER (bit-bit) operation between 2 binary 4-bits and the 4-bit result will be displayed as a hexadecimal number using the transcoder at a). restrictions:

  • Create a new project where the top-level module is named top.
  • The two inputs will be marked with a and b respectively and will be connected to SW3-SW0 switches (corresponding to the bits 3-> 0 of a in this order) respectively SW9-SW6 bit 3> 0 of b in this order).
  • Outputs will connect to the corresponding pins for the 7-segment display, Digit 2.
  • The logic circuit and the transcoder will be described in different modules (called or_exclusiv and afisaj7seg), written in different files, and instantiated in the 'top' module.

Exercise 4

a. Modify the transcoder of example 2 so that it can display values ​​from 0 to 15 in the base 16 (10=A, 11=b, 12=C, 13=d, 14=E, 15=F) to the left position.

  • Name the module afisaj7seg
  • Bits out_seg match the segments in the following way:
    • Bit 6 corresponds to segment 2
    • Bit 5 corresponds to segment 4
    • Bit 4 corresponds to segment 6
    • Bit 3 corresponds to segment 3
    • Bit 2 corresponds to segment 5
    • Bit 1 corresponds to segment 1
    • Bit 0 corresponds to segment 0

Check the correct operation of the display on the DE1 board by connecting the input to SW9-SW6. Change the pins to the output so that the value is displayed on Digit 3.

b. Build a circuit that collects two binary numbers on 3 bits, and the 4-bit result will be displayed as a hexadecimal number with the transcoder at a). restrictions:

  • Create a new project where the top-level module is named top.
  • The two inputs will be marked with in1, respectively in2, and will be connected to the switches SW7-SW5 (corresponding to the bits 2-> 0 of in1 in this order) respectively SW4-SW2 bit 2> 0 of in2 in this order).
  • Outputs will connect to the corresponding pins for the 7-segment display, Digit 3.
  • Sumator and transcoder will be described in different modules (called ' and display' ', written in different files and instantiated in the' top 'module.

Exercise 5

a. Modify the transcoder of example 2 so that it can display values ​​from 0 to 15 in the base 16 (10=A, 11=b, 12=C, 13=d, 14=E, 15=F) on the second position on the left.

  • Name the module afisaj7seg
  • Bits out_seg match the segments in the following way:
    • Bit 6 corresponds to segment 3
    • Bit 5 corresponds to segment 4
    • Bit 4 corresponds to segment 1
    • Bit 3 corresponds to segment 2
    • Bit 2 corresponds to segment 0
    • Bit 1 corresponds to segment 5
    • Bit 0 corresponds to segment 6

Check the display function on the DE1 board by connecting the input to the SW8-SW5. Change the pins to the output so that the value is displayed on Digit 2.

b. Make a circuit that multiplies two binary numbers, in1, 2 bits, and in2, 3 bits, and the 4-bit result will be displayed as a hexadecimal digit with the transcoder at a). restrictions:

  • Create a new project where the top-level module is named top.
  • The two inputs will be marked with in1, respectively in2, and will be connected to the switches SW3-SW2 (corresponding to the bits 1-> 0 of in1 in this order) respectively SW9-SW7 bit 2> 0 of in2 in this order).
  • Outputs will connect to the corresponding pins for the 7-segment display, Digit 2.
  • The multiplier and transcoder will be described in different modules (called prod and afisaj7seg, written in different files, and instantiated in the' top 'module.

Note: The product of the two numbers (the output of the multiplier) is a 5-bit number, for example prod. If the result exceeds 15, we will display "error" at the output, which can be symbolized, for example, by a dash on the center position (segment 6). The output of the top module, denoted out, is calculated as follows:

assign out=prod [4]? 7'b1111110: out_seg;

Exercise 6

a. Modify the transcoder of example 2 so that it can display values ​​from 0 to 15 in the base 16 (10=A, 11=b, 12=C, 13=d, 14=E, 15=F) at second right position.

  • Name the module afisaj7seg
  • Bits out_seg match the segments in the following way:
    • Bit 6 corresponds to segment 1
    • Bit 5 corresponds to segment 3
    • Bit 4 corresponds to segment 2
    • Bit 3 corresponds to segment 6
    • Bit 2 corresponds to segment 4
    • Bit 1 corresponds to segment 5
    • Bit 0 corresponds to segment 0

Check the correct operation of the display on the DE1 board by connecting the input to SW4-SW1. Change the pins to the output so that the value is displayed on Digit 1.

b. Implement a circuit that performs the OR (bit-bit) operation between 2 binary 4-bit numbers and the 4-bit result will be displayed as hexadecimal by the transcoder at a). restrictions:

  • Create a new project where the top-level module is named top.
  • The two inputs will be marked with in1, respectively in2, and will be connected to the SW8-SW5 switches (corresponding to the bits 3-> 0 of in1 in this order), respectively SW4-SW1 bit 3> 0 of in2 in this order).
  • Outputs will connect to the corresponding pins for the 7-segment display, Digit1.
  • The logic circuit and the transcoder will be described in different modules (called or and afisaj7seg, written in different files, and instantiated in the 'top' module.

Submission of Exercises

For scoring, the following files will be submitted to the e-mail address indicated by the teacher.

An archive zip

  • Three Verilog files with the .v extension containing the Verilog description of the logic circuit, the transceiver, and the top module.
  • A constraint file with the .qsf extension
  • A Quartus project file with the .qpf extension

Note that the archive will contain only the 5 files (no directories).

The subject of the email message must be in the [Name] _ [First name] _ [Group] _7seg_ [ Exercise] for example Petrica_Lucian_423B_7seg_4