SOGO論壇
  登入   註冊   找回密碼
查看: 559|回覆: 0
列印 上一主題 下一主題

[技術文章] 多工器 [複製連結]

Rank: 11Rank: 11Rank: 11Rank: 11

熱心參予論壇活動及用心回覆主題勳章 數位硬體勳章

狀態︰ 離線
跳轉到指定樓層
1
發表於 2012-7-14 10:39:04 |只看該作者 |倒序瀏覽
Verilog 程式
module mux4(input[1:0]  select, input[3:0] d, output reg q );
always @( select or d )
begin
   case( select )
       0 : q = d[0];
       1 : q = d[1];
       2 : q = d[2];
       3 : q = d[3];
   endcase
end
endmodule

module main;
reg [3:0] d;
reg [1:0] s;
wire q;

mux4 DUT (s, d, q);

initial
begin
  s = 0;
  d = 4'b0110;
end

always #50 begin
  s=s+1;
  $monitor("%4dns monitor: s=%d d=%d q=%d", $stime, s, d, q);
end

initial #1000 $finish;

endmodule
Icarus 執行結果
D:\ccc101\icarus>iverilog mux4.v -o mux4

D:\ccc101\icarus>vvp mux4
  50ns monitor: s=1 d= 6 q=1
100ns monitor: s=2 d= 6 q=1
150ns monitor: s=3 d= 6 q=0
200ns monitor: s=0 d= 6 q=0
250ns monitor: s=1 d= 6 q=1
300ns monitor: s=2 d= 6 q=1
350ns monitor: s=3 d= 6 q=0
400ns monitor: s=0 d= 6 q=0
450ns monitor: s=1 d= 6 q=1
500ns monitor: s=2 d= 6 q=1
550ns monitor: s=3 d= 6 q=0
600ns monitor: s=0 d= 6 q=0
650ns monitor: s=1 d= 6 q=1
700ns monitor: s=2 d= 6 q=1
750ns monitor: s=3 d= 6 q=0
800ns monitor: s=0 d= 6 q=0
850ns monitor: s=1 d= 6 q=1
900ns monitor: s=2 d= 6 q=1
950ns monitor: s=3 d= 6 q=0
1000ns monitor: s=0 d= 6 q=0
喜歡嗎?分享這篇文章給親朋好友︰
               感謝作者     

請注意︰利用多帳號發表自問自答的業配文置入性行銷廣告者,將直接禁訪或刪除帳號及全部文章!
您需要登錄後才可以回覆 登入 | 註冊


本論壇為非營利自由討論平台,所有個人言論不代表本站立場。文章內容如有涉及侵權,請通知管理人員,將立即刪除相關文章資料。侵權申訴或移除要求:abuse@oursogo.com

GMT+8, 2024-5-10 05:06

© 2004-2024 SOGO論壇 OURSOGO.COM
回頂部