From 5032b0834679109dc271694515dd9422325df262 Mon Sep 17 00:00:00 2001 From: lf <15201710458@163.com> Date: Wed, 29 Jul 2020 09:52:13 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=A1=AB=E5=85=85=E4=B8=AD=E7=9A=84bug?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E9=80=9A=E8=BF=87=E8=BF=AD=E4=BB=A3=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9=E7=9A=842=E4=B8=AA=E4=BE=8B=E5=AD=90=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=AE=8C=E5=96=84=E4=BB=BF?= =?UTF-8?q?=E7=9C=9F=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rtl/sm3_cmprss_core.v | 13 +++++++------ rtl/sm3_expnd_core.v | 1 - rtl/sm3_pad_core.v | 4 ++-- rtl/wrppr/sm3_cmprss_core_wrapper.sv | 2 +- sim/run/run_sim.bat | 2 +- sim/script/run_sm3_cmprss_tb.do | 22 +++++++++++----------- sim/script/run_sm3_expnd_tb.do | 15 ++++++++------- sim/tb/tb_sm3_cmprss_top.sv | 2 +- 8 files changed, 31 insertions(+), 30 deletions(-) diff --git a/rtl/sm3_cmprss_core.v b/rtl/sm3_cmprss_core.v index d1cdb6b..8f3bd2d 100644 --- a/rtl/sm3_cmprss_core.v +++ b/rtl/sm3_cmprss_core.v @@ -109,12 +109,13 @@ wire inpt_wrd_of_blk_cntr_clr; //管理tj寄存器 always @(posedge clk or negedge rst_n) begin - if(~rst_n) begin + if(~rst_n |cmprss_blk_res_finish) begin reg_tj <= 32'h79cc4519; end else if(sm3_wj_wjj_vld_r)begin if(reg_cmprss_round == 6'd16 - INPT_WORD_NUM) reg_tj <= 32'h9d8a7a87; + else begin `ifdef SM3_INPT_DW_32 reg_tj <= {reg_tj[30:0],reg_tj[31]}; @@ -138,8 +139,8 @@ always @(posedge clk or negedge rst_n) begin sm3_wj_wjj_lst_r <= 1'b0; end else begin - sm3_wj_wjj_vld_r <= sm3_wj_wjj_valid_i; - sm3_wj_wjj_lst_r <= sm3_wj_wjj_last_i; + sm3_wj_wjj_vld_r <= expnd_inpt_vld_i; + sm3_wj_wjj_lst_r <= expnd_inpt_lst_i; end end @@ -150,8 +151,8 @@ end wjj_rnd_r <= 32'd0; end else begin - wj_rnd_r <= sm3_exp_wj_i; - wjj_rnd_r <= sm3_exp_wjj_i; + wj_rnd_r <= expnd_inpt_wj_i; + wjj_rnd_r <= expnd_inpt_wjj_i; end end @@ -381,4 +382,4 @@ assign cmprss_otpt_res_o = sm3_res; endgenerate `endif -`endif \ No newline at end of file +endmodule \ No newline at end of file diff --git a/rtl/sm3_expnd_core.v b/rtl/sm3_expnd_core.v index bd595d3..508392d 100644 --- a/rtl/sm3_expnd_core.v +++ b/rtl/sm3_expnd_core.v @@ -420,5 +420,4 @@ assign pad_inpt_rdy_o = pad_inpt_d_inpt_rdy; //反 end endgenerate `endif - endmodule diff --git a/rtl/sm3_pad_core.v b/rtl/sm3_pad_core.v index 568b620..4dc57b9 100644 --- a/rtl/sm3_pad_core.v +++ b/rtl/sm3_pad_core.v @@ -208,7 +208,8 @@ always @(*) begin end INPT_PAD_LST_DATA: begin//根据最后一个输入数据的情况,确定填充策略 if(inpt_vld_byte_cmplt) begin - if(inpt_wd_cntr[3:0] == 4'd0 && ~(inpt_wd_cntr == 16'd0))begin + // if(inpt_wd_cntr[3:0] == 4'd0 && ~(inpt_wd_cntr == 16'd0))begin + if(inpt_wd_cntr[3:0] == PAD_BLK_WD_NUM - INPT_WORD_NUM)begin nxt_state = PAD_10_WAT_NEW_BLK;//填充以'1'为首的新块 end else begin//本块中填1 nxt_state = PAD_10_DATA; @@ -299,6 +300,5 @@ assign pad_otpt_ena = state == PAD_10_DATA assign pad_otpt_vld_o = msg_inpt_vld_r1 || pad_otpt_ena; assign msg_inpt_rdy_o = pad_otpt_ena_i && (state == IDLE || state == INPT_DATA); - endmodule \ No newline at end of file diff --git a/rtl/wrppr/sm3_cmprss_core_wrapper.sv b/rtl/wrppr/sm3_cmprss_core_wrapper.sv index 7403925..39c0f64 100644 --- a/rtl/wrppr/sm3_cmprss_core_wrapper.sv +++ b/rtl/wrppr/sm3_cmprss_core_wrapper.sv @@ -17,7 +17,7 @@ module sm3_cmprss_core_wrapper ( sm3_if.CMPRSS sm3if ); -sm3_expnd_core sm3_cmprss_core( +sm3_cmprss_core U_sm3_cmprss_core( .clk (sm3if.clk ), .rst_n (sm3if.rst_n ), diff --git a/sim/run/run_sim.bat b/sim/run/run_sim.bat index af4fa76..c3e6ad3 100644 --- a/sim/run/run_sim.bat +++ b/sim/run/run_sim.bat @@ -14,7 +14,7 @@ REM REM **************************************************************************** set bin_path=C:\modeltech64_10.5\win64 REM call %bin_path%/vsim -do "do ../script/{run_sm3_expnd_tb.do}" -l run_sim.log -call %bin_path%/vsim -do "do ../script/{run_sm3_cmprss_tb.do}" -l run_sim.log +call %bin_path%/vsim -do "do ../script/run_sm3_cmprss_tb.do" -l run_sim.log if "%errorlevel%"=="1" goto END if "%errorlevel%"=="0" goto SUCCESS diff --git a/sim/script/run_sm3_cmprss_tb.do b/sim/script/run_sm3_cmprss_tb.do index dab80c0..c49cfc5 100644 --- a/sim/script/run_sm3_cmprss_tb.do +++ b/sim/script/run_sm3_cmprss_tb.do @@ -1,10 +1,10 @@ #//////////////////////////////////////////////////////////////////////////////// # Author: ljgibbs / lf_gibbs@163.com -# Create Date: 2020/07/26 +# Create Date: 2020/07/28 # Design Name: sm3 -# Module Name: run_sm3_expnd_tb +# Module Name: run_sm3_cmprss_tb # Description: -# 运行 sm3 扩展模块 tb 的 Modelsim 脚本 +# 运行 sm3 迭代压缩模块 tb 的 Modelsim 脚本 # - 使用相对路径 # - 使用库 sm3_core # Revision: @@ -13,17 +13,17 @@ vlib sm3_core -vlog -64 -incr -work sm3_core "+incdir+../rtl/inc" \ -"../rtl/*.v" \ +vlog -64 -incr -work sm3_core "+incdir+../../rtl/inc" \ +"../../rtl/*.v" \ +"../../rtl/util/*.v" \ -vlog -64 -incr -sv -work sm3_core "+incdir+../rtl/inc" \ -"../rtl/*.v" \ -"../rtl/if/*.sv" \ -"../rtl/wrppr/*.sv" \ -"../rtl/util/*.sv" \ +vlog -64 -incr -sv -work sm3_core "+incdir+../../rtl/inc" \ +"../../rtl/if/*.sv" \ +"../../rtl/wrppr/*.sv" \ "../tb/*.sv" \ +"../sim_rtl/*.sv" \ -vsim -voptargs="+acc" -t 1ps -L unisims_ver -L unimacro_ver -L secureip -lib sm3_core sm3_core.tb_sm3_expnd_top; +vsim -voptargs="+acc" -t 1ps -L unisims_ver -L unimacro_ver -L secureip -lib sm3_core sm3_core.tb_sm3_cmprss_top; add wave * diff --git a/sim/script/run_sm3_expnd_tb.do b/sim/script/run_sm3_expnd_tb.do index 7fb0b9c..17243ea 100644 --- a/sim/script/run_sm3_expnd_tb.do +++ b/sim/script/run_sm3_expnd_tb.do @@ -13,16 +13,17 @@ vlib sm3_core -vlog -64 -incr -work sm3_core "+incdir+../rtl/inc" \ -"../rtl/*.v" \ +vlog -64 -incr -work sm3_core "+incdir+../../rtl/inc" \ +"../../rtl/*.v" \ +"../../rtl/util/*.v" \ -vlog -64 -incr -sv -work sm3_core "+incdir+../rtl/inc" \ -"../rtl/*.v" \ -"../rtl/if/*.sv" \ -"../rtl/wrppr/*.sv" \ +vlog -64 -incr -sv -work sm3_core "+incdir+../../rtl/inc" \ +"../../rtl/if/*.sv" \ +"../../rtl/wrppr/*.sv" \ "../tb/*.sv" \ +"../sim_rtl/*.sv" \ -vsim -voptargs="+acc" -t 1ps -L unisims_ver -L unimacro_ver -L secureip -lib sm3_core sm3_core.tb_sm3_cmprss_top; +vsim -voptargs="+acc" -t 1ps -L unisims_ver -L unimacro_ver -L secureip -lib sm3_core sm3_core.tb_sm3_expnd_top; add wave * diff --git a/sim/tb/tb_sm3_cmprss_top.sv b/sim/tb/tb_sm3_cmprss_top.sv index de50e47..309cdab 100644 --- a/sim/tb/tb_sm3_cmprss_top.sv +++ b/sim/tb/tb_sm3_cmprss_top.sv @@ -73,7 +73,7 @@ initial begin // sm3_inpt_byte_num = $urandom % (64*100) + 1; @(posedge sm3if.clk); - task_pad_inpt_gntr_exmpl0(); + task_pad_inpt_gntr_exmpl1(); @(posedge sm3if.clk); end