Jump to content

david.wcc

Members
  • Content Count

    16
  • Joined

  • Last visited

Posts posted by david.wcc

  1. For the smart meter development, the hardware consists of MCU, DSP,and an external memory. We programmed after finished the hardware.

    Although MCU provides some functions like DSP and embedded memory on it. We still need external chips to meet SPEC's requirement due to the signal accuracy and the memory capacity. Once, the performance can't satisfy the SPEC and we had to do everything again. With TLM, we can get modules from IP providers and have abstraction modeling for the specification. Finally we can make a SoC (System on Chip)

    according to SPEC. In other words, we won't have useless circuits on the hardware. Well, that will be easy to program because we may do it during TLM stage.

  2. Most of materials mentioned TLM, however, there are many discussions on TLM. For example, specification model, component-assembly model, bus-arbitration model, Bus-functional model, Cycle-accurate computation model and implementation model introduced by Lukai Cai and Daniel Gajski,"Transaction Level Modeling: An Overview". It will be great to understand them for choosing a right model on your simulation. In fact, I participated a project for developing the smart meter specified by IEC 62056 few years ago but our work was not successful because of the wrong modeling methodology(software and hardware developing are separated or we didn't have any abstraction modeling for the specification). TLM can be the solution for that.

  3. I would like to point out what differences between them.

    1. A SystemC Primer focus on digital hardware. However, some descriptions are outdated.

    Users may refer SystemC 2.0.1 Language Reference Manual Revision 1.0 to modify them.

    2. SystemC 2.0.1 Language Reference Manual Revision 1.0 only shows you the definition of SystemC.

    3. SystemC Version 2.0 User’s Guide will explain how to build the communication protocol on SystemC.

    Unfortunately, the codes of examples in those documents are outdated or not complete.

    If somebody mix three of them and fix the mentioned problems, then it will be a good material.

  4. Hi : ElliottCB :

    You can refer and modify the following example as your template, actually it was modified by using SystemC example

    (pipe project as i remember). Due to the version of SystemC, some descriptions indicated in old documents can not work properly at

    this moment. That will be a major problem for you as a beginner.

    It works after referring many documents and examples about SystemC. :blink:

    Good Luck to make it happen ^_^

    #define DISPLAY_H

    // display.h

    #include "systemc.h"

    class display : public sc_module {

    public:

    sc_in<bool> inPort0;

    sc_in<bool> inPort1;

    sc_in<bool> cin; // input port 1

    sc_in<bool> sum;

    sc_in<bool> clk; // clock

    void print_result(); // method to display input port values

    //Constructor

    SC_CTOR( display ) {

    SC_METHOD( print_result ); // declare print_result as SC_METHOD and

    dont_initialize();

    sensitive << clk.pos(); // make it sensitive to positive clock edge

    }

    };

    #endif

    #include "systemc.h"

    class driver : public sc_module{

    public:

    sc_out<bool> outPort_a;

    sc_out<bool> outPort_b; // output port

    sc_in<bool> clk;

    void prc_driver();

    // Constructor

    SC_CTOR(driver) {

    SC_METHOD(prc_driver); // Method process to print data

    dont_initialize();

    sensitive << clk.pos(); //make it sensitive to positive clock edge

    }

    };

    #ifndef HALFADDER_H

    #define HALFADDER_H

    #include "systemc.h"

    class halfadder : public sc_module{

    public:

    sc_in<bool> inPort_0,inPort_1; //input 1

    sc_out<bool> sum,carry; //output 1

    sc_in<bool> clk;

    //halfadder():sc

    void prc_half_adder(); //method implementing functionality

    //Counstructor

    SC_CTOR(halfadder) {

    SC_METHOD(prc_half_adder); //Declare addsub as SC_METHOD and

    //sensitive << a<<b ; //make it sensitive to positive clock edge

    dont_initialize();

    sensitive << clk.pos(); //make it sensitive to positive clock edge

    }

    };

    #endif

    #include "waveform.h"

    #include "halfadder.h"

    #include "monitor.h"

    int sc_main(int argc, char* argv[])

    {

    sc_signal<bool> in1; // initial signals for the system

    sc_signal<bool> in2;

    sc_signal<bool> t_cin;

    sc_signal<bool> t_sum;

    sc_signal<bool> clk;

    WaveForm wave("waveforms"); //instance of `waveform' module

    wave(in1,in2,clk);

    HalfAdder h1("halfadder"); //instance of `halfadder' module

    h1.inPort_0(in1);

    h1.inPort_1(in2);

    h1.carry(t_cin);

    h1.sum(t_sum);

    h1.clk(clk);

    Monitor m("monitor"); //instance of `monitor' module

    m(in1,in2,t_cin,t_sum,clk); //Positional port binding

    cout<<"start waveform :"<<endl;

    sc_start(0, SC_NS); //Initialize simulation

    for(int i = 0; i < 50; i++){

    clk.write(1);

    sc_start( 10, SC_NS );

    clk.write(0);

    sc_start( 10, SC_NS );

    }

    system("Pause");

    return 0;

    }

    Diagram of Example

  5. Hi :

    I would like to provide my experience of programming on both Qt and Visual C++ platforms. Yes, there is a limitation for the compiler specially when you program with a thread(process). It will shunt down if you generate a large file up to around 500M byte with a thread under Qt platform :o . Although I modified codes by using the dynamic allocation, it still shunt down. Finally, i just re-wrote it under console mode(DOS mode). Recently, i try the new version of visual C++, it can generate a file up to 7G bytes with a thread.

    By the way, Bjarne Stroustrup(creator of C++) has an idea for a simple GC as bellow : :D

    // ConsoleApplication1.cpp : Defines the entry point for the console application.

    //

    #include "stdafx.h"

    #include <iostream>

    #include <map>

    #include <vector>

    using namespace std;

    class Register {

    map<void*,void (*)(void*)> m;

    public :

    void insert(void* po, void (*pf)(void*)) { m[po]=pf;}

    void remove(void* po){m.erase(po);}

    void showInf(){cout<<"There are "<<m.size()<<" shape elements "<<endl;}

    };

    Register cleanup_register;

    class shape {

    protected :

    int x,y;

    static void cleanup(void* pv)

    {

    shape* px = (shape*)pv;

    cleanup_register.remove(px);

    // delete px;

    }

    public:

    shape(int vx, int vy)

    { x=vx; y=vy; cout<<" shape constructor "<<endl;

    cleanup_register.insert(this,&cleanup);

    }

    ~shape(){ cleanup(this); }

    virtual void draw()=0;

    };

    class circle : public shape{

    int z;

    public:

    circle(int vx, int vy, int vz):shape(vx,vy){ z =vz ; cout<<" circle constructor "<<endl;}

    void draw(){ cout <<" is a circle at "<<x<<" : "<<y<<" : "<<z<<endl;}

    };

    class line : protected shape{

    int z;

    public:

    line(int vx, int vy):shape(vx,vy){ cout<<" circle constructor "<<endl;}

    void draw(){ cout <<" is a circle at "<<x<<" : "<<y<<endl;}

    };

    int _tmain(int argc, _TCHAR* argv[])

    {

    vector<shape*> shapeVector0;

    vector<shape*> shapeVector1;

    vector<shape*> shapeVector2;

    shapeVector0.push_back(new circle(4,7,5));

    shapeVector0.push_back(new circle(4,7,5));

    shapeVector0.push_back(new circle(2,5,7));

    shapeVector1.push_back(new circle(6,8,3));

    shapeVector1.push_back(new circle(4,7,5));

    shapeVector1.push_back(new circle(1,4,6));

    shapeVector2.push_back(new circle(2,4,7));

    shapeVector2.push_back(new circle(5,7,6));

    shapeVector2.push_back(new circle(1,5,7));

    cleanup_register.showInf();

    system("Pause");

    return 0;

    }

    The result will be .............

    shape constructor

    circle constructor

    shape constructor

    circle constructor

    shape constructor

    circle constructor

    shape constructor

    circle constructor

    shape constructor

    circle constructor

    shape constructor

    circle constructor

    shape constructor

    circle constructor

    shape constructor

    circle constructor

    shape constructor

    circle constructor

    There are 9 shape elements

  6. Entry point is the first problem but I think it is possible to be solved :D .Furthermore, if you want to create separate processes, you still consider windows programming (it provides a real multitask environment). I learn from SystemC. It looks like having it's own scheduler for multitask processing(similar to MicroC/OS). As i knew, there was a thought from OSCI for replacing such scheduler by using OS threads. :)

×
×
  • Create New...