仿真通过
parent
720eabcfe4
commit
77caedf906
@ -0,0 +1,97 @@
|
||||
#! /usr/local/Cellar/icarus-verilog/12.0/bin/vvp
|
||||
:ivl_version "12.0 (stable)";
|
||||
:ivl_delay_selection "TYPICAL";
|
||||
:vpi_time_precision - 9;
|
||||
:vpi_module "/usr/local/Cellar/icarus-verilog/12.0/lib/ivl/system.vpi";
|
||||
:vpi_module "/usr/local/Cellar/icarus-verilog/12.0/lib/ivl/vhdl_sys.vpi";
|
||||
:vpi_module "/usr/local/Cellar/icarus-verilog/12.0/lib/ivl/vhdl_textio.vpi";
|
||||
:vpi_module "/usr/local/Cellar/icarus-verilog/12.0/lib/ivl/v2005_math.vpi";
|
||||
:vpi_module "/usr/local/Cellar/icarus-verilog/12.0/lib/ivl/va_math.vpi";
|
||||
S_0x7f9736404160 .scope module, "tb_dt" "tb_dt" 2 2;
|
||||
.timescale -9 -9;
|
||||
v0x7f9736404340_0 .var "CNT", 5 0;
|
||||
v0x7f97365140b0_0 .var "data", 7 0;
|
||||
v0x7f9736514160_0 .var "sys_clk", 0 0;
|
||||
v0x7f9736514210_0 .var "sys_rst", 0 0;
|
||||
E_0x7f97364042e0/0 .event negedge, v0x7f9736514210_0;
|
||||
E_0x7f97364042e0/1 .event posedge, v0x7f9736514160_0;
|
||||
E_0x7f97364042e0 .event/or E_0x7f97364042e0/0, E_0x7f97364042e0/1;
|
||||
.scope S_0x7f9736404160;
|
||||
T_0 ;
|
||||
%pushi/vec4 0, 0, 1;
|
||||
%assign/vec4 v0x7f9736514160_0, 0;
|
||||
%pushi/vec4 0, 0, 1;
|
||||
%assign/vec4 v0x7f9736514210_0, 0;
|
||||
%delay 200, 0;
|
||||
%pushi/vec4 1, 0, 1;
|
||||
%assign/vec4 v0x7f9736514210_0, 0;
|
||||
%end;
|
||||
.thread T_0;
|
||||
.scope S_0x7f9736404160;
|
||||
T_1 ;
|
||||
%delay 10, 0;
|
||||
%load/vec4 v0x7f9736514160_0;
|
||||
%inv;
|
||||
%store/vec4 v0x7f9736514160_0, 0, 1;
|
||||
%jmp T_1;
|
||||
.thread T_1;
|
||||
.scope S_0x7f9736404160;
|
||||
T_2 ;
|
||||
%wait E_0x7f97364042e0;
|
||||
%load/vec4 v0x7f9736514210_0;
|
||||
%cmpi/e 0, 0, 1;
|
||||
%jmp/0xz T_2.0, 4;
|
||||
%pushi/vec4 0, 0, 6;
|
||||
%assign/vec4 v0x7f9736404340_0, 0;
|
||||
%jmp T_2.1;
|
||||
T_2.0 ;
|
||||
%load/vec4 v0x7f9736404340_0;
|
||||
%cmpi/u 24, 0, 6;
|
||||
%jmp/0xz T_2.2, 5;
|
||||
%load/vec4 v0x7f9736404340_0;
|
||||
%addi 1, 0, 6;
|
||||
%assign/vec4 v0x7f9736404340_0, 0;
|
||||
%jmp T_2.3;
|
||||
T_2.2 ;
|
||||
%pushi/vec4 0, 0, 6;
|
||||
%assign/vec4 v0x7f9736404340_0, 0;
|
||||
T_2.3 ;
|
||||
T_2.1 ;
|
||||
%jmp T_2;
|
||||
.thread T_2;
|
||||
.scope S_0x7f9736404160;
|
||||
T_3 ;
|
||||
%wait E_0x7f97364042e0;
|
||||
%load/vec4 v0x7f9736514210_0;
|
||||
%cmpi/e 0, 0, 1;
|
||||
%jmp/0xz T_3.0, 4;
|
||||
%pushi/vec4 128, 0, 8;
|
||||
%assign/vec4 v0x7f97365140b0_0, 0;
|
||||
%jmp T_3.1;
|
||||
T_3.0 ;
|
||||
%load/vec4 v0x7f9736404340_0;
|
||||
%cmpi/e 24, 0, 6;
|
||||
%jmp/0xz T_3.2, 4;
|
||||
%load/vec4 v0x7f97365140b0_0;
|
||||
%parti/s 4, 0, 2;
|
||||
%addi 1, 0, 4;
|
||||
%ix/load 4, 0, 0;
|
||||
%ix/load 5, 0, 0;
|
||||
%flag_set/imm 4, 0;
|
||||
%assign/vec4/off/d v0x7f97365140b0_0, 4, 5;
|
||||
%load/vec4 v0x7f97365140b0_0;
|
||||
%parti/s 2, 5, 4;
|
||||
%addi 1, 0, 2;
|
||||
%ix/load 4, 5, 0;
|
||||
%ix/load 5, 0, 0;
|
||||
%flag_set/imm 4, 0;
|
||||
%assign/vec4/off/d v0x7f97365140b0_0, 4, 5;
|
||||
T_3.2 ;
|
||||
T_3.1 ;
|
||||
%jmp T_3;
|
||||
.thread T_3;
|
||||
# The file index is used to find the file name in the following table.
|
||||
:file_names 3;
|
||||
"N/A";
|
||||
"<interactive>";
|
||||
"tb_dt.v";
|
@ -0,0 +1,90 @@
|
||||
`timescale 1ns/1ns
|
||||
|
||||
module tb_lm();
|
||||
|
||||
reg k_1;
|
||||
reg k_2;
|
||||
|
||||
reg flag; // 状态改变周期 现在500ns改变一次状态
|
||||
|
||||
reg sys_clk;
|
||||
reg sys_rst;
|
||||
|
||||
|
||||
always #10 sys_clk = ~sys_clk;
|
||||
|
||||
initial begin
|
||||
sys_clk <= 1'b0;
|
||||
sys_rst <= 1'b0;
|
||||
#200
|
||||
sys_rst <= 1'b1;
|
||||
|
||||
{k_2, k_1} <= 2'b10;
|
||||
|
||||
#4000
|
||||
{k_2, k_1} <= 2'b01;
|
||||
|
||||
#4000
|
||||
{k_2, k_1} <= 2'b00;
|
||||
end
|
||||
|
||||
|
||||
reg [5:0] CNT;
|
||||
always @(posedge sys_clk or negedge sys_rst) begin
|
||||
if (sys_rst == 1'b0) begin
|
||||
CNT <= 5'd0;
|
||||
end
|
||||
else if (CNT < (5'd25 - 5'd1)) begin
|
||||
CNT <= CNT + 5'd1;
|
||||
end
|
||||
else begin
|
||||
CNT <= 5'b0;
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
reg [7:0]x;
|
||||
reg [7:0]y;
|
||||
always @(posedge sys_clk or negedge sys_rst) begin
|
||||
if (sys_rst == 1'b0) begin
|
||||
k_1 <= 1'b0;
|
||||
k_2 <= 1'b0;
|
||||
x <= 8'b00000000;
|
||||
y <= 8'b11111111; // 所有的都显示算了
|
||||
end
|
||||
else if ({k_2, k_1} == 2'b10) begin
|
||||
case (flag)
|
||||
1'b0: x <= 8'b1010_1010;
|
||||
1'b1: x <= 8'b0101_0101;
|
||||
endcase
|
||||
end
|
||||
else if ({k_2, k_1} == 2'b01) begin
|
||||
case (flag)
|
||||
1'b0: x <= 8'b1111_0000;
|
||||
1'b1: x <= 8'b0000_1111;
|
||||
endcase
|
||||
end
|
||||
else begin
|
||||
x <= 8'b00000000;
|
||||
end
|
||||
end
|
||||
|
||||
always @(posedge sys_clk or negedge sys_rst) begin
|
||||
if (sys_rst == 1'b0) begin
|
||||
flag <= 1'b0;
|
||||
end
|
||||
else if (CNT == (5'd25 - 5'd1)) begin
|
||||
flag <= !flag;
|
||||
end
|
||||
else begin
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
lm u_lm(
|
||||
.x (x),
|
||||
.y (y)
|
||||
);
|
||||
|
||||
|
||||
endmodule
|
@ -0,0 +1,167 @@
|
||||
#! /usr/local/Cellar/icarus-verilog/12.0/bin/vvp
|
||||
:ivl_version "12.0 (stable)";
|
||||
:ivl_delay_selection "TYPICAL";
|
||||
:vpi_time_precision - 9;
|
||||
:vpi_module "/usr/local/Cellar/icarus-verilog/12.0/lib/ivl/system.vpi";
|
||||
:vpi_module "/usr/local/Cellar/icarus-verilog/12.0/lib/ivl/vhdl_sys.vpi";
|
||||
:vpi_module "/usr/local/Cellar/icarus-verilog/12.0/lib/ivl/vhdl_textio.vpi";
|
||||
:vpi_module "/usr/local/Cellar/icarus-verilog/12.0/lib/ivl/v2005_math.vpi";
|
||||
:vpi_module "/usr/local/Cellar/icarus-verilog/12.0/lib/ivl/va_math.vpi";
|
||||
S_0x7fb95300a8d0 .scope module, "tb_lm" "tb_lm" 2 3;
|
||||
.timescale -9 -9;
|
||||
v0x7fb953008920_0 .var "CNT", 5 0;
|
||||
v0x7fb95301a6d0_0 .var "flag", 0 0;
|
||||
v0x7fb95301a770_0 .var "k_1", 0 0;
|
||||
v0x7fb95301a800_0 .var "k_2", 0 0;
|
||||
v0x7fb95301a8a0_0 .var "sys_clk", 0 0;
|
||||
v0x7fb95301a980_0 .var "sys_rst", 0 0;
|
||||
v0x7fb95301aa20_0 .var "x", 7 0;
|
||||
v0x7fb95301aad0_0 .var "y", 7 0;
|
||||
E_0x7fb9530086e0/0 .event negedge, v0x7fb95301a980_0;
|
||||
E_0x7fb9530086e0/1 .event posedge, v0x7fb95301a8a0_0;
|
||||
E_0x7fb9530086e0 .event/or E_0x7fb9530086e0/0, E_0x7fb9530086e0/1;
|
||||
.scope S_0x7fb95300a8d0;
|
||||
T_0 ;
|
||||
%delay 10, 0;
|
||||
%load/vec4 v0x7fb95301a8a0_0;
|
||||
%inv;
|
||||
%store/vec4 v0x7fb95301a8a0_0, 0, 1;
|
||||
%jmp T_0;
|
||||
.thread T_0;
|
||||
.scope S_0x7fb95300a8d0;
|
||||
T_1 ;
|
||||
%pushi/vec4 0, 0, 1;
|
||||
%assign/vec4 v0x7fb95301a8a0_0, 0;
|
||||
%pushi/vec4 0, 0, 1;
|
||||
%assign/vec4 v0x7fb95301a980_0, 0;
|
||||
%delay 200, 0;
|
||||
%pushi/vec4 1, 0, 1;
|
||||
%assign/vec4 v0x7fb95301a980_0, 0;
|
||||
%end;
|
||||
.thread T_1;
|
||||
.scope S_0x7fb95300a8d0;
|
||||
T_2 ;
|
||||
%wait E_0x7fb9530086e0;
|
||||
%load/vec4 v0x7fb95301a980_0;
|
||||
%cmpi/e 0, 0, 1;
|
||||
%jmp/0xz T_2.0, 4;
|
||||
%pushi/vec4 0, 0, 6;
|
||||
%assign/vec4 v0x7fb953008920_0, 0;
|
||||
%jmp T_2.1;
|
||||
T_2.0 ;
|
||||
%load/vec4 v0x7fb953008920_0;
|
||||
%cmpi/u 24, 0, 6;
|
||||
%jmp/0xz T_2.2, 5;
|
||||
%load/vec4 v0x7fb953008920_0;
|
||||
%addi 1, 0, 6;
|
||||
%assign/vec4 v0x7fb953008920_0, 0;
|
||||
%jmp T_2.3;
|
||||
T_2.2 ;
|
||||
%pushi/vec4 0, 0, 6;
|
||||
%assign/vec4 v0x7fb953008920_0, 0;
|
||||
T_2.3 ;
|
||||
T_2.1 ;
|
||||
%jmp T_2;
|
||||
.thread T_2;
|
||||
.scope S_0x7fb95300a8d0;
|
||||
T_3 ;
|
||||
%wait E_0x7fb9530086e0;
|
||||
%load/vec4 v0x7fb95301a980_0;
|
||||
%cmpi/e 0, 0, 1;
|
||||
%jmp/0xz T_3.0, 4;
|
||||
%pushi/vec4 0, 0, 1;
|
||||
%assign/vec4 v0x7fb95301a770_0, 0;
|
||||
%pushi/vec4 0, 0, 1;
|
||||
%assign/vec4 v0x7fb95301a800_0, 0;
|
||||
%pushi/vec4 0, 0, 8;
|
||||
%assign/vec4 v0x7fb95301aa20_0, 0;
|
||||
%pushi/vec4 255, 0, 8;
|
||||
%assign/vec4 v0x7fb95301aad0_0, 0;
|
||||
%jmp T_3.1;
|
||||
T_3.0 ;
|
||||
%load/vec4 v0x7fb95301a800_0;
|
||||
%load/vec4 v0x7fb95301a770_0;
|
||||
%concat/vec4; draw_concat_vec4
|
||||
%cmpi/e 2, 0, 2;
|
||||
%jmp/0xz T_3.2, 4;
|
||||
%load/vec4 v0x7fb95301a6d0_0;
|
||||
%dup/vec4;
|
||||
%pushi/vec4 0, 0, 1;
|
||||
%cmp/u;
|
||||
%jmp/1 T_3.4, 6;
|
||||
%dup/vec4;
|
||||
%pushi/vec4 1, 0, 1;
|
||||
%cmp/u;
|
||||
%jmp/1 T_3.5, 6;
|
||||
%jmp T_3.6;
|
||||
T_3.4 ;
|
||||
%pushi/vec4 170, 0, 8;
|
||||
%assign/vec4 v0x7fb95301aa20_0, 0;
|
||||
%jmp T_3.6;
|
||||
T_3.5 ;
|
||||
%pushi/vec4 85, 0, 8;
|
||||
%assign/vec4 v0x7fb95301aa20_0, 0;
|
||||
%jmp T_3.6;
|
||||
T_3.6 ;
|
||||
%pop/vec4 1;
|
||||
%jmp T_3.3;
|
||||
T_3.2 ;
|
||||
%load/vec4 v0x7fb95301a800_0;
|
||||
%load/vec4 v0x7fb95301a770_0;
|
||||
%concat/vec4; draw_concat_vec4
|
||||
%cmpi/e 1, 0, 2;
|
||||
%jmp/0xz T_3.7, 4;
|
||||
%load/vec4 v0x7fb95301a6d0_0;
|
||||
%dup/vec4;
|
||||
%pushi/vec4 0, 0, 1;
|
||||
%cmp/u;
|
||||
%jmp/1 T_3.9, 6;
|
||||
%dup/vec4;
|
||||
%pushi/vec4 1, 0, 1;
|
||||
%cmp/u;
|
||||
%jmp/1 T_3.10, 6;
|
||||
%jmp T_3.11;
|
||||
T_3.9 ;
|
||||
%pushi/vec4 240, 0, 8;
|
||||
%assign/vec4 v0x7fb95301aa20_0, 0;
|
||||
%jmp T_3.11;
|
||||
T_3.10 ;
|
||||
%pushi/vec4 15, 0, 8;
|
||||
%assign/vec4 v0x7fb95301aa20_0, 0;
|
||||
%jmp T_3.11;
|
||||
T_3.11 ;
|
||||
%pop/vec4 1;
|
||||
%jmp T_3.8;
|
||||
T_3.7 ;
|
||||
%pushi/vec4 0, 0, 8;
|
||||
%assign/vec4 v0x7fb95301aa20_0, 0;
|
||||
T_3.8 ;
|
||||
T_3.3 ;
|
||||
T_3.1 ;
|
||||
%jmp T_3;
|
||||
.thread T_3;
|
||||
.scope S_0x7fb95300a8d0;
|
||||
T_4 ;
|
||||
%wait E_0x7fb9530086e0;
|
||||
%load/vec4 v0x7fb95301a980_0;
|
||||
%cmpi/e 0, 0, 1;
|
||||
%jmp/0xz T_4.0, 4;
|
||||
%pushi/vec4 0, 0, 1;
|
||||
%assign/vec4 v0x7fb95301a6d0_0, 0;
|
||||
%jmp T_4.1;
|
||||
T_4.0 ;
|
||||
%load/vec4 v0x7fb953008920_0;
|
||||
%cmpi/e 24, 0, 6;
|
||||
%jmp/0xz T_4.2, 4;
|
||||
%load/vec4 v0x7fb95301a6d0_0;
|
||||
%nor/r;
|
||||
%assign/vec4 v0x7fb95301a6d0_0, 0;
|
||||
T_4.2 ;
|
||||
T_4.1 ;
|
||||
%jmp T_4;
|
||||
.thread T_4;
|
||||
# The file index is used to find the file name in the following table.
|
||||
:file_names 3;
|
||||
"N/A";
|
||||
"<interactive>";
|
||||
"tb_lm.v";
|
Loading…
Reference in New Issue