企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
verilog中`case`和`casez`都是caed语句,只是`casez`中的匹配项可以使用`?`。</br> 如下是一个使用`casez`写的四选一含有优先级的四选一选择器。 ``` `timescale 1ns / 1ps // ******************************************************************** // FileName : mux_casez.v // Author :hpy // Email :yuan_hp@qq.com // Date :2020年06月18日 // Description :casez描述的数据选择器 // -------------------------------------------------------------------- module mux_casez( input wire[ 3 : 0 ] a, input wire[ 3 : 0 ] b, input wire[ 3 : 0 ] c, input wire[ 3 : 0 ] d, input wire[ 3 : 0 ] sel, output reg[ 3 : 0 ] q ); always@(*) begin casez(sel) 4'b???1: q = a ; 4'b??1?: q = b ; 4'b?1??: q = c ; 4'b1???: q = d ; default: q = 4'b1111 ; endcase end endmodule ``` </br> 仿真波形如下: ![](https://img.kancloud.cn/73/d7/73d7c0054be2169f803fa06c1c2a91b0_1022x178.png)