quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bullet_green_ball.gif 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

   

space.gif

Well I am also going to show how to write a "hello world" program in E.

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Hello World Code
   

space.gif


  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
   

space.gif

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.

   

space.gif

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.

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Simulating Hello World

Hello World example can be simulating with following command

   

space.gif

$specman -c "load hello.e; test;"

   

space.gif

Output of specman is as given below.

   

space.gif

Hello World
   

space.gif

   

space.gif

  ../images/main/bullet_green_ball.gif 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.

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Random Memory Command Generator Code
   

space.gif


  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
   

space.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif Simulating Random Generator

Memory example can be simulating with following command

   

space.gif

$specman -c "load memory.e; test;"

   

space.gif

Output of specman is as given below.

   

space.gif

  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
   

space.gif

   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com