raghava216
Junior Member level 3
Hi..
I want to know the best way of converting the below VHDL code to verilog code
First type of VHDL code:
There are two ways I can think of writing this code in verilog.
1)
2)
Second type of VHDL code:
1)
2)
Now, For this code, writing in an always block is better or writing as conditional statement is better (in verilog) ? or both are equivalent?
What are the implications of these 2 versions?
Which one is to be used when? and Which is more optimum? I think their synthesis results are the same.
I want to know the best way of converting the below VHDL code to verilog code
First type of VHDL code:
Code VHDL - [expand] 1 2 3 4 a0_n <= a_i(0) WHEN d_en_i = '1' AND dat_en_i= '1' ELSE '1' WHEN d_en_i = '1' ELSE 'Z';
There are two ways I can think of writing this code in verilog.
1)
Code:
assign a0_n = (d_en_i == 1'b1 && dat_en_i == 1'b1) ? a_i[0] : (d_en_i == 1'b1 ? 1'b1 : 1'bZ);
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 always @ (*) begin if(d_en_i == 1'b1 && dat_en_i == 1'b1) a0_n = a_i[0]; else if (d_en_i == 1'b1) a0_n = 1'b1; else a0_n = 1'bZ; end
Second type of VHDL code:
Code VHDL - [expand] 1 2 3 4 5 6 d <= d_i WHEN rd_en1_i = '1' AND dat_en_i= '1' ELSE dc1 WHEN (rd_en2_i='1' AND dat_en_i= '1')OR ld_en = '1' ELSE d1 WHEN (in_n_i = '0' OR (int_i = '0' AND pro_i = '1' AND tran_i = '1')) ELSE "ZZZZZZZZ";
1)
Code Verilog - [expand] 1 2 3 4 5 6 7 8 9 10 11 always @(*) begin if(rd_en1_i == 1'b1 && dat_en_i == 1'b1) d = d_i; else if ((rd_en2_i == 1'b1 && dat_en_i == 1'b1) || (ld_en == 1'b1)) d = dc1; else if ((in_n_i = 1'b0 ||(int_i == 1'b0 && pro_i == 1'b1 && tran_i == 1'b1)) d = d1; else d = 8'bZ; end
2)
Code Verilog - [expand] 1 assign d = (rd_en1_i == 1'b1 && dat_en_i == 1'b1) ? d_i : (((rd_en2_i == 1'b1 && dat_en_i == 1'b1) || (ld_en == 1'b1))) ? dc1 : (((in_n_i = 1'b0 ||(int_i == 1'b0 && pro_i == 1'b1 && tran_i == 1'b1))) ? d1 : 8'bZ;
Now, For this code, writing in an always block is better or writing as conditional statement is better (in verilog) ? or both are equivalent?
What are the implications of these 2 versions?
Which one is to be used when? and Which is more optimum? I think their synthesis results are the same.
Last edited: