XR02 recJs Example: Bus logic


Outline

This recJs script creates a simple bus logic.

Platforms
32/64bit 32/64bit 32/64bit
Requirements
  • None
Parameters:
  • None
Content of example record files
  • recJs/r02_bus.recJs


Output



Usage

  1. Copy the script code onto a file resource with "recJs" ending or use the impulse record examples.
  2. Open the impulse viewer with the file resource (e.g. double-click the file in the eclipse explorer).

R003 recJs Reader 10 Signal Script Script Examples impulse JDK Open JavaDoc



Script

The script create a set of random bus signals of type Logic.


//-recjs (keep this line)
// generator   : Record generator (de.toem.impulse.samples.ISingleDomainRecordGenerator)
// file        : File object of the executed recJs file (java.io.File)
// p0..p9      : Parameters from the reader configuration (java.lang.String)
// progress    : Progress control (de.toem.impulse.cells.ports.IPortProgress)
// console     : Console output (de.toem.impulse.scripting.IScriptConsole)

// Init the record
generator.initRecord("Example Record",TimeBase.ns);
progress.setTimeout(50000);

// Create a record with scopes and some signals
var signals = generator.addScope(null, "External Signals");
var clk = generator.addSignal(signals, "Clk", "", ProcessType.Discrete, SignalType.Logic, SignalDescriptor.DEFAULT);
var addrbus = generator.addSignal(signals, "Addr", "", ProcessType.Discrete, SignalType.Logic,SignalDescriptor.LogicWidth(32));
var databus = generator.addSignal(signals, "Data", "", ProcessType.Discrete, SignalType.Logic,SignalDescriptor.LogicWidth(8));
var en = generator.addSignal(signals, "Enable", "", ProcessType.Discrete, SignalType.Logic, SignalDescriptor.DEFAULT);
var rw = generator.addSignal(signals, "R_W", "", ProcessType.Discrete, SignalType.Logic, SignalDescriptor.DEFAULT);

console.println(generator.getScope("\\External Signals"));
console.println(generator.getSignal("\\External Signals\\Clk"));

// We start at 0 ns
var t = 0; // 0 ns
var MAX_T=100000;
var writer;
generator.open(t);

// init signals
generator.getWriter(addrbus).write(0,false,Logic.valueOf('u'));
generator.getWriter(databus).write(0,false,Logic.valueOf('u'));
generator.getWriter(rw).write(0, false, Logic.valueOf('u'));
generator.getWriter(en).write(0, false, Logic.valueOf('u'));
generator.getWriter(en).write(0, false, Logic.valueOf('u'));

// clk signal
writer = generator.getWriter(clk);
for (t=0;t<MAX_T;t+=50)
     writer.write(t, false,  Logic.valueOf(t % 100 == 0));

function generateWrite(t,a,d){

     generator.getWriter(addrbus).write(t,false,Logic.valueOf(new java.lang.Long(a)));
     generator.getWriter(addrbus).attachRelation(en.getPath(),"Settle=${delta}", 65);
     generator.getWriter(databus).write(t+25,false,Logic.valueOf(new java.lang.Long(d)));
     generator.getWriter(databus).attachRelation(databus.getPath(),"Full=${delta}/fa752e", 200);
     generator.getWriter(rw).write(t+50, false, Logic.valueOf(false));
     generator.getWriter(en).write(t+65, false, Logic.valueOf(false));
     generator.getWriter(en).write(t+115, false, Logic.valueOf(true));
     generator.getWriter(en).attachRelation(addrbus.getPath(),"Delay=${delta}", 185);
}

for (var n = 0;n<MAX_T/300;n++)
      generateWrite(n*300,0x1000+n*4,Math.random()*255);

// And close finally
generator.close(MAX_T);

// add simple view
var config = generator.addViewConfiguration( "Demo", "");
var folder = generator.addFolderConfiguration( config, "My Folder", null);
generator.addPlotConfiguration( folder, addrbus);

toem

technical software and tooling

Company

Contact Us

This email address is being protected from spambots. You need JavaScript enabled to view it.