| 1 | package Verilog::VCD::Writer::Module; | ||
| 2 | 3 | $Verilog::VCD::Writer::Module::VERSION = '0.002'; | |
| 3 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 3 | ▶ | use DateTime; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | # ABSTRACT: Module abstraction layer for Verilog::VCD::Writer | ||
| 8 | |||
| 9 | 3 | ▶ | use Verilog::VCD::Writer::Signal; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 3 | ▶ | use v5.10; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 3 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 3 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 3 | has name => (is=>'ro'); | |
| 15 | 3 | has type => (is=>'ro',default=>'module'); | |
| 16 | has signals=>(is=>'rw',isa=>'ArrayRef[Verilog::VCD::Writer::Signal]', | ||
| 17 | 7 | ▶ | default=>sub{[]}, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 18 | 3 | traits=>['Array'], | |
| 19 | handles=>{signals_push=>'push', | ||
| 20 | signals_all=>'elements'} | ||
| 21 | ); | ||
| 22 | has modules=>(is=>'rw',isa=>'ArrayRef[Verilog::VCD::Writer::Module]', | ||
| 23 | 7 | ▶ | default=>sub{[]}, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 24 | 3 | traits=>['Array'], | |
| 25 | handles=>{modules_push=>'push', | ||
| 26 | modules_all=>'elements'} | ||
| 27 | ); | ||
| 28 | #has modules=>(is=>'rw',isa=>'ArrayRef'); | ||
| 29 | |||
| 30 | #my @signals; | ||
| 31 | #my $modules; | ||
| 32 | |||
| 33 | |||
| 34 | sub addSignal { | ||
| 35 | 13 | ▶ | my ($self,$name,$bitmax,$bitmin)=@_; |
|
Subroutine
addSignal: called CC=1 SCAR=0.0
Pod
documented
| |||
| 36 | 13 | my $s=Verilog::VCD::Writer::Signal->new( | |
| 37 | name=>$name, | ||
| 38 | bitmax=>$bitmax, | ||
| 39 | bitmin=>$bitmin | ||
| 40 | ); | ||
| 41 | 13 | $self->signals_push($s); | |
| 42 | 13 | return $s; | |
| 43 | } | ||
| 44 | |||
| 45 | sub dupSignal { | ||
| 46 | 6 | ▶ | my ($self,$signal,$name,$bitmax,$bitmin)=@_; |
|
Subroutine
dupSignal: called CC=1 SCAR=0.0
Pod
documented
| |||
| 47 | 6 | my $s=Verilog::VCD::Writer::Signal->new( | |
| 48 | name=>$name, | ||
| 49 | bitmax=>$bitmax, | ||
| 50 | bitmin=>$bitmin, | ||
| 51 | symbol=>$signal->symbol | ||
| 52 | ); | ||
| 53 | 6 | $self->signals_push($s); | |
| 54 | #push @signals,$s; | ||
| 55 | 6 | return $s; | |
| 56 | } | ||
| 57 | |||
| 58 | sub addSubModule { | ||
| 59 | 2 | ▶ | my ($self,$name,$type)=@_; |
|
Subroutine
addSubModule: called CC=1 SCAR=0.0
Pod
documented
| |||
| 60 | 2 | my $m=Verilog::VCD::Writer::Module->new( | |
| 61 | name=>$name, | ||
| 62 | type=>$type # Module,Function,Task etc. | ||
| 63 | ); | ||
| 64 | 2 | $self->modules_push($m); | |
| 65 | 2 | return $m; | |
| 66 | } | ||
| 67 | |||
| 68 | |||
| 69 | sub printScope { | ||
| 70 | 7 | ▶ | my ($self,$fh)=@_; |
|
Subroutine
printScope: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 71 | 7 | say $fh '$scope '.$self->type.' '.$self->name.' $end'; | |
| 72 | 7 | map{$_->printScope($fh)} $self->signals_all; | |
| 73 | 7 | map{$_->printScope($fh)} $self->modules_all; | |
| 74 | 7 | say $fh '$upscope $end'; | |
| 75 | } | ||
| 76 | |||
| 77 | |||
| 78 | 3 | 1 | |
| 79 | |||
| 80 | __END__ | ||
| 81 | |||
| 82 | =pod | ||
| 83 | |||
| 84 | =encoding UTF-8 | ||
| 85 | |||
| 86 | =head1 NAME | ||
| 87 | |||
| 88 | Verilog::VCD::Writer::Module - Module abstraction layer for Verilog::VCD::Writer | ||
| 89 | |||
| 90 | =head1 VERSION | ||
| 91 | |||
| 92 | version 0.002 | ||
| 93 | |||
| 94 | =head2 addSignal(name,bitmax,bitmin) | ||
| 95 | |||
| 96 | This method takes 3 parameters and returns a newly created Verilog::VCD::Writer::Signal Object. | ||
| 97 | |||
| 98 | Parameters are | ||
| 99 | |||
| 100 | name: Module name. Required. | ||
| 101 | bitmax: The upper index of the bitrange e.g. for byte[7:0] bitmax is 7 | ||
| 102 | bitmin: The lower index of the bitrange e.g. for byte[7:0] bitmin is 0 | ||
| 103 | |||
| 104 | bitmax and bitmin are not required for a single bit signal. | ||
| 105 | |||
| 106 | =head2 dupSignal (Signal,...) | ||
| 107 | |||
| 108 | Adds a signal to the current module which is an exact duplicate of a signal elsewhere. | ||
| 109 | |||
| 110 | The first parameter is a Verilog::VCD::Writer::Signal object, the rest are the same as the addSignal method. | ||
| 111 | |||
| 112 | =head2 addSubModule(name,type) | ||
| 113 | |||
| 114 | Adds a submodule/function/task etc under the current module. | ||
| 115 | |||
| 116 | This method takes two parameter | ||
| 117 | |||
| 118 | name: Name of the module that will be added | ||
| 119 | |||
| 120 | type: a string which is either module,function or task | ||
| 121 | |||
| 122 | returns a newly created object of the type Verilog::VCD::Writer::Module | ||
| 123 | |||
| 124 | =for Pod::Coverage printScope | ||
| 125 | |||
| 126 | =head1 AUTHOR | ||
| 127 | |||
| 128 | Vijayvithal Jahagirdar<jvs@cpan.org> | ||
| 129 | |||
| 130 | =head1 COPYRIGHT AND LICENSE | ||
| 131 | |||
| 132 | This software is copyright (c) 2017 by Vijayvithal. | ||
| 133 | |||
| 134 | This is free software; you can redistribute it and/or modify it under | ||
| 135 | the same terms as the Perl 5 programming language system itself. | ||
| 136 | |||
| 137 | =cut | ||