是构成设计的最基本单元,通过真值表描述其功能,包括基本逻辑门在内有26个预定义功能模型
输入可以是0,1,x,所以考虑所有情况的2输入多路复用器如下:
primitive mux_two(out, select, a, b); output out; input select, a, b; // y = select ? a : b; table // select a b : out 0 0 0 : 0; 0 0 1 : 0; 0 0 x : 0; 0 1 0 : 1; 0 1 1 : 1; 0 1 x : 1; 1 0 0 : 0; 1 1 0 : 0; 1 x 0 : 0; 1 0 1 : 1; 1 1 1 : 1; 1 x 1 : 1; x 0 0 : 0; x 1 1 : 1; endtable endprimitive使用助记符?简化,?=0,1,x
primitive mux_two(out, select, a, b); output out; input select, a, b; // y = select ? a : b; table // select a b : out 0 0 ? : 0; 0 1 ? : 1; 1 ? 0 : 0; 1 ? 1 : 1; ? 0 0 : 0; ? 1 1 : 1; endtable endprimitive其实就是带使能的锁存器
primitive latch_with_enable(q_out, enable, data); output q_out; input enable, data; reg q_out; // q_out = enable ? data : q_out; // - 表示保持 table // 时序逻辑table格式 // input1 input2 state : output/next_state // enable data state : q_out/next_state 1 1 ? : 1; 1 0 ? : 0; 0 ? ? : -; x 0 0 : -; x 1 1 : -; endtable endprimitive