diff --git a/digital_tube/dt.v b/digital_tube/dt.v index c6f6d97..1769424 100644 --- a/digital_tube/dt.v +++ b/digital_tube/dt.v @@ -7,11 +7,6 @@ module dt( output reg S1, S2, S3, S4 ); -parameter _SELECT_1 = 4'b1110; -parameter _SELECT_2 = 4'b1101; -parameter _SELECT_3 = 4'b1011; -parameter _SELECT_4 = 4'b0111; - // ABCDEFG parameter _SHOW_0 = 8'B1111110; @@ -55,13 +50,12 @@ always @(data) begin default: ; endcase - case (data[7:5]) - 3'b000: {S4, S3, S2, S1} = _SELECT_1; - 3'b001: {S4, S3, S2, S1} = _SELECT_2; - 3'b010: {S4, S3, S2, S1} = _SELECT_3; - 3'b011: {S4, S3, S2, S1} = _SELECT_4; - default: {S4, S3, S2, S1} = 4'b1111; - endcase + if (data[7]) begin + {S4, S3, S2, S1} = ~(4'b0001 << data[6:5]); + end + else begin + {S4, S3, S2, S1} = 4'b1111; + end end endmodule \ No newline at end of file diff --git a/led/led_1.v b/led/led_1.v index 95d0edc..c9c2953 100644 --- a/led/led_1.v +++ b/led/led_1.v @@ -67,7 +67,7 @@ wire [4:0]U; assign U = W & V; // 连个操作数 按位相与 赋值给U, 如果某个操作数宽度不够, 则对宽度小的操作数在左侧补0 -// 逻辑运算符 && || ! 只有1或者0 两个结果, 而 | & ^ ~ 则可以对多位进行操作得到多位的结果 +// 逻辑运算符 && || ! 只有1或者0 两个结果(比特位中只要有一个1, 那么该值就是1, 比如 3'b010 && 3'b100 两边都是1), 而 | & ^ ~ 则可以对多位进行操作得到多位的结果 // 比较运算符