Introduction to Hardware Design by PARTHENON

Back to Table of Contents of PARTHENON User's Manual

## 2.2 Simulation using SECONDS

Basic Use of SECONDS

Advanced Use of SECONDS

This section verifies whether the clock timer behavior described in SFL in Section 2.1 is as intended by the designer, by using the SFL simulator SECONDS (Sfl Extended CONversational Design System).

Conventional logic simulators used in logic design are intended to verify:

(1) Whether the functional design is correct; and

(2) Whether the timing constraints are satisfied

In contrast, the only timing information SFL has is a single-phase synchronous clock. Therefore, SECONDS cannot verify item (2). However, it is more appropriate to say that PARTHENON does not require item (2) to be verified in simulation. This is because in PARTHENON the only constraints on timing are that data transfer should be completed within the synchronous clock period and that data leakage should not occur due to clock skew. These items can be verified with synthesis tools statically. SECONDS is more a "debugger of program language SFL" than a logic simulator.

Let's look at the operation of SECONDS. Let the timer module and the decrementer module described in Section 2.1 be stored in files TIMER.SFL and DECR8.SFL, respectively. In the following, this decrementer can be just a function description, or implemented with the carry-look-ahead or ripple carry method - it does not matter. Since the SFL descriptions of List 2.1 and List 2.9, presented in Section 2.1, are in the directory, example.dir\chapter2, where PARTHENON was installed, the following operations can be tried immediately by specifying this directory as the current directory.

### • Basic Use of SECONDS

Activating SECONDS
Reading SFL in
Creating a simulation image
Setting simulation data and displaying results
Using a command script
Terminating SECONDS

To master the basic use of SFL simulator SECONDS, it is suggested that you simulate only the decrementer.

>

Activating SECONDS

First activate SECONDS as follows.

A>seconds
***************************************************************
* SECONDS Version 2.3.0 1994/07/05 *
* This program is a part of the PARTHENON system. *
* Copyright (C) 1989-1994 NTT *
***************************************************************
!!Type 'help' if you need help messages!!
SECONDS>

After SECONDS is activated, "SECONDS> " appears on the screen. This is a command prompt of SECONDS. SECONDS is an interactive tool and all operations are controlled with commands.

< >

Reading SFL in

In simulation, the design description in SFL must first be read into SECONDS. Use the command 'sflread' (type lowercase characters to enter commands) to read SFL. Let's read the 8-bit decrementer DECR8, presented in Section 2.1.

SECONDS> sflread DECR8.SFL

If any SFL error is detected, the command 'sflread' activates an editor and requests the user to make a correction. For details, see Section 2 (How to deal with errors) of Chapter 6 (SFLEXP). Use command 'lmc' to check whether the description has been correctly read into SFL.

SECONDS> lmc
DECR8 (module )

After completing the above operation, are we ready to start simulation? Sorry! There is one more step to go. Simulation with SECONDS is similar to building a circuit on a breadboard and then testing it. In this analogy, we have just collected parts in a parts box. Since the simulator can copy as many parts as necessary, it is not the number of parts but the types of part that are important.

< >

Creating a simulation image

(1)Creating a breadboard

Testing a circuit on a breadboard requires not only collecting parts but also building the circuit. In SECONDS, this circuit is a simulation image. The simulation image is formed by making an instance of the top module (which is equivalent to putting parts on a breadboard in our analogy).

Let's create a simulation image of DECR8

SECONDS> install DECR8 /

This command indicates that the instance is to be constructed with a part called DECR8 as the top module ("/"). As DECR8 does not have a sub-module, the simulation image is completed with this operation alone (we will think about the case where multiple modules are provided later).

(2) Simulation Time

Once a simulation image has been created, "simulation time" is defined.

SECONDS> time
0

The command 'time' displays the current simulation time (cycle). Can you tell what appears when this command is issued before you have made a simulation image? I won't tell you the answer. See it for yourself.

The command 'lc' is available to view the simulation image.

SECONDS> lc
/ (module )
C (term internal )
ENABLE (instr input )
IN (term input )
OUT (term output )

This indicates that "we are currently at the top module (root) and that four objects exist under the top module."

< >

Setting simulation data and displaying results

(1) Applying a tester to the IN and OUT terminals at the beginning

We are now ready to start the simulation. Apply a tester to the input terminal IN (8 bits) and output terminal OUT on the DECR8 breadboard.

SECONDS> print "IN=%B OUT=%B\n" IN OUT
IN=zzzzzzzz OUT=zzzzzzzz

The first parameter of the command "print" specifies a format in which the value of the object subjected to the tester is displayed. The above command example specifies binary notation for display. (Note: As described in section 5.8, %B indicates binary format; \n indicates new line.) The outputs of all bits for IN and OUT are "z" which indicates that the process is not driven (high impedance).

(2) IN and OUT terminals with control terminal ENABLE asserted.

Let's assert control terminal ENABLE. Although it is not possible to assign "1" or "0" to the control terminal with SFL, it is possible with commands of SECONDS (setting by using a command takes priority over SFL description).

SECONDS> set ENABLE 1
SECONDS> print "IN=%B OUT=%B\n" IN OUT
Error :(forward) on 0 in /
(W)Referred terminal /IN is not driven.
End of Errors
IN=zzzzzzzz OUT=uuuuuuuu

SECONDS scolded me for asserting ENABLE with the set command. This is because input terminal IN does not have the required data in spite of the fact that ENABLE has been asserted. However, this is a warning "(W)" and does not mean that the simulation cannot continue.

The value of OUT is displayed as "u". The sign "u" denotes an "undetermined value," which cannot be specified to be "0" or "1". The difference from "z" lies in that the terminal object is driven.

(3) Setting a value at the IN terminal

Set IN to 1. This must yield 0 at OUT (displayed in hexadecimal this time).

SECONDS> set IN X01 ; print "IN=%X OUT=%X\n" IN OUT
IN=01 OUT=00

We did indeed obtain 0. From now on, you can input various values to check the results for correctness.

< >

Using a command script

Before we proceed with further operations, let's create the file below, which will save us from the need to enter repetitively and in full commands such as the following:

set IN ?? ; print "IN=%X OUT=%X\n" IN OUT

(Note: As indicated in section 5.8, %X indicates hexadecimal format.)

The following file includes command strings for SECONDS. It is called a script.

<TRY.SEC>

set IN $1
print "IN=%X OUT=%X\n" IN OUT

(1)Creating a script with 'speak' command

If you use a multi-window system, you can open an editor window. If you cannot, enter the following to create file 'TRY.SEC',

SECONDS> speak TRY.SEC
SECONDS> echo 'set IN $1'
SECONDS> echo 'print "IN=%X OUT=%X\n" IN OUT'
SECONDS> speak

The "speak" command switches command outputs. If no parameter is provided, it makes the system responses return to the standard output (the visual display screen) and also closes TRY.SEC. "$1" is the first parameter given to this script.

(2) Using the script with 'listen' command

Next, use the following script.

SECONDS> listen TRY.SEC X01
IN=01 OUT=00

The "listen" command switches command inputs and reads a command from the script file specified by the first parameter. Any subsequent parameters are used by this script file. When an unknown command is given, SECONDS assumes that the input of 'listen' command has been omitted. Therefore, 'listen' command can be omitted.

(3) Results of simulation

The results of the simulation are as given below.

SECONDS> TRY.SEC X02
IN=02 OUT=01
SECONDS> TRY.SEC X03
IN=03 OUT=02
SECONDS> TRY.SEC X04
IN=04 OUT=03
SECONDS> TRY.SEC X08
IN=08 OUT=07
SECONDS> TRY.SEC X10
IN=10 OUT=0f
SECONDS> TRY.SEC X20
IN=20 OUT=1f
SECONDS> TRY.SEC X40
IN=40 OUT=3f
SECONDS> TRY.SEC X80
IN=80 OUT=7f
SECONDS> TRY.SEC X00
IN=00 OUT=ff

The simulation results seem to show that the decrementer module operates correctly.

Since the 'set' command can set up not only external inputs as shown in this example but also values for any objects, including register, stage states and memory (though 'memset' and 'memclr' commands are used for memory; otherwise they are essentially the same as 'set'), any pattern, in principle, can be simulated with this command.

< >

Terminating SECONDS

The above covers the minimum you have to know to use SECONDS, except that you will also have to know how to terminate SECONDS (by a means other than pressing the reset button).

SECONDS> bye
******************************
* Good bye, see you later. *
******************************

<

### • Advanced use of SECONDS

Installing multiple modules
Using the report function
Setting clock forward
Using the schedule function
Using the request function
Transferring the results of SECONDS output to other application software

Combinational circuits and very simple sequential circuits can be simulated with a breadboard and tester (using its basic functions) only. However, these tools do not suffice for a moderately large sequential circuit. If you can afford it, you may use a logic analyzer. Of course, SECONDS can be used as a logic analyzer.

Let's simulate a sequential circuit, taking the entire clock timer as an example.

>

Installing multiple modules

(1)Reading multiple files with the 'sflread' command

The TIMER module and DECR8 module are created in separate files. Since the 'sflread' command can be used only for a single file, the two files must be read separately.

A>seconds
SECONDS> sflread TIMER.SFL
SECONDS> sflread DECR8.SFL
SECONDS> lmc
TIMER (module )
DECR8 (module )

(2) Making the specified part the top module with the 'autoinstall' command

SECONDS> autoinstall TIMER

The 'autoinstall' command installs a specified part as the top module and places the parts (DECR8) specified by the master module in all sub-module positions (DECR only in this case).

In this example, this command is equivalent to the following commands.

SECONDS> install TIMER /
SECONDS> install DECR8 DECR

Connect-lines are automatically drawn between parts in accordance with the names of the terminals (ports).

< >

Using the report function

We will use the report function in place of the 'print' command this time.

SECONDS> rpt_add ext "%4T: START=%B RESET=%B INIT=%X EXPIRE=%B" START RESET INIT EXPIRE
SECONDS> rpt_add int " REMAINED=%X TASK=%B STATE=%S\n" REMAINED MAIN.RUN MAIN

Here, the first parameters 'ext' and 'int' are identifiers to faciliate erasing or changing the order in a later process. The second and subsequent parameters are the same as the parameters of the 'print' command.

Unlike the 'print' command, the 'rpt_add' command does not display values immediately. This is because the report function displays values as time elapses, and this is driven by the 'forward' command. However, you may want to know immediately whether the values you except will actually be displayed.

SECONDS> report do

This will do the job. It forces the report content to be displayed. In this case, the following will be displayed:

0 : START=0 RESET=0 INIT=zz EXPIRE=0 REMAINED=uu TASK=0 STATE=DOWN

In this way, you can check the format.

< >

Setting clock forward

The clock timer will not start unless the START terminal is asserted. Set INIT to 3 first, then assert START.

SECONDS> set INIT X3 ; set START 1
SECONDS> report do
0 : START=1 RESET=0 INIT=03 EXPIRE=0 REMAINED=uu TASK=0 STATE=DOWN

The REMAINED and TASK values have not changed. Since they are register objects, their values remain unchanged until the clock is started.

Use the 'forward' command to apply a clock pulse.

SECONDS> forward +1
1 : START=0 RESET=0 INIT=zz EXPIRE=0 REMAINED=03 TASK=1 STATE=DOWN

The report function displays the results at the new time. Let's continue to apply clock pulses.

SECONDS> forward +1
2 : START=0 RESET=0 INIT=zz EXPIRE=0 REMAINED=02 TASK=1 STATE=DOWN
SECONDS> forward +1
3 : START=0 RESET=0 INIT=zz EXPIRE=0 REMAINED=01 TASK=1 STATE=DOWN
SECONDS> forward +1
4 : START=0 RESET=0 INIT=zz EXPIRE=1 REMAINED=00 TASK=1 STATE=ASSERT

So far, everything appears to be operating correctly. However, you may have to consider other cases.

< >

Using the schedule function

It is too much to enter the 'forward' command for each cycle. Let's complete all the cycles at a single stroke. Before we can do that, however, we have to perform what we call a "ritual." Create a script file as given below.

<reset.sec>

sch_add +100 reset 'set RESET 1 ; reset.sec'

<start.sec>

sch_add %e 30 100 50 start 'set START 1 ; start.sec'

File 'reset.sec' is a script to assert RESET every 100 cycles. File 'start.sec' is a script to specify START assertion intervals with random numbers (from 30 to 100 inclusive) that are exponentially distributed with the average being 50 cycles.

The schedule function defers command execution until the specified time. Execute the above scripts to check the function. You will see the following:

SECONDS> start.sec
SECONDS> reset.sec
SECONDS> schedule
<Schedule on 37>
start 'set START 1 ; start.sec'
<Schedule on 104>
reset 'set RESET 1 ; reset.sec'

< >

Using the request function

Before you assert START, you must enter an initial value into INIT. Otherwise, SECONDS will not accept your operation. You may add the 'set' command to the 'start.sec' file to set INIT. In this example, however, let's choose to enter the command each time the need arises. Ever thoughtful, SECONDS has the function (request function) of requesting the user to enter an object value (limited to terminal data object) when such is required during simulation.

SECONDS> req_add INIT
SECONDS> request on

You are now all set. Proceed about 300 cycles. Since the screen will scroll rapidly, the result should be output to the 'timer.cht' file.

SECONDS> speak timer.cht
SECONDS> forward +300
Request for 'INIT' on 41 : X40
Request for 'INIT' on 77 : X80
Request for 'INIT' on 120 : Xff
Request for 'INIT' on 155 : X90
Request for 'INIT' on 212 : X80
Request for 'INIT' on 250 : X20

Since the random number generator of SECONDS is not reproducible, the time when the INIT value is requested differs each time the operation is executed. Therefore, the same result cannot be obtained even if this command sequence is repeated.

How can you view the result output in a file? The 'exec' command executed the character strings of the first parameter as a DOS command.

SECONDS> speak
SECONDS> exec "type timer.cht | more"
5 : START=0 RESET=0 INIT=zz EXPIRE=1 REMAINED=00 TASK=1 STATE=ASSERT
6 : START=0 RESET=0 INIT=zz EXPIRE=1 REMAINED=00 TASK=1 STATE=ASSERT
......................................
40 : START=0 RESET=0 INIT=zz EXPIRE=1 REMAINED=00 TASK=1 STATE=ASSERT
41 : START=1 RESET=0 INIT=40 EXPIRE=0 REMAINED=00 TASK=1 STATE=ASSERT
42 : START=0 RESET=0 INIT=zz EXPIRE=0 REMAINED=40 TASK=1 STATE=DOWN
......................................
76 : START=0 RESET=0 INIT=zz EXPIRE=0 REMAINED=1e TASK=1 STATE=DOWN
77 : START=1 RESET=0 INIT=80 EXPIRE=0 REMAINED=1d TASK=1 STATE=DOWN
78 : START=0 RESET=0 INIT=zz EXPIRE=0 REMAINED=80 TASK=1 STATE=DOWN
......................................
103 : START=0 RESET=0 INIT=zz EXPIRE=0 REMAINED=67 TASK=1 STATE=DOWN
104 : START=0 RESET=1 INIT=zz EXPIRE=0 REMAINED=66 TASK=1 STATE=DOWN
105 : START=0 RESET=0 INIT=zz EXPIRE=0 REMAINED=66 TASK=0 STATE=DOWN
......................................
281 : START=0 RESET=0 INIT=zz EXPIRE=0 REMAINED=02 TASK=1 STATE=DOWN
282 : START=0 RESET=0 INIT=zz EXPIRE=0 REMAINED=01 TASK=1 STATE=DOWN
283 : START=0 RESET=0 INIT=zz EXPIRE=1 REMAINED=00 TASK=1 STATE=ASSERT
......................................
303 : START=0 RESET=0 INIT=zz EXPIRE=1 REMAINED=00 TASK=1 STATE=ASSERT
304 : START=0 RESET=1 INIT=zz EXPIRE=0 REMAINED=00 TASK=1 STATE=ASSERT

In simulation, test patterns should be carefully selected. However, random data within the specified range were used in this simulation. In this type of simulation, you should carefully analyze the simulation results to make sure that simulation was fully carried out.

< >

Transferring the output results of SECONDS to other application software

SECONDS does not graphically display simulated results, nor does it provide the search function for specific patterns. Instead, SECONDS provides the 'print' command with a formatting function. It also provides the report function and auxiliary 'echo' command. These output the simulation results in an appropriate format (or pipe) so that the results can be processed by the user as a post process. This is because SECONDS was originally designed assuming execution on a UNIX OS, for which various text processing programs such as sh, grep, awk, sed, perl, etc. are available.

SECONDS will prove to be more convenient if similar programs are available in an MS-DOS environment. If the simulation is not too long, you may also use Lotus 1-2-3.

SECONDS> echo '"TIME" "START" "RESET" "INIT" "EXPIRE" "REMAINED" "TASK" "STATE"'
SECONDS> rpt_add ext '"%4T" "%B" "%B" "%X" "%B" ' START RESET INIT EXPIRE
SECONDS> rpt_add int '"%X" "%B" "%S"\n' REMAINED MAIN MAIN.RUN

(Note: As described in section 5.8, %S denotes character string format; %B denotes binary format; %4T denotes time format.)

All the commonly used functions of SECONDS are used and explained in the above example. In addition to the commands explained above, SECONDS has many other commands useful in debugging. For detail, see SECONDS Reference in Chapter 5.

Note: The workstation version is currently equipped with a more advanced simulator called 2SECONDS. It is a successor to SECONDS as the name implies. The following extensions are provided in the new version.

- Operation of character strings and bit strings

- Conditional branching of command strings

- Saving of simulation images

- Conditional termination of 'forward' command

- User definition of errors

- Definition of a reproducible random number generator

<