ali_
Newbie level 3
i have made a simple fsm to detect a number which is divisible by 5. i have also written a test bench. the code is working good. Now i want to check the code coverage using following statements in modelsim
vlog -cover bcsefx tb_question_2.v question_2.v
vsim -coverage tb_question_2
modelsim is giving the code coverage for tb file but not for the rtl file. i have tried to find the code coverage for other sequential circuits i am getting code coverage for both rtl and tb files. but not in the case of fsm. am i making any mistake in making this fsm:
vlog -cover bcsefx tb_question_2.v question_2.v
vsim -coverage tb_question_2
modelsim is giving the code coverage for tb file but not for the rtl file. i have tried to find the code coverage for other sequential circuits i am getting code coverage for both rtl and tb files. but not in the case of fsm. am i making any mistake in making this fsm:
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 module question_2 ( // Module Inputs input reset , input x , input clk , // Module Outputs output reg q ); //register declaration reg [4:0] state_reg ; reg [4:0] state_next ; // state parameters localparam [4:0] S_0 = 5'b00001; localparam [4:0] S_1 = 5'b00010; localparam [4:0] S_2 = 5'b00100; localparam [4:0] S_3 = 5'b01000; localparam [4:0] S_4 = 5'b10000; //state register always @(posedge clk) if (reset) state_reg <= S_0 ; else state_reg <= state_next ; //Next state logic always @* begin case(state_reg) S_0 : if(x) state_next = S_1 ; else state_next = S_0 ; S_1 : if(x) state_next = S_3 ; else state_next = S_2 ; S_2 : if(x) state_next = S_0 ; else state_next = S_4 ; S_3 : if(x) state_next = S_2 ; else state_next = S_1 ; S_4 : if(x) state_next = S_4 ; else state_next = S_3 ; default : state_next = S_0 ; endcase end //moore type output //input is 0 which is divisible by 5 always @(posedge clk) if (reset) q <= 1'b0; else q <= state_reg[0]; endmodule
Last edited by a moderator: