Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

3.6 Exercises




  1. Write a code segment that contains just one statement to import file basic_types.e.




  2. Determine which comments in the following piece of e code are written correctly. Circle the comments that are written incorrectly.




    <'
    Import the basic test environment for the CPU...
        import cpu_test_env;
    '>
    
    This particular test requires the code that bypasses bug#72 as well as the constraints
    graphics/ccc.gif that focus on the immediate instructions.
             
             <'
             /*Import the bypass bug file*/
             import bypass_bug72;
             //Import the cpu test file_0012
             import cpu_test0012;
             --Import the cpu test file_0013
             import cpu_test0013;
             
             '>
             
  3. Practice writing the following numbers. Use _ for readability.

    1. Decimal number 123 as a sized 8-bit number in binary

    2. A 16-bit hexadecimal with decimal value 135

    3. An unsized hex number 1234

    4. 64K in decimal

    5. 64K in e

  4. Name the predefined constants in e.

  5. Write the correct string to produce each of the following outputs.

    1. “This is a string displaying the % sign”

    2. “out = in1 + in2 \\”

    3. “Please ring a bell \t”

    4. “This is a backslash \ character\n”

  6. Determine whether the following identifiers are legal:

    1. system1

    2. 1reg

    3. ~latch

    4. @latch

    5. exec[

    6. exec@

  7. Define a macro LENGTH equal to 16.

  8. Declare the following fields in e.

    1. An 8-bit unsigned vector called a_in

    2. A 24-bit unsigned vector called b_in

    3. A 24-bit signed vector called c_in

    4. An integer called count

    5. A time field called snap_shot

    6. A string called l_str

    7. A 1-bit field called b

  9. Declare an enumerated type called frame_type. It can have values SMALL and LARGE. Declare a field called frame of this enumerated type.

  10. Write the following actions with simulator variables.

    1. Assign the value of simulator variable top.x1.value to len field in e.

    2. Write the value 7 to the simulator variable top.x1.value.

  11. Describe the four levels of e syntax hierarchy. Identify three keywords used at each level of the hierarchy.

  • + Share This
  • 🔖 Save To Your Account