Class: Origen::Models::ScanRegister

Inherits:
Object
  • Object
show all
Includes:
Origen::Model
Defined in:
lib/origen/models/scan_register.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Origen::Model

#==, #_initialized?, #_resolve_controller_class, #add_configuration, #add_mode, #app, #attributes, #clock!, #configuration, #configuration=, #configurations, #current_configuration, #current_mode, #current_mode=, #delete_all_modes, #delete_all_specs_and_notes, #find_specs, #has_mode?, #inspect, #ip_name, #is_a_model_and_controller?, #is_an_origen_model?, #is_top_level?, #load_block, #log, #model, #modes, #read_memory, #respond_to_directly?, #to_json, #with_configuration, #with_each_mode, #with_mode, #wrap_in_controller, #write_memory

Constructor Details

#initialize(options = {}) ⇒ ScanRegister

Returns a new instance of ScanRegister.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/origen/models/scan_register.rb', line 8

def initialize(options = {})
  # The shift register
  reg :sr, 0, size: size, reset: options[:reset] || 0
  # The update register, this is the value presented to the outside world
  reg :ur, 0, size: size, reset: options[:reset] || 0

  port :si              # Scan in
  port :so              # Scan out
  port :c, size: size   # Capture in

  # Control signals
  port :se  # Shift enable
  port :ce  # Capture enable
  port :ue  # Update enable

  so.connect_to(sr[0])
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/origen/models/scan_register.rb', line 26

def method_missing(method, *args, &block)
  if BitCollection.instance_methods.include?(method)
    ur.send(method, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



6
7
8
# File 'lib/origen/models/scan_register.rb', line 6

def size
  @size
end

Instance Method Details

#clock_applyObject



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/origen/models/scan_register.rb', line 61

def clock_apply
  if @mode == :shift
    sr.shift_right(@din)
  elsif @mode == :capture
    sr.write(@din)
  elsif @mode == :update
    ur.write(@din)
  end
  @din = nil
  @mode = nil
end

#clock_prepareObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/origen/models/scan_register.rb', line 50

def clock_prepare
  @mode = mode
  if @mode == :shift
    @din = si.data
  elsif @mode == :capture
    @din = c.data
  elsif @mode == :update
    @din = sr.data
  end
end

#modeObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/origen/models/scan_register.rb', line 38

def mode
  if se.data == 1
    :shift
  elsif ce.data == 1
    :capture
  elsif ue.data == 1
    :update
  else
    undefined
  end
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/origen/models/scan_register.rb', line 34

def respond_to?(*args)
  super(*args) || BitCollection.instance_methods.include?(args.first)
end