/* ** HDL4SE: 软件Verilog综合仿真平台 ** Copyright (C) 2021-2021, raoxianhong ** LCOM: 轻量级组件对象模型 ** Copyright (C) 2021-2021, raoxianhong ** All rights reserved. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are met: ** ** * Redistributions of source code must retain the above copyright notice, ** this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright notice, ** this list of conditions and the following disclaimer in the documentation ** and/or other materials provided with the distribution. ** * The name of the author may be used to endorse or promote products ** derived from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE ** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF ** THE POSSIBILITY OF SUCH DAMAGE. */ #include "stdlib.h" #include "stdio.h" #include "string.h" #include "time.h" #include "object.h" #include "bignumber.h" #include "hdl4secell.h" #include "hdl4sesim.h" #include "hdl4sevcdfile.h" #include "terris.h" IHDL4SESimulator** sim; IHDL4SEUnit** topmodule; IHDL4SEUnit** gui; unsigned long long clocks = 0; static int running = 1; #define VCDOUTPUT 1 int StopRunning() { running = 0; return 0; } IHDL4SEUnit** hdl4seCreate_main(IHDL4SEModule** parent, const char* instanceparam, const char* name); extern int (*A_u_t_o_registor_terrisctrl)(); extern int (*A_u_t_o_registor_terrisctrl1)(); extern int (*A_u_t_o_registor_terris_flushtodisp)(); extern int (*A_u_t_o_registor_terris_blockwrite)(); extern int (*A_u_t_o_registor_terris_canblocksetto)(); extern int (*A_u_t_o_registor_terris_checkline)(); extern int (*A_u_t_o_registor_terris_init)(); extern int (*A_u_t_o_registor_terris_copylines)(); extern int (*A_u_t_o_registor_terris_copylines)(); extern int (*A_u_t_o_registor_terrisdevice)(); int main(int argc, char* argv[]) { int i; int width; int resetwidth; int count, unitcount; IHDL4SEUnit** sim_unit; IHDL4SEWaveOutput** vcdfile; srand((unsigned int)time(NULL)); resetwidth = 10 + rand() % 50; A_u_t_o_registor_terrisctrl(); A_u_t_o_registor_terrisctrl1(); A_u_t_o_registor_terris_flushtodisp(); A_u_t_o_registor_terris_blockwrite(); A_u_t_o_registor_terris_canblocksetto(); A_u_t_o_registor_terris_checkline(); A_u_t_o_registor_terris_init(); A_u_t_o_registor_terris_copylines(); A_u_t_o_registor_terrisdevice(); sim = hdl4sesimCreateSimulator(); topmodule = hdl4seCreate_main(NULL, "", "top"); objectCall1(sim, SetTopModule, topmodule); objectCall1(sim, SetReset, 0); unitcount = 0; objectQueryInterface(sim, IID_HDL4SEUNIT, (void**) &sim_unit); objectPrintInfo(stdout, fprintf); #if VCDOUTPUT vcdfile = hdl4sesimCreateVCDFile("terris.vcd"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl", "bWriteAddr"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl", "bWriteData"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/bCtrlState", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/wCtrlStateComplete", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/bCurBlockPos", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_curblock", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_nextblock", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_curposx", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_curposy", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_tick", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_speed", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/cur_key", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/outputx", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_curposx", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/outputy", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_curposy", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_testid", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/bResult", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_testx", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_testy", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_curposx", "out"); objectCall2(vcdfile, AddSignal, "/top/terrisctrl/ctrl/wireout_curposy", "out"); objectCall1(vcdfile, SetTopModule, topmodule); objectCall0(vcdfile, StartRecord); #endif do { //objectCall0(sim, RunClockTick); objectCall0(sim_unit, ClkTick); #if VCDOUTPUT objectCall1(vcdfile, ClkTick, clocks); #endif objectCall0(sim_unit, Setup); clocks++; if (clocks == resetwidth) objectCall1(sim, SetReset, 1); } while (running); #if VCDOUTPUT objectCall0(vcdfile, StopRecord); objectRelease(vcdfile); #endif return 0; }