Class: Constraints

Inherits:
Object
  • Object
show all
Defined in:
lib/tdl/exlib/constraints.rb

Constant Summary collapse

@@ex_constraints =
""

Class Method Summary collapse

Class Method Details

.Add(*names) ⇒ Object



145
146
147
148
149
# File 'lib/tdl/exlib/constraints.rb', line 145

def self.Add(*names)
    names.each do |e|
        self.sadd(e)
    end
end

.add_const(*strs) ⇒ Object



139
140
141
142
143
# File 'lib/tdl/exlib/constraints.rb', line 139

def self.add_const(*strs)
    strs.each do |str|
        @@ex_constraints  += (str+"\n")
    end
end

.add_property(port_name, pin_name, iostandard, pulltype = nil, drive = nil) ⇒ Object

Raises:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/tdl/exlib/constraints.rb', line 9

def self.add_property(port_name,pin_name,iostandard,pulltype=nil,drive=nil)
    if pin_name.respond_to?("empty?") && pin_name.empty?
        pin_name = ""
    end

    if iostandard.respond_to?("empty?") && iostandard.empty?
        iostandard = ""
    end

    if pin_name.empty? && iostandard.empty?
        return
    end

    @@clock_xds << port_name if (port_name.is_a? Clock)

    raise TdlError.new("\nConstraints port_name[#{port_name.to_s}] is'nt a SignalElm\n" ) unless port_name.is_a? SignalElm
    unless port_name.respond_to?(:dsize) && port_name.dsize != 1
        # raise TdlError.new("\nConstraints pin_name is a Array\n" ) if pin_name.is_a? Array
        # raise TdlError.new("\nConstraints iostandard is a Array\n" ) if iostandard.is_a? Array
        # @@clock_xds << port_name if (port_name.is_a? Clock) && (port_name.freqM.is_a? Numeric)
        pin_name = pin_name[0] if pin_name.is_a? Array
        @@package_pin_and_IOSTANDARD << [port_name.signal,pin_name.to_s.upcase,iostandard.to_s.upcase,pulltype,drive.to_s]
        if @@pins_used.include? pin_name.to_s.upcase
            raise TdlError.new("\nConstraints: PORT[#{port_name.signal}]@PIN[#{pin_name.to_s.upcase}] is fault,because #{pin_name.to_s.upcase} has be used\n")
        end
        @@pins_used << pin_name.to_s.upcase
    else
        iostandard = ([iostandard] * pin_name.size ) unless iostandard.is_a? Array
        pulltype = ([pulltype] * pin_name.size ) unless pulltype.is_a? Array
        drive = ([drive] * pin_name.size ) unless drive.is_a? Array

        pin_name.each_index do |index|
            @@package_pin_and_IOSTANDARD << [port_name[index],pin_name[index].to_s.upcase,iostandard[index].to_s.upcase,pulltype[index].to_s,drive[index].to_s]

            if @@pins_used.include?  pin_name[index].to_s.upcase
                raise TdlError.new("\nConstraints: PORT[#{port_name[index]}]@PIN[#{ pin_name[index].to_s.upcase}] is fault,because #{ pin_name[index].to_s.upcase} has be used\n")
            end
            @@pins_used << pin_name[index].to_s.upcase
        end
    end
end

.ClockPropertiesObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/tdl/exlib/constraints.rb', line 96

def self.ClockProperties
    head_str = "##-------------------------- CLOCK SET ---------------------------------- ##\n"
    end_str  = "##========================== CLOCK SET ================================== ##\n"
    str = @@clock_xds.map do |c|
        prie = ((1000.0)/c.freqM).round(3)
        half_prie = ((500.0)/c.freqM).round(3)
        if c.dsize == 1
            "create_clock -period #{prie} -name #{c.signal} -waveform {0.000 #{half_prie}} [get_ports #{c.signal}]\n"
        else
            sub_str = ''
            c.dsize.times do |xi|
                sub_str += "create_clock -period #{prie} -name #{c.name}_#{xi} -waveform {0.000 #{half_prie}} [get_ports #{c.signal(xi)}]\n"
            end
            sub_str
        end
    end.join("")
    head_str + str + end_str
end

.constPropertiesObject



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/tdl/exlib/constraints.rb', line 115

def self.constProperties
"
## -------------------------- FALSE PATH SET ---------------------------------- ##
# set_false_path -from [get_pins -hier -regexp .*cross_clk.*ltc.*] -to [all_registers]
set_max_delay -from [get_pins -hier -regexp .*cross_clk.*ltc.*] -to [all_registers] 20.00
## set_false_path -from [get_pins -hierarchical \"*cross_clk*\"] -to [all_registers]
# set_false_path -from [all_registers] -to [get_pins -hier -regexp .*cross_clk.*ltc.*]
set_max_delay -from [all_registers] -to [get_pins -hier -regexp .*cross_clk.*ltc.*] 20.00
## set_false_path -from [all_registers] -to [get_pins -hierarchical \"*cross_clk*\"]

# set_false_path -from [get_pins -hier -regexp .*xilinx_reset_sync.*reset_sync.*] -to [all_registers]
set_max_delay -from [get_pins -hier -regexp .*xilinx_reset_sync.*reset_sync.*] -to [all_registers] 40.000
## set_false_path -from [get_pins -hierarchical \"*xilinx_reset_sync*reset_sync*\"] -to [all_registers]
#{@@hash_const.map{|key,value| value}.join("")}
## ========================== FALSE PATH SET =================================== ##
## -------------------------- EX SET ---------------------------------- ##
#{@@ex_constraints}
## ========================== EX SET =================================== ##
## -------------------------- BITSTREAM SET ---------------------------------- ##
#{@@hash_bitstream_const.map{|key,value| value}.join("")}
## ========================== BITSTREAM SET =================================== ##
"
end

.PinPropertiesObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/tdl/exlib/constraints.rb', line 51

def self.PinProperties
    cstr = self.ClockProperties
    head_str = "##-------------------------- PIN SET ---------------------------------- ##\n"
    end_str  = "##========================== PIN SET ================================== ##\n"
    pstr = @@package_pin_and_IOSTANDARD.map do |ar|
        if ar[0] =~ /\[.*\]$/
            qstr = "{#{ar[0]}}"
        else
            qstr = ar[0]
        end
        unless ar[1].empty?
            str1 = "set_property PACKAGE_PIN #{ar[1]} [get_ports #{qstr}]\n"
        else
            str1 = "# #{ar[0]} dont have any PIN to be assigned\n"
        end

        if  ar[2].empty? || ar[2].to_s.empty?
            str2 = "# #{ar[0]} dont have any IOSTANDARD to be assigned\n"
        else
            str2 = "set_property IOSTANDARD #{ar[2]} [get_ports #{qstr}]\n"
        end

        if ar[3]  && !ar[3].empty?  # PULLUP PULLDOWN
            str_pullup = "set_property #{ar[3].upcase} true [get_ports #{qstr}]\n"
        else
            str_pullup = ""
        end

        if ar[4] && !ar[4].empty?
            str_drive = "set_property DRIVE #{ar[4]} [get_ports #{qstr}]\n"
        else
            str_drive = ""
        end

        str1 + str2 + str_pullup + str_drive

    end.join("")

    cstr + head_str + pstr + end_str
end

.xdsObject



92
93
94
# File 'lib/tdl/exlib/constraints.rb', line 92

def self.xds
    self.PinProperties() + self.constProperties
end