File Coverage

blib/lib/Verilog/VCD/Writer/Signal.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Verilog::VCD::Writer::Signal;
2             $Verilog::VCD::Writer::Signal::VERSION = '0.001';
3 1     1   15341 use strict;
  1         2  
  1         24  
4 1     1   4 use warnings;
  1         3  
  1         22  
5 1     1   941 use DateTime;
  0            
  0            
6              
7             # ABSTRACT: Signal abstraction layer for Verilog::VCD::Writer
8             use Verilog::VCD::Writer::Symbol;
9             use v5.10;
10             use Moose;
11             use namespace::clean;
12             has name=>(is=>'ro',required=>1);
13             has type=>(is=>'ro',default=>'wire');
14             has bitmax=>(is=>'ro');
15             has bitmin=>(is=>'ro');
16             has width=>(is=>'ro',lazy=>1,builder=>"_getWidth");
17             has symbol=>(is=>'ro',builder=>"_getSymbol");
18              
19              
20              
21              
22             sub _getSymbol{
23             my $symTable=Verilog::VCD::Writer::Symbol->instance();
24             return $symTable->symbol;
25             }
26             sub _getWidth{
27             my $self=shift;
28             return 1 if (not defined $self->bitmax or not defined $self->bitmin);
29             return 1+$self->bitmax-$self->bitmin if($self->bitmax>$self->bitmin);
30             return 1+$self->bitmin - $self->bitmax;
31             }
32              
33              
34             sub printScope {
35             my ($self,$fh)=@_;
36             my $bus='';
37             $bus="[$self->{bitmax}:$self->{bitmin}]" if(defined $self->bitmax and defined $self->bitmin);
38             say $fh join(' ',('$var ', $self->{type},$self->width,$self->{symbol},$self->{name},$bus,'$end')) ;
39             }
40              
41             1
42              
43             __END__