2020年5月7日 星期四

以Verilog 設計一個數位電路 (EX_202)--- always行為模式 --2x1 mux 電路

以Verilog 設計一個數位電路 (EX_202)--- always行為模式 --2x1 mux 電路


`timescale 1 ns/1 ns

module EX_202 (a, b, c, sel);
input a, b, sel;
output c;
reg c;

// non-behavioral writing style in EX_104 is also listed for
// comparison. c should be declared as wire in
// non-behavioral writing style.
//
// wire c;
//
// assign c = ( sel == 1'b1 ) ? a : b;

always@(sel or a or b)
begin
if (sel==1'b1)
  c = a;
else
  c = b;
end

endmodule


`timescale 100 ns/1 ns

module testbench;
reg     sel ,a, b ;
wire c;
integer i;
EX_202 UUT(
.a(a),
.b(b),
.c(c),
.sel(sel) );
initial
begin
for (i=0;i<=7;i=i+1) begin
{sel,a,b}=i;
#20;
end
#20;
$stop;
end
endmodule

沒有留言:

張貼留言

ESP32-Flutter-MQTT-IoT-Controller

 ESP32-Flutter-MQTT-IoT-Controller 這套系統包含了 Flutter 跨平台 App 、 ESP32 韌體 與 MQTT 雲端傳輸機制 。 專案中採用的 功能命名原則與對應關係 整理如下: 1. 核心功能名稱對照表 功能區塊 Python / ...