This folder contains additional material for the book Arm Modern SoC Design by DJ Greaves. For information on all Arm Education Media publications, visit our website at BOOKS.
Materials are provided (C) DJ Greaves 2021 with no expressed or implied warranty. You may use them as you wish, without warranty or license from the author, provided this copyright message is preserved.
This folder contains a basic SystemC net-level system. There are two 'hello world examples'. Build and run these before trying the toy-esl examples in the next folder.
The definitions in Makefile.inc may need adjusting according to how your machine is set up. For non-linux use, you will have to create your own Makefile.inc
Try this source file hworld1.cpp.
g++ -o hworld1 $(CXXFLAGS) hworld1.cpp $(LDFLAGS)
LD_LIBRARY_PATH=$(SCLIB) ./hworld1

If you have enabled vcd tracing, output will be written to a vcd trace file.
This can be viewed using gtkwave.
Start gtkwave from the command line. Browse one level down in the signal
hierarchy and drag the signals of interest to the signals box.
Full src file hworld2.cpp.
Illustrating the sc_uint fixed-field operators.
SC_MODULE(fivebitcounter)
{
sc_in <bool> clk, reset, load;
sc_out <sc_uint<5> > q;
sc_out <sc_uint<5> > parallelin;
SC_CTOR(fivebitcounter)
{
void clkme();
SC_METHOD(clkme); sensitive << clk.pos() << reset.pos();
}
void clkme()
{
if (reset.read()) q = 0;
else if (load.read()) q = parallelin.read();
else
{
int nv = q.read() + 1;
printf("Five pending set to %i\n", nv);
q = nv;
}
}
};
Console output log: note the 32 becomes a zero when stored in the field.
Five pending set to 31 Toggle at 4200 ns Toggle at 4250 ns Five pending set to 32 Toggle at 4300 ns Toggle at 4350 ns Five pending set to 1 Toggle at 4400 ns
(C) 2000-2021 DJ Greaves.