sanforyou
sanforyou

Reputation: 455

Passing bus to another module via port mapping in SystemVerilog

I have below code inside SV module, where I instantiate another SV module and pass 5-bit bus to it to check for X and Z's as coded below:

  input  [4:0] analdo_trim; 
  cds_XZ_checker XZ_check_analdo_trim (.in(analdo_trim),.in_ok(analdo_trim_ok));

Here is module definition for cds_XZ_checker:

module cds_XZ_checker(in,in_ok);
input in;
output bit in_ok;

always_comb  begin              //Asynchronous assertion check block
      asynch_XZ_check: assert (!($isunknown(in))) in_ok=1'b1; 
        else begin 
            $warning ("WARNING (%M) digital signal in=%b is undefined at time %t",in,$time); 
            in_ok=1'b0;
        end//else
end

endmodule

The issue is when I read 5-bit analdo_trim in above module via in port, it only reads LSB of analdo_trim. Any ideas why the whole 5-bit array is not being passed with above syntax?

Upvotes: 1

Views: 500

Answers (2)

Erling Olsen
Erling Olsen

Reputation: 740

Now 5-bit bus to it to check for X and Z's it will be passed. Yours was a small mistake in the declaration

module cds_XZ_checker(in,in_ok);
input [4:0] in; 
output bit in_ok;

always_comb  begin              //Asynchronous assertion check block
      asynch_XZ_check: assert (!($isunknown(in))) in_ok=1'b1; 
        else begin 
            $warning ("WARNING (%M) digital signal in=%b is undefined at time %t",in,$time); 
            in_ok=1'b0;
        end//else
end

endmodule

Upvotes: 0

toolic
toolic

Reputation: 62037

You declared the module input to be 1-bit wide. You need to declare it as 5-bit wide. Change:

input in;

to:

input [4:0] in; 

Upvotes: 2

Related Questions