Jump to content


  • Content Count

  • Joined

  • Last visited

Posts posted by ZhangRan

  1. 2 hours ago, Eyck said:

    There is no such thing as CPU TLM modeling. Usually you write a C/C++ processor model with the needed accuracy (instruction accurate, cycle approximate, cycle accurate) and wrap it in a way that you translate memory accesses into TLM socket accesses. Along with that you need to manage to syncronization of the time of your model and the SystemC time (to run e.g. in loosly timed mode). Another task is to take the returned execution time of the bus accesses into account for the execution of the CPU model. This involves also the selection and implementation of the accesses (DMI & blocking or non-blocking).

    You can find a complete example of an instruction accurate VP at https://git.minres.com/DVCon2018/RISCV-VP (or https://git.minres.com/VP/RISCV-VP which is a newer version).  The wrapper for the C++ model in SystemC can be found at https://git.minres.com/DVCon2018/RISCV-VP/src/branch/develop/riscv.sc/incl/sysc/core_complex.h

    To put it straight: doing this correctly is a non-trivial task as it is the implementation of a micro-architecture model of a CPU. One option is to build an instruction accurate ISS and add a microarchitecture model like it is done in the ESECS project (https://github.com/MIPS/esesc)


    Thank you so much, I will working hard on your example.

  2. Hi, 

    I am a noob of systemC and tlm modeling. I just go through same example of systemC TLM modeling, such as “”simple_bus“”.

    I am trying develop a TLM processor model. This processor is high performance out of oroder processor(more than 10 stages). At first, i am focusing on the performance affected by branch prediction. Is there any examples related to TLM processor modelling? 

    Thank you very much.

  3. 27 minutes ago, vrsm said:

    Its because printer input.num_available() non-blocking call which is executed even before fork.output2 is written. Printer input.read() is working fine as it a blocking call which is waiting for fifo to get filled, once fork.output2 is written and fifo have a item now and now read() is unblocked and things are working fine.

    You cannot predict the thread execution order unless otherwise you are explicitly making them to happen in order. I suggest you keep multiple print statements to see how threads are executed in your simulation.

    num_available() is not mandatory for any implementation. But the correct way to use num_available in your experiment is,

    while(fifo.num_available() == 0)   
          wait(SC_ZERO_TIME); //by calling wait you are giving chance for other threads in simulation to run
    cout<<" items in fifo "<<fifo.num_available()<<endl; 




    many thanks, i have a better understand of block and non-block now.

  4. 9 hours ago, vrsm said:

    You are not writing to output2 of fork, hence printer input fifo is not filled. For debugging use num_available() to get the number of available items in the fifo.
    "value = input.read()"  is not breaking out of the loop, here read() is a blocking call, as fifo is empty it kept blocking the thread.
    As there are no other pending events or waits simulation stopped naturally.



    Thanks, it works well now. 

    In addition, I insert :"input.num_available()"  before input.read(). I am curious that the "input.num_available()" is 0 ,but it still can output data. 



  5. #include "systemc.h"
    	sc_fifo_in<int> input1, input2;
    	sc_fifo_out<int> output;
    	void process(){
    		while (1) {
    			output.write(input1.read() + input2.read());
    	SC_CTOR(DF_Adder) {SC_THREAD(process);}
    	sc_fifo_out<int> output;
    	void process() {
    		 while (1) {
    	DF_Const(sc_module_name N, int C):
    		sc_module(N), constant_(C) { SC_THREAD(process); }
    	int constant_;
    	sc_fifo_in<int> input;
    	sc_fifo_out<int> output1,output2;
    	void process(){
    			int value = input.read();
    	SC_CTOR(DF_Fork) {SC_THREAD(process);}
    	sc_fifo_in<int> input;
    	DF_Printer(sc_module_name N, unsigned N_ITER):
    		sc_module(N), n_iterations_(N_ITER), done_(false) { SC_THREAD(process); }
    	void process(){
    		cout << n_iterations_<< endl;
    		for (unsigned i=0; i<n_iterations_; i++) {
    			int value;
     			value = input.read();
    			cout<< name() << "read data is(in print) " << value << endl ;
    		done_ = true;
    	~DF_Printer() {
    		if (!done_) cout << name() << "not done yet" << endl;
    	unsigned n_iterations_;
    	bool done_;
    	int value;
    #include "systemc.h"
    #include "adder.h"
    int sc_main(int, char**){
    	DF_Const constant("constant", 1);
    	DF_Adder adder("adder");
    	DF_Fork fork("fork");
    	DF_Printer printer("printer",10);
    	sc_fifo<int> const_out("const_out", 5);
    	sc_fifo<int> adder_out("adder_put", 1);
    	sc_fifo<int> feedback("feedback", 1);
    	sc_fifo<int> to_printer("to_printer", 1);
    	return 0;


    I am a noob of sysC, and trying some basic case.

    This case is a simple add 1 counter, and using the DF_Printer to print the result. However, the printed value never comes up. It seems like that "value = input.read()" can break the for loop.

    can anyone give me some idea of this question?

    Thank you very much.




  • Create New...