提交 5078a3b9 编写于 作者: 饶先宏's avatar 饶先宏

202108101925

上级 c491d5fa
......@@ -31,7 +31,7 @@
/*
* Created by HDL4SE @ Tue Aug 10 06:27:38 2021
* Created by HDL4SE @ Tue Aug 10 11:07:56 2021
* Don't edit it.
*/
......@@ -68,19 +68,19 @@ GEN_MODULE_DECLARE
unsigned int RESETVALUE;
END_GEN_MODULE_DECLARE
DEFINE_FUNC_DEPEND(counter_gen_bCounter, "wireout_bCurrentCounter") {
DEFINE_FUNC(counter_gen_bCounter, "wireout_bCurrentCounter, ") {
VWRITE_S32(bCounter, VREAD_S32(wireout_bCurrentCounter));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(counter_gen_wCounterOverflow, "overflow") {
DEFINE_FUNC(counter_gen_wCounterOverflow, "overflow, ") {
VWRITE_S32(wCounterOverflow, VREAD_S32(overflow));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(counter_gen_wirein_bCurrentCounter, "nwReset, overflow, , wCounterIt, wireout_bCurrentCounter, , wireout_bCurrentCounter, ") {
DEFINE_FUNC(counter_gen_wirein_bCurrentCounter, "nwReset, overflow, wCounterIt, wireout_bCurrentCounter, ") {
VWRITE_S32(wirein_bCurrentCounter, (VREAD_S32(nwReset))?((VREAD_S32(overflow))?(pobj->RESETVALUE):((VREAD_S32(wCounterIt))?((VREAD_S32(wireout_bCurrentCounter)) + (1)):(VREAD_S32(wireout_bCurrentCounter)))):(pobj->RESETVALUE));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(counter_gen_overflow, "wireout_bCurrentCounter, , wCounterIt") {
DEFINE_FUNC(counter_gen_overflow, "wireout_bCurrentCounter, wCounterIt, ") {
VWRITE_S32(overflow, ((VREAD_S32(wireout_bCurrentCounter)) == (pobj->MAXVALUE)) & (VREAD_S32(wCounterIt)));
} END_DEFINE_FUNC
......@@ -131,47 +131,47 @@ END_IDLIST
GEN_MODULE_DECLARE
END_GEN_MODULE_DECLARE
DEFINE_FUNC_DEPEND(dec2seg_gen_mux_dec_dot_in0, "") { /* port:mux_dec(hdl4se_mux16).in0, 1 */
DEFINE_FUNC(dec2seg_gen_mux_dec_dot_in0, "") { /* port:mux_dec(hdl4se_mux16).in0, 1 */
VWRITE_S32(mux_dec_dot_in0, 63);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(dec2seg_gen_mux_dec_dot_in1, "") { /* port:mux_dec(hdl4se_mux16).in1, 2 */
DEFINE_FUNC(dec2seg_gen_mux_dec_dot_in1, "") { /* port:mux_dec(hdl4se_mux16).in1, 2 */
VWRITE_S32(mux_dec_dot_in1, 6);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(dec2seg_gen_mux_dec_dot_in2, "") { /* port:mux_dec(hdl4se_mux16).in2, 3 */
DEFINE_FUNC(dec2seg_gen_mux_dec_dot_in2, "") { /* port:mux_dec(hdl4se_mux16).in2, 3 */
VWRITE_S32(mux_dec_dot_in2, 91);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(dec2seg_gen_mux_dec_dot_in3, "") { /* port:mux_dec(hdl4se_mux16).in3, 4 */
DEFINE_FUNC(dec2seg_gen_mux_dec_dot_in3, "") { /* port:mux_dec(hdl4se_mux16).in3, 4 */
VWRITE_S32(mux_dec_dot_in3, 79);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(dec2seg_gen_mux_dec_dot_in4, "") { /* port:mux_dec(hdl4se_mux16).in4, 5 */
DEFINE_FUNC(dec2seg_gen_mux_dec_dot_in4, "") { /* port:mux_dec(hdl4se_mux16).in4, 5 */
VWRITE_S32(mux_dec_dot_in4, 102);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(dec2seg_gen_mux_dec_dot_in5, "") { /* port:mux_dec(hdl4se_mux16).in5, 6 */
DEFINE_FUNC(dec2seg_gen_mux_dec_dot_in5, "") { /* port:mux_dec(hdl4se_mux16).in5, 6 */
VWRITE_S32(mux_dec_dot_in5, 109);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(dec2seg_gen_mux_dec_dot_in6, "") { /* port:mux_dec(hdl4se_mux16).in6, 7 */
DEFINE_FUNC(dec2seg_gen_mux_dec_dot_in6, "") { /* port:mux_dec(hdl4se_mux16).in6, 7 */
VWRITE_S32(mux_dec_dot_in6, 125);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(dec2seg_gen_mux_dec_dot_in7, "") { /* port:mux_dec(hdl4se_mux16).in7, 8 */
DEFINE_FUNC(dec2seg_gen_mux_dec_dot_in7, "") { /* port:mux_dec(hdl4se_mux16).in7, 8 */
VWRITE_S32(mux_dec_dot_in7, 7);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(dec2seg_gen_mux_dec_dot_in8, "") { /* port:mux_dec(hdl4se_mux16).in8, 9 */
DEFINE_FUNC(dec2seg_gen_mux_dec_dot_in8, "") { /* port:mux_dec(hdl4se_mux16).in8, 9 */
VWRITE_S32(mux_dec_dot_in8, 127);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(dec2seg_gen_mux_dec_dot_in9, "") { /* port:mux_dec(hdl4se_mux16).in9, 10 */
DEFINE_FUNC(dec2seg_gen_mux_dec_dot_in9, "") { /* port:mux_dec(hdl4se_mux16).in9, 10 */
VWRITE_S32(mux_dec_dot_in9, 111);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(dec2seg_gen_wire_error, "") {
DEFINE_FUNC(dec2seg_gen_wire_error, "") {
VWRITE_S32(wire_error, 121);
} END_DEFINE_FUNC
......@@ -294,139 +294,139 @@ END_IDLIST
GEN_MODULE_DECLARE
END_GEN_MODULE_DECLARE
DEFINE_FUNC_DEPEND(main_gen_wRead, "") {
DEFINE_FUNC(main_gen_wRead, "") {
VWRITE_S32(wRead, 1);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_bReadAddr, "") {
DEFINE_FUNC(main_gen_bReadAddr, "") {
VWRITE_S32(bReadAddr, 0xf0000000);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wirein_wCounterChanged0, "nwReset, wCounterin3210, ") {
DEFINE_FUNC(main_gen_wirein_wCounterChanged0, "nwReset, wCounterin3210, ") {
VWRITE_S32(wirein_wCounterChanged0, (VREAD_S32(nwReset))?(VREAD_S32(wCounterin3210)):(0));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wirein_wCounterChanged1, "nwReset, wCounterin7654, ") {
DEFINE_FUNC(main_gen_wirein_wCounterChanged1, "nwReset, wCounterin7654, ") {
VWRITE_S32(wirein_wCounterChanged1, (VREAD_S32(nwReset))?(VREAD_S32(wCounterin7654)):(0));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wirein_wCounterChanged2, "nwReset, wCounterin98, ") {
DEFINE_FUNC(main_gen_wirein_wCounterChanged2, "nwReset, wCounterin98, ") {
VWRITE_S32(wirein_wCounterChanged2, (VREAD_S32(nwReset))?(VREAD_S32(wCounterin98)):(0));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wWrite, "wireout_wWrite") {
DEFINE_FUNC(main_gen_wWrite, "wireout_wWrite, ") {
VWRITE_S32(wWrite, VREAD_S32(wireout_wWrite));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_bWriteAddr, "wireout_bWriteAddr") {
DEFINE_FUNC(main_gen_bWriteAddr, "wireout_bWriteAddr, ") {
VWRITE_S32(bWriteAddr, VREAD_S32(wireout_bWriteAddr));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_bWriteData, "wireout_bWriteData") {
DEFINE_FUNC(main_gen_bWriteData, "wireout_bWriteData, ") {
VWRITE_S32(bWriteData, VREAD_S32(wireout_bWriteData));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_bWriteMask, "wireout_bWriteMask") {
DEFINE_FUNC(main_gen_bWriteMask, "wireout_bWriteMask, ") {
VWRITE_S32(bWriteMask, VREAD_S32(wireout_bWriteMask));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wirein_bWriteMask, "nwReset, wire_bWriteMask_if_bCounterChanged2, ") {
DEFINE_FUNC(main_gen_wirein_bWriteMask, "nwReset, wire_bWriteMask_if_bCounterChanged2, ") {
VWRITE_S32(wirein_bWriteMask, (VREAD_S32(nwReset))?(VREAD_S32(wire_bWriteMask_if_bCounterChanged2)):(0));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wirein_bWriteAddr, "nwReset, wire_bWriteAddr_if_bCounterChanged2, ") {
DEFINE_FUNC(main_gen_wirein_bWriteAddr, "nwReset, wire_bWriteAddr_if_bCounterChanged2, ") {
VWRITE_S32(wirein_bWriteAddr, (VREAD_S32(nwReset))?(VREAD_S32(wire_bWriteAddr_if_bCounterChanged2)):(0));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wirein_bWriteData, "nwReset, wire_bWriteData_if_bCounterChanged2, ") {
DEFINE_FUNC(main_gen_wirein_bWriteData, "nwReset, wire_bWriteData_if_bCounterChanged2, ") {
VWRITE_S32(wirein_bWriteData, (VREAD_S32(nwReset))?(VREAD_S32(wire_bWriteData_if_bCounterChanged2)):(0));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wirein_wWrite, "nwReset, wire_or_wCounterChanged") {
DEFINE_FUNC(main_gen_wirein_wWrite, "nwReset, wire_or_wCounterChanged, ") {
VWRITE_S32(wirein_wWrite, (VREAD_S32(nwReset)) & (VREAD_S32(wire_or_wCounterChanged)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wButton0Pressed, "bReadData") {
DEFINE_FUNC(main_gen_wButton0Pressed, "bReadData, ") {
VWRITE_S32(wButton0Pressed, (VREAD_U32(bReadData) >> (0)) & 1);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wButton1Pressed, "bReadData") {
DEFINE_FUNC(main_gen_wButton1Pressed, "bReadData, ") {
VWRITE_S32(wButton1Pressed, (VREAD_U32(bReadData) >> (1)) & 1);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wButton2Pressed, "bReadData") {
DEFINE_FUNC(main_gen_wButton2Pressed, "bReadData, ") {
VWRITE_S32(wButton2Pressed, (VREAD_U32(bReadData) >> (2)) & 1);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wCounterIt, "wButton1Pressed, wButton2Pressed") {
DEFINE_FUNC(main_gen_wCounterIt, "wButton1Pressed, wButton2Pressed, ") {
VWRITE_S32(wCounterIt, (~(VREAD_S32(wButton1Pressed))) & (VREAD_S32(wButton2Pressed)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_nwResetCount, "wButton0Pressed, nwReset") {
DEFINE_FUNC(main_gen_nwResetCount, "wButton0Pressed, nwReset, ") {
VWRITE_S32(nwResetCount, (~(VREAD_S32(wButton0Pressed))) & (VREAD_S32(nwReset)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wCounterin98, "wOverflow8, wOverflow7") {
DEFINE_FUNC(main_gen_wCounterin98, "wOverflow8, wOverflow7, ") {
VWRITE_S32(wCounterin98, (VREAD_S32(wOverflow8)) | (VREAD_S32(wOverflow7)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wCounterin7654, "wOverflow6, wOverflow5, wOverflow4, wOverflow3") {
DEFINE_FUNC(main_gen_wCounterin7654, "wOverflow6, wOverflow5, wOverflow4, wOverflow3, ") {
VWRITE_S32(wCounterin7654, (((VREAD_S32(wOverflow6)) | (VREAD_S32(wOverflow5))) | (VREAD_S32(wOverflow4))) | (VREAD_S32(wOverflow3)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wCounterin3210, "wOverflow2, wOverflow1, wOverflow0, wCounterIt") {
DEFINE_FUNC(main_gen_wCounterin3210, "wOverflow2, wOverflow1, wOverflow0, wCounterIt, ") {
VWRITE_S32(wCounterin3210, (((VREAD_S32(wOverflow2)) | (VREAD_S32(wOverflow1))) | (VREAD_S32(wOverflow0))) | (VREAD_S32(wCounterIt)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_b0098, "code9, code8") {
DEFINE_FUNC(main_gen_b0098, "code9, code8, ") {
VAssignVar(b0098, varConcat(1, varConst(16, 0x0), Var(code9), Var(code8), NULL));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_b7654, "code7, code6, code5, code4") {
DEFINE_FUNC(main_gen_b7654, "code7, code6, code5, code4, ") {
VAssignVar(b7654, varConcat(1, Var(code7), Var(code6), Var(code5), Var(code4), NULL));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_b3210, "code3, code2, code1, code0") {
DEFINE_FUNC(main_gen_b3210, "code3, code2, code1, code0, ") {
VAssignVar(b3210, varConcat(1, Var(code3), Var(code2), Var(code1), Var(code0), NULL));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wire_bWriteMask_if_bCounterChanged0, "wCounterChanged0, , wireout_bWriteMask") {
DEFINE_FUNC(main_gen_wire_bWriteMask_if_bCounterChanged0, "wCounterChanged0, wireout_bWriteMask, ") {
VWRITE_S32(wire_bWriteMask_if_bCounterChanged0, (VREAD_S32(wCounterChanged0))?(0):(VREAD_S32(wireout_bWriteMask)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wire_bWriteAddr_if_bCounterChanged0, "wCounterChanged0, , wireout_bWriteAddr") {
DEFINE_FUNC(main_gen_wire_bWriteAddr_if_bCounterChanged0, "wCounterChanged0, wireout_bWriteAddr, ") {
VWRITE_S32(wire_bWriteAddr_if_bCounterChanged0, (VREAD_S32(wCounterChanged0))?(0xf0000010):(VREAD_S32(wireout_bWriteAddr)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wire_bWriteData_if_bCounterChanged0, "wCounterChanged0, b3210, wireout_bWriteData") {
DEFINE_FUNC(main_gen_wire_bWriteData_if_bCounterChanged0, "wCounterChanged0, b3210, wireout_bWriteData, ") {
VWRITE_S32(wire_bWriteData_if_bCounterChanged0, (VREAD_S32(wCounterChanged0))?(VREAD_S32(b3210)):(VREAD_S32(wireout_bWriteData)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wire_bWriteMask_if_bCounterChanged1, "wCounterChanged1, , wire_bWriteMask_if_bCounterChanged0") {
DEFINE_FUNC(main_gen_wire_bWriteMask_if_bCounterChanged1, "wCounterChanged1, wire_bWriteMask_if_bCounterChanged0, ") {
VWRITE_S32(wire_bWriteMask_if_bCounterChanged1, (VREAD_S32(wCounterChanged1))?(0):(VREAD_S32(wire_bWriteMask_if_bCounterChanged0)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wire_bWriteAddr_if_bCounterChanged1, "wCounterChanged1, , wire_bWriteAddr_if_bCounterChanged0") {
DEFINE_FUNC(main_gen_wire_bWriteAddr_if_bCounterChanged1, "wCounterChanged1, wire_bWriteAddr_if_bCounterChanged0, ") {
VWRITE_S32(wire_bWriteAddr_if_bCounterChanged1, (VREAD_S32(wCounterChanged1))?(0xf0000014):(VREAD_S32(wire_bWriteAddr_if_bCounterChanged0)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wire_bWriteData_if_bCounterChanged1, "wCounterChanged1, b7654, wire_bWriteData_if_bCounterChanged0") {
DEFINE_FUNC(main_gen_wire_bWriteData_if_bCounterChanged1, "wCounterChanged1, b7654, wire_bWriteData_if_bCounterChanged0, ") {
VWRITE_S32(wire_bWriteData_if_bCounterChanged1, (VREAD_S32(wCounterChanged1))?(VREAD_S32(b7654)):(VREAD_S32(wire_bWriteData_if_bCounterChanged0)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wire_bWriteMask_if_bCounterChanged2, "wCounterChanged2, , wire_bWriteMask_if_bCounterChanged1") {
DEFINE_FUNC(main_gen_wire_bWriteMask_if_bCounterChanged2, "wCounterChanged2, wire_bWriteMask_if_bCounterChanged1, ") {
VWRITE_S32(wire_bWriteMask_if_bCounterChanged2, (VREAD_S32(wCounterChanged2))?(12):(VREAD_S32(wire_bWriteMask_if_bCounterChanged1)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wire_bWriteAddr_if_bCounterChanged2, "wCounterChanged2, , wire_bWriteAddr_if_bCounterChanged1") {
DEFINE_FUNC(main_gen_wire_bWriteAddr_if_bCounterChanged2, "wCounterChanged2, wire_bWriteAddr_if_bCounterChanged1, ") {
VWRITE_S32(wire_bWriteAddr_if_bCounterChanged2, (VREAD_S32(wCounterChanged2))?(0xf0000018):(VREAD_S32(wire_bWriteAddr_if_bCounterChanged1)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wire_bWriteData_if_bCounterChanged2, "wCounterChanged2, b0098, wire_bWriteData_if_bCounterChanged1") {
DEFINE_FUNC(main_gen_wire_bWriteData_if_bCounterChanged2, "wCounterChanged2, b0098, wire_bWriteData_if_bCounterChanged1, ") {
VWRITE_S32(wire_bWriteData_if_bCounterChanged2, (VREAD_S32(wCounterChanged2))?(VREAD_S32(b0098)):(VREAD_S32(wire_bWriteData_if_bCounterChanged1)));
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(main_gen_wire_or_wCounterChanged, "wCounterChanged0, wCounterChanged1, wCounterChanged2") {
DEFINE_FUNC(main_gen_wire_or_wCounterChanged, "wCounterChanged0, wCounterChanged1, wCounterChanged2, ") {
VWRITE_S32(wire_or_wCounterChanged, ((VREAD_S32(wCounterChanged0)) | (VREAD_S32(wCounterChanged1))) | (VREAD_S32(wCounterChanged2)));
} END_DEFINE_FUNC
......
......@@ -109,15 +109,15 @@ MODULE_DECLARE(digitled)
END_MODULE_DECLARE(digitled)
DEFINE_FUNC(digitled_store_wRead) {
DEFINE_FUNC(digitled_store_wRead, "wRead") {
VAssign(wRead_reg, wRead);
} END_DEFINE_FUNC
DEFINE_FUNC(digitled_store_bReadAddr) {
DEFINE_FUNC(digitled_store_bReadAddr, "bReadAddr") {
VAssign(bReadAddr_reg, bReadAddr);
} END_DEFINE_FUNC
DEFINE_FUNC(digitled_gen_bReadData) {
DEFINE_FUNC(digitled_gen_bReadData, "keypressed") {
VAssign(bReadData, keypressed);
} END_DEFINE_FUNC
......@@ -263,7 +263,7 @@ int StopRunning();
#define isMyAddr(addr) ((addr & 0xFFFFFF00) == (pobj->baseaddr & 0xFFFFFF00))
DEFINE_FUNC(digitled_clktick) {
DEFINE_FUNC(digitled_clktick, "") {
/* 读nwReset信号,看是否复位 */
int i, j;
int reset = VREAD_U32(nwReset);
......@@ -332,7 +332,7 @@ DEFINE_FUNC(digitled_clktick) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(M_ID(deinit)) {
DEFINE_FUNC(digitled_deinit, "") {
glfwTerminate();
} END_DEFINE_FUNC
......@@ -355,7 +355,7 @@ MODULE_INIT(digitled)
REG(keypressed, 32);
CLKTICK_FUNC(digitled_clktick);
DEINIT_FUNC(M_ID(deinit));
DEINIT_FUNC(digitled_deinit);
pobj->baseaddr = 0xF0000000;
pobj->data.canruninthread = 0;
......
......@@ -82,7 +82,7 @@ MODULE_DECLARE(cnncell_buf_r4)
int wordsize, wordcount;
END_MODULE_DECLARE(cnncell_buf_r4)
DEFINE_FUNC(cnncell_buf_r4_gen_write) {
DEFINE_FUNC(cnncell_buf_r4_gen_write, "wDataWriteEnable_0, wDataWriteEnable_1, wDataWriteEnable_2, wDataWriteEnable_3") {
vput(wDataWriteEnable,
vget(wDataWriteEnable_0)
&& vget(wDataWriteEnable_1)
......
......@@ -96,12 +96,12 @@ MODULE_DECLARE(cnncell_coeffbuf)
int header_loaded;
END_MODULE_DECLARE(cnncell_coeffbuf)
DEFINE_FUNC(M_ID(deinit)) {
DEFINE_FUNC(cncell_coeffbuf_deinit, "") {
if (pobj->databuf != NULL)
free(pobj->databuf);
} END_DEFINE_FUNC
DEFINE_FUNC(cncell_coeffbuf_gen_info){
DEFINE_FUNC(cncell_coeffbuf_gen_info, "") {
if (pobj->header_loaded == 0) {
struct sCoeffFileHeader * pFileHeader = (struct sCoeffFileHeader *)pobj->databuf;
vput(bCoeffOffset, pFileHeader->groupInfo[0].offset);
......@@ -120,7 +120,7 @@ DEFINE_FUNC(cncell_coeffbuf_gen_info){
}
} END_DEFINE_FUNC
DEFINE_FUNC(cncell_coeffbuf_gen_CoeffRead){
DEFINE_FUNC(cncell_coeffbuf_gen_CoeffRead, "read") {
vput(wCoeffReadValid, 0);
if (vget(read)) {
vput(bCoeffReadData, *(unsigned int*)&(pobj->databuf[vget(readaddr)]));
......@@ -128,7 +128,7 @@ DEFINE_FUNC(cncell_coeffbuf_gen_CoeffRead){
}
} END_DEFINE_FUNC
DEFINE_FUNC(cncell_coeffbuf_gen_read_reg) {
DEFINE_FUNC(cncell_coeffbuf_gen_read_reg, "wCoeffRead, bCoeffReadAddr") {
vput(read, vget(wCoeffRead));
vput(readaddr, vget(bCoeffReadAddr));
} END_DEFINE_FUNC
......@@ -178,6 +178,6 @@ MODULE_INIT(cnncell_coeffbuf)
GREG(read, 1, cncell_coeffbuf_gen_read_reg);
GREG(readaddr, 32, cncell_coeffbuf_gen_read_reg);
DEINIT_FUNC(M_ID(deinit));
DEINIT_FUNC(cncell_coeffbuf_deinit);
END_MODULE_INIT(cnncell_coeffbuf)
......@@ -83,7 +83,12 @@ MODULE_DECLARE(cnncell_concat)
int reset;
END_MODULE_DECLARE(cnncell_concat)
DEFINE_FUNC(cncell_concat_gen_read_write) {
DEFINE_FUNC(cncell_concat_gen_read_write,
"index, wDataWriteEnable, "
"wDataReadValid_0, bDataReadData_0, "
"wDataReadValid_1, bDataReadData_1, "
"wDataReadValid_2, bDataReadData_2, "
"wDataReadValid_3, bDataReadData_3") {
int index = vget(index);
int read0 = 0;
int read1 = 0;
......@@ -119,7 +124,12 @@ DEFINE_FUNC(cncell_concat_gen_read_write) {
vput(wDataWrite, write);
} END_DEFINE_FUNC
DEFINE_FUNC(cncell_concat_gen_write_data) {
DEFINE_FUNC(cncell_concat_gen_write_data,
"index, wDataWriteEnable, "
"wDataReadValid_0, bDataReadData_0, "
"wDataReadValid_1, bDataReadData_1, "
"wDataReadValid_2, bDataReadData_2, "
"wDataReadValid_3, bDataReadData_3") {
int index = vget(index);
vput(bDataWriteData, 0xcdcdcdcd);
if (pobj->reset && vget(wDataWriteEnable)) {
......@@ -139,7 +149,12 @@ DEFINE_FUNC(cncell_concat_gen_write_data) {
} END_DEFINE_FUNC
DEFINE_FUNC(cncell_concat_gen_write) {
DEFINE_FUNC(cncell_concat_gen_write,
"index, wDataWriteEnable, "
"wDataReadValid_0, "
"wDataReadValid_1, "
"wDataReadValid_2, "
"wDataReadValid_3 ") {
int index = vget(index);
vput(wDataWrite, 0);
if (pobj->reset && vget(wDataWriteEnable)) {
......@@ -154,7 +169,7 @@ DEFINE_FUNC(cncell_concat_gen_write) {
} END_DEFINE_FUNC
DEFINE_FUNC(cncell_concat_gen_read_0) {
DEFINE_FUNC(cncell_concat_gen_read_0, "index, wDataWriteEnable, wDataReadValid_0") {
int index = vget(index);
vput(wDataRead_0, 0);
if (pobj->reset && vget(wDataWriteEnable)) {
......@@ -164,7 +179,7 @@ DEFINE_FUNC(cncell_concat_gen_read_0) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cncell_concat_gen_read_1) {
DEFINE_FUNC(cncell_concat_gen_read_1, "index, wDataWriteEnable, wDataReadValid_1") {
int index = vget(index);
vput(wDataRead_1, 0);
if (pobj->reset && vget(wDataWriteEnable)) {
......@@ -174,7 +189,7 @@ DEFINE_FUNC(cncell_concat_gen_read_1) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cncell_concat_gen_read_2) {
DEFINE_FUNC(cncell_concat_gen_read_2, "index, wDataWriteEnable, wDataReadValid_2") {
int index = vget(index);
vput(wDataRead_2, 0);
if (pobj->reset && vget(wDataWriteEnable)) {
......@@ -184,7 +199,7 @@ DEFINE_FUNC(cncell_concat_gen_read_2) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cncell_concat_gen_read_3) {
DEFINE_FUNC(cncell_concat_gen_read_3, "index, wDataWriteEnable, wDataReadValid_3") {
int index = vget(index);
vput(wDataRead_3, 0);
if (pobj->reset && vget(wDataWriteEnable)) {
......@@ -194,7 +209,7 @@ DEFINE_FUNC(cncell_concat_gen_read_3) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cncell_concat_gen_clktick) {
DEFINE_FUNC(cncell_concat_gen_clktick, "") {
int index;
if (pobj->reset == 0) {
if (vget(nwReset) == 0) {
......
......@@ -113,7 +113,7 @@ enum convstate {
CONV_STRIPLINE,
};
DEFINE_FUNC(cnncell_convolution_gen_output_coeff) {
DEFINE_FUNC(cnncell_convolution_gen_output_coeff, "state, wCoeffReadValid, bCoeffOffset, bCoeffBiasOffset") {
if (pobj->reset == 0) {
vput(wCoeffRead, 0);
vput(bCoeffReadAddr, 0);
......@@ -153,7 +153,7 @@ DEFINE_FUNC(cnncell_convolution_gen_output_coeff) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_convolution_gen_output_read) {
DEFINE_FUNC(cnncell_convolution_gen_output_read, "state, wDataReadValid, readline, index") {
vput(wDataRead,0);
if (pobj->reset != 0) {
int state = vget(state);
......@@ -173,7 +173,7 @@ DEFINE_FUNC(cnncell_convolution_gen_output_read) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_convolution_gen_output_write) {
DEFINE_FUNC(cnncell_convolution_gen_output_write, "state, wDataWriteEnable") {
vput(wDataWrite, 0);
if (vget(state) == CONV_WRITELINE && vget(wDataWriteEnable)) {
int index = vget(index);
......@@ -184,7 +184,7 @@ DEFINE_FUNC(cnncell_convolution_gen_output_write) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_convolution_gen_line) {
DEFINE_FUNC(cnncell_convolution_gen_line, "") {
int ww, cc;
int lineindex = vget(lineindex);
for (ww = 0; ww < pobj->output_w; ww++) {
......@@ -228,7 +228,7 @@ DEFINE_FUNC(cnncell_convolution_gen_line) {
}
END_DEFINE_FUNC
DEFINE_FUNC(cnncell_convolution_clktick) {
DEFINE_FUNC(cnncell_convolution_clktick, "") {
//wDataRead = 0;
if (pobj->reset == 0) {
if (vget(nwReset) == 0) {
......@@ -372,7 +372,7 @@ DEFINE_FUNC(cnncell_convolution_clktick) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_convolution_deinit) {
DEFINE_FUNC(cnncell_convolution_deinit, "") {
if (pobj->coeff != NULL)
free(pobj->coeff);
if (pobj->bias != NULL)
......
......@@ -99,7 +99,7 @@ MODULE_DECLARE(cnncell_dataoutput)
int reset;
END_MODULE_DECLARE(cnncell_dataoutput)
DEFINE_FUNC(cnncell_dataoutput_output) {
DEFINE_FUNC(cnncell_dataoutput_output, "") {
int i;
for (i = 0; i < 1000; i++) {
items[i].label = labels[i];
......@@ -112,7 +112,7 @@ DEFINE_FUNC(cnncell_dataoutput_output) {
return 0;
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_dataoutput_clktick) {
DEFINE_FUNC(cnncell_dataoutput_clktick, "") {
if (pobj->reset == 0) {
if (vget(nwReset) == 0) {
vput(state, READ_DATA);
......@@ -146,7 +146,7 @@ DEFINE_FUNC(cnncell_dataoutput_clktick) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_dataoutput_gen_output_read) {
DEFINE_FUNC(cnncell_dataoutput_gen_output_read, "state, wDataReadValid") {
vput(wDataRead, 0);
if (pobj->reset != 0) {
int state = vget(state);
......@@ -158,7 +158,7 @@ DEFINE_FUNC(cnncell_dataoutput_gen_output_read) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_dataoutput_deinit) {
DEFINE_FUNC(cnncell_dataoutput_deinit, "") {
if (pobj->buf != NULL)
free(pobj->buf);
} END_DEFINE_FUNC
......
......@@ -75,15 +75,15 @@ MODULE_DECLARE(cnncell_datasource)
int reset;
END_MODULE_DECLARE(cnncell_datasource)
DEFINE_FUNC(cnncell_datasource_gen_wDataWrite) {
DEFINE_FUNC(cnncell_datasource_gen_wDataWrite, "complete, wDataWriteEnable") {
vput(wDataWrite, (vget(complete) == 0) && (pobj->reset != 0) && vget(wDataWriteEnable));
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_datasource_gen_bDataWriteData) {
DEFINE_FUNC(cnncell_datasource_gen_bDataWriteData, "cur_c, cur_h, cur_w") {
vput(bDataWriteData, *((unsigned int *)&keyboard[vget(cur_c)][vget(cur_h)][vget(cur_w)]));
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_datasource_gen_cur_whc) {
DEFINE_FUNC(cnncell_datasource_gen_cur_whc, "complete, wDataWriteEnable, index, cur_c, cur_w, cur_h") {
if (pobj->reset == 0) {/* 低电平有效 */
vput(index, 0);
vput(complete, 0);
......@@ -121,7 +121,7 @@ DEFINE_FUNC(cnncell_datasource_gen_cur_whc) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_datasource_clktick){
DEFINE_FUNC(cnncell_datasource_clktick, "") {
if (pobj->reset == 0) {
if (vget(nwReset))
pobj->reset = 1;
......
......@@ -104,7 +104,7 @@ enum innerproductstate {
DO_WRITE,
};
DEFINE_FUNC(cnncell_innerproduct_gen_output_coeff) {
DEFINE_FUNC(cnncell_innerproduct_gen_output_coeff, "state, index, wCoeffReadValid, bCoeffOffset, bCoeffBiasOffset") {
if (pobj->reset == 0) {
vput(wCoeffRead, 0);
vput(bCoeffReadAddr, 0);
......@@ -144,7 +144,7 @@ DEFINE_FUNC(cnncell_innerproduct_gen_output_coeff) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_innerproduct_calc) {
DEFINE_FUNC(cnncell_innerproduct_calc, "") {
int oc, cc;
short* coeff;
short* bias;
......@@ -178,7 +178,7 @@ DEFINE_FUNC(cnncell_innerproduct_calc) {
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_innerproduct_clktick) {
DEFINE_FUNC(cnncell_innerproduct_clktick, "") {
if (pobj->reset == 0) {
if (vget(nwReset) == 0) {
vput(state, READ_COEFF);
......@@ -267,7 +267,7 @@ DEFINE_FUNC(cnncell_innerproduct_clktick) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_innerproduct_gen_output_read) {
DEFINE_FUNC(cnncell_innerproduct_gen_output_read, "state, wDataReadValid") {
vput(wDataRead, 0);
if (pobj->reset != 0) {
int state = vget(state);
......@@ -279,7 +279,7 @@ DEFINE_FUNC(cnncell_innerproduct_gen_output_read) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_innerproduct_gen_output_write) {
DEFINE_FUNC(cnncell_innerproduct_gen_output_write, "index, wDataWriteEanble") {
int index;
index = vget(index);
vput(wDataWrite, 0);
......@@ -289,7 +289,7 @@ DEFINE_FUNC(cnncell_innerproduct_gen_output_write) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_innerproduct_deinit) {
DEFINE_FUNC(cnncell_innerproduct_deinit, "") {
if (pobj->coeff != NULL)
free(pobj->coeff);
if (pobj->bias != NULL)
......
......@@ -84,7 +84,7 @@ enum cnncell_lrn_state {
LRN_WRITE,
};
DEFINE_FUNC(cnncell_lrn_gen_read) {
DEFINE_FUNC(cnncell_lrn_gen_read, "state, wDataReadValid") {
vput(wDataRead, 0);
if (pobj->reset != 0) {
if (vget(state) == LRN_READ) {
......@@ -95,7 +95,7 @@ DEFINE_FUNC(cnncell_lrn_gen_read) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_lrn_gen_write) {
DEFINE_FUNC(cnncell_lrn_gen_write, "wDataWriteEnable, state, index") {
vput(wDataWrite, 0);
if (vget(state) == LRN_WRITE && vget(wDataWriteEnable)) {
int index = vget(index);
......@@ -112,7 +112,7 @@ enum {
};
DEFINE_FUNC(cnncell_lrn_gen_line) {
DEFINE_FUNC(cnncell_lrn_gen_line, "") {
if (pobj->region == LRN_NormRegion_ACROSS_CHANNELS) {
int cc, i, j;
/* 计算平方 */
......@@ -156,7 +156,7 @@ DEFINE_FUNC(cnncell_lrn_gen_line) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_lrn_clktick) {
DEFINE_FUNC(cnncell_lrn_clktick, "") {
int state = vget(state);
int index = vget(index);
if (pobj->reset == 0) {
......@@ -199,7 +199,7 @@ DEFINE_FUNC(cnncell_lrn_clktick) {
vput(index, index);
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_lrn_deinit) {
DEFINE_FUNC(cnncell_lrn_deinit, "") {
if (pobj->buf != NULL)
free(pobj->buf);
if (pobj->square != NULL)
......
......@@ -93,7 +93,7 @@ enum poolingstate {
};
DEFINE_FUNC(cnncell_pooling_gen_read) {
DEFINE_FUNC(cnncell_pooling_gen_read, "state, wDataReadValid, readline, index, ") {
vput(wDataRead, 0);
if (pobj->reset != 0) {
int state = vget(state);
......@@ -113,7 +113,7 @@ DEFINE_FUNC(cnncell_pooling_gen_read) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_pooling_gen_write) {
DEFINE_FUNC(cnncell_pooling_gen_write, "state, wDataWriteEnable, index") {
vput(wDataWrite, 0);
if (vget(state) == POOLING_WRITELINE && vget(wDataWriteEnable)) {
int index = vget(index);
......@@ -130,7 +130,7 @@ enum pooling_method {
CNN_POOLING_RAN,
};
DEFINE_FUNC(cnncell_pooling_gen_line) {
DEFINE_FUNC(cnncell_pooling_gen_line, "") {
int ww, cc;
int lineindex = vget(lineindex);
if (pobj->methodfunc == CNN_POOLING_MAX) {
......@@ -200,7 +200,7 @@ DEFINE_FUNC(cnncell_pooling_gen_line) {
END_DEFINE_FUNC
DEFINE_FUNC(cnncell_pooling_clktick) {
DEFINE_FUNC(cnncell_pooling_clktick, "") {
//wDataRead = 0;
if (pobj->reset == 0) {
if (vget(nwReset) == 0) {
......@@ -300,7 +300,7 @@ DEFINE_FUNC(cnncell_pooling_clktick) {
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_pooling_deinit) {
DEFINE_FUNC(cnncell_pooling_deinit, "") {
if (pobj->line_in != NULL)
free(pobj->line_in);
if (pobj->line_out != NULL)
......
......@@ -81,7 +81,7 @@ enum softmaxstate {
DO_WRITE,
};
DEFINE_FUNC(cnncell_softmax_calc) {
DEFINE_FUNC(cnncell_softmax_calc, "") {
int i;
float total, maxv;
total = 0.0f;
......@@ -112,7 +112,7 @@ DEFINE_FUNC(cnncell_softmax_calc) {
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_softmax_clktick) {
DEFINE_FUNC(cnncell_softmax_clktick, "") {
if (pobj->reset == 0) {
if (vget(nwReset) == 0) {
vput(state, READ_DATA);
......@@ -160,7 +160,7 @@ DEFINE_FUNC(cnncell_softmax_clktick) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_softmax_gen_output_read) {
DEFINE_FUNC(cnncell_softmax_gen_output_read, "state, wDataReadValid") {
vput(wDataRead, 0);
if (pobj->reset != 0) {
int state = vget(state);
......@@ -172,7 +172,7 @@ DEFINE_FUNC(cnncell_softmax_gen_output_read) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_softmax_gen_output_write) {
DEFINE_FUNC(cnncell_softmax_gen_output_write, "state, idnex, wDataWriteEnable") {
int index;
index = vget(index);
vput(wDataWrite, 0);
......@@ -182,14 +182,13 @@ DEFINE_FUNC(cnncell_softmax_gen_output_write) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(cnncell_softmax_deinit) {
DEFINE_FUNC(cnncell_softmax_deinit, "") {
if (pobj->inbuf != NULL)
free(pobj->inbuf);
if (pobj->outbuf != NULL)
free(pobj->outbuf);
} END_DEFINE_FUNC
MODULE_INIT(cnncell_softmax)
pobj->w = (int)MODULE_PARAM(0);
pobj->h = (int)MODULE_PARAM(1);
......
......@@ -31,7 +31,7 @@
/*
* Created by HDL4SE @ Fri Aug 6 21:35:41 2021
* Created by HDL4SE @ Tue Aug 10 11:07:46 2021
* Don't edit it.
*/
......@@ -1578,15 +1578,15 @@ END_IDLIST
GEN_MODULE_DECLARE
END_GEN_MODULE_DECLARE
DEFINE_FUNC(googlenet_gen_wSrcDataRead) {
DEFINE_FUNC(googlenet_gen_wSrcDataRead, "wDataRead_2, ") {
VWRITE_S32(wSrcDataRead, VREAD_S32(wDataRead_2));
} END_DEFINE_FUNC
DEFINE_FUNC(googlenet_gen_wDataReadValid_2) {
DEFINE_FUNC(googlenet_gen_wDataReadValid_2, "wSrcDataReadValid, ") {
VWRITE_S32(wDataReadValid_2, VREAD_S32(wSrcDataReadValid));
} END_DEFINE_FUNC
DEFINE_FUNC(googlenet_gen_bDataReadData_2) {
DEFINE_FUNC(googlenet_gen_bDataReadData_2, "bSrcDataReadData, ") {
VWRITE_S32(bDataReadData_2, VREAD_S32(bSrcDataReadData));
} END_DEFINE_FUNC
......
......@@ -67,18 +67,18 @@ END_IDLIST
MODULE_DECLARE(terris_blockwrite)
END_MODULE_DECLARE(terris_blockwrite)
DEFINE_FUNC(gen_wCtrlStateComplete) {
DEFINE_FUNC(gen_wCtrlStateComplete, "ramreadaddr_delay_1") {
int t;
t = VREAD_U32(ramreadaddr_delay_1);
VWRITE_U32(wCtrlStateComplete, t>=4?1:0);
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bBWReadAddr) {
DEFINE_FUNC(gen_bBWReadAddr, "bCurBlockPos, ramreadaddr") {
int blocky = (VREAD_U32(bCurBlockPos) >> 8) & 0xff;
VWRITE_U32(bBWReadAddr, VREAD_U32(ramreadaddr) + (blocky) - 4);
} END_DEFINE_FUNC
DEFINE_FUNC(gen_wBWWrite) {
DEFINE_FUNC(gen_wBWWrite, "ramreadaddr, ramreadaddr_delay_1") {
int addr, addr_1;
addr = VREAD_U32(ramreadaddr);
addr_1 = VREAD_U32(ramreadaddr_delay_1);
......@@ -87,12 +87,12 @@ DEFINE_FUNC(gen_wBWWrite) {
&& (addr_1 <= 3)) ? 1 : 0);
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bBWWriteAddr) {
DEFINE_FUNC(gen_bBWWriteAddr, "bCurBlockPos, ramreadaddr_delay_1") {
int blocky = (VREAD_U32(bCurBlockPos) >> 8) & 0xff;
VWRITE_U32(bBWWriteAddr, VREAD_U32(ramreadaddr_delay_1) + (blocky) - 4);
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bBWWriteData) {
DEFINE_FUNC(gen_bBWWriteData, "bCurBlockPos, bCurBlock, ramreadaddr_delay_1, bBWReadData") {
int blockx = VREAD_U32(bCurBlockPos) & 0xff;
unsigned long long curblockline_1 = (VREAD_U64(bCurBlock) >> ((3 - VREAD_U32(ramreadaddr_delay_1)) * 16)) & 0xffff;
unsigned long long curblockline = (blockx < 3) ? (curblockline_1 >> ((3 - blockx) * 4))
......@@ -100,11 +100,11 @@ DEFINE_FUNC(gen_bBWWriteData) {
VWRITE_U64(bBWWriteData, VREAD_U64(bBWReadData) | curblockline);
} END_DEFINE_FUNC
DEFINE_FUNC(gen_ramreadaddr) {
DEFINE_FUNC(gen_ramreadaddr, "bCtrlState, ramreadaddr") {
VWRITE_U32(ramreadaddr, (VREAD_U32(bCtrlState) == ST_BLOCKWRITE) ? (VREAD_U32(ramreadaddr) + 1) : 0);
} END_DEFINE_FUNC
DEFINE_FUNC(gen_ramreadaddr_delay_1) {
DEFINE_FUNC(gen_ramreadaddr_delay_1, "ramreadaddr") {
VAssign(ramreadaddr_delay_1, ramreadaddr);
} END_DEFINE_FUNC
......
......@@ -63,13 +63,13 @@ END_IDLIST
MODULE_DECLARE(terris_canblocksetto)
END_MODULE_DECLARE(terris_canblocksetto)
DEFINE_FUNC(gen_wCtrlStateComplete) {
DEFINE_FUNC(gen_wCtrlStateComplete, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bCBWReadAddr) {
DEFINE_FUNC(gen_bCBWReadAddr, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_wCanSet) {
DEFINE_FUNC(gen_wCanSet, "") {
} END_DEFINE_FUNC
MODULE_INIT(terris_canblocksetto)
......
......@@ -62,13 +62,13 @@ END_IDLIST
MODULE_DECLARE(terris_checkline)
END_MODULE_DECLARE(terris_checkline)
DEFINE_FUNC(gen_wCtrlStateComplete) {
DEFINE_FUNC(gen_wCtrlStateComplete, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bCKLReadAddr) {
DEFINE_FUNC(gen_bCKLReadAddr, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bFindLine) {
DEFINE_FUNC(gen_bFindLine, "") {
} END_DEFINE_FUNC
MODULE_INIT(terris_checkline)
......
......@@ -64,22 +64,22 @@ END_IDLIST
MODULE_DECLARE(terris_copylines)
END_MODULE_DECLARE(terris_copylines)
DEFINE_FUNC(gen_wCtrlStateComplete) {
DEFINE_FUNC(gen_wCtrlStateComplete, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bCKLReadAddr) {
DEFINE_FUNC(gen_bCKLReadAddr, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bReadAddr) {
DEFINE_FUNC(gen_bReadAddr, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_wWrite) {
DEFINE_FUNC(gen_wWrite, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bWriteAddr) {
DEFINE_FUNC(gen_bWriteAddr, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bWriteData) {
DEFINE_FUNC(gen_bWriteData, "") {
} END_DEFINE_FUNC
MODULE_INIT(terris_copylines)
......
......@@ -73,19 +73,19 @@ END_IDLIST
MODULE_DECLARE(terris_flushtodisp)
END_MODULE_DECLARE(terris_flushtodisp)
DEFINE_FUNC(gen_wCtrlStateComplete) {
DEFINE_FUNC(gen_wCtrlStateComplete, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bReadAddr) {
DEFINE_FUNC(gen_bReadAddr, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_wWrite) {
DEFINE_FUNC(gen_wWrite, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bWriteAddr) {
DEFINE_FUNC(gen_bWriteAddr, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bWriteData) {
DEFINE_FUNC(gen_bWriteData, "") {
} END_DEFINE_FUNC
MODULE_INIT(terris_flushtodisp)
......
......@@ -63,16 +63,16 @@ END_IDLIST
MODULE_DECLARE(terris_init)
END_MODULE_DECLARE(terris_init)
DEFINE_FUNC(gen_wCtrlStateComplete) {
DEFINE_FUNC(gen_wCtrlStateComplete, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_wWrite) {
DEFINE_FUNC(gen_wWrite, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bWriteAddr) {
DEFINE_FUNC(gen_bWriteAddr, "") {
} END_DEFINE_FUNC
DEFINE_FUNC(gen_bWriteData) {
DEFINE_FUNC(gen_bWriteData, "") {
} END_DEFINE_FUNC
MODULE_INIT(terris_init)
......
......@@ -258,7 +258,7 @@ static void terrisctrl1_hdl4se_unit_PressKeyStart(MODULE_DATA_TYPE* pobj, int ke
}
}
DEFINE_FUNC(terrisctrl1ClkTick) {
DEFINE_FUNC(terrisctrl1ClkTick, "") {
unsigned int statecomplete;
int state;
state = VREAD_U32(state);
......@@ -387,7 +387,7 @@ DEFINE_FUNC(terrisctrl1ClkTick) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(terrisctrl_GetValue)
DEFINE_FUNC(terrisctrl_GetValue, "state")
{
unsigned long long data;
int i, j;
......
......@@ -55,16 +55,16 @@
#define WIDTH 600
#define HEIGHT 800
static int keypressed = 0;
static int __keypressed = 0;
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
keypressed = 0;
__keypressed = 0;
if (action != GLFW_PRESS)
return;
if (key >= GLFW_KEY_RIGHT && key <= GLFW_KEY_UP) {
key -= GLFW_KEY_RIGHT;
keypressed = (1 << key);
__keypressed = (1 << key);
}
}
......@@ -87,6 +87,7 @@ IDLIST
VID(wRead_reg),
VID(bReadAddr_reg),
VID(keypressed),
END_IDLIST
MODULE_DECLARE(terrisdevice)
......@@ -108,15 +109,15 @@ MODULE_DECLARE(terrisdevice)
END_MODULE_DECLARE(terrisdevice)
DEFINE_FUNC(terrisdevice_store_wRead) {
DEFINE_FUNC(terrisdevice_store_wRead, "wRead") {
VAssign(wRead_reg, wRead);
} END_DEFINE_FUNC
DEFINE_FUNC(terrisdevice_store_bReadAddr) {
DEFINE_FUNC(terrisdevice_store_bReadAddr, "bReadAddr") {
VAssign(bReadAddr_reg, bReadAddr);
} END_DEFINE_FUNC
DEFINE_FUNC(terrisdevice_gen_bReadData) {
DEFINE_FUNC(terrisdevice_gen_bReadData, "keypressed") {
VWRITE_U32(bReadData, pobj->keypressed);
} END_DEFINE_FUNC
......@@ -242,14 +243,14 @@ int StopRunning();
#define isMyAddr(addr) ((addr & 0xFFFFFF00) == (pobj->baseaddr & 0xFFFFFF00))
DEFINE_FUNC(terrisdevice_clktick) {
DEFINE_FUNC(terrisdevice_clktick, "") {
/* 读nwReset信号,看是否复位 */
int reset = VREAD_U32(nwReset);
pobj->keypressed = keypressed;
pobj->keypressed = __keypressed;
if (reset == 0) {
pobj->keypressed = 0;
}
vput(keypressed, pobj->keypressed);
/* 读写命令,看是否写 */
if (reset != 0) {
int wWrite = VREAD_U32(wWrite);
......@@ -313,7 +314,7 @@ DEFINE_FUNC(terrisdevice_clktick) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(terrisdevice_deinit) {
DEFINE_FUNC(terrisdevice_deinit, "") {
glfwTerminate();
} END_DEFINE_FUNC
......@@ -332,6 +333,7 @@ MODULE_INIT(terrisdevice)
REG(wRead_reg, 1);
REG(bReadAddr_reg, 32);
REG(keypressed, 32);
GEN_FUNC("wRead_reg", terrisdevice_store_wRead);
GEN_FUNC("bReadAddr_reg", terrisdevice_store_bReadAddr);
GEN_FUNC("bReadData", terrisdevice_gen_bReadData);
......
......@@ -19,7 +19,7 @@ END_IDLIST
GEN_MODULE_DECLARE
END_GEN_MODULE_DECLARE
DEFINE_FUNC(do_Generate_Result) {
DEFINE_FUNC(do_Generate_Result, "a, b") {
unsigned int ia, ib;
ia = VREAD_U32(a);
ib = VREAD_U32(b);
......@@ -53,7 +53,7 @@ END_IDLIST
GEN_MODULE_DECLARE
END_GEN_MODULE_DECLARE
DEFINE_FUNC(do_Generate_Or) {
DEFINE_FUNC(do_Generate_Or, "c1, c2") {
unsigned int c1, c2;
c1 = VREAD_U32(c1);
c2 = VREAD_U32(c2);
......@@ -87,17 +87,17 @@ GEN_MODULE_DECLARE
unsigned int pattern;
END_GEN_MODULE_DECLARE
DEFINE_FUNC(do_Generate_Data) {
DEFINE_FUNC(do_Generate_Data, "") {
VWRITE_U32(d_a, (pobj->pattern & 1) ? 1 : 0);
VWRITE_U32(d_b, (pobj->pattern & 2) ? 1 : 0);
VWRITE_U32(d_cin, (pobj->pattern & 4) ? 1 : 0);
} END_DEFINE_FUNC
DEFINE_FUNC(test_driver_setup) {
DEFINE_FUNC(test_driver_setup, "") {
pobj->pattern = pobj->pattern + 1;
} END_DEFINE_FUNC
DEFINE_FUNC(test_driver_init) {
DEFINE_FUNC(test_driver_init, "") {
pobj->pattern = 0;
} END_DEFINE_FUNC
......@@ -127,7 +127,7 @@ END_IDLIST
GEN_MODULE_DECLARE
END_GEN_MODULE_DECLARE
DEFINE_FUNC(test_monitor_clktick) {
DEFINE_FUNC(test_monitor_clktick, "") {
printf("\nclocks: %d\n", clocks);
printf("(a, b, carry_in):%1d%1d%1d\n", VREAD_U32(m_a), VREAD_U32(m_b), VREAD_U32(m_cin));
printf("(sum, carry_out):%1d%1d\n", VREAD_U32(m_sum), VREAD_U32(m_cout));
......
......@@ -120,7 +120,6 @@ typedef struct sModuleVariable {
unsigned long long data_reg;
#endif
THREADLOCK lock;
//void (*func_UpdateVariable)(struct sModuleVariable* var);
int updatefunc;
}ModuleVariable;
......@@ -289,11 +288,8 @@ IHDL4SEModuleVar* hdl4seCreateModule3(HOBJECT parent, const char* clsid, const c
#define MODULE_DATA_TYPE M_ID(sHDL4SE_data)
#define MODULE_DATA_STRUCT M_ID(_sHDL4SE_data)
#define DEFINE_FUNC_DEPEND(funcname, dependlist) \
#define DEFINE_FUNC(funcname, dependlist) \
static const char * __##funcname##_depend_list = dependlist; \
DEFINE_FUNC(funcname)
#define DEFINE_FUNC(funcname) \
static int funcname(MODULE_DATA_TYPE* pobj, ModuleVariable * variable) {
#define CALL_FUNC(funcname) funcname(pobj, NULL)
......@@ -465,7 +461,11 @@ do { \
hdl4se_setgen_func_by_index(pobj->pmodule, VID(name), (void *)func); \
} while(0)
#define GEN_FUNC(signal_list, func) hdl4se_set_gen_func(pobj->pmodule, signal_list, (void *)func)
#define GEN_FUNC(signal_list, func) \
do { \
hdl4se_set_gen_func(pobj->pmodule, signal_list, (void*)func); \
} while (0)
#define SETUP_FUNC(func) pobj->pmodule->setup_func = func
#define CLKTICK_FUNC(func) pobj->pmodule->clktick_func = func
#define DEINIT_FUNC(func) pobj->pmodule->deinit_func = func
......
......@@ -74,7 +74,7 @@ MODULE_DECLARE(hdl4se_fifo)
int reset;
END_MODULE_DECLARE(hdl4se_fifo)
DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_bReadData, "readpos") {
DEFINE_FUNC(hdl4se_fifo_gen_bReadData, "readpos") {
unsigned int readaddr = vget(readpos);
var readdata = Var(bReadData);
unsigned int j;
......@@ -83,15 +83,15 @@ DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_bReadData, "readpos") {
}
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_wDataValid, "wReadEn") {
DEFINE_FUNC(hdl4se_fifo_gen_wDataValid, "wReadEn") {
VAssign(wDataValid, wReadEn);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_wWriteEnable, "wWriteEn") {
DEFINE_FUNC(hdl4se_fifo_gen_wWriteEnable, "wWriteEn") {
VAssign(wWriteEnable, wWriteEn);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_readpos, "readpos, wRead, wReadEn") {
DEFINE_FUNC(hdl4se_fifo_gen_readpos, "readpos, wRead, wReadEn") {
if (pobj->reset == 0) {
vput(readpos, 0);
}
......@@ -106,7 +106,7 @@ DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_readpos, "readpos, wRead, wReadEn") {
}
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_writepos, "writepos, wWrite, wWriteEn") {
DEFINE_FUNC(hdl4se_fifo_gen_writepos, "writepos, wWrite, wWriteEn") {
if (pobj->reset == 0) {
vput(writepos, 0);
}
......@@ -121,7 +121,7 @@ DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_writepos, "writepos, wWrite, wWriteEn") {
}
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_outputcount, "wRead, wReadEn, outputcount") {
DEFINE_FUNC(hdl4se_fifo_gen_outputcount, "wRead, wReadEn, outputcount") {
if (pobj->reset == 0) {
vput(outputcount, 0);
}
......@@ -132,7 +132,7 @@ DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_outputcount, "wRead, wReadEn, outputcount") {
}
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_inputcount, "wWrite, wWriteEn, inputcount") {
DEFINE_FUNC(hdl4se_fifo_gen_inputcount, "wWrite, wWriteEn, inputcount") {
if (pobj->reset == 0) {
vput(inputcount, 0);
}
......@@ -143,7 +143,7 @@ DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_inputcount, "wWrite, wWriteEn, inputcount") {
}
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(hdl4se_fifo_count, "readpos, writepos") {
DEFINE_FUNC(hdl4se_fifo_count, "readpos, writepos") {
unsigned int readaddr = vget(readpos);
unsigned int writeaddr = vget(writepos);
unsigned int datacount;
......@@ -154,7 +154,7 @@ DEFINE_FUNC_DEPEND(hdl4se_fifo_count, "readpos, writepos") {
vput(count, datacount);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_maxcount, "readpos, writepos, maxcount") {
DEFINE_FUNC(hdl4se_fifo_gen_maxcount, "readpos, writepos, maxcount") {
if (pobj->reset == 0) {
vput(maxcount, 0);
}
......@@ -175,7 +175,7 @@ DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_maxcount, "readpos, writepos, maxcount") {
}
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_wReadEn, "readpos, writepos, wRead, wReadEn, wWrite, wWriteEn") {
DEFINE_FUNC(hdl4se_fifo_gen_wReadEn, "readpos, writepos, wRead, wReadEn, wWrite, wWriteEn") {
unsigned int readaddr = vget(readpos);
unsigned int writeaddr = vget(writepos);
if (vget(wRead) && vget(wReadEn)) {
......@@ -186,7 +186,7 @@ DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_wReadEn, "readpos, writepos, wRead, wReadEn,
vput(wReadEn, (readaddr != writeaddr) ? 1 : 0);
} END_DEFINE_FUNC
DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_wWriteEn, "readpos, writepos, wRead, wReadEn, wWrite, wWriteEn") {
DEFINE_FUNC(hdl4se_fifo_gen_wWriteEn, "readpos, writepos, wRead, wReadEn, wWrite, wWriteEn") {
if (pobj->reset == 0) {
vput(wWriteEn, 0);
}
......@@ -206,7 +206,7 @@ DEFINE_FUNC_DEPEND(hdl4se_fifo_gen_wWriteEn, "readpos, writepos, wRead, wReadEn,
#define DEPEND_OPT 0
#if DEPEND_OPT
DEFINE_FUNC_DEPEND(hdl4se_fifo_ClkTick, "nwReset, readpos, writepos, wRead, wReadEn, outputcount, wWrite, wWriteEn, inputcount, maxcount") {
DEFINE_FUNC(hdl4se_fifo_ClkTick, "nwReset, readpos, writepos, wRead, wReadEn, outputcount, wWrite, wWriteEn, inputcount, maxcount") {
if (pobj->reset == 0) {
if (vget(nwReset) != 0) {
pobj->reset = 1;
......@@ -226,7 +226,7 @@ DEFINE_FUNC_DEPEND(hdl4se_fifo_ClkTick, "nwReset, readpos, writepos, wRead, wRea
#else
DEFINE_FUNC_DEPEND(hdl4se_fifo_ClkTick, "nwReset, readpos, writepos, wRead, wReadEn, outputcount, wWrite, wWriteEn, inputcount, maxcount") {
DEFINE_FUNC(hdl4se_fifo_ClkTick, "nwReset, readpos, writepos, wRead, wReadEn, outputcount, wWrite, wWriteEn, inputcount, maxcount") {
if (pobj->reset == 0) {
if (vget(nwReset) == 0) {
vput(readpos, 0);
......@@ -281,7 +281,7 @@ DEFINE_FUNC_DEPEND(hdl4se_fifo_ClkTick, "nwReset, readpos, writepos, wRead, wRea
} END_DEFINE_FUNC
#endif
DEFINE_FUNC(M_ID(deinit)) {
DEFINE_FUNC(hdl4se_fifo_deinit, "") {
if (pobj->fifo_data != NULL)
mt_free(pobj->fifo_data);
} END_DEFINE_FUNC
......@@ -328,6 +328,6 @@ MODULE_INIT(hdl4se_fifo)
#endif
CLKTICK_FUNC(hdl4se_fifo_ClkTick);
DEINIT_FUNC(M_ID(deinit));
DEINIT_FUNC(hdl4se_fifo_deinit);
END_MODULE_INIT(hdl4se_fifo)
......@@ -78,6 +78,7 @@ inline static void hdl4seUpdateVariableGenFunc(ModuleVariable* var)
inline static void hdl4seUpdateVariableGetValue(ModuleVariable* var)
{
int updatefunc = var->updatefunc;
// var->func_UpdateVariable = hdl4seUpdateVariableNone;
//functionCallAndSetNone(var->moduledata->funcs.array[var->genfuncindex]);
var->updatefunc = 0;
......@@ -109,16 +110,16 @@ do { \
#define UpdateVariable(v) \
do { \
if (v->type != VTYPE_REG) { \
threadlockLock(v->lock); \
if (v->updatefunc != 0) { \
threadlockLock(v->lock); \
if (v->updatefunc == 1) { \
hdl4seUpdateVariableGenFunc(v); \
} \
else { \
hdl4seUpdateVariableGetValue(v); \
} \
threadlockUnlock(v->lock); \
} \
threadlockUnlock(v->lock); \
} \
} while (0)
#endif
......
......@@ -73,7 +73,7 @@ END_IDLIST
MODULE_DECLARE(hdl4se_mux16)
END_MODULE_DECLARE(hdl4se_mux16)
DEFINE_FUNC(do_Generate_Result) {
DEFINE_FUNC(do_Generate_Result, "sel") {
unsigned int sel;
sel = VREAD_U32(sel);
VAssign_idx(17, (sel & 15) + 1);
......
......@@ -59,7 +59,7 @@ END_IDLIST
MODULE_DECLARE(hdl4se_mux2)
END_MODULE_DECLARE(hdl4se_mux2)
DEFINE_FUNC(do_Generate_Result) {
DEFINE_FUNC(do_Generate_Result, "sel") {
unsigned int sel;
sel = VREAD_U32(sel);
if (sel == 0)
......
......@@ -61,7 +61,7 @@ END_IDLIST
MODULE_DECLARE(hdl4se_mux4)
END_MODULE_DECLARE(hdl4se_mux4)
DEFINE_FUNC(do_Generate_Result) {
DEFINE_FUNC(do_Generate_Result, "sel") {
unsigned int sel;
sel = VREAD_U32(sel);
VAssign_idx(5, (sel & 3) + 1);
......
......@@ -65,7 +65,7 @@ END_IDLIST
MODULE_DECLARE(hdl4se_mux8)
END_MODULE_DECLARE(hdl4se_mux8)
DEFINE_FUNC(do_Generate_Result) {
DEFINE_FUNC(do_Generate_Result, "sel") {
unsigned int sel;
sel = VREAD_U32(sel);
VAssign_idx(VID(data), (sel & 7) + 1);
......
......@@ -77,7 +77,7 @@ MODULE_DECLARE(hdl4se_ram1p)
unsigned int* ram_data;
END_MODULE_DECLARE(hdl4se_ram1p)
DEFINE_FUNC(hdl4se_ram1p_do_Generate_ReadData) {
DEFINE_FUNC(hdl4se_ram1p_do_Generate_ReadData, "bReadAddr_reg") {
unsigned int readaddr = VREAD_U32(bReadAddr_reg);
var readdata = Var(bReadData);
if (readaddr < pobj->wordcount) {
......@@ -88,7 +88,7 @@ DEFINE_FUNC(hdl4se_ram1p_do_Generate_ReadData) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(hdl4se_ram1p_do_Generate_ClkTick) {
DEFINE_FUNC(hdl4se_ram1p_do_Generate_ClkTick, "") {
unsigned int write;
unsigned int addr;
write = VREAD_U32(wWrite);
......@@ -104,11 +104,11 @@ DEFINE_FUNC(hdl4se_ram1p_do_Generate_ClkTick) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(hdl4se_ram1p_do_Store_bReadAddr) {
DEFINE_FUNC(hdl4se_ram1p_do_Store_bReadAddr, "bReadAddr") {
VAssign(bReadAddr_reg, bReadAddr);
} END_DEFINE_FUNC
DEFINE_FUNC(M_ID(deinit)) {
DEFINE_FUNC(hdl4se_ram1p_deinit, "") {
if (pobj->ram_data != NULL)
mt_free(pobj->ram_data);
} END_DEFINE_FUNC
......@@ -137,6 +137,6 @@ MODULE_INIT(hdl4se_ram1p)
GEN_FUNC("bReadData", hdl4se_ram1p_do_Generate_ReadData);
GEN_FUNC("bReadAddr_reg", hdl4se_ram1p_do_Store_bReadAddr);
CLKTICK_FUNC(hdl4se_ram1p_do_Generate_ClkTick);
DEINIT_FUNC(M_ID(deinit));
DEINIT_FUNC(hdl4se_ram1p_deinit);
END_MODULE_INIT(hdl4se_ram1p)
......@@ -83,7 +83,7 @@ MODULE_DECLARE(hdl4se_ram2p)
unsigned int* ram_data;
END_MODULE_DECLARE(hdl4se_ram2p)
DEFINE_FUNC(hdl4se_ram2p_do_Generate_ReadData) {
DEFINE_FUNC(hdl4se_ram2p_do_Generate_ReadData, "bReadAddr_reg") {
unsigned int readaddr = VREAD_U32(bReadAddr_reg);
if (readaddr < pobj->wordcount) {
var dst = Var(bReadData);
......@@ -94,11 +94,11 @@ DEFINE_FUNC(hdl4se_ram2p_do_Generate_ReadData) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(hdl4se_ram2p_do_Store_bReadAddr) {
DEFINE_FUNC(hdl4se_ram2p_do_Store_bReadAddr, "bReadAddr") {
VAssign(bReadAddr_reg, bReadAddr);
} END_DEFINE_FUNC
DEFINE_FUNC(hdl4se_ram2p_do_Generate_ReadData2) {
DEFINE_FUNC(hdl4se_ram2p_do_Generate_ReadData2, "bReadAddr2_reg") {
unsigned int readaddr = VREAD_U32(bReadAddr2_reg);
if (readaddr < pobj->wordcount) {
var dst = Var(bReadData2);
......@@ -109,12 +109,12 @@ DEFINE_FUNC(hdl4se_ram2p_do_Generate_ReadData2) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(hdl4se_ram2p_do_Store_bReadAddr2) {
DEFINE_FUNC(hdl4se_ram2p_do_Store_bReadAddr2, "bReadAddr2") {
VAssign(bReadAddr2_reg, bReadAddr2);
} END_DEFINE_FUNC
DEFINE_FUNC(hdl4se_ram2p_do_Generate_ClkTick) {
DEFINE_FUNC(hdl4se_ram2p_do_Generate_ClkTick, "") {
unsigned int write;
unsigned int addr;
write = VREAD_U32(wWrite);
......@@ -141,7 +141,7 @@ DEFINE_FUNC(hdl4se_ram2p_do_Generate_ClkTick) {
}
} END_DEFINE_FUNC
DEFINE_FUNC(M_ID(deinit)) {
DEFINE_FUNC(hdl4se_ram2p_deinit, "") {
if (pobj->ram_data != NULL)
mt_free(pobj->ram_data);
} END_DEFINE_FUNC
......@@ -180,6 +180,6 @@ MODULE_INIT(hdl4se_ram2p)
GEN_FUNC("bReadData2", hdl4se_ram2p_do_Generate_ReadData2);
GEN_FUNC("bReadAddr2_reg", hdl4se_ram2p_do_Store_bReadAddr2);
CLKTICK_FUNC(hdl4se_ram2p_do_Generate_ClkTick);
DEINIT_FUNC(M_ID(deinit));
DEINIT_FUNC(hdl4se_ram2p_deinit);
END_MODULE_INIT(hdl4se_ram2p)
......@@ -58,11 +58,11 @@ END_IDLIST
MODULE_DECLARE(hdl4se_reg)
END_MODULE_DECLARE(hdl4se_reg)
DEFINE_FUNC(hdl4se_reg_store_wirein) {
DEFINE_FUNC(hdl4se_reg_store_wirein, "wirein") {
VAssign(reg, wirein);
} END_DEFINE_FUNC
DEFINE_FUNC(hdl4se_reg_gen_wireout) {
DEFINE_FUNC(hdl4se_reg_gen_wireout, "reg") {
VAssign(wireout, reg);
} END_DEFINE_FUNC
......
......@@ -2038,28 +2038,34 @@ const char* verilogparseGenExprDependStr(HOBJECT expr, HOBJECT module)
sExpr* pobj;
pobj = (sExpr*)objectThis(expr);
if (pobj == NULL)
return 0;
return NULL;
expr_verilognode_procheck(expr, module, NULL);
width = verilogparseGenExprWidth(expr, module);
switch (pobj->data.exprtype) {
case EXPRTYPE_BINOP:
{
const char* rst;
char* src0;
char* src1;
char* buf;
char* src0 = NULL;
char* src1 = NULL;
rst = verilogparseGenExprDependStr(pobj->data.expr0, module);
if (rst == NULL)
return NULL;
src0 = STRDUP(rst);
if (rst != NULL)
src0 = STRDUP(rst);
rst = verilogparseGenExprDependStr(pobj->data.expr1, module);
if (rst == NULL) {
if (rst != NULL)
src1 = STRDUP(rst);
buf = hdl4se_parse_logbuf();
buf[0] = 0;
if (src0 != NULL) {
strcat(buf, src0);
free(src0);
return NULL;
}
src1 = STRDUP(rst);
sprintf(hdl4se_parse_logbuf(), "%s, %s", src0, src1);
free(src0);
free(src1);
if (src1 != NULL) {
strcat(buf, src1);
free(src1);
}
if (strlen(hdl4se_parse_logbuf()) == 0)
return NULL;
return hdl4se_parse_logbuf();
break;
}
......@@ -2069,31 +2075,36 @@ const char* verilogparseGenExprDependStr(HOBJECT expr, HOBJECT module)
}
case EXPRTYPE_IFOP:
{
char* buf;
const char* rst;
char* src0;
char* src1;
char* src2;
char* src0 = NULL;
char* src1 = NULL;
char* src2 = NULL;
rst = verilogparseGenExprDependStr(pobj->data.expr0, module);
if (rst == NULL)
return NULL;
src0 = STRDUP(rst);
if (rst != NULL)
src0 = STRDUP(rst);
rst = verilogparseGenExprDependStr(pobj->data.expr1, module);
if (rst == NULL) {
free(src0);
return NULL;
}
src1 = STRDUP(rst);
if (rst != NULL)
src1 = STRDUP(rst);
rst = verilogparseGenExprDependStr(pobj->data.expr2, module);
if (rst == NULL) {
if (rst != NULL)
src2 = STRDUP(rst);
buf = hdl4se_parse_logbuf();
buf[0] = 0;
if (src0 != NULL) {
strcat(buf, src0);
free(src0);
}
if (src1 != NULL) {
strcat(buf, src1);
free(src1);
return NULL;
}
src2 = STRDUP(rst);
sprintf(hdl4se_parse_logbuf(), "%s, %s, %s", src0, src1, src2);
free(src0);
free(src1);
free(src2);
if (src2 != NULL) {
strcat(buf, src2);
free(src2);
}
if (strlen(hdl4se_parse_logbuf()) == 0)
return NULL;
return hdl4se_parse_logbuf();
break;
}
......@@ -2103,12 +2114,16 @@ const char* verilogparseGenExprDependStr(HOBJECT expr, HOBJECT module)
/* 目前只取第一个名称 */
verilogVarSel* select;
select = verilogVarSelGetData(pobj->data.hierarchical_identifier->__dlist_pNext);
if (select == NULL)
return NULL;
if (select != NULL) {
index = verilogModuleGetParamIndex(module, select->name->string);
}
if (index < 0)
return select->name->string;
return "";
if (index < 0) {
sprintf(hdl4se_parse_logbuf(), "%s, ", select->name->string);
return hdl4se_parse_logbuf();
}
return NULL;
break;
}
case EXPRTYPE_CONCAT: {
......@@ -2121,26 +2136,20 @@ const char* verilogparseGenExprDependStr(HOBJECT expr, HOBJECT module)
pitem = plist->__dlist_pNext;
buf[0] = 0;
while (pitem != plist) {
char* vbuf = verilogparseGenExprDependStr(pitem, module);
pnextitem = pitem->__dlist_pNext;
vbuf = buf + strlen(buf);
if (strlen(buf) > 0)
sprintf(vbuf, ", %s", verilogparseGenExprDependStr(pitem, module));
else
sprintf(vbuf, "%s", verilogparseGenExprDependStr(pitem, module));
if (vbuf != NULL) {
strcat(buf, vbuf);
}
pitem = pnextitem;
}
}
strcpy(hdl4se_parse_logbuf(), buf);
free(buf);
if (strlen(hdl4se_parse_logbuf()) == 0)
return NULL;
return hdl4se_parse_logbuf();
}
default:
{
return "";
break;
}
}
return NULL;
}
......
......@@ -51,6 +51,7 @@
#include "verilog_parameter.h"
#include "verilog_paraminst.h"
#include "threadlock.h"
#include "pointerarray.h"
#define IMPLEMENT_GUID
#include "verilog_module.h"
......@@ -480,6 +481,35 @@ verilogVariableInfo* lvalueGetDecl(verilogVarSel* lvalue, verilogModule* modulei
char* moduleinstanceGetParameterString(verilogModuleInstance* moduleinstance);
static void removeDuplicateIdentify(char *depend)
{
int i;
PointerArray tokenarray;
char* p;
if (depend == NULL)
return;
pointerarrayInit(&tokenarray);
p = strtok(depend, " ,");
while (p != NULL) {
int i;
for (i = 0; i < tokenarray.itemcount; i++) {
if (strcmp((const char *)tokenarray.array[i], p) == 0)
break;
}
if (i == tokenarray.itemcount) {
pointerarrayAddItem(&tokenarray, STRDUP(p));
}
p = strtok(NULL, " ,");
}
depend[0] = 0;
for (i = 0; i < tokenarray.itemcount; i++) {
strcat(depend, (const char*)tokenarray.array[i]);
strcat(depend, ", ");
}
pointerarrayDestroy(&tokenarray, free);
}
static int verilogmodule_verilognode_gencode(HOBJECT object, FILE * pFile, HOBJECT module, void * param)
{
sVerilogModule* pobj;
......@@ -663,10 +693,12 @@ static int verilogmodule_verilognode_gencode(HOBJECT object, FILE * pFile, HOBJE
if (verilogparseIsLValueExpr(connect->expr0, pobj, NULL) == 0) {
int width = verilogparseGenExprWidth(connect->expr0, pobj);
const char* exprstr = NULL;
fprintf(pFile, "\nDEFINE_FUNC_DEPEND(%s_gen_%s_dot_%s, \"%s\") { /* port:%s(%s).%s, %d */\n",
char* depend = verilogparseGenExprDependStr(connect->expr0, pobj);
removeDuplicateIdentify(depend);
fprintf(pFile, "\nDEFINE_FUNC(%s_gen_%s_dot_%s, \"%s\") { /* port:%s(%s).%s, %d */\n",
pobj->data.name->string,
moduleinst->instname->string, port->name->string,
verilogparseGenExprDependStr(connect->expr0, pobj),
depend==NULL?"":depend,
moduleinst->instname->string, moduleinfo->name->string, port->name->string,
port->index);
if (width <= 64)
......@@ -705,13 +737,15 @@ static int verilogmodule_verilognode_gencode(HOBJECT object, FILE * pFile, HOBJE
verilog_Assignment* assignment = verilogAssignmentGetData(pitem);
verilogVarSel* lvalue = verilogVarSelGetData(assignment->hierarchical_identifier->__dlist_pNext);
const char* exprstr = NULL;
char* depend = verilogparseGenExprDependStr(assignment->expr, pobj);
removeDuplicateIdentify(depend);
int width = verilogparseGenExprWidth(assignment->expr, pobj);
pitemtemp = pitem->__dlist_pNext;
/*if (isWireLValue(&pobj->data, lvalue)) */ {
fprintf(pFile, "\nDEFINE_FUNC_DEPEND(%s_gen_%s, \"%s\") { \n",
fprintf(pFile, "\nDEFINE_FUNC(%s_gen_%s, \"%s\") { \n",
pobj->data.name->string,
lvalue->name->string,
verilogparseGenExprDependStr(assignment->expr, pobj)
depend==NULL?"":depend
);
if (width <= 64)
exprstr = verilogparseGenExprStr(assignment->expr, pobj);
......
......@@ -125,7 +125,7 @@ static filestack* filestack_push_string(filestack * stack, const char * string,
pitem->pLast = stack->pLast;
pitem->pNext->pLast = pitem;
pitem->pLast->pNext = pitem;
pitem->buf = strdup(string);
pitem->buf = STRDUP(string);
pitem->buflen = strlen(string);
pitem->isbufonly = 1;
return pitem;
......
......@@ -33,6 +33,11 @@
修改记录:
202105140816: 根据git的要求增加License
*/
#ifdef WIN32
#define STRDUP _strdup
#else
#define STRDUP strdup
#endif
typedef struct s_stringitem {
struct s_stringitem * pNext;
......
......@@ -53,7 +53,11 @@ int my_printf(char* fmt, ...) {
#include "verilog_preprocess.h"
#undef IMPLEMENT_GUID
#ifdef WIN32
#define STRDUP _strdup
#else
#define STRDUP strdup
#endif
#include "stringlist.h"
#include "filestack.h"
......@@ -380,7 +384,7 @@ static int verilog_preprocess_preprocess_SetFile(HOBJECT object, const char * fi
FREE_MEMBER(cwd);
if (len > 0) {
pPreprocess->cwd = strdup(buf);
pPreprocess->cwd = STRDUP(buf);
}
}
pPreprocess->last_file_stack_top =
......@@ -618,7 +622,7 @@ static int verilog_preprocess_HandleCDName(sVerilogPreprocess * pPreprocess)
pPreprocess->tokenstate = TOKEN_NONE;
pPreprocess->tokentype = TT_NONE;
FREE_MEMBER(macro_name);
pPreprocess->macro_name = strdup(pPreprocess->token);
pPreprocess->macro_name = STRDUP(pPreprocess->token);
DLIST_DESTROY(stringitem, &pPreprocess->macro_param_list);
}
} else if (pPreprocess->tokentype == TT_ESCIDENT) {
......@@ -626,7 +630,7 @@ static int verilog_preprocess_HandleCDName(sVerilogPreprocess * pPreprocess)
pPreprocess->tokenstate = TOKEN_NONE;
pPreprocess->tokentype = TT_NONE;
FREE_MEMBER(macro_name);
pPreprocess->macro_name = strdup(pPreprocess->token);
pPreprocess->macro_name = STRDUP(pPreprocess->token);
DLIST_DESTROY(stringitem, &pPreprocess->macro_param_list);
}
pPreprocess->tokentype = TT_NONE;
......@@ -1005,7 +1009,7 @@ static int verilog_preprocess_state_undef(sVerilogPreprocess * pPreprocess, int
if (pPreprocess->tokentype == TT_SIMIDENT ||
pPreprocess->tokentype == TT_ESCIDENT) {
FREE_MEMBER(define_name);
pPreprocess->define_name = strdup(pPreprocess->token);
pPreprocess->define_name = STRDUP(pPreprocess->token);
DLIST_DESTROY(stringitem, &pPreprocess->define_param_list);
pPreprocess->tokentype = TT_NONE;
pPreprocess->tokenstate = TOKEN_NONE;
......@@ -1053,7 +1057,7 @@ static int verilog_preprocess_state_elseif(sVerilogPreprocess * pPreprocess, int
if (pPreprocess->tokentype == TT_SIMIDENT ||
pPreprocess->tokentype == TT_ESCIDENT) {
FREE_MEMBER(define_name);
pPreprocess->define_name = strdup(pPreprocess->token);
pPreprocess->define_name = STRDUP(pPreprocess->token);
DLIST_DESTROY(stringitem, &pPreprocess->define_param_list);
pPreprocess->tokentype = TT_NONE;
pPreprocess->tokenstate = TOKEN_NONE;
......@@ -1101,7 +1105,7 @@ static int verilog_preprocess_state_ifdef(sVerilogPreprocess * pPreprocess, int
if (pPreprocess->tokentype == TT_SIMIDENT ||
pPreprocess->tokentype == TT_ESCIDENT) {
FREE_MEMBER(define_name);
pPreprocess->define_name = strdup(pPreprocess->token);
pPreprocess->define_name = STRDUP(pPreprocess->token);
DLIST_DESTROY(stringitem, &pPreprocess->define_param_list);
pPreprocess->tokentype = TT_NONE;
pPreprocess->tokenstate = TOKEN_NONE;
......@@ -1149,7 +1153,7 @@ static int verilog_preprocess_state_ifndef(sVerilogPreprocess * pPreprocess, int
if (pPreprocess->tokentype == TT_SIMIDENT ||
pPreprocess->tokentype == TT_ESCIDENT) {
FREE_MEMBER(define_name);
pPreprocess->define_name = strdup(pPreprocess->token);
pPreprocess->define_name = STRDUP(pPreprocess->token);
DLIST_DESTROY(stringitem, &pPreprocess->define_param_list);
pPreprocess->tokentype = TT_NONE;
pPreprocess->tokenstate = TOKEN_NONE;
......@@ -1266,7 +1270,7 @@ static int verilog_preprocess_state_timescale(sVerilogPreprocess * pPreprocess,
} else if (pPreprocess->state == STATE_CD_TIMESCALE_UNIT_NAME) {
if (pPreprocess->tokentype == TT_SIMIDENT) {
FREE_MEMBER(time_unitname);
pPreprocess->time_unitname = strdup(pPreprocess->token);
pPreprocess->time_unitname = STRDUP(pPreprocess->token);
pPreprocess->tokentype = TT_NONE;
pPreprocess->tokenstate = TOKEN_NONE;
}
......@@ -1356,7 +1360,7 @@ static int verilog_preprocess_state_timescale(sVerilogPreprocess * pPreprocess,
} else if (pPreprocess->state == STATE_CD_TIMESCALE_PRECISION_NAME) {
if (pPreprocess->tokentype == TT_SIMIDENT) {
FREE_MEMBER(time_precisionname);
pPreprocess->time_precisionname = strdup(pPreprocess->token);
pPreprocess->time_precisionname = STRDUP(pPreprocess->token);
PRINTF("[CD] timescale %d %s/%d %s\n",
pPreprocess->time_unit,
pPreprocess->time_unitname,
......@@ -1628,7 +1632,7 @@ static int verilog_preprocess_state_define(sVerilogPreprocess * pPreprocess, int
if (pPreprocess->tokentype == TT_SIMIDENT ||
pPreprocess->tokentype == TT_ESCIDENT) {
FREE_MEMBER(define_name);
pPreprocess->define_name = strdup(pPreprocess->token);
pPreprocess->define_name = STRDUP(pPreprocess->token);
DLIST_DESTROY(stringitem, &pPreprocess->define_param_list);
pPreprocess->tokentype = TT_NONE;
}
......@@ -1674,7 +1678,7 @@ static int verilog_preprocess_state_define(sVerilogPreprocess * pPreprocess, int
} else if (pPreprocess->state == STATE_CD_DEFINE_TEXT) {
if (pPreprocess->tokentype == TT_MACRO_TEXT) {
FREE_MEMBER(define_text);
pPreprocess->define_text = strdup(pPreprocess->token);
pPreprocess->define_text = STRDUP(pPreprocess->token);
pPreprocess->state = STATE_INITIAL;
verilog_preprocess_setdefineparam(pPreprocess);
verilog_preprocess_preprocess_PreAction(pPreprocess, PA_DEFINE, pPreprocess->define_name, pPreprocess->define_text);
......@@ -1750,7 +1754,7 @@ static int verilog_preprocess_state_line(sVerilogPreprocess * pPreprocess, int c
if (pPreprocess->tokentype == TT_STRING) {
pPreprocess->tokentype = TT_NONE;
FREE_MEMBER(line_filename);
pPreprocess->line_filename = strdup(pPreprocess->token);
pPreprocess->line_filename = STRDUP(pPreprocess->token);
pPreprocess->state = STATE_CD_LINE_LEVEL;
} else if (ch == '"') {
pPreprocess->tokenlen = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册