|
|
|
|
|
|
|
|
|
|
|
|
Hello World
|
|
|
If you refer to any book on programming language it starts with "hello World" program, once you have written the program, you can be sure that you can do something in that language
|
|
|
|
|
|
Well I am also going to show how to write a "hello world" program in E.
|
|
|
|
|
|
Hello World Code
|
|
|
|
|
|
1
2 <'
3 // This program prints hello world
4
5 extend sys {
6 run() is also {
7 out ("Hello World");
8 };
9 };
10
11 '>
You could download file hello.e
here
|
|
|
|
|
|
In the above code, lines in green are comments, and blue are keywords in E language, "sys" is the top most module. Like in Verilog we have top module. run() is a method, which is executed at the start of simulation. out is same as printf in C language or $display in verilog.
|
|
|
|
|
|
Line number 2, 11 mark the code segement, anything outside this is ignored by Specman, so this can be used for writing comments. Line 5 is extend, which extends the "sys" to tell specman to include the code below it into simulator. run() is also method is extended to have out statement.
|
|
|
|
|
|
|
|
|
|
|
|
Simulating Hello World
|
|
|
Hello World example can be simulating with following command
|
|
|
|
|
|
$specman -c "load hello.e; test;"
|
|
|
|
|
|
Output of specman is as given below.
|
|
|
|
|
|
Hello World
|
|
|
|
|
|
|
|
|
Simple Random Generator
|
|
|
To demonstrate a random generator of Specman, lets consider a simple memory, which needs address, data and read/write command to access memory.
|
|
|
|
|
|
Random Memory Command Generator Code
|
|
|
|
|
|
1 <'
2 // This Examples shows how random
3 // Test vectors is generated
4
5 // This is base object
6 struct m_base_o {
7 addr : byte;
8 data : byte;
9 rd_wr: bool;
10 };
11
12 // This is transcation generator
13 struct txgen {
14 ! base_ob : m_base_o;
15 num_cmds : int;
16 i : int;
17 // Method to generate commands
18 gen_tx () is {
19 // Generate num_cmds commands
20 for i from 0 to num_cmds do {
21 gen base_ob;
22 print base_ob;
23 };
24 };
25 };
26
27 extend sys {
28 txgen : txgen;
29 keep txgen.num_cmds == 2;
30 run() is also {
31 // Start the transcation generator
32 txgen.gen_tx();
33 };
34 };
35 '>
You could download file memory.e
here
|
|
|
|
|
|
|
|
|
|
|
|
Simulating Random Generator
|
|
|
Memory example can be simulating with following command
|
|
|
|
|
|
$specman -c "load memory.e; test;"
|
|
|
|
|
|
Output of specman is as given below.
|
|
|
|
|
|
base_ob = m_base_o-@0: m_base_o
---------------------------------------------- @memory
0 addr: 7
1 data: 138
2 rd_wr: TRUE
base_ob = m_base_o-@1: m_base_o
---------------------------------------------- @memory
0 addr: 116
1 data: 2
2 rd_wr: FALSE
base_ob = m_base_o-@2: m_base_o
---------------------------------------------- @memory
0 addr: 230
1 data: 240
2 rd_wr: TRUE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Copyright © 1998-2014 |
Deepak Kumar Tala - All rights reserved |
Do you have any Comment? mail me at:deepak@asic-world.com
|
|
|