Guest
As part of a personal project I am making a 7 segment decoder, the
following code
module bcdassign(bcd, seg);
input [3:0] bcd;
output [6:0] seg;
assign seg = bcd == 1'd0 ? 6'b100011 :
(bcd == 1'd1 ? 6'b100101 :
(bcd == 1'd2 ? 6'b101001 :
(bcd == 1'd3 ? 6'b110001 :
(bcd == 1'd4 ? 6'b000001 :
(bcd == 1'd5 ? 6'b010001 :
(bcd == 1'd6 ? 6'b111001 :
(bcd == 1'd7 ? 6'b111101 :
(bcd == 1'd8 ? 6'b111111 :
(bcd == 1'd9 ? 6'b100001 : 6'b000000)))))))))
;
endmodule
works as predicted, but
module bcdassign(bcd, seg);
input [3:0] bcd;
output [6:0] seg;
assign seg = bcd == 1'd0 ? 6'b100011 :
(bcd == 1 ? 6'b100101 :
(bcd == 2 ? 6'b101001 :
(bcd == 3 ? 6'b110001 :
(bcd == 4 ? 6'b000001 :
(bcd == 5 ? 6'b010001 :
(bcd == 6 ? 6'b111001 :
(bcd == 7 ? 6'b111101 :
(bcd == 8 ? 6'b111111 :
(bcd == 9 ? 6'b100001 : 6'b000000)))))))))
;
endmodule
ends up making a ROM for some reason. I was wondering a) why this
occurred, I was under the impression that the default radix in Verilog
was 10, or is something else going on here?
I figured out how to do this but I am trying to understand what is
going on...
do you always have to cast the numbers when you assign? it worked fine
when using case...
following code
module bcdassign(bcd, seg);
input [3:0] bcd;
output [6:0] seg;
assign seg = bcd == 1'd0 ? 6'b100011 :
(bcd == 1'd1 ? 6'b100101 :
(bcd == 1'd2 ? 6'b101001 :
(bcd == 1'd3 ? 6'b110001 :
(bcd == 1'd4 ? 6'b000001 :
(bcd == 1'd5 ? 6'b010001 :
(bcd == 1'd6 ? 6'b111001 :
(bcd == 1'd7 ? 6'b111101 :
(bcd == 1'd8 ? 6'b111111 :
(bcd == 1'd9 ? 6'b100001 : 6'b000000)))))))))
;
endmodule
works as predicted, but
module bcdassign(bcd, seg);
input [3:0] bcd;
output [6:0] seg;
assign seg = bcd == 1'd0 ? 6'b100011 :
(bcd == 1 ? 6'b100101 :
(bcd == 2 ? 6'b101001 :
(bcd == 3 ? 6'b110001 :
(bcd == 4 ? 6'b000001 :
(bcd == 5 ? 6'b010001 :
(bcd == 6 ? 6'b111001 :
(bcd == 7 ? 6'b111101 :
(bcd == 8 ? 6'b111111 :
(bcd == 9 ? 6'b100001 : 6'b000000)))))))))
;
endmodule
ends up making a ROM for some reason. I was wondering a) why this
occurred, I was under the impression that the default radix in Verilog
was 10, or is something else going on here?
I figured out how to do this but I am trying to understand what is
going on...
do you always have to cast the numbers when you assign? it worked fine
when using case...