Return to Video

TCM Example cs348 unit3new

  • 0:02 - 0:06
    The syntax of a TCM is very similar to a method. You have a name, a parameter
  • 0:06 - 0:11
    list, and a block of code. The noticeable difference is the at followed by an
  • 0:11 - 0:16
    event name. This is called the default sampling event of the TCM. And it's the
  • 0:16 - 0:22
    main synchronization event for the execution. Inside the TCM you can execute
  • 0:22 - 0:28
    procedural action, actions and synchronization statements. So back in our
  • 0:28 - 0:34
    packet driver, we have our clock event. And here is our first example TCM. One
  • 0:34 - 0:40
    parameter called duration. And the default event is clock_f. But when you start
  • 0:40 - 0:44
    a thread or when you start a TCM, before anything gets executed, you need one
  • 0:44 - 0:50
    occurrence of the default event. So before we get into executing any of this,
  • 0:50 - 0:55
    this event needs to happen. We have two print statements, and then we have our
  • 0:55 - 1:00
    first synchronization action. We want to suspend the TCM execution by a number
  • 1:00 - 1:07
    of cycles, so we do wait duration times cycle. Cycle refers to the default
  • 1:07 - 1:11
    event, and duration is our input parameter. So here we can control how long
  • 1:11 - 1:17
    this TCM will suspend here. Once this temporal expression is finished. We fall,
  • 1:17 - 1:21
    fall down here, and execute further actions. So we have another print
  • 1:21 - 1:26
    statement, and then stop run to stop the simulation. In order to span off a
  • 1:26 - 1:32
    thread, you use the start action. So in the run phase at time 0, or just before
  • 1:32 - 1:38
    the simulation starts. We spawn off our thread, our TCM. And pass in 5 as a
  • 1:38 - 1:45
    parameter. You cannot call a TCM from a method because TCMs consume time. From
  • 1:45 - 1:50
    within a TCM, you could call another TCM. And this is like a suspend. So
  • 1:50 - 1:55
    calling another TCM will start that TCM. And when it's finished, they will,
  • 1:55 - 2:00
    control returns back to the calling TCM, and it will execute further. Let's
  • 2:00 - 2:07
    have a look at the log file. So here we can see, when we start running, we
  • 2:07 - 2:12
    don't get the print statements. We only get them after we had the first clock.
  • 2:12 - 2:17
    So at time 100 we get our clock, and then we get indication that our TCM has
  • 2:17 - 2:23
    started. It then waits for 5 cycles and prints that the TCM is now going to
  • 2:23 - 2:30
    end. And we call stop run to stop the simulation. So this is how you can
  • 2:30 - 2:36
    execute a method over time, and it's called a time consuming method.
Title:
TCM Example cs348 unit3new
Video Language:
English
Team:
Udacity
Project:
CS348 - Functional Hardware Verification
Duration:
02:36
Cogi-Admin added a translation

English subtitles

Revisions