ming_node 3.0.2 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/extlib/MingExcelTool.js +75 -0
  2. package/index.js +4 -10
  3. package/output/ming_api_mock/ming_api_mock.js +3251 -0
  4. package/output/ming_api_mock/mock.bat +21 -0
  5. package/output/ming_api_mock/mock.sh +15 -0
  6. package/output/npr/npr.bat +7 -0
  7. package/output/npr/npr_plugins/MakeModelsim/index.js +157 -0
  8. package/output/npr/npr_plugins/Modelsim/index.js +72 -0
  9. package/output/npr/npr_plugins/common/ming_node.js +58 -0
  10. package/output/npr/npr_plugins/demo/index.js +1 -0
  11. package/output/npr/npr_plugins/hello/index.js +1 -0
  12. package/output/npr/npr_plugins/install/index.js +27 -0
  13. package/output/npr/npr_plugins/list/index.js +20 -0
  14. package/output/npr/npr_plugins/verilog/Readme.md +1 -0
  15. package/output/npr/npr_plugins/verilog/breath_led/breath_led.v +99 -0
  16. package/output/npr/npr_plugins/verilog/breath_led/tb.v +39 -0
  17. package/output/npr/npr_plugins/verilog/demo/led.v +12 -0
  18. package/output/npr/npr_plugins/verilog/demo/sims/Makefile +25 -0
  19. package/output/npr/npr_plugins/verilog/demo/sims/filelist.f +1 -0
  20. package/output/npr/npr_plugins/verilog/demo/sims/run.do +3 -0
  21. package/output/npr/npr_plugins/verilog/demo/tb.v +30 -0
  22. package/output/npr/npr_plugins/verilog/index.js +25 -0
  23. package/output/npr/npr_plugins/verilog/key_led/key_debounce.v +57 -0
  24. package/output/npr/npr_plugins/verilog/key_led/tb.v +78 -0
  25. package/output/npr/npr_plugins/verilog/key_led/toggle_pin.v +35 -0
  26. package/output/npr/npr_plugins/verilog/led/led.v +12 -0
  27. package/output/npr/npr_plugins/verilog/led/tb.v +30 -0
  28. package/output/npr/npr_plugins/verilog/modelsim_tcl/filelist.f +2 -0
  29. package/output/npr/npr_plugins/verilog/modelsim_tcl/restart.tcl +1 -0
  30. package/output/npr/npr_plugins/verilog/modelsim_tcl/run.do +3 -0
  31. package/output/npr/npr_plugins/verilog/modelsim_tcl//346/216/247/345/210/266/345/217/260_Makefile +24 -0
  32. package/output/npr/npr_plugins/verilog/modelsim_tcl//347/252/227/345/217/243_Makefile +24 -0
  33. package/output/npr/npr_plugins/verilog/simple_verilog/sims/C_Makefile +27 -0
  34. package/output/npr/npr_plugins/verilog/simple_verilog/sims/Makefile +25 -0
  35. package/output/npr/npr_plugins/verilog/simple_verilog/sims/W_Makefile +24 -0
  36. package/output/npr/npr_plugins/verilog/simple_verilog/sims/filelist.f +1 -0
  37. package/output/npr/npr_plugins/verilog/simple_verilog/sims/run.do +3 -0
  38. package/output/npr/npr_plugins/verilog/simple_verilog/tb/led.sv +72 -0
  39. package/output/npr/npr_plugins/verilog/simple_verilog/tb/tb.sv +54 -0
  40. package/output/npr/npr_plugins/verilog/smg/HC_FPGA_Demo_Top.v +29 -0
  41. package/output/npr/npr_plugins/verilog/smg/digital_tube.v +93 -0
  42. package/output/npr/npr_plugins/verilog/smg/tb.v +56 -0
  43. package/output/npr/npr_plugins/verilog/uart/calc.js +4 -0
  44. package/output/npr/npr_plugins/verilog/uart/tb.v +35 -0
  45. package/output/npr/npr_plugins/verilog/uart/top_UART_RX.v +37 -0
  46. package/output/npr/npr_plugins/verilog/uart/top_UART_TX.v +41 -0
  47. package/output/npr/npr_plugins/verilog/uart/uart_rx.v +148 -0
  48. package/output/npr/npr_plugins/verilog/uart/uart_rx_led.v +23 -0
  49. package/output/npr/npr_plugins/verilog/uart/uart_tx.v +121 -0
  50. package/output/npr/npr_plugins/verilog/uart/uart_tx_count.v +72 -0
  51. package/output/npr/readme.md +7 -0
  52. package/package.json +1 -1
  53. package/plugins/Modelsim/Modelsim.js +29 -0
  54. package/plugins/Modelsim/run.bat +6 -0
  55. package/plugins/Modelsim/top.do +6 -0
@@ -0,0 +1,41 @@
1
+ `timescale 1ns / 1ns
2
+
3
+ module top_UART_TX
4
+ (
5
+ input sys_clk, //系统时钟
6
+ input sys_rst_n, //系统复位,低电平有效
7
+ output txd
8
+ );
9
+
10
+ //wire define
11
+
12
+ wire [7:0] data_inline; //UART接收数据
13
+ wire uart_send_en; //UART发送使能
14
+
15
+
16
+ wire uart_recv_done; //UART接收完成
17
+
18
+ wire [7:0] uart_send_data; //UART发送数据
19
+ wire uart_tx_busy; //UART发送忙状态标志
20
+
21
+ uart_tx#(.UART_BPS(960000)) u_uart_transmit
22
+ (
23
+ .sys_clk (sys_clk), //系统时钟
24
+ .sys_rst_n (sys_rst_n), //系统复位,低电平有效
25
+ .uart_en (uart_send_en), //发送使能信号
26
+ .uart_din (data_inline), //待发送数据
27
+ .uart_txd (txd) //UART发送端口
28
+ );
29
+
30
+
31
+
32
+
33
+ uart_tx_count#(.COUNT_200(3000)) u_uart_tx_count
34
+ (
35
+ .sys_clk (sys_clk),
36
+ .sys_rst_n (sys_rst_n),
37
+ .enable_txd (uart_send_en), //允许串口发送
38
+ .data (data_inline)
39
+ );
40
+
41
+ endmodule
@@ -0,0 +1,148 @@
1
+ `timescale 1ns / 1ns
2
+ /***************************************************************
3
+ * Copyright(C), 2022 蓝萌电子 All Rights Reserved.
4
+ * ModuleName : uart_rx.v
5
+ * Date : 2022年6月9日
6
+ * Time : 0:28:11
7
+ * Author : 沈玲玲
8
+ * Version : V1.0
9
+ * Version | Modify
10
+ * ----------------------------------
11
+ * v1.0 .....
12
+ * * Copyright: 2022 蓝萌电子 All Rights Reserved.
13
+ * *
14
+ * * This software is licensed under terms that can be found in the LICENSE file
15
+ * * in the root directory of this software component.
16
+ * * If no LICENSE file comes with this software, it is provided GPL3.0.
17
+ * *
18
+ * * Description:
19
+ ***************************************************************/
20
+
21
+
22
+
23
+ module uart_rx
24
+ #(
25
+ parameter CLK_FREQ = 50000000,
26
+ parameter UART_BPS = 9600
27
+ )
28
+ (
29
+ input sys_clk,
30
+ input sys_rst_n,
31
+ input uart_rxd,
32
+ output reg uart_done,
33
+ output reg [7:0] uart_data
34
+ );
35
+
36
+ localparam BPS_CNT = CLK_FREQ/UART_BPS;
37
+ //reg define
38
+ reg uart_rxd_d0;
39
+ reg uart_rxd_d1;
40
+ reg [15:0] clk_cnt;
41
+ reg [3:0] rx_cnt;
42
+ reg rx_flag;
43
+ reg [7:0] rxdata;
44
+
45
+ //wire define
46
+ wire start_flag;
47
+
48
+ /**
49
+ * Main Code
50
+ * 主要运行代码
51
+ **/
52
+ //捕获下降沿
53
+ assign start_flag = uart_rxd_d1&(~uart_rxd_d0);
54
+ //对UART接收端口数据延时两个周期
55
+ always @ (posedge sys_clk or negedge sys_rst_n) begin
56
+ if(!sys_rst_n) begin
57
+ uart_rxd_d0 <= 1'b0;
58
+ uart_rxd_d1 <= 1'b0;
59
+ end
60
+ else begin
61
+ uart_rxd_d0 <= uart_rxd;
62
+ uart_rxd_d1 <= uart_rxd_d0;
63
+ end
64
+ end
65
+ //检测脉冲信号srart_flag 进入接受过程
66
+ always @ (posedge sys_clk or negedge sys_rst_n) begin
67
+ if(!sys_rst_n)
68
+ rx_flag <= 1'b0;
69
+ else begin
70
+ if(start_flag)
71
+ rx_flag <= 1'b1;
72
+ else if((rx_cnt == 4'd9)&&(clk_cnt == BPS_CNT/2))
73
+ rx_flag <= 1'b0;
74
+ else
75
+ rx_flag <= rx_flag;
76
+ end
77
+ end
78
+ //进入接受过程,启动系统时钟计数器
79
+ always @ (posedge sys_clk or negedge sys_rst_n) begin
80
+ if(!sys_rst_n) begin
81
+ clk_cnt <= 16'd0;
82
+ end
83
+ else if(rx_flag) begin
84
+ if(clk_cnt < BPS_CNT -1)
85
+ clk_cnt <= clk_cnt +1'b1;
86
+ else
87
+ clk_cnt <= 16'd0;
88
+ end
89
+ else
90
+ clk_cnt <= 16'd0;
91
+ end
92
+
93
+ //进入接受过程,启动接收数据计数器
94
+ always @ (posedge sys_clk or negedge sys_rst_n) begin
95
+ if(!sys_rst_n) begin
96
+ rx_cnt <= 4'd0;
97
+ end
98
+ else if(rx_flag) begin
99
+ if(clk_cnt < BPS_CNT -1)
100
+ rx_cnt <= rx_cnt +1'b1;
101
+ else
102
+ rx_cnt <= rx_cnt;
103
+ end
104
+ else
105
+ rx_cnt <= 4'd0;
106
+ end
107
+
108
+ //根据接收数据计数器来寄存uart接收端口数据
109
+ always @(posedge sys_clk or negedge sys_rst_n) begin
110
+ if ( !sys_rst_n)
111
+ rxdata <= 8'd0;
112
+ else if(rx_flag) //系统处于接收过程
113
+ if (clk_cnt == BPS_CNT/2) begin //判断系统时钟计数器计数到数据位中间
114
+ case ( rx_cnt )
115
+ 4'd1 : rxdata[0] <= uart_rxd_d1; //寄存数据位最低位
116
+ 4'd2 : rxdata[1] <= uart_rxd_d1;
117
+ 4'd3 : rxdata[2] <= uart_rxd_d1;
118
+ 4'd4 : rxdata[3] <= uart_rxd_d1;
119
+ 4'd5 : rxdata[4] <= uart_rxd_d1;
120
+ 4'd6 : rxdata[5] <= uart_rxd_d1;
121
+ 4'd7 : rxdata[6] <= uart_rxd_d1;
122
+ 4'd8 : rxdata[7] <= uart_rxd_d1; //寄存数据位最高位
123
+ default:;
124
+ endcase
125
+ end
126
+ else
127
+ rxdata <= rxdata;
128
+ else
129
+ rxdata <= 8'd0;
130
+ end
131
+
132
+ //数据接收完毕后给出标志信号并寄存输出接收到的数据
133
+ always @(posedge sys_clk or negedge sys_rst_n) begin
134
+ if (!sys_rst_n) begin
135
+ uart_data <= 8'd0;
136
+ uart_done <= 1'b0;
137
+ end
138
+ else if(rx_cnt == 4'd9) begin //接收数据计数器计数到停止位时
139
+ uart_data <= rxdata; //寄存输出接收到的数据
140
+ uart_done <= 1'b1; //并将接收完成标志位拉高
141
+ end
142
+ else begin
143
+ uart_data <= uart_data;
144
+ uart_done <= 1'b0;
145
+ end
146
+ end
147
+
148
+ endmodule
@@ -0,0 +1,23 @@
1
+ `timescale 1ns / 1ns
2
+
3
+
4
+ module uart_rx_led
5
+ (
6
+ input [7:0] input_led,
7
+ output reg [7:0] output_led,
8
+ input sys_clk,
9
+ input sys_rst_n
10
+ );
11
+
12
+
13
+ always @ (posedge sys_clk or negedge sys_rst_n) begin
14
+ if(!sys_rst_n) begin
15
+ output_led <= 8'b1111_1111;
16
+ end
17
+ else begin
18
+ output_led <= ~input_led;
19
+ end
20
+ end
21
+
22
+
23
+ endmodule
@@ -0,0 +1,121 @@
1
+ `timescale 1ns / 1ns
2
+ module uart_tx
3
+ #(
4
+ parameter CLK_FREQ = 50000000, //系统时钟频率
5
+ parameter UART_BPS = 9600 //串口波特率
6
+ )
7
+ (
8
+ input sys_clk, //系统时钟
9
+ input sys_rst_n, //系统复位,低电平有效
10
+
11
+ input uart_en, //发送使能信号
12
+ input [7:0] uart_din, //待发送数据
13
+ output uart_tx_busy, //发送忙状态标志
14
+ output reg uart_txd //UART发送端口
15
+ );
16
+
17
+ localparam BPS_CNT = CLK_FREQ/UART_BPS;
18
+ //reg define
19
+ reg uart_en_d0;
20
+ reg uart_en_d1;
21
+ reg [15:0] clk_cnt; //系统时钟计数器
22
+ reg [ 3:0] tx_cnt; //发送数据计数器
23
+ reg tx_flag; //发送过程标志信号
24
+ reg [ 7:0] tx_data; //寄存发送数据
25
+
26
+ //wire define
27
+ wire en_flag;
28
+
29
+ /****************************************
30
+ * Main Code
31
+ * 主要代码
32
+ ****************************************/
33
+ //在串口发送过程中给出忙状态标志
34
+ assign uart_tx_busy = tx_flag;
35
+
36
+ //捕获uart_en上升沿,得到一个时钟周期的脉冲信号
37
+ assign en_flag = (~uart_en_d1) & uart_en_d0;
38
+
39
+ always @ (posedge sys_clk or negedge sys_rst_n) begin
40
+ if(!sys_rst_n) begin
41
+ uart_en_d0 <= 1'b0;
42
+ uart_en_d1 <= 1'b0;
43
+ end
44
+ else begin
45
+ uart_en_d0 <= uart_en;
46
+ uart_en_d1 <= uart_en_d0;
47
+ end
48
+ end
49
+
50
+ //当脉冲信号en_flag到达时,寄存待发送的数据,并进入发送过程
51
+ always @(posedge sys_clk or negedge sys_rst_n) begin
52
+ if (!sys_rst_n) begin
53
+ tx_flag <= 1'b0;
54
+ tx_data <= 8'd0;
55
+ end
56
+ else if (en_flag) begin //检测到发送使能上升沿
57
+ tx_flag <= 1'b1; //进入发送过程,标志位tx_flag拉高
58
+ tx_data <= uart_din; //寄存待发送的数据
59
+ end
60
+ //计数到停止位结束时,停止发送过程
61
+ else if ((tx_cnt == 4'd9) && (clk_cnt == BPS_CNT -(BPS_CNT/16))) begin
62
+ tx_flag <= 1'b0; //发送过程结束,标志位tx_flag拉低
63
+ tx_data <= 8'd0;
64
+ end
65
+ else begin
66
+ tx_flag <= tx_flag;
67
+ tx_data <= tx_data;
68
+ end
69
+ end
70
+
71
+ //进入发送过程后,启动系统时钟计数器
72
+ always @(posedge sys_clk or negedge sys_rst_n) begin
73
+ if (!sys_rst_n)
74
+ clk_cnt <= 16'd0;
75
+ else if (tx_flag) begin //处于发送过程
76
+ if (clk_cnt < BPS_CNT - 1)
77
+ clk_cnt <= clk_cnt + 1'b1;
78
+ else
79
+ clk_cnt <= 16'd0; //对系统时钟计数达一个波特率周期后清零
80
+ end
81
+ else
82
+ clk_cnt <= 16'd0; //发送过程结束
83
+ end
84
+
85
+ //进入发送过程后,启动发送数据计数器
86
+ always @(posedge sys_clk or negedge sys_rst_n) begin
87
+ if (!sys_rst_n)
88
+ tx_cnt <= 4'd0;
89
+ else if (tx_flag) begin //处于发送过程
90
+ if (clk_cnt == BPS_CNT - 1) //对系统时钟计数达一个波特率周期
91
+ tx_cnt <= tx_cnt + 1'b1; //此时发送数据计数器加1
92
+ else
93
+ tx_cnt <= tx_cnt;
94
+ end
95
+ else
96
+ tx_cnt <= 4'd0; //发送过程结束
97
+ end
98
+
99
+ //根据发送数据计数器来给uart发送端口赋值
100
+ always @(posedge sys_clk or negedge sys_rst_n) begin
101
+ if (!sys_rst_n)
102
+ uart_txd <= 1'b1;
103
+ else if (tx_flag)
104
+ case(tx_cnt)
105
+ 4'd0: uart_txd <= 1'b0; //起始位
106
+ 4'd1: uart_txd <= tx_data[0]; //数据位最低位
107
+ 4'd2: uart_txd <= tx_data[1];
108
+ 4'd3: uart_txd <= tx_data[2];
109
+ 4'd4: uart_txd <= tx_data[3];
110
+ 4'd5: uart_txd <= tx_data[4];
111
+ 4'd6: uart_txd <= tx_data[5];
112
+ 4'd7: uart_txd <= tx_data[6];
113
+ 4'd8: uart_txd <= tx_data[7]; //数据位最高位
114
+ 4'd9: uart_txd <= 1'b1; //停止位
115
+ default: ;
116
+ endcase
117
+ else
118
+ uart_txd <= 1'b1; //空闲时发送端口为高电平
119
+ end
120
+
121
+ endmodule
@@ -0,0 +1,72 @@
1
+ `timescale 1ns / 1ns
2
+
3
+ module uart_tx_count
4
+ #(
5
+ parameter COUNT_200 = 26'd10000000
6
+ )
7
+ (
8
+ input sys_clk,
9
+ input sys_rst_n,
10
+ output reg enable_txd, //允许串口发送
11
+ output reg [7:0] data
12
+ );
13
+
14
+ reg [25:0] clk_cnt; //计数器
15
+ reg [3:0] dat_cnt;//数据计数器,发送第几个
16
+
17
+
18
+
19
+
20
+ always @ (posedge sys_clk or negedge sys_rst_n) begin
21
+ if(!sys_rst_n) begin
22
+ clk_cnt <= 26'b0;
23
+ end
24
+ else if(clk_cnt == COUNT_200) begin
25
+ clk_cnt <= 26'b0;
26
+ end
27
+ else begin
28
+ clk_cnt <= clk_cnt + 1'b1;
29
+ end
30
+ end
31
+
32
+ always @ (posedge sys_clk or negedge sys_rst_n) begin
33
+ if(!sys_rst_n) begin
34
+ dat_cnt <= 4'b0;
35
+ enable_txd <= 1'b0;
36
+ end
37
+ else if(clk_cnt == COUNT_200 - 1'b1) begin
38
+ dat_cnt <= dat_cnt + 1'b1;
39
+ enable_txd <= 1'b1;
40
+ end
41
+ else
42
+ enable_txd <= 1'b0;
43
+ end
44
+
45
+ always @ (posedge sys_clk or negedge sys_rst_n) begin
46
+ if(!sys_rst_n) begin
47
+ data <= 8'b0;
48
+ end
49
+ else begin
50
+ case(dat_cnt)
51
+ 4'd0:data <= 8'b00110000;
52
+ 4'd1:data <= 8'b00110001;
53
+ 4'd2:data <= 8'b00110010;
54
+ 4'd3:data <= 8'b00110011;
55
+ 4'd4:data <= 8'b00110100;
56
+ 4'd5:data <= 8'b00110101;
57
+ 4'd6:data <= 8'b00110110;
58
+ 4'd7:data <= 8'b00110111;
59
+ 4'd8:data <= 8'b00111000;
60
+ 4'd9:data <= 8'b00111001;
61
+ 4'd10:data <= 8'b00111010;
62
+ 4'd11:data <= 8'b00111011;
63
+ 4'd12:data <= 8'b00111100;
64
+ 4'd13:data <= 8'b00111101;
65
+ 4'd14:data <= 8'b00111110;
66
+ 4'd15:data <= 8'b00111111;
67
+ default:;
68
+ endcase
69
+ end
70
+ end
71
+
72
+ endmodule
@@ -0,0 +1,7 @@
1
+ # npr
2
+
3
+ npr 用于执行个js文件
4
+
5
+ ```markdown
6
+ npr hello
7
+ ```
package/package.json CHANGED
@@ -46,5 +46,5 @@
46
46
  "scripts": {
47
47
  "test": "echo \"Error: no test specified\" && exit 1"
48
48
  },
49
- "version": "3.0.2"
49
+ "version": "3.0.5"
50
50
  }
@@ -0,0 +1,29 @@
1
+ /**
2
+ build/CUR_DIR
3
+ led/tb.v led.v
4
+ */
5
+
6
+ const fs = require('fs');
7
+
8
+ fs.writeFileSync('run.bat',
9
+
10
+ `rmdir /s /q work
11
+ del server.js
12
+ del vsim.wlf
13
+ del transcript
14
+ set MY_PARAM=%1%
15
+ modelsim -do top.do`
16
+
17
+ );
18
+
19
+
20
+ fs.writeFileSync('top.do',
21
+
22
+ `vlib work
23
+ vmap work work
24
+ vlog ../$::env(MY_PARAM)/*.v
25
+ vsim -voptargs=+acc work.tb
26
+ add wave -position insertpoint sim:/tb/*
27
+ run 100ns`
28
+
29
+ );
@@ -0,0 +1,6 @@
1
+ rmdir /s /q work
2
+ del server.js
3
+ del vsim.wlf
4
+ del transcript
5
+ set MY_PARAM=%1%
6
+ modelsim -do top.do
@@ -0,0 +1,6 @@
1
+ vlib work
2
+ vmap work work
3
+ vlog ../$::env(MY_PARAM)/*.v
4
+ vsim -voptargs=+acc work.tb
5
+ add wave -position insertpoint sim:/tb/*
6
+ run 100ns