Class: Clock
- Inherits:
-
SignalElm
- Object
- AxiTdl::SdlModuleActiveBaseElm
- BaseElm
- SignalElm
- Clock
- Includes:
- BaseModule, ClassHDL::AssignDefOpertor
- Defined in:
- lib/tdl/elements/clock.rb,
lib/tdl/elements/clock.rb,
lib/tdl/exlib/clock_reset_verify.rb,
lib/tdl/class_hdl/hdl_redefine_opertor.rb
Overview
require_relative “./tdlerror” require_relative “./basefunc”
Constant Summary
Constants included from ClassHDL::AssignDefOpertor
ClassHDL::AssignDefOpertor::OP_SYMBOLS
Instance Attribute Summary collapse
-
#dsize ⇒ Object
Returns the value of attribute dsize.
-
#freqM ⇒ Object
Returns the value of attribute freqM.
-
#ghost ⇒ Object
Returns the value of attribute ghost.
-
#id ⇒ Object
Returns the value of attribute id.
-
#jitter ⇒ Object
Returns the value of attribute jitter.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#port ⇒ Object
Returns the value of attribute port.
Attributes inherited from BaseElm
Class Method Summary collapse
- .checkpclock(aclk, bclk, blm) ⇒ Object
- .checkpclockdraw(aclk, bclk, blm) ⇒ Object
-
.parse_ports(port_str) ⇒ Object
parse text for autogen method and constant ###.
- .same_clock(blm, *clks) ⇒ Object
Instance Method Summary collapse
-
#initialize(name: "system_clock", freqM: 100.0, port: false, dsize: 1, jitter: 0.01, belong_to_module: nil) ⇒ Clock
constructor
A new instance of Clock.
-
#inst_port(align_len = 7) ⇒ Object
def port_length (@port.to_s + “ ”).length end.
- #to_sim_source ⇒ Object
Methods included from ClassHDL::AssignDefOpertor
curr_assign_block, curr_assign_block=, curr_assign_block_stack, curr_opertor_stack, included, init_op_methods, use_new_yield_opertors, use_old_cond_opertors, with_new_assign_block, with_new_opertor, with_normal_opertor, with_rollback_opertors
Methods included from BaseModule
Methods inherited from SignalElm
#[], inherited, #inst, subclass
Methods inherited from BaseElm
#matrix, #name_copy, #path_refs, recfg_nc, #s, #signal
Methods included from TdlSpace::ExCreateTP
Methods included from AxiTdl::TestUnitTrack
Constructor Details
#initialize(name: "system_clock", freqM: 100.0, port: false, dsize: 1, jitter: 0.01, belong_to_module: nil) ⇒ Clock
Returns a new instance of Clock.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tdl/elements/clock.rb', line 8 def initialize(name:"system_clock",freqM:100.0,port:false,dsize:1,jitter: 0.01, belong_to_module: nil) name_legal?(name) # @id = GlobalParam.CurrTdlModule.BindEleClassVars.Clock.id @name = name @freqM = freqM @port = port @dsize = dsize @jitter = jitter @belong_to_module = belong_to_module unless @belong_to_module raise TdlError.new("Clock<#{name}> dnot have belong_to_module") end end |
Instance Attribute Details
#dsize ⇒ Object
Returns the value of attribute dsize.
6 7 8 |
# File 'lib/tdl/elements/clock.rb', line 6 def dsize @dsize end |
#freqM ⇒ Object
Returns the value of attribute freqM.
6 7 8 |
# File 'lib/tdl/elements/clock.rb', line 6 def freqM @freqM end |
#ghost ⇒ Object
Returns the value of attribute ghost.
6 7 8 |
# File 'lib/tdl/elements/clock.rb', line 6 def ghost @ghost end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/tdl/elements/clock.rb', line 6 def id @id end |
#jitter ⇒ Object
Returns the value of attribute jitter.
6 7 8 |
# File 'lib/tdl/elements/clock.rb', line 6 def jitter @jitter end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/tdl/elements/clock.rb', line 5 def name @name end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/tdl/elements/clock.rb', line 6 def port @port end |
Class Method Details
.checkpclock(aclk, bclk, blm) ⇒ Object
150 151 152 |
# File 'lib/tdl/elements/clock.rb', line 150 def self.checkpclock(aclk,bclk,blm) blm.Clock_draw << self.checkpclockdraw(aclk,bclk,blm) end |
.checkpclockdraw(aclk, bclk, blm) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/tdl/elements/clock.rb', line 154 def self.checkpclockdraw(aclk,bclk,blm) @@_cpc_id ||= 0 cc_done = "cc_done_#{@@_cpc_id}" cc_same = "cc_same_#{@@_cpc_id}" cc_afreq = "cc_afreq_#{@@_cpc_id}" cc_bfreq = "cc_bfreq_#{@@_cpc_id}" str = "//--->> CheckClock <<---------------- logic #{cc_done},#{cc_same}; integer #{cc_afreq},#{cc_bfreq}; ClockSameDomain CheckPClock_inst_#{@@_cpc_id}( /* input */ .aclk (#{align_signal(aclk,q_mark=false)}), /* input */ .bclk (#{align_signal(bclk,q_mark=false)}), /* output logic */ .done (#{cc_done}), /* output logic */ .same (#{cc_same}), /* output integer */ .aFreqK (#{cc_afreq}), /* output integer */ .bFreqK (#{cc_bfreq}) ); initial begin wait(#{cc_done}); assert(#{cc_same}) else begin $error(\"--- Error : `#{blm.module_name}` clock is not same, #{aclk}< %0f M> != #{bclk}<%0f M>\",1000000.0/#{cc_afreq}, 1000000.0/#{cc_bfreq}); repeat(10)begin @(posedge #{aclk}); end $stop; end end //---<< CheckClock >>---------------- " @@_cpc_id += 1 str end |
.parse_ports(port_str) ⇒ Object
parse text for autogen method and constant ###
131 132 133 134 135 |
# File 'lib/tdl/elements/clock.rb', line 131 def self.parse_ports(port_str) rh = super.parse_ports(port_str) rh[:type] = Clock return rh end |
.same_clock(blm, *clks) ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/tdl/elements/clock.rb', line 142 def self.same_clock(blm,*clks) blm.Clock_draw << "//-------- CLOCKs Total #{clks.size} ----------------------" clks[1,clks.size].each do |c| self.checkpclock(clks[0],c,blm) end blm.Clock_draw << "//======== CLOCKs Total #{clks.size} ======================" end |
Instance Method Details
#inst_port(align_len = 7) ⇒ Object
def port_length
(@port.to_s + " ").length
end
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tdl/elements/clock.rb', line 26 def inst_port(align_len = 7) # if align_len >= port_length # sub_len = align_len - port_length # else # sub_len = 0 # end # # if @port # (@port.to_s + " " + " "*sub_len + @name.to_s) # end if dsize.eql? 1 n = "" else n = "[#{(@dsize-1)}:0]" end return [@port.to_s+n, @name.to_s,""] end |
#to_sim_source ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/tdl/exlib/clock_reset_verify.rb', line 4 def to_sim_source @belong_to_module.instance_exec(self) do |_self| Initial do _self <= 1.b0 initial_exec("#(100ns)") initial_exec("forever begin #(#{1000.0/_self.freqM/2}ns);#{_self} = ~#{_self};end") end end end |