ming_node 3.0.3 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +0 -7
- package/output/ming_api_mock/ming_api_mock.js +3251 -0
- package/output/ming_api_mock/mock.bat +21 -0
- package/output/ming_api_mock/mock.sh +15 -0
- package/output/npr/npr.bat +7 -0
- package/output/npr/npr_plugins/MakeModelsim/index.js +157 -0
- package/output/npr/npr_plugins/Modelsim/index.js +72 -0
- package/output/npr/npr_plugins/common/ming_node.js +58 -0
- package/output/npr/npr_plugins/demo/index.js +1 -0
- package/output/npr/npr_plugins/hello/index.js +1 -0
- package/output/npr/npr_plugins/install/index.js +27 -0
- package/output/npr/npr_plugins/list/index.js +20 -0
- package/output/npr/npr_plugins/verilog/Readme.md +1 -0
- package/output/npr/npr_plugins/verilog/breath_led/breath_led.v +99 -0
- package/output/npr/npr_plugins/verilog/breath_led/tb.v +39 -0
- package/output/npr/npr_plugins/verilog/demo/led.v +12 -0
- package/output/npr/npr_plugins/verilog/demo/sims/Makefile +25 -0
- package/output/npr/npr_plugins/verilog/demo/sims/filelist.f +1 -0
- package/output/npr/npr_plugins/verilog/demo/sims/run.do +3 -0
- package/output/npr/npr_plugins/verilog/demo/tb.v +30 -0
- package/output/npr/npr_plugins/verilog/index.js +25 -0
- package/output/npr/npr_plugins/verilog/key_led/key_debounce.v +57 -0
- package/output/npr/npr_plugins/verilog/key_led/tb.v +78 -0
- package/output/npr/npr_plugins/verilog/key_led/toggle_pin.v +35 -0
- package/output/npr/npr_plugins/verilog/led/led.v +12 -0
- package/output/npr/npr_plugins/verilog/led/tb.v +30 -0
- package/output/npr/npr_plugins/verilog/modelsim_tcl/filelist.f +2 -0
- package/output/npr/npr_plugins/verilog/modelsim_tcl/restart.tcl +1 -0
- package/output/npr/npr_plugins/verilog/modelsim_tcl/run.do +3 -0
- package/output/npr/npr_plugins/verilog/modelsim_tcl//346/216/247/345/210/266/345/217/260_Makefile +24 -0
- package/output/npr/npr_plugins/verilog/modelsim_tcl//347/252/227/345/217/243_Makefile +24 -0
- package/output/npr/npr_plugins/verilog/simple_verilog/sims/C_Makefile +27 -0
- package/output/npr/npr_plugins/verilog/simple_verilog/sims/Makefile +25 -0
- package/output/npr/npr_plugins/verilog/simple_verilog/sims/W_Makefile +24 -0
- package/output/npr/npr_plugins/verilog/simple_verilog/sims/filelist.f +1 -0
- package/output/npr/npr_plugins/verilog/simple_verilog/sims/run.do +3 -0
- package/output/npr/npr_plugins/verilog/simple_verilog/tb/led.sv +72 -0
- package/output/npr/npr_plugins/verilog/simple_verilog/tb/tb.sv +54 -0
- package/output/npr/npr_plugins/verilog/smg/HC_FPGA_Demo_Top.v +29 -0
- package/output/npr/npr_plugins/verilog/smg/digital_tube.v +93 -0
- package/output/npr/npr_plugins/verilog/smg/tb.v +56 -0
- package/output/npr/npr_plugins/verilog/uart/calc.js +4 -0
- package/output/npr/npr_plugins/verilog/uart/tb.v +35 -0
- package/output/npr/npr_plugins/verilog/uart/top_UART_RX.v +37 -0
- package/output/npr/npr_plugins/verilog/uart/top_UART_TX.v +41 -0
- package/output/npr/npr_plugins/verilog/uart/uart_rx.v +148 -0
- package/output/npr/npr_plugins/verilog/uart/uart_rx_led.v +23 -0
- package/output/npr/npr_plugins/verilog/uart/uart_tx.v +121 -0
- package/output/npr/npr_plugins/verilog/uart/uart_tx_count.v +72 -0
- package/output/npr/readme.md +7 -0
- package/package.json +1 -1
- package/plugins/Modelsim/Modelsim.js +29 -0
- package/plugins/Modelsim/run.bat +6 -0
- package/plugins/Modelsim/top.do +6 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
|
2
|
+
`timescale 1ns / 1ns //仿真单位/仿真精度
|
3
|
+
|
4
|
+
module tb();
|
5
|
+
|
6
|
+
//parameter define
|
7
|
+
parameter CLK_PERIOD = 10; //时钟周期 10ns
|
8
|
+
parameter CNT_MAX = 20'd10; //消抖时间 10ns
|
9
|
+
|
10
|
+
//reg define
|
11
|
+
reg sys_clk;
|
12
|
+
reg sys_rst_n;
|
13
|
+
reg key;
|
14
|
+
|
15
|
+
wire key_out;
|
16
|
+
wire beep;
|
17
|
+
|
18
|
+
//信号初始化
|
19
|
+
initial begin
|
20
|
+
sys_clk <= 1'b0;
|
21
|
+
sys_rst_n <= 1'b0;
|
22
|
+
key <= 1'b1;
|
23
|
+
#200
|
24
|
+
sys_rst_n <= 1'b1;
|
25
|
+
//key信号变化
|
26
|
+
#20
|
27
|
+
key <= 1'b0;
|
28
|
+
#20
|
29
|
+
key <= 1'b1;
|
30
|
+
#50
|
31
|
+
key <= 1'b0;
|
32
|
+
#40
|
33
|
+
key <= 1'b1;
|
34
|
+
#20
|
35
|
+
key <= 1'b0;
|
36
|
+
#300
|
37
|
+
key <= 1'b1;
|
38
|
+
#50
|
39
|
+
key <= 1'b0;
|
40
|
+
#40
|
41
|
+
key <= 1'b1;
|
42
|
+
#300
|
43
|
+
key <= 1'b0;
|
44
|
+
#300
|
45
|
+
key <= 1'b1;
|
46
|
+
#500
|
47
|
+
key <= 1'b0;
|
48
|
+
#500
|
49
|
+
key <= 1'b1;
|
50
|
+
#500
|
51
|
+
key <= 1'b0;
|
52
|
+
#500
|
53
|
+
key <= 1'b1;
|
54
|
+
end
|
55
|
+
|
56
|
+
//产生时钟
|
57
|
+
always #(CLK_PERIOD/2) sys_clk = ~sys_clk;
|
58
|
+
|
59
|
+
//按键消抖
|
60
|
+
key_debounce #(
|
61
|
+
.MAX_CNT (CNT_MAX)
|
62
|
+
)u_top_key_beep(
|
63
|
+
.clk (sys_clk),
|
64
|
+
.rst_n (sys_rst_n),
|
65
|
+
.key_in (key),
|
66
|
+
.key_out(key_out)
|
67
|
+
);
|
68
|
+
|
69
|
+
//灯取反
|
70
|
+
toggle_pin u_toggle_pin(
|
71
|
+
.clk (sys_clk),
|
72
|
+
.rst_n (sys_rst_n),
|
73
|
+
.in_pin(~key_out),
|
74
|
+
.out_pin(beep)
|
75
|
+
);
|
76
|
+
|
77
|
+
endmodule
|
78
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module toggle_pin(
|
2
|
+
input clk,
|
3
|
+
input rst_n,
|
4
|
+
input in_pin,
|
5
|
+
output reg out_pin
|
6
|
+
);
|
7
|
+
|
8
|
+
|
9
|
+
reg in_pin_d0; //将消抖后的按键值延迟一个时钟周期
|
10
|
+
reg in_pin_d1;
|
11
|
+
|
12
|
+
|
13
|
+
always @ (posedge clk or negedge rst_n) begin
|
14
|
+
if(!rst_n) begin
|
15
|
+
in_pin_d0 <= 1'b1;
|
16
|
+
in_pin_d1 <= 1'b1;
|
17
|
+
end
|
18
|
+
else begin
|
19
|
+
in_pin_d0 <= in_pin;
|
20
|
+
in_pin_d1 <= in_pin_d0;
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
//每次按键按下时,就翻转蜂鸣器的状态
|
26
|
+
always @ (posedge clk or negedge rst_n) begin
|
27
|
+
if(!rst_n)
|
28
|
+
out_pin <= 1'b1;
|
29
|
+
else if(in_pin_d0==0 && in_pin_d1 == 1)
|
30
|
+
out_pin <= ~out_pin;
|
31
|
+
else
|
32
|
+
out_pin <= out_pin;
|
33
|
+
end
|
34
|
+
|
35
|
+
endmodule
|
@@ -0,0 +1,30 @@
|
|
1
|
+
`timescale 1ns / 1ns //���浥λ/���澫��
|
2
|
+
|
3
|
+
module tb();
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
reg key;
|
8
|
+
wire led;
|
9
|
+
|
10
|
+
|
11
|
+
initial begin
|
12
|
+
key <= 1'b1;
|
13
|
+
#2
|
14
|
+
key <= 1'b1;
|
15
|
+
#3
|
16
|
+
key <= 1'b0;
|
17
|
+
#2
|
18
|
+
key <= 1'b1;
|
19
|
+
#2
|
20
|
+
key <= 1'b0;
|
21
|
+
end
|
22
|
+
|
23
|
+
//����ledģ��
|
24
|
+
led u_led(
|
25
|
+
.key (key),
|
26
|
+
.led (led)
|
27
|
+
);
|
28
|
+
|
29
|
+
endmodule
|
30
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
vlog -f filelist.f;restart -f;run 100ns
|
package/output/npr/npr_plugins/verilog/modelsim_tcl//346/216/247/345/210/266/345/217/260_Makefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#setting parameter
|
2
|
+
work= work
|
3
|
+
output= ../opt
|
4
|
+
vsimbatch0= -do "run -all"
|
5
|
+
|
6
|
+
|
7
|
+
#commandbegin
|
8
|
+
all:compile vsim
|
9
|
+
lib:
|
10
|
+
echo "start compile for Questasim10.6c"
|
11
|
+
vlib $(work)
|
12
|
+
vmap work $(work)
|
13
|
+
vlog :
|
14
|
+
vlog -f filelist.f -l $(output)/compile.log
|
15
|
+
compile: lib vlog
|
16
|
+
run:
|
17
|
+
vsim work.tb -l tb.log -c -do "run -all;exit;"
|
18
|
+
#make clean
|
19
|
+
clean:
|
20
|
+
del *.wlf
|
21
|
+
del vsim_stacktrace.vstf
|
22
|
+
del transcript
|
23
|
+
del modelsim.ini
|
24
|
+
rmdir /s /q work
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#setting parameter
|
2
|
+
work= work
|
3
|
+
output= ../opt
|
4
|
+
vsimbatch0= -do "run -all"
|
5
|
+
|
6
|
+
|
7
|
+
#commandbegin
|
8
|
+
all:compile vsim
|
9
|
+
lib:
|
10
|
+
echo "start compile for Questasim10.6c"
|
11
|
+
vlib $(work)
|
12
|
+
vmap work $(work)
|
13
|
+
vlog :
|
14
|
+
vlog -f filelist.f -l $(output)/compile.log
|
15
|
+
compile: lib vlog
|
16
|
+
run:
|
17
|
+
modelsim -do ./run.do
|
18
|
+
#make clean
|
19
|
+
clean:
|
20
|
+
del *.wlf
|
21
|
+
del vsim_stacktrace.vstf
|
22
|
+
del transcript
|
23
|
+
del modelsim.ini
|
24
|
+
rmdir /s /q work
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#setting parameter
|
2
|
+
work= work
|
3
|
+
output= ./
|
4
|
+
vsimbatch0= -do "run -all"
|
5
|
+
|
6
|
+
#commandbegin
|
7
|
+
all:compile vsim
|
8
|
+
lib:
|
9
|
+
echo "start compile for Questasim10.6c"
|
10
|
+
vlib $(work)
|
11
|
+
vmap work $(work)
|
12
|
+
vlog :
|
13
|
+
vlog -f filelist.f -l $(output)/compile.log
|
14
|
+
compile: lib vlog
|
15
|
+
run:
|
16
|
+
vsim work.tb -l tb.log -c -do "run -all;exit;"
|
17
|
+
restart:
|
18
|
+
vlog -f filelist.f -l $(output)/compile.log
|
19
|
+
vsim work.tb -l tb.log -c -do "run -all;exit;"
|
20
|
+
#make clean
|
21
|
+
clean:
|
22
|
+
del *.log
|
23
|
+
del *.wlf
|
24
|
+
del vsim_stacktrace.vstf
|
25
|
+
del transcript
|
26
|
+
del modelsim.ini
|
27
|
+
rmdir /s /q work
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#setting parameter
|
2
|
+
work= work
|
3
|
+
output= ./
|
4
|
+
vsimbatch0= -do "run -all"
|
5
|
+
|
6
|
+
|
7
|
+
#commandbegin
|
8
|
+
all:compile vsim
|
9
|
+
lib:
|
10
|
+
echo "start compile for Questasim10.6c"
|
11
|
+
vlib $(work)
|
12
|
+
vmap work $(work)
|
13
|
+
vlog :
|
14
|
+
vlog -f filelist.f -l $(output)/compile.log
|
15
|
+
compile: lib vlog
|
16
|
+
run:
|
17
|
+
modelsim -do ./run.do
|
18
|
+
#make clean
|
19
|
+
clean:
|
20
|
+
del *.log
|
21
|
+
del *.wlf
|
22
|
+
del vsim_stacktrace.vstf
|
23
|
+
del transcript
|
24
|
+
del modelsim.ini
|
25
|
+
rmdir /s /q work
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#setting parameter
|
2
|
+
work= work
|
3
|
+
output= ../opt
|
4
|
+
vsimbatch0= -do "run -all"
|
5
|
+
|
6
|
+
|
7
|
+
#commandbegin
|
8
|
+
all:compile vsim
|
9
|
+
lib:
|
10
|
+
echo "start compile for Questasim10.6c"
|
11
|
+
vlib $(work)
|
12
|
+
vmap work $(work)
|
13
|
+
vlog :
|
14
|
+
vlog -f filelist.f -l $(output)/compile.log
|
15
|
+
compile: lib vlog
|
16
|
+
run:
|
17
|
+
modelsim -do ./run.do
|
18
|
+
#make clean
|
19
|
+
clean:
|
20
|
+
del *.wlf
|
21
|
+
del vsim_stacktrace.vstf
|
22
|
+
del transcript
|
23
|
+
del modelsim.ini
|
24
|
+
rmdir /s /q work
|
@@ -0,0 +1 @@
|
|
1
|
+
"../tb/*v"
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module led(
|
2
|
+
input clk,
|
3
|
+
input rst_n,
|
4
|
+
input key,
|
5
|
+
output wire[2:0] led
|
6
|
+
);
|
7
|
+
|
8
|
+
typedef enum reg [2:0] {
|
9
|
+
S0,
|
10
|
+
S1,
|
11
|
+
S2,
|
12
|
+
S3
|
13
|
+
} state_t;
|
14
|
+
state_t state_c=S0, state_n=S0;
|
15
|
+
logic s0_s1_start;
|
16
|
+
logic s1_s2_start;
|
17
|
+
logic s2_s3_start;
|
18
|
+
|
19
|
+
|
20
|
+
always@(posedge clk or negedge rst_n)begin
|
21
|
+
if(!rst_n)begin
|
22
|
+
state_c <= S0;
|
23
|
+
end
|
24
|
+
else begin
|
25
|
+
state_c <= state_n;
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
always@(*)begin
|
30
|
+
case(state_c)
|
31
|
+
S0: begin
|
32
|
+
if(s0_s1_start)begin
|
33
|
+
state_n = S1;
|
34
|
+
end
|
35
|
+
else begin
|
36
|
+
state_n = state_c;
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
S1:begin
|
41
|
+
if(s1_s2_start)begin
|
42
|
+
state_n = S2;
|
43
|
+
end
|
44
|
+
else begin
|
45
|
+
state_n = state_c;
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
S2:begin
|
50
|
+
if(s2_s3_start)begin
|
51
|
+
state_n = S3;
|
52
|
+
end
|
53
|
+
else begin
|
54
|
+
state_n = state_c;
|
55
|
+
end
|
56
|
+
end
|
57
|
+
default:begin
|
58
|
+
state_n = S0;
|
59
|
+
end
|
60
|
+
endcase
|
61
|
+
end
|
62
|
+
|
63
|
+
assign s0_s1_start = state_c==S0 ;
|
64
|
+
assign s1_s2_start = state_c==S1 ;
|
65
|
+
assign s2_s3_start = state_c==S2 ;
|
66
|
+
|
67
|
+
|
68
|
+
assign led=state_c;
|
69
|
+
|
70
|
+
|
71
|
+
endmodule
|
72
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
`timescale 1ns / 1ns
|
2
|
+
|
3
|
+
module tb();
|
4
|
+
|
5
|
+
|
6
|
+
parameter PERIOD = 10;
|
7
|
+
|
8
|
+
reg clk=1;
|
9
|
+
reg rst_n=1;
|
10
|
+
reg key;
|
11
|
+
wire[2:0] led;
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
initial begin
|
16
|
+
forever #(PERIOD/2) clk=~clk;
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
initial begin
|
22
|
+
$monitor ("rst_n=%0b led=%0b",rst_n, led);
|
23
|
+
#(PERIOD*2)
|
24
|
+
rst_n = 1;
|
25
|
+
key <= 1'b1;
|
26
|
+
#(PERIOD*2)
|
27
|
+
key <= 1'b1;
|
28
|
+
#(PERIOD*2)
|
29
|
+
key <= 1'b0;
|
30
|
+
#(PERIOD*2)
|
31
|
+
key <= 1'b1;
|
32
|
+
#(PERIOD*2)
|
33
|
+
key <= 1'b0;
|
34
|
+
#(PERIOD*2)
|
35
|
+
key <= 1'b1;
|
36
|
+
#(PERIOD*2)
|
37
|
+
key <= 1'b0;
|
38
|
+
#(PERIOD*2)
|
39
|
+
key <= 1'b1;
|
40
|
+
#(PERIOD*2)
|
41
|
+
key <= 1'b0;
|
42
|
+
$display("TTTT");
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
led u_led(
|
47
|
+
.clk (clk),
|
48
|
+
.rst_n (rst_n),
|
49
|
+
.key (key),
|
50
|
+
.led (led)
|
51
|
+
);
|
52
|
+
|
53
|
+
endmodule
|
54
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module HC_FPGA_Demo_Top
|
2
|
+
(
|
3
|
+
input CLOCK_XTAL_50MHz,
|
4
|
+
input RESET,
|
5
|
+
output[7:0] DIG,
|
6
|
+
output[5:0] SEL
|
7
|
+
);
|
8
|
+
|
9
|
+
|
10
|
+
wire[3:0] d0=5;
|
11
|
+
wire[3:0] d1=2;
|
12
|
+
wire[3:0] d2=1;
|
13
|
+
wire[3:0] d3=7;
|
14
|
+
|
15
|
+
|
16
|
+
digital_tube u_digital_tube (
|
17
|
+
.clk ( CLOCK_XTAL_50MHz ),
|
18
|
+
.rst_n ( RESET ),
|
19
|
+
.d0 ( d0 ),
|
20
|
+
.d1 ( d1 ),
|
21
|
+
.d2 ( d2 ),
|
22
|
+
.d3 ( d3 ),
|
23
|
+
.dp_in ( ~0 ),
|
24
|
+
.sel ( SEL [5:0] ),
|
25
|
+
.dig ( DIG [7:0] )
|
26
|
+
);
|
27
|
+
|
28
|
+
|
29
|
+
endmodule
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module digital_tube(
|
2
|
+
input clk,
|
3
|
+
input rst_n,
|
4
|
+
input [3:0] d0, //第一个数码管显示的数字
|
5
|
+
input [3:0] d1,
|
6
|
+
input [3:0] d2,
|
7
|
+
input [3:0] d3,
|
8
|
+
input [3:0] dp_in, //小数点控制
|
9
|
+
output reg [5:0] sel, //片选
|
10
|
+
output reg [7:0] dig //段选
|
11
|
+
);
|
12
|
+
|
13
|
+
localparam N = 16; //使用低16位对50Mhz的时钟进行分频(50MHZ/2^16)
|
14
|
+
localparam
|
15
|
+
NUM0 = ~8'h3f,
|
16
|
+
NUM1 = ~8'h06,
|
17
|
+
NUM2 = ~8'h5b,
|
18
|
+
NUM3 = ~8'h4f,
|
19
|
+
NUM4 = ~8'h66,
|
20
|
+
NUM5 = ~8'h6d,
|
21
|
+
NUM6 = ~8'h7d,
|
22
|
+
NUM7 = ~8'h07,
|
23
|
+
NUM8 = ~8'h7f,
|
24
|
+
NUM9 = ~8'h6f,
|
25
|
+
NUMA = ~8'h77,
|
26
|
+
NUMB = ~8'h7c,
|
27
|
+
NUMC = ~8'h39,
|
28
|
+
NUMD = ~8'h5e,
|
29
|
+
NUME = ~8'h79,
|
30
|
+
NUMF = ~8'h71;
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
reg [N-1:0] regN; //高两位作为控制信号,低16位为计数器,对时钟进行分频
|
35
|
+
reg [3:0] hex_in; //段选控制信号
|
36
|
+
reg dp;
|
37
|
+
|
38
|
+
always@(posedge clk or negedge rst_n)
|
39
|
+
begin
|
40
|
+
if(rst_n==0)
|
41
|
+
regN <= 0;
|
42
|
+
else
|
43
|
+
regN <= regN + 1;
|
44
|
+
end
|
45
|
+
|
46
|
+
always@(*) begin
|
47
|
+
case(regN[N-1:N-2])
|
48
|
+
2'b00:begin
|
49
|
+
sel = 6'b111110; //选中第1个数码管
|
50
|
+
hex_in = d0; //数码管显示的数字由hex_in控制,显示d0输入的数字;
|
51
|
+
dp = dp_in[0]; //控制该数码管的小数点的亮灭
|
52
|
+
end
|
53
|
+
2'b01:begin
|
54
|
+
sel = 6'b111101; //选中第二个数码管
|
55
|
+
hex_in = d1;
|
56
|
+
dp = dp_in[1];
|
57
|
+
end
|
58
|
+
2'b10:begin
|
59
|
+
sel = 6'b111011;
|
60
|
+
hex_in = d2;
|
61
|
+
dp = dp_in[2];
|
62
|
+
end
|
63
|
+
default:begin
|
64
|
+
sel = 6'b110111;
|
65
|
+
hex_in = d3;
|
66
|
+
dp = dp_in[3];
|
67
|
+
end
|
68
|
+
endcase
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
always@(posedge clk) begin
|
73
|
+
case(hex_in)
|
74
|
+
4'h0: dig[7:0] = NUM0;
|
75
|
+
4'h1: dig[7:0] = NUM1;
|
76
|
+
4'h2: dig[7:0] = NUM2;
|
77
|
+
4'h3: dig[7:0] = NUM3;
|
78
|
+
4'h4: dig[7:0] = NUM4;
|
79
|
+
4'h5: dig[7:0] = NUM5;
|
80
|
+
4'h6: dig[7:0] = NUM6;
|
81
|
+
4'h7: dig[7:0] = NUM7;
|
82
|
+
4'h8: dig[7:0] = NUM8;
|
83
|
+
4'h9: dig[7:0] = NUM9;
|
84
|
+
4'ha: dig[7:0] = NUMA;
|
85
|
+
4'hb: dig[7:0] = NUMB;
|
86
|
+
4'hc: dig[7:0] = NUMC;
|
87
|
+
4'hd: dig[7:0] = NUMD;
|
88
|
+
4'he: dig[7:0] = NUME;
|
89
|
+
default: dig[6:0] = 7'b0111000;
|
90
|
+
endcase
|
91
|
+
dig[7] = dp;
|
92
|
+
end
|
93
|
+
endmodule
|
@@ -0,0 +1,56 @@
|
|
1
|
+
`timescale 1ns / 1ps
|
2
|
+
|
3
|
+
module tb;
|
4
|
+
|
5
|
+
// digital_tube Parameters
|
6
|
+
parameter PERIOD = 10;
|
7
|
+
|
8
|
+
|
9
|
+
// digital_tube Inputs
|
10
|
+
reg clk = 0 ;
|
11
|
+
reg rst_n = 0 ;
|
12
|
+
reg[3:0] d0=4'b0011;
|
13
|
+
reg[3:0] d1=4'b0111;
|
14
|
+
reg[3:0] d2=4'b1111;
|
15
|
+
reg[3:0] d3=4'b1011;
|
16
|
+
reg [3:0] dp_in = 0 ;
|
17
|
+
|
18
|
+
// digital_tube Outputs
|
19
|
+
wire [3:0] sel ;
|
20
|
+
wire [7:0] dig ;
|
21
|
+
|
22
|
+
|
23
|
+
initial begin
|
24
|
+
forever #(PERIOD/2) clk=~clk;
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
initial begin
|
30
|
+
#(PERIOD*2)
|
31
|
+
rst_n = 1;
|
32
|
+
d0=4'b0001;
|
33
|
+
#(PERIOD*2)
|
34
|
+
d0=4'b0011;
|
35
|
+
#(PERIOD*2)
|
36
|
+
d0=4'b0110;
|
37
|
+
#(PERIOD*2)
|
38
|
+
d0=4'b0111;
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
digital_tube u_digital_tube (
|
43
|
+
.clk ( clk ),
|
44
|
+
.rst_n ( rst_n ),
|
45
|
+
.d0 ( d0 ),
|
46
|
+
.d1 ( d1 ),
|
47
|
+
.d2 ( d2 ),
|
48
|
+
.d3 ( d3 ),
|
49
|
+
.dp_in ( d3 ),
|
50
|
+
.sel (sel),
|
51
|
+
.dig (dig )
|
52
|
+
);
|
53
|
+
|
54
|
+
|
55
|
+
endmodule
|
56
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
`timescale 1ns / 1ns
|
2
|
+
|
3
|
+
module tb;
|
4
|
+
|
5
|
+
// digital_tube Parameters
|
6
|
+
parameter PERIOD = 2;
|
7
|
+
|
8
|
+
|
9
|
+
// digital_tube Inputs
|
10
|
+
reg clk = 0 ;
|
11
|
+
reg rst_n = 1 ;
|
12
|
+
wire txd;
|
13
|
+
|
14
|
+
initial begin
|
15
|
+
forever #(PERIOD/2) clk=~clk;
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
initial begin
|
20
|
+
#(PERIOD*2)
|
21
|
+
rst_n = 0;
|
22
|
+
#(PERIOD*2)
|
23
|
+
rst_n = 1;
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
top_UART_TX u_top_UART_TX (
|
28
|
+
.sys_clk ( clk ),
|
29
|
+
.sys_rst_n ( rst_n ),
|
30
|
+
.txd ( txd )
|
31
|
+
);
|
32
|
+
|
33
|
+
|
34
|
+
endmodule
|
35
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
`timescale 1ns / 1ns
|
2
|
+
module top_UART_RX
|
3
|
+
(
|
4
|
+
input sys_clk,
|
5
|
+
input sys_rst_n,
|
6
|
+
input rxd,
|
7
|
+
//write wire
|
8
|
+
output wire [7:0] led_output
|
9
|
+
);
|
10
|
+
|
11
|
+
wire [7:0] rxd_data;
|
12
|
+
/****************************************
|
13
|
+
* Main Code
|
14
|
+
* 主要代码
|
15
|
+
****************************************/
|
16
|
+
|
17
|
+
//串口接收模块
|
18
|
+
uart_rx u_uart_recv
|
19
|
+
(
|
20
|
+
.sys_clk (sys_clk),
|
21
|
+
.sys_rst_n (sys_rst_n),
|
22
|
+
|
23
|
+
.uart_rxd (rxd),
|
24
|
+
.uart_data (rxd_data)
|
25
|
+
);
|
26
|
+
|
27
|
+
//LED灯
|
28
|
+
uart_rx_led u_uart_rx_led
|
29
|
+
(
|
30
|
+
.input_led (rxd_data),
|
31
|
+
.output_led (led_output),
|
32
|
+
.sys_clk (sys_clk),
|
33
|
+
.sys_rst_n (sys_rst_n)
|
34
|
+
);
|
35
|
+
|
36
|
+
|
37
|
+
endmodule
|