LoginSignup
0
0

More than 3 years have passed since last update.

windowsでiverilog その89

Posted at

概要 

windowsでiverilogやってみた。
inout使ってみた。

サンプルコード



module gpio(input clk, input rw, input [7:0] inp, output [7:0] outp, inout [7:0] porta);
    reg [7:0] a;
    reg [7:0] b;
    assign porta = rw ? a : 8'bZ;
    assign outp = b;
    always @(posedge clk)
    begin
        b <= porta;
        a <= inp;
    end
endmodule

module test;
    reg clk,
        rw;
    reg [7:0] inp;
    wire [7:0] outp,
        porta;
    gpio u(.clk(clk), .rw(rw), .inp(inp), .outp(outp), .porta(porta));
    assign porta = rw ? 8'bZ : inp;
    initial
    begin
        $display("rw inp outp porta");
        $monitor("%h  %h   %h    %h", rw, inp, outp, porta);
        clk = 0;
        rw = 0;
        inp = 8'h0;
        #2
            rw = 1;
        #2
            inp = 8'h55;
        #2
            rw = 0;
        #2
            inp = 8'haa;
        #2
            $finish;
    end
    always
        #1
            clk = ~clk;
endmodule




実効結果



rw inp outp porta
0  00   xx    00
0  00   00    00
1  00   00    00
1  55   00    00
1  55   00    55
0  55   00    55
0  55   55    55
0  aa   55    aa
0  aa   aa    aa


以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0